goog.math.Matrix
Classgoog.math.Matrix(m, opt_n)
Class for representing and manipulating matrices. The entry that lies in the i-th row and the j-th column of a matrix is typically referred to as the i,j entry of the matrix. The m-by-n matrix A would have its entries referred to as: [ a0,0 a0,1 a0,2 ... a0,j ... a0,n ] [ a1,0 a1,1 a1,2 ... a1,j ... a1,n ] [ a2,0 a2,1 a2,2 ... a2,j ... a2,n ] [ . . . . . ] [ . . . . . ] [ . . . . . ] [ ai,0 ai,1 ai,2 ... ai,j ... ai,n ] [ . . . . . ] [ . . . . . ] [ . . . . . ] [ am,0 am,1 am,2 ... am,j ... am,n ]
m
{goog.math.Matrix
|Array
.<Array
.<number
>>|goog.math.Size
|number
}
opt_n
{number
=}
.add(m)
Returns a new matrix that is the sum of this and the provided matrix.
m
{goog.math.Matrix
}
goog.math.Matrix
}
.appendColumns(m)
Appends the given matrix to the right side of this matrix.
m
{goog.math.Matrix
}
goog.math.Matrix
}
.appendRows(m)
Appends the given matrix to the bottom of this matrix.
m
{goog.math.Matrix
}
goog.math.Matrix
}
.createIdentityMatrix(n)
Creates a square identity matrix. i.e. for n = 3:
[ 1 0 0 ] [ 0 1 0 ] [ 0 0 1 ]
n
{number
}
goog.math.Matrix
}
.equals(m, opt_tolerance)
Returns whether the given matrix equals this matrix.
m
{goog.math.Matrix
}
opt_tolerance
{number
=}
boolean
}
.forEach(matrix, fn, opt_obj)
Calls a function for each cell in a matrix.
matrix
{goog.math.Matrix
}
fn
{Function
}
opt_obj
{Object
=}
.getDeterminant()
Returns the determinant of this matrix. The determinant of a matrix A is often denoted as |A| and can only be applied to a square matrix.
number
}
.getInverse()
Returns the inverse of this matrix if it exists or null if the matrix is not invertible.
goog.math.Matrix
}
.getReducedRowEchelonForm()
Transforms this matrix into reduced row echelon form.
goog.math.Matrix
}
.getSize()
goog.math.Size
}
.getTranspose()
Return the transpose of this matrix. For an m-by-n matrix, the transpose is the n-by-m matrix which results from turning rows into columns and columns into rows
goog.math.Matrix
}
.getValueAt(i, j)
Retrieves the value of a particular coordinate in the matrix or null if the requested coordinates are out of range.
i
{number
}
j
{number
}
number
}
.isSquare()
boolean
}
.isValidArray(arr)
Tests whether an array is a valid matrix. A valid array is an array of arrays where all arrays are of the same length and all elements are numbers.
arr
{Array
}
boolean
}
.map(matrix, fn, opt_obj)
Calls a function for every cell in a matrix and inserts the result into a new matrix of equal dimensions.
matrix
{goog.math.Matrix
}
fn
{Function
}
opt_obj
{Object
=}
goog.math.Matrix
}
.multiply(m)
Performs matrix or scalar multiplication on a matrix and returns the resultant matrix. Matrix multiplication is defined between two matrices only if the number of columns of the first matrix is the same as the number of rows of the second matrix. If A is an m-by-n matrix and B is an n-by-p matrix, then their product AB is an m-by-p matrix Scalar multiplication returns a matrix of the same size as the original, each value multiplied by the given value.
m
{goog.math.Matrix
|number
}
goog.math.Matrix
}
.setValueAt(i, j, value)
Sets the value at a particular coordinate (if the coordinate is within the bounds of the matrix).
i
{number
}
j
{number
}
value
{number
}
.subtract(m)
Returns a new matrix that is the difference of this and the provided matrix.
m
{goog.math.Matrix
}
goog.math.Matrix
}
.toArray()
Array
.<!Array
.<number
>>}
.toString()
Returns a string representation of the matrix. e.g.
[ 12 5 9 1 ] [ 4 16 0 17 ] [ 12 5 1 23 ]
string
}