Matrices are a 2-dimensional Array whose slots may only contain (at the moment 'real' ) numbers. Their shape is fully described by the number of rows and columns(cols). Each element can be adressed by 2 indices (row,col), where row (col) ranges between 0 and rows-1 (cols-1). For a lesson on matrices, read your math books from school. Or this reference if you like it the hard way: http://www.ee.ic.ac.uk/hp/staff/dmb/matrix/intro.html#Intro
Array2DMatrix uses an array-of-rows–notation. This is the same concept as found in Array2D. As a subclass of Array, Matrix responds to far more methods than given in this helpfile. Be aware of strange results when using them. This is meant to support only the basic matrix manipulations. Most of this is not designed for realtime action. Too slow, not optimized.
Part of MathLib, a diverse library of mathematical functions.
Create a new Matrix of shape (rows, cols) filled with zeros. Matrix.newClear(3,3).postln;
rows | |
cols |
Create a new Matrix whose rows are filled with the given subarrays.
Matrix.with([[1,2,3],[4,5,6],[7,8,9]]).postln;
array |
Create a new Matrix from a 1-dimensional array of shape (rows , cols). Matrix.withFlatArray(3,3,[1,2,3,4,5,6,7,8,9]).postln;
rows | |
cols | |
array |
Create a new identity matrix of shape (n,n). Matrix.newIdentity(3).postln;
n |
Create a new square diagonal matrix.
diagonal |
An array of values with which to fill the diagonal. |
Create a new discrete Fourier transform matrix of shape (n,n). Matrix.newDFT(3).postln;
n |
Create a new inverse discrete Foutier transform matrix of shape (n,n). Matrix.newIDFT(3).postln;
n |
fill the matrix by evaluating function. function is passed two arguments: row, col
rows | |
cols | |
function |
ArrayA | |
ArrayB |
the number of rows
the number of columns
the number of rows and columns as array [rows, cols]
post the matrix as 2D representation.
evaluate function for each element of row; function is passed two arguments: item, col
row | |
function |
evaluate function for each element of col; function is passed two arguments: item, row
col | |
function |
evaluate function for each element ; function is passed three arguments: item, row,col;
function |
Iterate over the columns. Each column will be passed to func in turn.
Iterate over the rows. Each row will be passed to func in turn.
put a single element at (row, col)
row | |
col | |
value |
put a row of elements at (row)
Matrix.newClear(3,3).putRow(0,[2,4,6]).postln
row | |
values |
put a column of elements at (col)
Matrix.newClear(3,3).putCol(1,[2,4,6]).postln
col | |
values |
fill a row by evaluating function for each element; function is passed two arguments: row, col.
row | |
function |
fill a column by evaluating function for each element; function is passed two arguments: row, col.
col | |
function |
exchange two rows
rowA | |
rowB |
exchange two cols
colA | |
colB |
row | |
col |
row | |
col |
element at (row,col)
row |
an array from row
col |
an array from column
an array from the diagonal elements
an array of rows
a one slot array of all elements
row |
a new matrix from row
col |
a new matrix from column
get a sub-matrix from within matrix.
rowStart |
Row index to begin copying. |
colStart |
Column index to begin copying. |
rowLength |
The number of elements to copy from each row. |
colHeight |
The number of elements to copy from each column. |
a new matrix
add a row (values) to the matrix and return. receiver is unchanged.
values |
add a column (values) to the matrix and return. receiver is unchanged.
values |
insert a row (values) in matrix and return. receiver is unchanged.
col | |
values |
insert a column (values) in matrix and return. receiver is unchanged.
row | |
values |
row |
a new matrix without row
col |
a new matrix without column
function |
a new matrix by evaluating function for each element. function is passed three arguments: item, row, col.
row | |
col |
a submatrix that results from matrix by crossing out row and col
the transpose of matrix
the adjoint or adjugate of a square matrix
the inverse of a square matrix
the gram matrix (the transpose of matrix multiplied with matrix) T^t * T
the pseudoInverse of a matrix
the result of matrix multiplication: matrix * matrix2 matrix.cols must equal matrix2.rows
multiplication with aNumber for each element
(matrix + matrix2) matrix must have the same shape as matrix2
summation with aNumber for each element
(matrix - matrix2) matrix must have the same shape as matrix2
subtraction with aNumber for each element
mean |
a matrix centred around the mean vector (which will be calculated for you if not supplied)
Bilateral thresholding.
thresh |
When the |
adverb |
Optional, for processing Collections. See Adverbs for Binary Operators. |
the sum of all elements
row |
the sum of all elements of desired row
col |
the sum of all elements of desired column
function |
an array giving the sum for every row
function |
an array giving the sum for every column
the grammian of a matrix (determinant of the gram matrix)
the mean array, calculated over the rows
mean |
the sample covariance, if rows represent observations
mean |
the Maximum-Likelihood covariance estimate, if rows represent observations and the distribution is assumed to be Gaussian
the determinant
row | |
col |
the cofactor to element (row, col) this is the determinant of the matrix.sub(row, col) mutiplied with (-1)**(row+col)
the trace of matrix: (sum of the diagonal elements)
the euclidean norm of matrix ( sqrt( tr [ A*A(T) ] ) )
true for (n x n) - matrices
true if determiant is zero
true if determiant is Non-zero
true if matrix is symmetric
true if matrix is antisymmetric
true if matrix is strictly positive
true if matrix is positive / non negative (zeros allowed)
true if matrix is normal
true for a zero matrix
true if matrix is integral An Integral matrix is one whose elements are all integers.
true if matrix is an identity matrix (the diagonal elements are all 1; the nondigonal elements are all zero)
true if matrix is diagonal a(i,j)=0 unless i=j.
true if matrix is orthogonal (the matrix multiplied with its transpose is an identity matrix)
true if matrix is idempotent (the squared matrix equals itself)
true if matrix equals matrix2
new matrices.
usage: matrix bop aNumber or: aNumber bop matrix
new matrices