jbrown1618 / vector Goto Github PK
View Code? Open in Web Editor NEWA linear algebra library for TypeScript and JavaScript
License: MIT License
A linear algebra library for TypeScript and JavaScript
License: MIT License
Consistent implementations for exact/approximate vector/matrix comparison would be nice.
Right now, the generated docs are tracked by git, which is not remotely ideal. Since it is generated markdown, the actual github repo can link to it and display it in a nice format - but for that, it has to be tracked.
If we deploy the docs as a static web page, we can take the generated markdown out of git (!).
Special named matrices:
Complex or generic versions of the existing functions (a generic version could take in any ScalarContainer
)
We've had issues three different times with unexpected breaking changes, and the generated api site isn't that great anyway.
Currently, the only complete implementations of Matrix
and Vector
are the subclasses of ArrayMatrix
and ArrayVector
. Since we're focusing on extensibility, it would be good to demonstrate alternative implementations, and sparse linear algebra is a good candidate.
Change index.ts
to modify how we export each module. It might be nicer to have a pattern like:
import { NumberVector, NumberMatrix } from '@jbrown/vector/types';
import { determinant } from '@jbrown/vector/algorithms'
Covariance matrix, correlation coefficients, etc.
tslint is going away and its functionality is being merged into eslint. Better to switch now than later.
Change builder.fromData
to builder.fromArray
- it would be much clearer.
It's kind of a nasty API to have the most common function be NumberVector.builder().fromArray([1, 2, 3])
. It would be nicer to do v([1, 2, 3])
. Likewise, we could replace NumberMatrix.builder().fromArray([[1, 2, 3], [4, 5, 6]])
with M([[1, 2, 3], [4, 5, 6]])
.
Could this be multiple repositories? Should applications/algorithms be separate from the core linear algebra data types? What if ML applications are added? Should vector-examples
live in the same repo?
Let's put these on an object.
RowOperations.addScalarMultipleOfRowToRow(...)
We want, for example, v.innerProduct(w)
to be accessible as v.dot(w)
. And ideally we wouldn't have to add the overhead of an extra function call.
One issue is that the documentation tool doesn't provide very good output for this:
export function mainFunction() {
// impl
}
export const alias = mainFunction;
even though it is simple and types well.
https://mathcs.clarku.edu/~ma130/inner2.pdf
Inner product should conjugate the second vector before summing the products.
Power method, iterative methods
https://en.wikipedia.org/wiki/Kronecker_product
Also tensor product
This is not technically a real matrix operation, but it is commonly needed, particularly for scaling. Right now, the approach commonly used is:
const inverse = ops.getMultiplicativeInverse(scaleFactor);
if (inverse === undefined) return someDefault;
return vector.scalarMultiply(inverse);
But this introduces a little bit of numerical error - 10 * (1/3)
is less accurate than 10 / 3
. We will need to re-implement NumberOperations.divide to get this to work correctly.
In particular, this will make the gauss-jordan equation solver more accurate.
Everything is 90% there. We just need:
newFromData()
public (so we can just make a new vector/matrix of the type passed in)getAdditiveInverse(scalar)
and getMultiplicativeInverse(scalar)
to ScalarContainer
Matrix<number>
to Matrix<any>
The current implementation of the cholesky decomposition involves lots of copying, like L = L.set(i, j, value)
. The whole thing would be a little bit more efficient if we operated on a S[][]
instead of a Matrix<S>
.
Tests for particular matrix properties - both exact and approximate
isInvertible()
isSymmetric()
isUpperTriangular()
isLowerTriangular()
isIdentity()
isHermitian()
isOrthogonal()
For random NxN matrices, save csv files for timings of:
A.add(B)
A.multiply(B)
A.apply(b)
inverse(A)
solve(A, b)
qr(A)
lu(A)
eig(A)
Write processes to
This will improve the convergence speed of eigenvalue finding. See http://people.inf.ethz.ch/arbenz/ewp/Lnotes/chapter4.pdf
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.