Package-level declarations
The overall package for the main Matrix
, MutableMatrix
, SparseMatrix
and MutableSparseMatrix
classes as well as pseudo-constructor factory functions declared on the type companions.
For example, to create a Matrix
, the following code can be used:
val matrix = Matrix(3, 4) { x, y -> x + y }
Type | Example | Description |
---|---|---|
Matrix | Matrix(orig) | Create a copy of the parameter using the copyOf member function. |
Matrix(3, 4, "Y") | A matrix that is contains the given "initial" value. The implementation is immutable. | |
Matrix(3, 4) { x, y -> x * y } | A simple array-like matrix that contains the values given by the function. The values are assigned at construction. | |
Matrix.fromFunction(2,5) { x, y -> x * y } | A matrix backed directly by the function. The function is invoked on each read of the matrix. | |
MutableMatrix | MutableMatrix(orig) | Create a new mutable matrix that is initialized from the given matrix. |
MutableMatrix(3, 4, "X") | A simple array-like mutable matrix that contains the given initial value "X" . | |
MutableMatrix(3, 4) { x, y -> x * y } | A simple array-like mutable matrix that contains the values given by the function. The values are assigned at construction. | |
SparseMatrix | SparseMatrix(orig) | Create a copy of the parameter using the copyOf member function. |
SparseMatrix(maxX, maxY, initValue) { x, y -> x + y % 2 == 0} | Create a sparse matrix that has the given maximum X and Y values, is initialized with the parameter value, and uses the function to determine whether the cell exists. | |
SparseMatrix(maxX, maxY, validator) { x, y -> "($x, $y)" } | Create a sparse matrix that has the given maximum X and Y values, has the given validator to determine sparseness and uses the given function to initialize the matrix (values set on construction). | |
SparseMatrix(maxX, maxY) { x, y -> if (x + y %3 == 0) sparse else value("($x, $y)") | Create a sparse matrix with given maximum X and Y that is initialized using the given "constructor" function. | |
SparseMatrix.fromSparseValueMatrix(source) | Create a sparse matrix from the given matrix with special SparseValue instances that indicate either a value or sparseness. | |
MutableSparseMatrix | MutableSparseMatrix(orig) | Create a mutable matrix initialised with the original sparse matrix |
MutableSparseMatrix(maxX, maxY, initValue) { x, y -> x + y % 2 == 0} | Create a sparse mutable matrix that has the given maximum X and Y values, is initialized with the parameter value, and uses the function to determine whether the cell exists. | |
MutableSparseMatrix(maxX, maxY, validator) { x, y -> "($x, $y)" } | Create a sparse mutable matrix that has the given maximum X and Y values, has the given validator to determine sparseness and uses the given function to initialize the matrix (values set on construction). | |
MutableSparseMatrix(maxX, maxY) { x, y -> if (x + y %3 == 0) sparse else value("($x, $y)") | Create a sparse mutable matrix with given maximum X and Y that is initialized using the given "constructor" function. | |
MutableSparseMatrix.fromSparseValueMatrix(source) | Create a sparse mutable matrix from the given matrix with special SparseValue instances that indicate either a value or sparseness. |
Types
An implementation of a read-only matrix that is backed by an array.
Mutable matrix class backed by an array.
Mutable matrix implementation based upon an array to store the data. It is the basis for implementing both ArrayMutableMatrix and ArrayMutableSparseMatrix.
Implementation of a MutableSparseMatrix based upon an array to store the data.
An implementation of a read-only sparse matrix that is backed by an array.
Implementation of a MutableSparseMatrix based upon an array to store data and validity. It uses the same array to record sparseness as well as data. It does not support changing validity of cells (at this point).
A matrix type (based upon SparseMatrix) but it has values at all coordinates.
An extension to Matrix that is mutable. This is effectively a 2D array.
A mutable version of SparseMatrix that adds a setter (set) to allow for changing the values in the matrix.
A 2-dimensional storage type/matrix that does not require values in all cells. This is a read-only type. The writable version is MutableSparseMatrix. The minimum coordinate is always
Functions
Helper function to set values into a MutableSparseMatrix.