8 people following this project (follow)

Project Description
While there are already countless math libraries for performing common matrix/array functions, StarMath is distinguished by its simplicity and flexbility. There is no need to declare vectors and matrices in a specific library format. It works simliar to Math.function calls in C#.

The library is small and compatible with .Net 3.5 and later. It takes advantage of many of the new Linq functions in order to be more general and capable of speed advantages such as easy parallel-processing (although not currently included in this release).

Is StarMath fast?

Many matrix libraries like to offer short, concise matrix operations (e.g. A*B), but this is not the case with StarMath. Given the way that Intellisense has changed how we program, it seems more important to offer functions that are quick and highly compatible as opposed to short.

Here are some examples that illustrate ways StarMath has been used to date.

The following are functions built into the library.

add(vector,vector) Adds arrays A and B
determinant(matrix) Returns the determinant of matrix, A.
divide(vector,scalar) Divides all elements of a 1D scalar array by the scalar value.
find(scalar,matrix) Finds the [rowIndex, colIndex] for the specified find value.
find(scalar,vector) Finds all the indices for the specified find value.
GetColumn(index,matrix) Gets a column of matrix, A.
GetColumns(indices,matrix) Get more than one column from a given 2D scalar array.
GetRow(index,matrix) Gets a row of matrix, A.
GetRows(indices,matrix) Get more than one row from a given 2D scalar array.
inverse(matrix) Inverses the matrix A only if the diagonal is all non-zero.  A[i,i] != 0.0
inverseUpper(matrix) Inverses the matrix A only if the matrix has already been "triangularized" - meaning there are no elements in the bottom triangle - A[i,j]=0.0 where j>i
JoinCol(matrix,matrix) Jions two 2D scalar arrays side by side and returns the results. The given variables remain unchanged
JoinMatrixColumnsIntoVector(matrix) Joins the matrix columns into vector.
JoinMatrixRowsIntoVector(matrix) Joins the matrix rows into vector.
JoinRow(matrix,matrix) Joins two 2D scalar arrays one under the other and returns the results. The given variables remain unchanged
JoinVectors(vector,vector) Concatenates two 1D scalar arrays and returns the result. The given variables remain unchanged
LUDecomposition([input]matrix, (out) Lmatrix,(out Umatrix) Returns the LU decomposition of A in a new matrix.
makeIdentity(index) Makes an identity matrix of size p by p.
makeIdentityInt(index) Makes an identity matrix of size p by p.
makeLinearProgression(scalar,scalar,scalar) Makes the linear progression.
MakePrintString(matrix) Makes the print string.
MakePrintString(vector) Makes the print string.
makeZero(index) Makes a sqare matrix of size p by p of all zeroes.
makeZero(index,index) Makes a matrix of size numRows by numCols of all zeroes.
makeZeroInt(index) Makes a sqare matrix of size p by p of all zeroes.
makeZeroInt(index,index) Makes a matrix of size numRows by numCols of all zeroes.
makeZeroIntVector(index) Makes the zero int vector.
makeZeroVector(index) Makes the zero vector.
Max(matrix,(out) row index,(out) col index) Finds the maximum value in the given 2D scalar array and returns the row and column indices along with it.
Max(vector,(out)index) Finds the minimum value in the given 1D scalar array and returns its index along with it.
Min(matrix,(out) row index,(out) col index) Finds the minimum value in the given 2D scalar array and returns the row and column indices along with it.
Min(vector,(out)index) Finds the minimum value in the given 1D scalar array and returns its index along with it.
multiply(matrix,matrix) Product of two matrices (2D scalar)
multiply(matrix,vector) Product of two matrices (2D scalar and 1D scalar)
multiply(scalar,vector) Multiplies all elements of a 1D scalar array with the scalar value.
multiply(vector,matrix) Product of two matrices (1D scalar and 2D scalar)
multiplyCross(vector,vector) The cross product of the two 1D scalar vectors A and B
multiplyDot(vector,vector) The dot product of the two 1D scalar vectors A and B
multiplyVectorsIntoAMatrix(vector,vector) Product of each element of array-1 (1D scalar) with each element of array-2 (1D scalar)
norm1(matrix) Returns to 1-norm (sum of absolute values of all terms) of the matrix, A.
norm1(vector) Returns to 1-norm (sum of absolute values of all terms) of the vector, x.
norm1(vector,vector) Returns to 1-norm (sum of absolute values of all terms) of the difference between x and y.
norm2(matrix,Boolean) Returns to 2-norm (square root of the sum of squares of all terms) of the matrix, A.
norm2(vector,Boolean) Returns to 2-norm (square root of the sum of squares of all terms) of the vector, x.
norm2(vector,vector,Boolean) Returns to 2-norm (square root of the sum of squares of all terms) of the difference between x and y.
normalize(vector) Returns to normalized vector (has lenght or 2-norm of 1)) of the vector, x.
normP(vector,scalar,Boolean) Returns to p-norm (p-root of the sum of each term raised to the p power)
RotationX(scalar) Creates a rotation matrix about the X-axis.
RotationY(scalar) Creates a rotation matrix about the Y-axis.
RotationZ(scalar) Creates a rotation matrix about the Z-axis.
SetColumn(index,matrix,vector) Sets/Replaces the given column of matrix A with the vector v.
SetRow(index,matrix,vector) Sets/Replaces the given row of matrix A with the vector v.
solve(matrix,vector) Solves the specified A matrix.
standardDeviation(matrix) Calculates the standard deviation assuming the whole population is provided (not sample st. dev.).
standardDeviation(vector) Calculates the standard deviation assuming the whole population is provided (not sample st. dev.).
subtract(matrix,matrix) Subtracts one matrix (B) from the other (A). C = A - B.
subtract(vector,vector) Subtracts one vector (B) from the other (A). C = A - B.
sum(matrix) Sum up all the elements of a given matrix
sum(vector) Sum up all the elements of a given matrix
Translate(scalar,scalar,scalar) Creates a translated coordinate frame.
transpose(matrix) Transposes the matrix, A.

 

I suppose there's always more to do! See and add to the discussion on Future Work.

Last edited Oct 12 2011 at 1:34 AM by mattica, version 9