Command line interface for linear algebra and modular arithmetic operations
Eigen is a simple CLI that performs matrix and vector operations, modular arithmetic, and basic arithmetic.
Eigen is currently a work in progress, so feel free to report any bugs or let me know if you have any suggestions for the program!
$ git clone https://github.com/tbliu/Eigen
$ cd Eigen
$ go run Main.go
+,-,/,*
to perform basic arithmetic in Eigen as you would normally.=
to assign a variable to a value.int, float64, *Matrix
exit, clear, clean
are all reserved key words and cannot be used as variables[
to denote the beginning of the matrix.,
;
]
to denote the end of the end of the matrix.[1, 2, 1; 4, 3, 1; 0, 2, 1]
creates the matrix: x = [1, 2, 1; 4, 3, 1; 0, 2, 1]
creates the same matrix as above, and assigns it to the variable x
.Vectors do not have a special definition in Eigen. They are simply defined as ℝNx1 matrices. Any references to the word “Vector” or the parameter “*Vector” should just be understood as a matrix with one column.
Command | Description | Return type |
---|---|---|
col(A *Matrix) |
Returns a matrix B whose columns span the column space of A | Matrix |
det(A *Matrix) |
Returns the determinant of a square matrix A | float64 |
id(N int) |
Returns the NxN identity matrix | Matrix |
inv(A *Matrix) |
Returns the inverse of a square matrix A | Matrix |
Lnull(A *Matrix) |
Returns a matrix B whose columns span the left null space of A | Matrix |
null(A *Matrix) |
Returns a matrix B whose columns span the null space of A | Matrix |
nullity(A *Matrix) |
Returns the dimension of the null space of A | int |
rank(A *Matrix) |
Returns the dimension of the column space of A | int |
row(A *Matrix) |
Returns a matrix B whose columns span the row space of A | Matrix |
rref(A *Matrix) |
Returns the reduced row echelon form of a matrix A | Matrix |
solve(A *Matrix, b *Matrix) |
Returns the vector x that solves the system of equations Ax=b | Vector |
transpose(A *Matrix) |
Returns the transpose of a matrix A | Matrix |
zeros(N int) |
Returns the NxN zero matrix | Matrix |
zeros(N int, M int) |
Returns the NxM zero matrix | Matrix |
dot(v *Vector, w *Vector) |
Returns the dot products of vector v and vector w | float64 |
orth(v *Vector, w *Vector) |
Returns 1 if v and w are orthogonal. 0 otherwise | int |
llse(A *Matrix, b *Vector) |
Returns the linear least squares estimate of x in Ax=b |
Vector |
proj(v *Vector, w *Vector) |
Returns the projection of the vector w onto the vector v | Vector |
gs(A *Matrix) |
Orthonormalizes the columns of A | Matrix |
qr(A *Matrix, tag string) |
Performs QR decomposition on A. If tag == ‘q’, Q. If tag == ‘r’, return R. Quotes are not necessary. | Matrix |
norm(v *Vector) |
Returns a vector w, which is the normalized version of v | Vector |
roll(v *Vector, N int) |
Returns a vector w, whose values are the same as v’s, shifted by N places | Vector |
xcorr(v *Vector, w *Vector) |
Returns the cross-correlation of w with respect to v | Vector |
autocorr(v *Vector) |
Returns the auto-correlation of v | Vector |
Command | Description | Return type |
---|---|---|
mod(x int, m int) |
Returns x modulo m | int |
modexp(x int, y int, m int) |
Returns x to the power of y modulo m. Uses repeated squaring, so this function works well with large ints. | int |
modinv(x int, m int) |
Returns the inverse of x modulo m. | int |
Command | Description | Return type |
---|---|---|
gcd(x int, y int) |
Returns the greatest common divisor of x and y | int |
sqrt(x float64) |
Returns the square root of a number up to 3 decimal points | float64 |
exit |
Exits the program | None |
clear |
Clears the terminal window | None |
clean |
Removes all variable assignments | None |
3*
) cause Eigen to panic (Index out of range error)