Package org.flag4j.core
Interface MatrixOperationsMixin<T,U,V,W,Y,X extends Number,TT extends VectorMixin<TT,UU,?,?,?,?,?,?>,UU extends VectorMixin<UU,UU,?,CVector,X,U,U,CMatrix>>
- Type Parameters:
T
- Matrix type.U
- Dense matrix type.V
- Sparse matrix type.W
- Complex matrix type.Y
- Complex sparse matrix type.X
- Matrix entry type.TT
- Vector type equivalent.UU
- Dense vector type.
- All Known Subinterfaces:
MatrixMixin<T,
U, V, W, VV, X, TT, UU>
- All Known Implementing Classes:
CMatrix
,CooCMatrix
,CooMatrix
,CsrCMatrix
,CsrMatrix
,Matrix
public interface MatrixOperationsMixin<T,U,V,W,Y,X extends Number,TT extends VectorMixin<TT,UU,?,?,?,?,?,?>,UU extends VectorMixin<UU,UU,?,CVector,X,U,U,CMatrix>>
This interface specifies operations which should be implemented by any matrix (rank 2 tensor).
-
Method Summary
Modifier and TypeMethodDescriptionComputes the element-wise addition between two tensors of the same rank.Computes the element-wise addition between two matrices.add
(CooCMatrix B) Computes the element-wise addition between two tensors of the same rank.Computes the element-wise addition between two tensors of the same rank.add
(CsrCMatrix B) Computes the element-wise addition between two tensors of the same rank.Computes the element-wise addition between two tensors of the same rank.Adds a vector to each column of a matrix.Adds a vector to each column of a matrix.Adds a vector to each column of a matrix.Adds a vector to each column of a matrix.Adds a vector to each row of a matrix.Adds a vector to each row of a matrix.Adds a vector to each row of a matrix.Adds a vector to each row of a matrix.Stacks matrices along rows.Augments a matrix with a vector.Stacks matrices along rows.Augments a matrix with a vector.Stacks matrices along rows.Augments a matrix with a vector.Stacks matrices along rows.Augments a matrix with a vector.default W
Stacks matrices along rows.default T
Stacks matrices along rows.copy()
Copies this matrix.det()
Computes the determinant of a square matrix.Computes the element-wise division between two matrices.Computes the element-wise division between two matrices.Computes the element-wise multiplication (Hadamard product) between two matrices.Computes the element-wise multiplication (Hadamard product) between two matrices.Computes the element-wise multiplication (Hadamard product) between two matrices.Computes the element-wise multiplication (Hadamard product) between two matrices.Computes the Frobenius inner product of two matrices.Computes the Frobenius inner product of two matrices.fib
(CooCMatrix B) Computes the Frobenius inner product of two matrices.Computes the Frobenius inner product of two matrices.getCol
(int j) Get the column of this matrix at the specified index.getCol
(int colIdx, int rowStart, int rowEnd) Gets a specified column of this matrix betweenrowStart
(inclusive) androwEnd
(exclusive).getColBelow
(int rowStart, int j) Get a specified column of this matrix at and below a specified row.getDiag()
Extracts the diagonal elements of this matrix and returns them as a vector.getRow
(int i) Get the row of this matrix at the specified index.getRowAfter
(int colStart, int i) Get a specified row of this matrix at and after a specified column.getSlice
(int rowStart, int rowEnd, int colStart, int colEnd) Gets a specified slice of this matrix.H()
Compute the hermitian transpose of this matrix.mult
(double factor) Computes scalar multiplication of a matrix.Computes the matrix multiplication between two matrices.Computes matrix-vector multiplication.Computes the matrix multiplication between two matrices.Computes matrix-vector multiplication.mult
(CooCMatrix B) Computes the matrix multiplication between two matrices.mult
(CooCVector b) Computes matrix-vector multiplication.Computes the matrix multiplication between two matrices.Computes matrix-vector multiplication.mult
(CsrCMatrix B) Computes the matrix multiplication between two matrices.Computes the matrix multiplication between two matrices.Computes the matrix multiplication between two matrices.Computes the matrix-vector multiplication.default CMatrix
Multiplies this matrix with the transpose of theB
tensor as if by {this.mult(B.T())
.default U
Multiplies this matrix with the transpose of theB
tensor as if bythis.mult(B.T())
.default CMatrix
Multiplies this matrix with the transpose of theB
tensor as if bythis.mult(B.T())
.default U
Multiplies this matrix with the transpose of theB
tensor as if bythis.mult(B.T())
.default CMatrix
Multiplies this matrix with the transpose of theB
tensor as if bythis.mult(B.T())
.default U
Multiplies this matrix with the transpose of theB
tensor as if bythis.mult(B.T())
.pow
(int exponent) Computes the matrix power with a given exponent.Sets a column of this matrix.Stacks matrices along columns.default CMatrix
Stacks matrices along specified axis.Stacks vector to this matrix along columns.default W
Stacks matrix and vector along specified axis.Stacks matrices along columns.default U
Stacks matrices along specified axis.Stacks vector to this matrix along columns.default T
Stacks matrix and vector along specified axis.stack
(CooCMatrix B) Stacks matrices along columns.default W
stack
(CooCMatrix B, int axis) Stacks matrices along specified axis.stack
(CooCVector b) Stacks vector to this matrix along columns.default W
stack
(CooCVector b, int axis) Stacks matrix and vector along specified axis.Stacks matrices along columns.default T
Stacks matrices along specified axis.Stacks vector to this matrix along columns.default T
Stacks matrix and vector along specified axis.default W
stack
(CsrCMatrix B) Stacks matrices along columns.default W
stack
(CsrCMatrix B, int axis) Stacks matrices along specified axis.default T
Stacks matrices along columns.default T
Stacks matrices along specified axis.Computes the element-wise subtraction of two tensors of the same rank.Computes the element-wise subtraction of two tensors of the same rank.sub
(CooCMatrix B) Computes the element-wise subtraction of two tensors of the same rank.Computes the element-wise subtraction of two tensors of the same rank.sub
(CsrCMatrix B) Computes the element-wise subtraction of two tensors of the same rank.Computes the element-wise subtraction of two tensors of the same rank.sumCols()
Sums together the columns of a matrix as if each column was a column vector.sumRows()
Sums together the rows of a matrix as if each row was a row vector.toVector()
Converts this matrix to an equivalent vector.tr()
Computes the trace of this matrix.trace()
Computes the trace of this matrix.
-
Method Details
-
add
Computes the element-wise addition between two matrices.- Parameters:
B
- Second matrix in the addition.- Returns:
- The result of adding the matrix B to this matrix element-wise.
- Throws:
IllegalArgumentException
- If A and B have different shapes.
-
add
Computes the element-wise addition between two tensors of the same rank.- Parameters:
B
- Second tensor in the addition.- Returns:
- The result of adding the tensor B to this tensor element-wise.
- Throws:
IllegalArgumentException
- If A and B have different shapes.
-
add
Computes the element-wise addition between two tensors of the same rank.- Parameters:
B
- Second tensor in the addition.- Returns:
- The result of adding the tensor B to this tensor element-wise.
- Throws:
IllegalArgumentException
- If A and B have different shapes.
-
add
Computes the element-wise addition between two tensors of the same rank.- Parameters:
B
- Second tensor in the addition.- Returns:
- The result of adding the tensor B to this tensor element-wise.
- Throws:
IllegalArgumentException
- If A and B have different shapes.
-
add
Computes the element-wise addition between two tensors of the same rank.- Parameters:
B
- Second tensor in the addition.- Returns:
- The result of adding the tensor B to this tensor element-wise.
- Throws:
IllegalArgumentException
- If A and B have different shapes.
-
add
Computes the element-wise addition between two tensors of the same rank.- Parameters:
B
- Second tensor in the addition.- Returns:
- The result of adding the tensor B to this tensor element-wise.
- Throws:
IllegalArgumentException
- If A and B have different shapes.
-
sub
Computes the element-wise subtraction of two tensors of the same rank.- Parameters:
B
- Second tensor in the subtraction.- Returns:
- The result of subtracting the tensor B from this tensor element-wise.
- Throws:
IllegalArgumentException
- If A and B have different shapes.
-
sub
Computes the element-wise subtraction of two tensors of the same rank.- Parameters:
B
- Second tensor in the subtraction.- Returns:
- The result of subtracting the tensor B from this tensor element-wise.
- Throws:
IllegalArgumentException
- If A and B have different shapes.
-
sub
Computes the element-wise subtraction of two tensors of the same rank.- Parameters:
B
- Second tensor in the subtraction.- Returns:
- The result of subtracting the tensor B from this tensor element-wise.
- Throws:
IllegalArgumentException
- If A and B have different shapes.
-
sub
Computes the element-wise subtraction of two tensors of the same rank.- Parameters:
B
- Second tensor in the subtraction.- Returns:
- The result of subtracting the tensor B from this tensor element-wise.
- Throws:
IllegalArgumentException
- If A and B have different shapes.
-
sub
Computes the element-wise subtraction of two tensors of the same rank.- Parameters:
B
- Second tensor in the subtraction.- Returns:
- The result of subtracting the tensor B from this tensor element-wise.
- Throws:
IllegalArgumentException
- If A and B have different shapes.
-
sub
Computes the element-wise subtraction of two tensors of the same rank.- Parameters:
B
- Second tensor in the subtraction.- Returns:
- The result of subtracting the tensor B from this tensor element-wise.
- Throws:
IllegalArgumentException
- If A and B have different shapes.
-
mult
Computes the matrix multiplication between two matrices.- Parameters:
B
- Second matrix in the matrix multiplication.- Returns:
- The result of matrix multiplying this matrix with matrix
B
. - Throws:
IllegalArgumentException
- If the number of columns in this matrix do not equal the number of rows in matrixB
.
-
mult
Computes the matrix-vector multiplication.- Parameters:
b
- Vector to multiply this matrix to.- Returns:
- The vector result from multiplying this matrix by the vector
b
. - Throws:
IllegalArgumentException
- If the number of columns in this matrix do not equal the number of entriesb
.
-
mult
Computes the matrix multiplication between two matrices.- Parameters:
B
- Second matrix in the matrix multiplication.- Returns:
- The result of matrix multiplying this matrix with matrix
B
. - Throws:
IllegalArgumentException
- If the number of columns in this matrix do not equal the number of rows in matrixB
.
-
mult
Computes the matrix multiplication between two matrices.- Parameters:
B
- Second matrix in the matrix multiplication.- Returns:
- The result of matrix multiplying this matrix with matrix B.
- Throws:
IllegalArgumentException
- If the number of columns in this matrix do not equal the number of rows in matrix B.
-
mult
Computes the matrix multiplication between two matrices.- Parameters:
B
- Second matrix in the matrix multiplication.- Returns:
- The result of matrix multiplying this matrix with matrix B.
- Throws:
IllegalArgumentException
- If the number of columns in this matrix do not equal the number of rows in matrix B.
-
mult
Computes the matrix multiplication between two matrices.- Parameters:
B
- Second matrix in the matrix multiplication.- Returns:
- The result of matrix multiplying this matrix with matrix B.
- Throws:
IllegalArgumentException
- If the number of columns in this matrix do not equal the number of rows in matrix B.
-
mult
Computes the matrix multiplication between two matrices.- Parameters:
B
- Second matrix in the matrix multiplication.- Returns:
- The result of matrix multiplying this matrix with matrix B.
- Throws:
IllegalArgumentException
- If the number of columns in this matrix do not equal the number of rows in matrix B.
-
mult
Computes the matrix multiplication between two matrices.- Parameters:
B
- Second matrix in the matrix multiplication.- Returns:
- The result of matrix multiplying this matrix with matrix B.
- Throws:
IllegalArgumentException
- If the number of columns in this matrix do not equal the number of rows in matrix B.
-
mult
Computes matrix-vector multiplication.- Parameters:
b
- Vector in the matrix-vector multiplication.- Returns:
- The result of matrix multiplying this matrix with vector b.
- Throws:
IllegalArgumentException
- If the number of columns in this matrix do not equal the number of entries in the vector b.
-
mult
Computes matrix-vector multiplication.- Parameters:
b
- Vector in the matrix-vector multiplication.- Returns:
- The result of matrix multiplying this matrix with vector b.
- Throws:
IllegalArgumentException
- If the number of columns in this matrix do not equal the number of entries in the vector b.
-
mult
Computes matrix-vector multiplication.- Parameters:
b
- Vector in the matrix-vector multiplication.- Returns:
- The result of matrix multiplying this matrix with vector b.
- Throws:
IllegalArgumentException
- If the number of columns in this matrix do not equal the number of entries in the vector b.
-
mult
Computes matrix-vector multiplication.- Parameters:
b
- Vector in the matrix-vector multiplication.- Returns:
- The result of matrix multiplying this matrix with vector b.
- Throws:
IllegalArgumentException
- If the number of columns in this matrix do not equal the number of entries in the vector b.
-
multTranspose
Multiplies this matrix with the transpose of theB
tensor as if bythis.mult(B.T())
. For large matrices, this method may be significantly faster than directly computing the transpose followed by the multiplication asthis.mult(B.T())
.- Parameters:
B
- The second matrix in the multiplication and the matrix to transpose/- Returns:
- The result of multiplying this matrix with the transpose of
B
.
-
multTranspose
Multiplies this matrix with the transpose of theB
tensor as if bythis.mult(B.T())
. For large matrices, this method may be significantly faster than directly computing the transpose followed by the multiplication asthis.mult(B.T())
.- Parameters:
B
- The second matrix in the multiplication and the matrix to transpose/- Returns:
- The result of multiplying this matrix with the transpose of
B
.
-
multTranspose
Multiplies this matrix with the transpose of theB
tensor as if bythis.mult(B.T())
. For large matrices, this method may be significantly faster than directly computing the transpose followed by the multiplication asthis.mult(B.T())
.- Parameters:
B
- The second matrix in the multiplication and the matrix to transpose/- Returns:
- The result of multiplying this matrix with the transpose of
B
.
-
multTranspose
Multiplies this matrix with the transpose of theB
tensor as if by {this.mult(B.T())
. For large matrices, this method may be significantly faster than directly computing the transpose followed by the multiplication asthis.mult(B.T())
.- Parameters:
B
- The second matrix in the multiplication and the matrix to transpose/- Returns:
- The result of multiplying this matrix with the transpose of
B
.
-
multTranspose
Multiplies this matrix with the transpose of theB
tensor as if bythis.mult(B.T())
. For large matrices, this method may be significantly faster than directly computing the transpose followed by the multiplication asthis.mult(B.T())
.- Parameters:
B
- The second matrix in the multiplication and the matrix to transpose/- Returns:
- The result of multiplying this matrix with the transpose of
B
.
-
multTranspose
Multiplies this matrix with the transpose of theB
tensor as if bythis.mult(B.T())
. For large matrices, this method may be significantly faster than directly computing the transpose followed by the multiplication asthis.mult(B.T())
.- Parameters:
B
- The second matrix in the multiplication and the matrix to transpose/- Returns:
- The result of multiplying this matrix with the transpose of
B
.
-
pow
Computes the matrix power with a given exponent. This is equivalent to multiplying a matrix to itself 'exponent' times. Note, this method is preferred over repeated multiplication of a matrix as this method will be significantly faster.- Parameters:
exponent
- The exponent in the matrix power.- Returns:
- The result of multiplying this matrix with itself 'exponent' times.
-
elemMult
Computes the element-wise multiplication (Hadamard product) between two matrices.- Parameters:
B
- Second matrix in the element-wise multiplication.- Returns:
- The result of element-wise multiplication of this matrix with the matrix B.
- Throws:
IllegalArgumentException
- If this matrix and B have different shapes.
-
elemMult
Computes the element-wise multiplication (Hadamard product) between two matrices.- Parameters:
B
- Second matrix in the element-wise multiplication.- Returns:
- The result of element-wise multiplication of this matrix with the matrix B.
- Throws:
IllegalArgumentException
- If this matrix and B have different shapes.
-
elemMult
Computes the element-wise multiplication (Hadamard product) between two matrices.- Parameters:
B
- Second matrix in the element-wise multiplication.- Returns:
- The result of element-wise multiplication of this matrix with the matrix B.
- Throws:
IllegalArgumentException
- If this matrix and B have different shapes.
-
elemMult
Computes the element-wise multiplication (Hadamard product) between two matrices.- Parameters:
B
- Second matrix in the element-wise multiplication.- Returns:
- The result of element-wise multiplication of this matrix with the matrix B.
- Throws:
IllegalArgumentException
- If this matrix and B have different shapes.
-
elemDiv
Computes the element-wise division between two matrices.- Parameters:
B
- Second matrix in the element-wise division.- Returns:
- The result of element-wise division of this matrix with the matrix B.
- Throws:
IllegalArgumentException
- If this matrix and B have different shapes.ArithmeticException
- If B contains any zero entries.
-
elemDiv
Computes the element-wise division between two matrices.- Parameters:
B
- Second matrix in the element-wise division.- Returns:
- The result of element-wise division of this matrix with the matrix B.
- Throws:
IllegalArgumentException
- If this matrix and B have different shapes.ArithmeticException
- If B contains any zero entries.
-
det
X det()Computes the determinant of a square matrix.- Returns:
- The determinant of this matrix.
- Throws:
IllegalArgumentException
- If this matrix is not square.
-
fib
Computes the Frobenius inner product of two matrices.- Parameters:
B
- Second matrix in the Frobenius inner product- Returns:
- The Frobenius inner product of this matrix and matrix B.
- Throws:
IllegalArgumentException
- If this matrix and B have different shapes.
-
fib
Computes the Frobenius inner product of two matrices.- Parameters:
B
- Second matrix in the Frobenius inner product- Returns:
- The Frobenius inner product of this matrix and matrix B.
- Throws:
IllegalArgumentException
- If this matrix and B have different shapes.
-
fib
Computes the Frobenius inner product of two matrices.- Parameters:
B
- Second matrix in the Frobenius inner product- Returns:
- The Frobenius inner product of this matrix and matrix B.
- Throws:
IllegalArgumentException
- If this matrix and B have different shapes.
-
fib
Computes the Frobenius inner product of two matrices.- Parameters:
B
- Second matrix in the Frobenius inner product- Returns:
- The Frobenius inner product of this matrix and matrix B.
- Throws:
IllegalArgumentException
- If this matrix and B have different shapes.
-
sumCols
UU sumCols()Sums together the columns of a matrix as if each column was a column vector.- Returns:
- The result of summing together all columns of the matrix as column vectors. If this matrix is an m-by-n matrix, then the result will be a vectors of length m.
-
sumRows
UU sumRows()Sums together the rows of a matrix as if each row was a row vector.- Returns:
- The result of summing together all rows of the matrix as row vectors. If this matrix is an m-by-n matrix, then the result will be a vector of length n.
-
addToEachCol
Adds a vector to each column of a matrix. The vector need not be a column vector. If it is a row vector it will be treated as if it were a column vector.- Parameters:
b
- Vector to add to each column of this matrix.- Returns:
- The result of adding the vector b to each column of this matrix.
-
addToEachCol
Adds a vector to each column of a matrix. The vector need not be a column vector. If it is a row vector it will be treated as if it were a column vector.- Parameters:
b
- Vector to add to each column of this matrix.- Returns:
- The result of adding the vector b to each column of this matrix.
-
addToEachCol
Adds a vector to each column of a matrix. The vector need not be a column vector. If it is a row vector it will be treated as if it were a column vector.- Parameters:
b
- Vector to add to each column of this matrix.- Returns:
- The result of adding the vector b to each column of this matrix.
-
addToEachCol
Adds a vector to each column of a matrix. The vector need not be a column vector. If it is a row vector it will be treated as if it were a column vector.- Parameters:
b
- Vector to add to each column of this matrix.- Returns:
- The result of adding the vector b to each column of this matrix.
-
addToEachRow
Adds a vector to each row of a matrix. The vector need not be a row vector. If it is a column vector it will be treated as if it were a row vector for this operation.- Parameters:
b
- Vector to add to each row of this matrix.- Returns:
- The result of adding the vector b to each row of this matrix.
-
addToEachRow
Adds a vector to each row of a matrix. The vector need not be a row vector. If it is a column vector it will be treated as if it were a row vector for this operation.- Parameters:
b
- Vector to add to each row of this matrix.- Returns:
- The result of adding the vector b to each row of this matrix.
-
addToEachRow
Adds a vector to each row of a matrix. The vector need not be a row vector. If it is a column vector it will be treated as if it were a row vector for this operation.- Parameters:
b
- Vector to add to each row of this matrix.- Returns:
- The result of adding the vector b to each row of this matrix.
-
addToEachRow
Adds a vector to each row of a matrix. The vector need not be a row vector. If it is a column vector it will be treated as if it were a row vector for this operation.- Parameters:
b
- Vector to add to each row of this matrix.- Returns:
- The result of adding the vector b to each row of this matrix.
-
stack
- Parameters:
B
- Matrix to stack to this matrix.- Returns:
- The result of stacking this matrix on top of the matrix B.
- Throws:
IllegalArgumentException
- If this matrix and matrix B have a different number of columns.
-
stack
- Parameters:
B
- Matrix to stack to this matrix.- Returns:
- The result of stacking this matrix on top of the matrix B.
- Throws:
IllegalArgumentException
- If this matrix and matrix B have a different number of columns.
-
stack
- Parameters:
B
- Matrix to stack to this matrix.- Returns:
- The result of stacking this matrix on top of the matrix B.
- Throws:
IllegalArgumentException
- If this matrix and matrix B have a different number of columns.
-
stack
- Parameters:
B
- Matrix to stack to this matrix.- Returns:
- The result of stacking this matrix on top of the matrix B.
- Throws:
IllegalArgumentException
- If this matrix and matrix B have a different number of columns.
-
stack
- Parameters:
B
- Matrix to stack to this matrix.- Returns:
- The result of stacking this matrix on top of the matrix B.
- Throws:
IllegalArgumentException
- If this matrix and matrix B have a different number of columns.
-
stack
- Parameters:
B
- Matrix to stack to this matrix.- Returns:
- The result of stacking this matrix on top of the matrix B.
- Throws:
IllegalArgumentException
- If this matrix and matrix B have a different number of columns.
-
stack
- Parameters:
B
- Matrix to stack to this matrix.axis
- Axis along which to stack.
- If axis=0, then stacks along rows and is equivalent toaugment(Matrix)
. - If axis=1, then stacks along columns and is equivalent tostack(Matrix)
.- Returns:
- The result of stacking this matrix and B along the specified axis.
- Throws:
IllegalArgumentException
- If this matrix and matrix B have a different length along the corresponding axis.IllegalArgumentException
- If axis is not either 0 or 1.
-
stack
- Parameters:
B
- Matrix to stack to this matrix.axis
- Axis along which to stack.
- If axis=0, then stacks along rows and is equivalent toaugment(Matrix)
. - If axis=1, then stacks along columns and is equivalent tostack(Matrix)
.- Returns:
- The result of stacking this matrix and B along the specified axis.
- Throws:
IllegalArgumentException
- If this matrix and matrix B have a different length along the corresponding axis.IllegalArgumentException
- If axis is not either 0 or 1.
-
stack
- Parameters:
B
- Matrix to stack to this matrix.axis
- Axis along which to stack.
- If axis=0, then stacks along rows and is equivalent toaugment(Matrix)
. - If axis=1, then stacks along columns and is equivalent tostack(Matrix)
.- Returns:
- The result of stacking this matrix and B along the specified axis.
- Throws:
IllegalArgumentException
- If this matrix and matrix B have a different length along the corresponding axis.IllegalArgumentException
- If axis is not either 0 or 1.
-
stack
- Parameters:
B
- Matrix to stack to this matrix.axis
- Axis along which to stack.
- If axis=0, then stacks along rows and is equivalent toaugment(Matrix)
. - If axis=1, then stacks along columns and is equivalent tostack(Matrix)
.- Returns:
- The result of stacking this matrix and B along the specified axis.
- Throws:
IllegalArgumentException
- If this matrix and matrix B have a different length along the corresponding axis.IllegalArgumentException
- If axis is not either 0 or 1.
-
stack
- Parameters:
B
- Matrix to stack to this matrix.axis
- Axis along which to stack.
- If axis=0, then stacks along rows and is equivalent toaugment(Matrix)
. - If axis=1, then stacks along columns and is equivalent tostack(Matrix)
.- Returns:
- The result of stacking this matrix and B along the specified axis.
- Throws:
IllegalArgumentException
- If this matrix and matrix B have a different length along the corresponding axis.IllegalArgumentException
- If axis is not either 0 or 1.
-
stack
- Parameters:
B
- Matrix to stack to this matrix.axis
- Axis along which to stack.
- If axis=0, then stacks along rows and is equivalent toaugment(Matrix)
. - If axis=1, then stacks along columns and is equivalent tostack(Matrix)
.- Returns:
- The result of stacking this matrix and B along the specified axis.
- Throws:
IllegalArgumentException
- If this matrix and matrix B have a different length along the corresponding axis.IllegalArgumentException
- If axis is not either 0 or 1.
-
augment
- Parameters:
B
- Matrix to stack to this matrix.- Returns:
- The result of stacking B to the right of this matrix.
- Throws:
IllegalArgumentException
- If this matrix and matrix B have a different number of rows.
-
augment
- Parameters:
B
- Matrix to stack to this matrix.- Returns:
- The result of stacking B to the right of this matrix.
- Throws:
IllegalArgumentException
- If this matrix and matrix B have a different number of rows.
-
augment
- Parameters:
B
- Matrix to stack to this matrix.- Returns:
- The result of stacking B to the right of this matrix.
- Throws:
IllegalArgumentException
- If this matrix and matrix B have a different number of rows.
-
augment
- Parameters:
B
- Matrix to stack to this matrix.- Returns:
- The result of stacking B to the right of this matrix.
- Throws:
IllegalArgumentException
- If this matrix and matrix B have a different number of rows.
-
augment
- Parameters:
B
- Matrix to stack to this matrix.- Returns:
- The result of stacking B to the right of this matrix.
- Throws:
IllegalArgumentException
- If this matrix and matrix B have a different number of rows.
-
augment
- Parameters:
B
- Matrix to stack to this matrix.- Returns:
- The result of stacking B to the right of this matrix.
- Throws:
IllegalArgumentException
- If this matrix and matrix B have a different number of rows.
-
stack
Stacks vector to this matrix along columns. Note that the orientation of the vector (i.e. row/column vector) does not affect the output of this function. All vectors will be treated as row vectors.
Also seestack(Vector, int)
andaugment(Vector)
.- Parameters:
b
- Vector to stack to this matrix.- Returns:
- The result of stacking this matrix on top of the vector b.
- Throws:
IllegalArgumentException
- If the number of columns in this matrix is different from the number of entries in the vector b.
-
stack
Stacks vector to this matrix along columns. Note that the orientation of the vector (i.e. row/column vector) does not affect the output of this function. All vectors will be treated as row vectors.
Also seestack(CooVector, int)
andaugment(CooVector)
.- Parameters:
b
- Vector to stack to this matrix.- Returns:
- The result of stacking this matrix on top of the vector b.
- Throws:
IllegalArgumentException
- If the number of columns in this matrix is different from the number of entries in the vector b.
-
stack
Stacks vector to this matrix along columns. Note that the orientation of the vector (i.e. row/column vector) does not affect the output of this function. All vectors will be treated as row vectors.
Also seestack(CVector, int)
andaugment(CVector)
.- Parameters:
b
- Vector to stack to this matrix.- Returns:
- The result of stacking this matrix on top of the vector b.
- Throws:
IllegalArgumentException
- If the number of columns in this matrix is different from the number of entries in the vector b.
-
stack
Stacks vector to this matrix along columns. Note that the orientation of the vector (i.e. row/column vector) does not affect the output of this function. All vectors will be treated as row vectors.
Also seestack(CooCVector, int)
andaugment(CooCVector)
.- Parameters:
b
- Vector to stack to this matrix.- Returns:
- The result of stacking this matrix on top of the vector b.
- Throws:
IllegalArgumentException
- If the number of columns in this matrix is different from the number of entries in the vector b.
-
stack
Stacks matrix and vector along specified axis. Note that the orientation of the vector (i.e. row/column vector) does not affect the output of this function. See the axis parameter for more info.- Parameters:
b
- Vector to stack to this matrix.axis
- Axis along which to stack.
- If axis=0, then stacks along rows and is equivalent toaugment(Vector)
. In this case, the vector b will be treated as a column vector regardless of the true orientation.
- If axis=1, then stacks along columns and is equivalent tostack(Vector)
. In this case, the vector b will be treated as a row vector regardless of the true orientation.- Returns:
- The result of stacking this matrix and B along the specified axis.
- Throws:
IllegalArgumentException
- If the number of entries in b is different from the length of this matrix along the corresponding axis.IllegalArgumentException
- If axis is not either 0 or 1.
-
stack
Stacks matrix and vector along specified axis. Note that the orientation of the vector (i.e. row/column vector) does not affect the output of this function. See the axis parameter for more info.- Parameters:
b
- Vector to stack to this matrix.axis
- Axis along which to stack.
- If axis=0, then stacks along rows and is equivalent toaugment(CooVector)
. In this case, the vector b will be treated as a column vector regardless of the true orientation.
- If axis=1, then stacks along columns and is equivalent tostack(CooVector)
. In this case, the vector b will be treated as a row vector regardless of the true orientation.- Returns:
- The result of stacking this matrix and B along the specified axis.
- Throws:
IllegalArgumentException
- If the number of entries in b is different from the length of this matrix along the corresponding axis.IllegalArgumentException
- If axis is not either 0 or 1.
-
stack
Stacks matrix and vector along specified axis. Note that the orientation of the vector (i.e. row/column vector) does not affect the output of this function. See the axis parameter for more info.- Parameters:
b
- Vector to stack to this matrix.axis
- Axis along which to stack.
- If axis=0, then stacks along rows and is equivalent toaugment(CVector)
. In this case, the vector b will be treated as a column vector regardless of the true orientation.
- If axis=1, then stacks along columns and is equivalent tostack(CVector)
. In this case, the vector b will be treated as a row vector regardless of the true orientation.- Returns:
- The result of stacking this matrix and B along the specified axis.
- Throws:
IllegalArgumentException
- If the number of entries in b is different from the length of this matrix along the corresponding axis.IllegalArgumentException
- If axis is not either 0 or 1.
-
stack
Stacks matrix and vector along specified axis. Note that the orientation of the vector (i.e. row/column vector) does not affect the output of this function. See the axis parameter for more info.- Parameters:
b
- Vector to stack to this matrix.axis
- Axis along which to stack.
- If axis=0, then stacks along rows and is equivalent toaugment(CooCVector)
. In this case, the vector b will be treated as a column vector regardless of the true orientation.
- If axis=1, then stacks along columns and is equivalent tostack(CooCVector)
. In this case, the vector b will be treated as a row vector regardless of the true orientation.- Returns:
- The result of stacking this matrix and B along the specified axis.
- Throws:
IllegalArgumentException
- If the number of entries in b is different from the length of this matrix along the corresponding axis.IllegalArgumentException
- If axis is not either 0 or 1.
-
augment
Augments a matrix with a vector. That is, stacks a vector along the rows to the right side of a matrix. Note that the orientation of the vector (i.e. row/column vector) does not affect the output of this function. The vector will be treated as a column vector regardless of the true orientation.
Also seestack(Vector)
andstack(Vector, int)
.- Parameters:
b
- vector to augment to this matrix.- Returns:
- The result of augmenting b to the right of this matrix.
- Throws:
IllegalArgumentException
- If this matrix has a different number of rows as entries in b.
-
augment
Augments a matrix with a vector. That is, stacks a vector along the rows to the right side of a matrix. Note that the orientation of the vector (i.e. row/column vector) does not affect the output of this function. The vector will be treated as a column vector regardless of the true orientation.
Also seestack(CooVector)
andstack(CooVector, int)
.- Parameters:
b
- vector to augment to this matrix.- Returns:
- The result of augmenting b to the right of this matrix.
- Throws:
IllegalArgumentException
- If this matrix has a different number of rows as entries in b.
-
augment
Augments a matrix with a vector. That is, stacks a vector along the rows to the right side of a matrix. Note that the orientation of the vector (i.e. row/column vector) does not affect the output of this function. The vector will be treated as a column vector regardless of the true orientation.
Also seestack(CVector)
andstack(CVector, int)
.- Parameters:
b
- vector to augment to this matrix.- Returns:
- The result of augmenting b to the right of this matrix.
- Throws:
IllegalArgumentException
- If this matrix has a different number of rows as entries in b.
-
augment
Augments a matrix with a vector. That is, stacks a vector along the rows to the right side of a matrix. Note that the orientation of the vector (i.e. row/column vector) does not affect the output of this function. The vector will be treated as a column vector regardless of the true orientation.
Also seestack(CooCVector)
andstack(CooCVector, int)
.- Parameters:
b
- vector to augment to this matrix.- Returns:
- The result of augmenting b to the right of this matrix.
- Throws:
IllegalArgumentException
- If this matrix has a different number of rows as entries in b.
-
getRow
Get the row of this matrix at the specified index.- Parameters:
i
- Index of row to get.- Returns:
- The specified row of this matrix.
-
getCol
Get the column of this matrix at the specified index.- Parameters:
j
- Index of column to get.- Returns:
- The specified column of this matrix.
-
getCol
Gets a specified column of this matrix betweenrowStart
(inclusive) androwEnd
(exclusive).- Parameters:
colIdx
- Index of the column of this matrix to get.rowStart
- Starting row of the column (inclusive).rowEnd
- Ending row of the column (exclusive).- Returns:
- The column at index
colIdx
of this matrix between therowStart
androwEnd
indices. - Throws:
IllegalArgumentException
- IfrowStart
is less than 0.NegativeArraySizeException
- IfrowEnd
is less thanrowStart
.
-
toVector
TT toVector()Converts this matrix to an equivalent vector. If this matrix is not shaped as a row/column vector, it will be flattened then converted to a vector.- Returns:
- A vector equivalent to this matrix.
-
getSlice
Gets a specified slice of this matrix.- Parameters:
rowStart
- Starting row index of slice (inclusive).rowEnd
- Ending row index of slice (exclusive).colStart
- Starting column index of slice (inclusive).colEnd
- Ending row index of slice (exclusive).- Returns:
- The specified slice of this matrix. This is a completely new matrix and NOT a view into the matrix.
- Throws:
ArrayIndexOutOfBoundsException
- If any of the indices are out of bounds of this matrix.IllegalArgumentException
- IfrowEnd
is not greater thanrowStart
or ifcolEnd
is not greater thancolStart
.
-
getColBelow
Get a specified column of this matrix at and below a specified row.- Parameters:
rowStart
- Index of the row to begin at.j
- Index of column to get.- Returns:
- The specified column of this matrix beginning at the specified row.
- Throws:
NegativeArraySizeException
- IfrowStart
is larger than the number of rows in this matrix.ArrayIndexOutOfBoundsException
- IfrowStart
orj
is outside the bounds of this matrix.
-
getRowAfter
Get a specified row of this matrix at and after a specified column.- Parameters:
colStart
- Index of the row to begin at.i
- Index of the row to get.- Returns:
- The specified row of this matrix beginning at the specified column.
- Throws:
NegativeArraySizeException
- IfcolStart
is larger than the number of columns in this matrix.ArrayIndexOutOfBoundsException
- Ifi
orcolStart
is outside the bounds of this matrix.
-
setCol
Sets a column of this matrix.- Parameters:
values
- Vector containing the new values for the matrix.j
- Index of the column of this matrix to set.- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If the number of entries in thevalues
vector is not the same as the number of rows in this matrix.IndexOutOfBoundsException
- Ifj
is not within the bounds of this matrix.
-
trace
X trace()Computes the trace of this matrix. That is, the sum of elements along the principle diagonal of this matrix. Same astr()
.- Returns:
- The trace of this matrix.
- Throws:
IllegalArgumentException
- If this matrix is not square.
-
tr
X tr()Computes the trace of this matrix. That is, the sum of elements along the principle diagonal of this matrix. Same astrace()
.- Returns:
- The trace of this matrix.
- Throws:
IllegalArgumentException
- If this matrix is not square.
-
getDiag
TT getDiag()Extracts the diagonal elements of this matrix and returns them as a vector.- Returns:
- A vector containing the diagonal entries of this matrix.
-
H
T H()Compute the hermitian transpose of this matrix. That is, the complex conjugate transpose of this matrix.- Returns:
- The complex conjugate transpose of this matrix.
-
copy
-
mult
Computes scalar multiplication of a matrix.- Parameters:
factor
- Scalar value to multiply with matrix.- Returns:
- The result of multiplying this matrix by the specified scalar.
-