Interface Matrix<E>
- Type Parameters:
E
-
- All Known Implementing Classes:
BaseMatrix
,MutableMatrix
,SparseMatrix
A representation of a matrix taking entries of type E.
Matrices are by default immutable, but calling the mutable()
returns an instance of a
MutableMatrix
which may be edited.
-
Method Summary
Modifier and TypeMethodDescriptioncollapseColumns
(E init, java.util.function.BinaryOperator<E> op) collapseRows
(E init, java.util.function.BinaryOperator<E> op) static <F> Matrix<F>
columns()
static <E> Matrix<E>
Create copy of a matrix.static <E> Matrix<E>
diagonal
(int n, java.util.function.IntFunction<E> populator, E zero) static <T> java.util.function.BinaryOperator<Matrix<T>>
entrywiseOperator
(java.util.function.BinaryOperator<T> op) boolean
Returns a new larger matrix of size m x n which has this matrix in the top left corner and pads the rest using the given padding value.extendWith
(int dm, int dn, E padding) static <E> Matrix<E>
static <E> Matrix<E>
eye
(int n, E one, E zero) static <E> Matrix<E>
fromBlocks
(Matrix<Matrix<E>> blocks) get
(int i, int j) default E
getColumn
(int j) int
getRow
(int i) int
getWidth()
boolean
isSquare()
static <E> Matrix<E>
lazy
(int m, int n, IntBinaryFunction<E> populator) Generate aMatrix<E>
where each element is created using the given populator when it is needed.<F> Matrix<F>
minor
(int i, int j) mutable()
Returns a mutable copy of this matrix.static <E> Matrix<E>
of
(int m, int n, IntBinaryFunction<E> populator) Create a new matrix with the given height, width and populate it using the given function.static <E> Matrix<E>
of
(int m, int n, IntBinaryFunction<E> populator, boolean populateSequentially) Create a new matrix with the given height, width and populate it using the given function.static <E> Matrix<E>
of
(int m, int n, E defaultValue) static <E> Matrix<E>
of
(int m, E... entries) Convenience function to quickly define (small) matrices.static <E> Matrix<E>
Create a new matrix with the given height and populate it using the given row populator.static <E> Matrix<E>
of
(E[]... rows) static <E> Matrix<E>
static <F> Matrix<F>
rows()
default java.util.stream.Stream<E>
stream()
submatrix
(int[] rows, int[] columns) Returns a new matrix with the given rows and columns from this matrix.submatrix
(int r0, int r1, int c0, int c1) Returns a new matrix of size (r1-r0) x (c1-c0) with rows r0, ..., r1-1 and columns c0, ..., c1-1 from this matrix.view()
Returns a view of the given matrix.Methods inherited from interface java.util.function.BiFunction
andThen, apply
-
Method Details
-
lazy
Generate aMatrix<E>
where each element is created using the given populator when it is needed.- Type Parameters:
E
- The type of the entries.- Parameters:
m
- The height of the matrixn
- The width of the matrixpopulator
- The populator function wherepopulator.apply(i, j)
generates the (i,j)'th entry.- Returns:
- A
Matrix<E>
where each element is created using the given populator when it is needed.
-
copy
Create copy of a matrix. Note that the entries will be the same as in the original, and is hence not cloned. -
of
Create a new matrix with the given height, width and populate it using the given function. The entries are created immediately in parallel. -
of
Create a new matrix with the given height, width and populate it using the given function. The entries are created immediately sequentially. -
of
Create a new matrix with the given height and populate it using the given row populator. The rows are created immediately in parallel. -
of
-
of
-
of
Convenience function to quickly define (small) matrices. The m is the number of rows and the remaining are the entries which should be divisible by the number of rows. -
of
-
eye
-
eye
-
fromBlocks
-
entrywiseOperator
static <T> java.util.function.BinaryOperator<Matrix<T>> entrywiseOperator(java.util.function.BinaryOperator<T> op) -
row
-
column
-
diagonal
-
getColumn
-
getRow
-
get
-
get
-
getHeight
int getHeight() -
getWidth
int getWidth() -
minor
-
transpose
-
map
-
rows
-
columns
-
equals
-
isSquare
boolean isSquare() -
extendTo
Returns a new larger matrix of size m x n which has this matrix in the top left corner and pads the rest using the given padding value. -
extendWith
-
submatrix
Returns a new matrix with the given rows and columns from this matrix. The given arrays are assumed to be sorted. -
submatrix
Returns a new matrix of size (r1-r0) x (c1-c0) with rows r0, ..., r1-1 and columns c0, ..., c1-1 from this matrix. -
view
Returns a view of the given matrix. This does not store any values but instead maps operations to this matrix. -
mutable
MutableMatrix<E> mutable()Returns a mutable copy of this matrix. -
collapseRows
-
collapseColumns
-
stream
-
toString
-