MatrixArray:

Filter:
Classes (extension)
| Linear Algebra | Math

Extension

A two-dimensional array structure to facilitate matrix operations.

Source: MatrixArray.sc

A two-dimensional array structure to facilitate matrix operations. This is a partial refactoring of the Matrix class from the MathLib quark. The modifications enable much faster calculation of some matrix operations, namely the determinant (-det), which subsequently speeds up the `inverse`

and others. Performance is further enhanced by storing the transpose , and doing in-place operations when possible.

NOTE: Because this class was designed around certain methods that involve a high amount of recursion, like the

`pseudoInverse`

, for efficiency, many of the underlying operations are done through Array's methods. As a consequence most methods will return a new Array rather than the MatrixArray object. So if you expect to call further methods on a result, the preferred pattern is to "cast" it into a new MatrixArray using *with.NOTE: Certain error checks are omitted, for example in operations that require a square matrix, this shape is assumed.

Fill the matrix by evaluating function.

rows |
The number of rows. |

cols |
The number of columns. |

func |
The function used to fill the matrix. The function is passed |

A MatrixArray.

Create a MatrixArray with values from a 2-D Array.

array |
A 2-D Array — an array of rows. |

A MatrixArray.

Create a MatrixArray of a specified size, filled with `nil`

s.

rows |
The number of rows. |

cols |
The number of columns. |

A MatrixArray.

NOTE: The following access methods return the objects that comprise MatrixArray's state, e.g. the row Arrays, **not a copy**, so use care not to unintentionally change these objects once you access them.

Get the value at `[row, col]`

.

row |
The row index. |

col |
The column index. |

The value stored at `[row, col]`

.

Get the MatrixArray as a 2-D array. Synonymous with -asArray.

Get the MatrixArray as a 2-D array. Synonymous with -matrix.

Get the flopped matrix (transpose). This transpose is computed on first request and stored thereafter for internal use and quick access.

Get the flopped matrix (transpose). This transpose is computed on first request and stored thereafter for internal use and quick access.

Get the number of rows in the matrix.

Get the number of columns in the matrix.

The following filter methods will return new objects (Arrays).

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. |

Get a new matrix that is this one without a specified row.

row |
The index of the row to omit. |

Get a new matrix that is this one without a specified column.

col |
The index of the column to omit. |

A convenience method, for optimized use by -cofactor, which, unlike -withoutRow and -withoutCol, returns a MatrixArray that is this one without a specified row and column.

row |
The index of the row to be removed. |

col |
The index of the column to be removed. |

A new MatrixArray.

Set the value in the matrix at a location.

row |
A row index. |

col |
A column index. |

val |
The value to set. |

Remove a row from the matrix.

row |
The index of the row to remove. |

This MatrixArray, which is now without row **row**.

Remove a column from the matrix.

col |
The index of the column to remove. |

This MatrixArray, which is now without column **col**.

WARNING: Deprecated: use -thresh2 instead.

Bilateral thresholding **in place**.

thresh |
When the input.abs < thresh, the output is forced to 0. Should be a positive value. Default is |

This MatrixArray.

Get the cofactor to element `[row, col]`

. This is the determinant of the sub-matrix up to `[row, col]`

mutiplied with `(-1)**(row+col)`

.

NOTE: The matrix is assumed to be square (no check is performed).

row |
The row index. |

col |
The column index. |

A Number, the cofactor.

Compute the gram matrix (the transpose of this matrix multiplied with itself).

`T^t * T`

A 2-D Array.

Matrix multiplication by another matrix or a number. If multiplying by another matrix, `this * that`

. `this.cols`

must equal `that.rows`

. See also -mulMatrix.

that |
Can be a Number, a MatrixArray, or a (2D) Array. |

A 2-D Array.

Matrix multiplication: `this * that`

. `this.cols`

must equal `that.rows`

.

`A(m,n) * B(n,r) = AB(m,r)`

mArray |
Can be a MatrixArray, or a (2D) Array. |

A 2-D Array.

A convenience method for "mixing" one-dimensional coefficients with this matrix, i.e. a matrix multiplication. For example, mixing ambisonic signal coefficients with a transform matrix.

coeffs |

An Array with size `this.rows`

.

This is a partial refactoring of the Matrix class from the MathLib quark originally authored by sc.solar, Till Bovermann, Christofer Fraunberger, and Dan Stowell.

This refactoring also includes a much faster determinant caclulation based on LU Decomposition.

The algorithm is published in:

Intel Application Notes AP-931, Streaming SIMD Extensions - LU Decomposition

helpfile source: /Library/Application Support/SuperCollider/downloaded-quarks/MatrixArray/HelpSource/Classes/MatrixArray.schelp

link::Classes/MatrixArray::

link::Classes/MatrixArray::