Package org.flag4j.arrays.dense
Class CMatrix
- All Implemented Interfaces:
Serializable
,ComplexMatrixMixin<CMatrix>
,ComplexTensorMixin<CMatrix,
,Matrix> DenseMatrixMixin<CMatrix,
,CNumber> DenseMixin<CNumber>
,MatrixComparisonsMixin<CMatrix>
,MatrixManipulationsMixin<CMatrix,
,CNumber> MatrixMixin<CMatrix,
,CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> MatrixOperationsMixin<CMatrix,
,CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> MatrixPropertiesMixin
,TensorComparisonsMixin
,TensorManipulationsMixin<CMatrix>
,TensorOperationsMixin<CMatrix,
,CMatrix, CMatrix, CMatrix, Matrix, CNumber> TensorPropertiesMixin
public class CMatrix
extends ComplexDenseTensorBase<CMatrix,Matrix>
implements MatrixMixin<CMatrix,CMatrix,CooCMatrix,CMatrix,CooCMatrix,CNumber,CVector,CVector>, ComplexMatrixMixin<CMatrix>, DenseMatrixMixin<CMatrix,CNumber>
Complex dense matrix. Stored in row major format. This class is mostly equivalent to a
complex dense tensor
.
However, specialized methods are provided for this class which may result in slightly better performance than
equivalent operations with a complex dense tensor
of rank 2. Additionally, methods specific to matrices
which may not be available for tensors are provided.- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionfinal int
The number of columns in this matrix.final int
The number of rows in this matrix.Fields inherited from class org.flag4j.core.TensorBase
DEFAULT_ROUND_TO_ZERO_THRESHOLD, entries, shape
-
Constructor Summary
ConstructorDescriptionCMatrix
(double[][] entries) Creates a complex dense matrix whose entries are specified by a double array.CMatrix
(int size) Constructs a square complex dense matrix of a specified size.CMatrix
(int[][] entries) Creates a complex dense matrix whose entries are specified by a double array.CMatrix
(int size, double value) Creates a square complex dense matrix with a specified fill value.CMatrix
(int rows, int cols) Creates a complex dense matrix of a specified shape filled with zeros.CMatrix
(int rows, int cols, double value) Creates a complex dense matrix with a specified shape and fills the matrix with the specified value.Creates a complex dense matrix with a specified shape and fills the matrix with the specified value.Constructs a complex matrix with specified shapes and entries.Creates a square complex dense matrix with a specified fill value.Creates a complex dense matrix whose entries are specified by a double array.Creates a complex dense matrix which is a copy of a specified matrix.Creates a complex dense matrix which is a copy of a specified matrix.Creates a complex dense matrix whose entries are specified by a double array.Creates a complex dense matrix with specified shape.Creates a complex dense matrix with specified shape filled with specified value.Creates a complex dense matrix with specified shape filled with specified entries.Creates a complex dense matrix with specified shape filled with specified value.Constructs a complex matrix with specified shapes and entries. -
Method Summary
Modifier and TypeMethodDescriptionComputes 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.void
Computes the element-wise addition of a matrix with a real dense matrix.void
addEq
(CooCMatrix B) Adds a complex sparse matrix to this matrix and stores the result in this matrix.void
Computes the element-wise addition of a matrix with a real sparse 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 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.det()
Computes the determinant of a square matrix.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.boolean
Checks if an object is equal to this matrix object.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.flatten()
Flattens a matrix to have a single row.flatten
(int axis) Flattens a matrix along a specified axis.get
(int... indices) Gets the element in this tensor at the specified indices.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).getColAsVector
(int j) Get the column of this matrix at the specified index.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.static CMatrix
getEmpty
(int rows, int cols) Constructs an empty complex dense matrix.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.getRowAsVector
(int i) Get the row of this matrix at the specified index.protected CMatrix
getSelf()
Simply returns a reference of this tensor.getSlice
(int rowStart, int rowEnd, int colStart, int colEnd) Gets a specified slice of this matrix.H()
Computes the hermitian transpose (i.e.static CMatrix
I
(int size) Constructs an identity matrix of the specified size.static CMatrix
I
(int numRows, int numCols) Constructs an identity-like matrix of the specified shape.static CMatrix
Constructs an identity-like matrix of the specified shape.boolean
Checks if a matrix is anti-Hermitian.boolean
Checks that this matrix is close to the identity matrix according toRealProperties.allClose(double[], double[])
boolean
Checks if a matrix has full rank.boolean
Checks if a matrix is Hermitian.boolean
isI()
Checks if this matrix is the identity matrix.boolean
Checks if a matrix is singular.boolean
isSquare()
Checks if this matrix is square.boolean
isTriL()
Checks if this matrix is lower triangular.boolean
isTriU()
Checks if this matrix is upper triangular.boolean
Checks if this matrix is unitary.boolean
isVector()
Checks if a matrix can be represented as a vector.protected Matrix
makeRealTensor
(Shape shape, double[] entries) Factory to create a real tensor with the specified shape and size.protected CMatrix
makeTensor
(Shape shape, CNumber... entries) Factory to create a tensor with the specified shape and size.int
Computes the rank of this matrix (i.e.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.int
numCols()
Gets the number of columns in this matrix.int
numRows()
Gets the number of rows in this matrix.pow
(int exponent) Computes the matrix power with a given exponent.removeCol
(int colIndex) Removes a specified column from this matrix.removeCols
(int... colIndices) Removes a specified set of columns from this matrix.removeRow
(int rowIndex) Removes a specified row from this matrix.removeRows
(int... rowIndices) Removes a specified set of rows from this matrix.round()
Rounds this matrix to the nearest whole number.round
(int precision) Rounds a matrix to the nearest whole number.Rounds values which are close to zero in absolute value to zero.roundToZero
(double threshold) Rounds values which are close to zero in absolute value to zero.private String
rowToString
(int i, int colStopIndex, List<Integer> maxList) Gets row of matrix formatted as a human-readable String.set
(double value, int row, int col) Sets an index of this matrix to the specified value.Sets an index of this matrix to the specified value.setCol
(double[] values, int colIndex) Sets a column of this matrix at the given index to the specified values.setCol
(int[] values, int colIndex) Sets a column of this matrix at the given index to the specified values.Sets a column of this matrix at the given index to the specified values.Sets a column of this matrix at the given index to the specified values.Sets a column of this matrix at the given index to the specified values.Sets a column of this matrix at the given index to the specified values.setCol
(CooCVector values, int colIndex) Sets a column of this matrix at the given index to the specified values.Sets a column of this matrix at the given index to the specified values.setRow
(double[] values, int rowIndex) Sets a row of this matrix at the given index to the specified values.setRow
(int[] values, int rowIndex) Sets a row of this matrix at the given index to the specified values.Sets a row of this matrix at the given index to the specified values.Sets a row of this matrix at the given index to the specified values.Sets a row of this matrix at the given index to the specified values.setRow
(CooCVector values, int rowIndex) Sets a row of this matrix at the given index to the specified values.Sets a row of this matrix at the given index to the specified values.setSlice
(double[][] values, int rowStart, int colStart) Sets a slice of this matrix to the specified values.setSlice
(int[][] values, int rowStart, int colStart) Sets a slice of this matrix to the specified values.Sets a slice of this matrix to the specified values.Sets a slice of this matrix to the specified values.Sets a slice of this matrix to the specified values.Sets a slice of this matrix to the specified values.setSlice
(CooCMatrix values, int rowStart, int colStart) Sets a slice of this matrix to the specified values.Sets a slice of this matrix to the specified values.Sets a slice of this matrix to the specified values.setSliceCopy
(double[][] values, int rowStart, int colStart) Creates a copy of this matrix and sets a slice of the copy to the specified values.setSliceCopy
(int[][] values, int rowStart, int colStart) Creates a copy of this matrix and sets a slice of the copy to the specified values.setSliceCopy
(Double[][] values, int rowStart, int colStart) Creates a copy of this matrix and sets a slice of the copy to the specified values.setSliceCopy
(Integer[][] values, int rowStart, int colStart) Creates a copy of this matrix and sets a slice of the copy to the specified values.setSliceCopy
(CMatrix values, int rowStart, int colStart) Creates a copy of this matrix and sets a slice of the copy to the specified values.setSliceCopy
(Matrix values, int rowStart, int colStart) Creates a copy of this matrix and sets a slice of the copy to the specified values.setSliceCopy
(CooCMatrix values, int rowStart, int colStart) Creates a copy of this matrix and sets a slice of the copy to the specified values.setSliceCopy
(CooMatrix values, int rowStart, int colStart) Creates a copy of this matrix and sets a slice of the copy to the specified values.setSliceCopy
(CNumber[][] values, int rowStart, int colStart) Creates a copy of this matrix and sets a slice of the copy to the specified values.setValues
(double[][] values) Sets the value of this matrix using a 2D array.setValues
(int[][] values) Sets the value of this matrix using a 2D array.Sets the value of this matrix using a 2D array.Sets the value of this matrix using a 2D array.shape()
Gets the shape of this matrix.Stacks matrices along columns.Stacks vector to this matrix along columns.Stacks matrices along columns.Stacks vector to this matrix along columns.stack
(CooCMatrix B) Stacks matrices along columns.stack
(CooCVector b) Stacks vector to this matrix along columns.Stacks matrices along columns.Stacks vector to this matrix along columns.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.void
Computes the element-wise subtraction of this matrix with a real dense matrix.void
subEq
(CooCMatrix B) Subtracts a complex sparse matrix from this matrix and stores the result in this matrix.void
Computes the element-wise subtraction of this matrix with a real sparse matrix.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.swapCols
(int colIndex1, int colIndex2) Swaps specified columns in the matrix.swapRows
(int rowIndex1, int rowIndex2) Swaps specified rows in the matrix.T()
Computes the transpose of a tensor.toCoo()
Converts this dense matrix to an equivalentCooCMatrix
.toCsr()
Converts this matrix to an equivalent sparse CSR matrix.toString()
Formats matrix contents as a human-readable String.toTensor()
Converts this matrix to an equivalent complex tensor.toVector()
Converts this matrix to an equivalent vector.tr()
Computes the trace of this matrix.trace()
Computes the trace of this matrix.int
Checks what type of vector this matrix is.Methods inherited from class org.flag4j.core.dense_base.ComplexDenseTensorBase
abs, add, add, add, addEq, addEq, addEq, allClose, argMax, argMin, conj, copy, div, div, elemDiv, elemMult, hashCode, isComplex, isOnes, isReal, isZeros, max, maxAbs, min, minAbs, mult, mult, recip, reshape, reshape, set, set, sqrt, sub, sub, sub, subEq, subEq, subEq, sum, toReal, toRealSafe
Methods inherited from class org.flag4j.core.TensorBase
allClose, getEntries, getRank, getShape, sameLength, sameShape, tensorEquals, totalEntries
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.flag4j.core.ComplexMatrixMixin
conj, conjT, isComplex, isReal
Methods inherited from interface org.flag4j.core.ComplexTensorMixin
hermTranspose
Methods inherited from interface org.flag4j.core.MatrixOperationsMixin
add, augment, augment, copy, elemDiv, elemMult, mult, multTranspose, multTranspose, stack, stack, stack, stack, stack, stack, stack, stack, stack, stack, stack, stack, sub
Methods inherited from interface org.flag4j.core.MatrixPropertiesMixin
isDiag, isInvertible, isTri
Methods inherited from interface org.flag4j.core.TensorOperationsMixin
transpose
-
Field Details
-
numRows
public final int numRowsThe number of rows in this matrix. -
numCols
public final int numColsThe number of columns in this matrix.
-
-
Constructor Details
-
CMatrix
public CMatrix(int size) Constructs a square complex dense matrix of a specified size. The entries of the matrix will default to zero.- Parameters:
size
- Size of the square matrix.- Throws:
IllegalArgumentException
- if size negative.
-
CMatrix
public CMatrix(int size, double value) Creates a square complex dense matrix with a specified fill value.- Parameters:
size
- Size of the square matrix.value
- Value to fill this matrix with.- Throws:
IllegalArgumentException
- if size negative.
-
CMatrix
Creates a square complex dense matrix with a specified fill value.- Parameters:
size
- Size of the square matrix.value
- Value to fill this matrix with.- Throws:
IllegalArgumentException
- if size negative.
-
CMatrix
public CMatrix(int rows, int cols) Creates a complex dense matrix of a specified shape filled with zeros.- Parameters:
rows
- The number of rows in the matrix.cols
- The number of columns in the matrix.- Throws:
IllegalArgumentException
- if either rows or cols is negative.
-
CMatrix
public CMatrix(int rows, int cols, double value) Creates a complex dense matrix with a specified shape and fills the matrix with the specified value.- Parameters:
rows
- Number of rows in the matrix.cols
- Number of columns in the matrix.value
- Value to fill this matrix with.- Throws:
IllegalArgumentException
- if either rows or cols is negative.
-
CMatrix
Creates a complex dense matrix with a specified shape and fills the matrix with the specified value.- Parameters:
rows
- Number of rows in the matrix.cols
- Number of columns in the matrix.value
- Value to fill this matrix with.- Throws:
IllegalArgumentException
- if either rows or cols is negative.
-
CMatrix
Creates a complex dense matrix with specified shape.- Parameters:
shape
- Shape of the matrix.
-
CMatrix
Creates a complex dense matrix with specified shape filled with specified value.- Parameters:
shape
- Shape of the matrix.value
- Value to fill matrix with.
-
CMatrix
Creates a complex dense matrix with specified shape filled with specified entries.- Parameters:
shape
- Shape of the matrix.entries
- Entries of this matrix.
-
CMatrix
-
CMatrix
Creates a complex dense matrix whose entries are specified by a double array.- Parameters:
entries
- Entries of the real dense matrix.
-
CMatrix
Creates a complex dense matrix whose entries are specified by a double array.- Parameters:
entries
- Entries of the real dense matrix.
-
CMatrix
public CMatrix(double[][] entries) Creates a complex dense matrix whose entries are specified by a double array.- Parameters:
entries
- Entries of the real dense matrix.
-
CMatrix
public CMatrix(int[][] entries) Creates a complex dense matrix whose entries are specified by a double array.- Parameters:
entries
- Entries of the real dense matrix.
-
CMatrix
Creates a complex dense matrix which is a copy of a specified matrix.- Parameters:
A
- The matrix defining the entries for this matrix.
-
CMatrix
Creates a complex dense matrix which is a copy of a specified matrix.- Parameters:
A
- The matrix defining the entries for this matrix.
-
CMatrix
-
CMatrix
Constructs a complex matrix with specified shapes and entries. Note, unlike other constructors, the entries parameter is not copied.- Parameters:
numRows
- Number of rows in the matrix.numCols
- Number of columns in the matrix.entries
- Entries of the matrix.
-
-
Method Details
-
getEmpty
Constructs an empty complex dense matrix. Note, the entries of this matrix will benull
as contrast toCMatrix(int, int)
which will create the zero matrix.- Parameters:
rows
- The number of rows for the empty matrix to construct.cols
- The number of columns for the empty matrix to construct.- Returns:
- An empty matrix with the specified number of rows and columns.
-
makeTensor
Factory to create a tensor with the specified shape and size.- Specified by:
makeTensor
in classDenseTensorBase<CMatrix,
CMatrix, Matrix, CNumber[], CNumber> - Parameters:
shape
- Shape of the tensor to make.entries
- Entries of the tensor to make.- Returns:
- A new tensor with the specified shape and entries.
-
getSelf
-
makeRealTensor
Factory to create a real tensor with the specified shape and size.- Specified by:
makeRealTensor
in classComplexDenseTensorBase<CMatrix,
Matrix> - Parameters:
shape
- Shape of the tensor to make.entries
- Entries of the tensor to make.- Returns:
- A new tensor with the specified shape and entries.
-
numRows
public int numRows()Gets the number of rows in this matrix.- Specified by:
numRows
in interfaceMatrixMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - Returns:
- The number of rows in this matrix.
-
numCols
public int numCols()Gets the number of columns in this matrix.- Specified by:
numCols
in interfaceMatrixMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - Returns:
- The number of columns in this matrix.
-
shape
Gets the shape of this matrix.- Specified by:
shape
in interfaceMatrixMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - Returns:
- The shape of this matrix.
-
toTensor
Converts this matrix to an equivalent complex tensor.- Returns:
- A complex tensor which is equivalent to this matrix.
-
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.- Specified by:
toVector
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - Returns:
- A vector equivalent to this matrix.
-
toCoo
Converts this dense matrix to an equivalentCooCMatrix
. Note, this is likely only worthwhile for very sparse matrices.- Specified by:
toCoo
in classDenseTensorBase<CMatrix,
CMatrix, Matrix, CNumber[], CNumber> - Returns:
- A
CooCMatrix
that is equivalent to this dense matrix. - See Also:
-
toCsr
Converts this matrix to an equivalent sparse CSR matrix.- Returns:
- A sparse coo matrix equivalent to this matrix.
- See Also:
-
equals
Checks if an object is equal to this matrix object.- Specified by:
equals
in interfaceTensorComparisonsMixin
- Overrides:
equals
in classObject
- Parameters:
object
- Object to check equality with this matrix.- Returns:
- True if the two matrices have the same shape, are numerically equivalent, and are of type
CMatrix
. False otherwise.
-
isI
public boolean isI()Checks if this matrix is the identity matrix.- Specified by:
isI
in interfaceMatrixComparisonsMixin<CMatrix>
- Returns:
- True if this matrix is the identity matrix. Otherwise, returns false.
-
isCloseToI
public boolean isCloseToI()Checks that this matrix is close to the identity matrix according toRealProperties.allClose(double[], double[])
- Returns:
- True if this matrix is approximately the identity matrix.
- See Also:
-
flatten
Flattens a matrix to have a single row. To flatten matrix to a single column, seeflatten(int)
.- Specified by:
flatten
in interfaceTensorManipulationsMixin<CMatrix>
- Returns:
- The flat version of this matrix.
-
flatten
Flattens a matrix along a specified axis. Also seeflatten()
.- Specified by:
flatten
in interfaceTensorManipulationsMixin<CMatrix>
- Parameters:
axis
- - If axis=0, flattens to a row vector.
- If axis=1, flattens to a column vector.- Returns:
- The flat version of this matrix.
-
setValues
Sets the value of this matrix using a 2D array.- Specified by:
setValues
in interfaceDenseMatrixMixin<CMatrix,
CNumber> - Parameters:
values
- New values of the matrix.- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If the values array has a different shape then this matrix.
-
setValues
Sets the value of this matrix using a 2D array.- Specified by:
setValues
in interfaceDenseMatrixMixin<CMatrix,
CNumber> - Parameters:
values
- New values of the matrix.- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If the values array has a different shape then this matrix.
-
setValues
Sets the value of this matrix using a 2D array.- Specified by:
setValues
in interfaceDenseMatrixMixin<CMatrix,
CNumber> - Parameters:
values
- New values of the matrix.- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If the values array has a different shape then this matrix.
-
setValues
Sets the value of this matrix using a 2D array.- Specified by:
setValues
in interfaceDenseMatrixMixin<CMatrix,
CNumber> - Parameters:
values
- New values of the matrix.- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If the values array has a different shape then this matrix.
-
set
Description copied from interface:MatrixManipulationsMixin
Sets an index of this matrix to the specified value.- Specified by:
set
in interfaceMatrixManipulationsMixin<CMatrix,
CNumber> - Parameters:
value
- Value to set.row
- Row index to set.col
- Column index to set.- Returns:
- A reference to this matrix.
-
set
Description copied from interface:MatrixManipulationsMixin
Sets an index of this matrix to the specified value.- Specified by:
set
in interfaceMatrixManipulationsMixin<CMatrix,
CNumber> - Parameters:
value
- Value to set.row
- Row index to set.col
- Column index to set.- Returns:
- A reference to this matrix.
-
setCol
Sets a column of this matrix at the given index to the specified values.- Specified by:
setCol
in interfaceComplexMatrixMixin<CMatrix>
- Specified by:
setCol
in interfaceMatrixManipulationsMixin<CMatrix,
CNumber> - Parameters:
values
- New values for the column.colIndex
- The index of the column which is to be set.- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If the values array has a different length than the number of rows of this matrix.
-
setCol
Sets a column of this matrix at the given index to the specified values.- Specified by:
setCol
in interfaceMatrixManipulationsMixin<CMatrix,
CNumber> - Parameters:
values
- New values for the column.colIndex
- The index of the column which is to be set.- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If the values array has a different length than the number of rows of this matrix.
-
setCol
Sets a column of this matrix at the given index to the specified values.- Specified by:
setCol
in interfaceMatrixManipulationsMixin<CMatrix,
CNumber> - Parameters:
values
- New values for the column.colIndex
- The index of the column which is to be set.- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If the values array has a different length than the number of rows of this matrix.
-
setCol
Sets a column of this matrix at the given index to the specified values.- Specified by:
setCol
in interfaceMatrixManipulationsMixin<CMatrix,
CNumber> - Parameters:
values
- New values for the column.colIndex
- The index of the column which is to be set.- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If the values array has a different length than the number of rows of this matrix.
-
setCol
Sets a column of this matrix at the given index to the specified values.- Specified by:
setCol
in interfaceMatrixManipulationsMixin<CMatrix,
CNumber> - Parameters:
values
- New values for the column.colIndex
- The index of the column which is to be set.- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If the values array has a different length than the number of rows of this matrix.
-
setRow
Sets a row of this matrix at the given index to the specified values.- Specified by:
setRow
in interfaceComplexMatrixMixin<CMatrix>
- Specified by:
setRow
in interfaceMatrixManipulationsMixin<CMatrix,
CNumber> - Parameters:
values
- New values for the row.rowIndex
- The index of the column which is to be set.- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If the values array has a different length than the number of columns of this matrix.
-
setRow
Sets a row of this matrix at the given index to the specified values.- Specified by:
setRow
in interfaceMatrixManipulationsMixin<CMatrix,
CNumber> - Parameters:
values
- New values for the row.rowIndex
- The index of the column which is to be set.- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If the values array has a different length than the number of columns of this matrix.
-
setCol
Sets a column of this matrix at the given index to the specified values.- Specified by:
setCol
in interfaceComplexMatrixMixin<CMatrix>
- Specified by:
setCol
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - Parameters:
values
- New values for the column.colIndex
- The index of the column which is to be set.- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If the values vector has a different length than the number of rows of this matrix.
-
setCol
Sets a column of this matrix at the given index to the specified values.- Parameters:
values
- New values for the column.colIndex
- The index of the column which is to be set.- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If the values vector has a different length than the number of rows of this matrix.
-
setCol
Sets a column of this matrix at the given index to the specified values.- Specified by:
setCol
in interfaceComplexMatrixMixin<CMatrix>
- Parameters:
values
- New values for the column.colIndex
- The index of the columns which is to be set.- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If the values vector has a different length than the number of rows of this matrix.
-
setRow
Sets a row of this matrix at the given index to the specified values.- Specified by:
setRow
in interfaceComplexMatrixMixin<CMatrix>
- Parameters:
values
- New values for the row.rowIndex
- The index of the row which is to be set.- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If the values vector has a different length than the number of columns of this matrix.
-
setRow
Sets a row of this matrix at the given index to the specified values.- Specified by:
setRow
in interfaceComplexMatrixMixin<CMatrix>
- Parameters:
values
- New values for the row.rowIndex
- The index of the row which is to be set.- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If the values vector has a different length than the number of columns of this matrix.
-
setSlice
Sets a slice of this matrix to the specified values. The rowStart and colStart parameters specify the upper left index location of the slice to set.- Specified by:
setSlice
in interfaceComplexMatrixMixin<CMatrix>
- Parameters:
values
- New values for the specified slice.rowStart
- Starting row index for the slice (inclusive).colStart
- Starting column index for the slice (inclusive).- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If rowStart or colStart are not within the matrix.IllegalArgumentException
- If the values slice, with upper left corner at the specified location, does not fit completely within this matrix.
-
setSliceCopy
Creates a copy of this matrix and sets a slice of the copy to the specified values. The rowStart and colStart parameters specify the upper left index location of the slice to set.- Parameters:
values
- New values for the specified slice.rowStart
- Starting row index for the slice (inclusive).colStart
- Starting column index for the slice (inclusive).- Returns:
- A copy of this matrix with the given slice set to the specified values.
- Throws:
IllegalArgumentException
- If rowStart or colStart are not within the matrix.IllegalArgumentException
- If the values slice, with upper left corner at the specified location, does not fit completely within this matrix.
-
setSlice
Sets a slice of this matrix to the specified values. The rowStart and colStart parameters specify the upper left index location of the slice to set.- Specified by:
setSlice
in interfaceMatrixManipulationsMixin<CMatrix,
CNumber> - Parameters:
values
- New values for the specified slice.rowStart
- Starting row index for the slice (inclusive).colStart
- Starting column index for the slice (inclusive).- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If rowStart or colStart are not within the matrix.IllegalArgumentException
- If the values slice, with upper left corner at the specified location, does not fit completely within this matrix.
-
setSlice
Sets a slice of this matrix to the specified values. The rowStart and colStart parameters specify the upper left index location of the slice to set.- Specified by:
setSlice
in interfaceMatrixManipulationsMixin<CMatrix,
CNumber> - Parameters:
values
- New values for the specified slice.rowStart
- Starting row index for the slice (inclusive).colStart
- Starting column index for the slice (inclusive).- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If rowStart or colStart are not within the matrix.IllegalArgumentException
- If the values slice, with upper left corner at the specified location, does not fit completely within this matrix.
-
setRow
Sets a row of this matrix at the given index to the specified values.- Specified by:
setRow
in interfaceMatrixManipulationsMixin<CMatrix,
CNumber> - Parameters:
values
- New values for the row.rowIndex
- The index of the column which is to be set.- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If the values array has a different length than the number of columns of this matrix.
-
setRow
Sets a row of this matrix at the given index to the specified values.- Specified by:
setRow
in interfaceMatrixManipulationsMixin<CMatrix,
CNumber> - Parameters:
values
- New values for the row.rowIndex
- The index of the column which is to be set.- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If the values array has a different length than the number of columns of this matrix.
-
setRow
Sets a row of this matrix at the given index to the specified values.- Specified by:
setRow
in interfaceMatrixManipulationsMixin<CMatrix,
CNumber> - Parameters:
values
- New values for the row.rowIndex
- The index of the column which is to be set.- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If the values array has a different length than the number of columns of this matrix.
-
setSlice
Sets a slice of this matrix to the specified values. The rowStart and colStart parameters specify the upper left index location of the slice to set.- Specified by:
setSlice
in interfaceMatrixManipulationsMixin<CMatrix,
CNumber> - Parameters:
values
- New values for the specified slice.rowStart
- Starting row index for the slice (inclusive).colStart
- Starting column index for the slice (inclusive).- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If rowStart or colStart are not within the matrix.IllegalArgumentException
- If the values slice, with upper left corner at the specified location, does not fit completely within this matrix.
-
setSlice
Sets a slice of this matrix to the specified values. The rowStart and colStart parameters specify the upper left index location of the slice to set.- Specified by:
setSlice
in interfaceMatrixManipulationsMixin<CMatrix,
CNumber> - Parameters:
values
- New values for the specified slice.rowStart
- Starting row index for the slice (inclusive).colStart
- Starting column index for the slice (inclusive).- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If rowStart or colStart are not within the matrix.IllegalArgumentException
- If the values slice, with upper left corner at the specified location, does not fit completely within this matrix.
-
setSlice
Sets a slice of this matrix to the specified values. The rowStart and colStart parameters specify the upper left index location of the slice to set.- Specified by:
setSlice
in interfaceMatrixManipulationsMixin<CMatrix,
CNumber> - Parameters:
values
- New values for the specified slice.rowStart
- Starting row index for the slice (inclusive).colStart
- Starting column index for the slice (inclusive).- Returns:
- A reference to this matrix.
- Throws:
IndexOutOfBoundsException
- If rowStart or colStart are not within the matrix.IllegalArgumentException
- If the values slice, with upper left corner at the specified location, does not fit completely within this matrix.
-
setSlice
Sets a slice of this matrix to the specified values. The rowStart and colStart parameters specify the upper left index location of the slice to set.- Specified by:
setSlice
in interfaceMatrixManipulationsMixin<CMatrix,
CNumber> - Parameters:
values
- New values for the specified slice.rowStart
- Starting row index for the slice (inclusive).colStart
- Starting column index for the slice (inclusive).- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If rowStart or colStart are not within the matrix.IllegalArgumentException
- If the values slice, with upper left corner at the specified location, does not fit completely within this matrix.
-
setSlice
Sets a slice of this matrix to the specified values. The rowStart and colStart parameters specify the upper left index location of the slice to set.- Specified by:
setSlice
in interfaceMatrixManipulationsMixin<CMatrix,
CNumber> - Parameters:
values
- New values for the specified slice.rowStart
- Starting row index for the slice (inclusive).colStart
- Starting column index for the slice (inclusive).- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If rowStart or colStart are not within the matrix.IllegalArgumentException
- If the values slice, with upper left corner at the specified location, does not fit completely within this matrix.
-
setSlice
Sets a slice of this matrix to the specified values. The rowStart and colStart parameters specify the upper left index location of the slice to set.- Specified by:
setSlice
in interfaceMatrixManipulationsMixin<CMatrix,
CNumber> - Parameters:
values
- New values for the specified slice.rowStart
- Starting row index for the slice (inclusive).colStart
- Starting column index for the slice (inclusive).- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If rowStart or colStart are not within the matrix.IllegalArgumentException
- If the values slice, with upper left corner at the specified location, does not fit completely within this matrix.
-
setSliceCopy
Creates a copy of this matrix and sets a slice of the copy to the specified values. The rowStart and colStart parameters specify the upper left index location of the slice to set.- Specified by:
setSliceCopy
in interfaceDenseMatrixMixin<CMatrix,
CNumber> - Parameters:
values
- New values for the specified slice.rowStart
- Starting row index for the slice (inclusive).colStart
- Starting column index for the slice (inclusive).- Returns:
- A copy of this matrix with the given slice set to the specified values.
- Throws:
IllegalArgumentException
- If rowStart or colStart are not within the matrix.IllegalArgumentException
- If the values slice, with upper left corner at the specified location, does not fit completely within this matrix.
-
setSliceCopy
Creates a copy of this matrix and sets a slice of the copy to the specified values. The rowStart and colStart parameters specify the upper left index location of the slice to set.- Specified by:
setSliceCopy
in interfaceDenseMatrixMixin<CMatrix,
CNumber> - Parameters:
values
- New values for the specified slice.rowStart
- Starting row index for the slice (inclusive).colStart
- Starting column index for the slice (inclusive).- Returns:
- A copy of this matrix with the given slice set to the specified values.
- Throws:
IllegalArgumentException
- If rowStart or colStart are not within the matrix.IllegalArgumentException
- If the values slice, with upper left corner at the specified location, does not fit completely within this matrix.
-
setSliceCopy
Creates a copy of this matrix and sets a slice of the copy to the specified values. The rowStart and colStart parameters specify the upper left index location of the slice to set.- Specified by:
setSliceCopy
in interfaceDenseMatrixMixin<CMatrix,
CNumber> - Parameters:
values
- New values for the specified slice.rowStart
- Starting row index for the slice (inclusive).colStart
- Starting column index for the slice (inclusive).- Returns:
- A copy of this matrix with the given slice set to the specified values.
- Throws:
IndexOutOfBoundsException
- If rowStart or colStart are not within the matrix.IllegalArgumentException
- If the values slice, with upper left corner at the specified location, does not fit completely within this matrix.
-
setSliceCopy
Creates a copy of this matrix and sets a slice of the copy to the specified values. The rowStart and colStart parameters specify the upper left index location of the slice to set.- Specified by:
setSliceCopy
in interfaceDenseMatrixMixin<CMatrix,
CNumber> - Parameters:
values
- New values for the specified slice.rowStart
- Starting row index for the slice (inclusive).colStart
- Starting column index for the slice (inclusive).- Returns:
- A copy of this matrix with the given slice set to the specified values.
- Throws:
IllegalArgumentException
- If rowStart or colStart are not within the matrix.IllegalArgumentException
- If the values slice, with upper left corner at the specified location, does not fit completely within this matrix.
-
setSliceCopy
Creates a copy of this matrix and sets a slice of the copy to the specified values. The rowStart and colStart parameters specify the upper left index location of the slice to set.- Specified by:
setSliceCopy
in interfaceDenseMatrixMixin<CMatrix,
CNumber> - Parameters:
values
- New values for the specified slice.rowStart
- Starting row index for the slice (inclusive).colStart
- Starting column index for the slice (inclusive).- Returns:
- A copy of this matrix with the given slice set to the specified values.
- Throws:
IllegalArgumentException
- If rowStart or colStart are not within the matrix.IllegalArgumentException
- If the values slice, with upper left corner at the specified location, does not fit completely within this matrix.
-
setSliceCopy
Creates a copy of this matrix and sets a slice of the copy to the specified values. The rowStart and colStart parameters specify the upper left index location of the slice to set.- Specified by:
setSliceCopy
in interfaceDenseMatrixMixin<CMatrix,
CNumber> - Parameters:
values
- New values for the specified slice.rowStart
- Starting row index for the slice (inclusive).colStart
- Starting column index for the slice (inclusive).- Returns:
- A copy of this matrix with the given slice set to the specified values.
- Throws:
IllegalArgumentException
- If rowStart or colStart are not within the matrix.IllegalArgumentException
- If the values slice, with upper left corner at the specified location, does not fit completely within this matrix.
-
setSliceCopy
Creates a copy of this matrix and sets a slice of the copy to the specified values. The rowStart and colStart parameters specify the upper left index location of the slice to set.- Specified by:
setSliceCopy
in interfaceDenseMatrixMixin<CMatrix,
CNumber> - Parameters:
values
- New values for the specified slice.rowStart
- Starting row index for the slice (inclusive).colStart
- Starting column index for the slice (inclusive).- Returns:
- A copy of this matrix with the given slice set to the specified values.
- Throws:
IllegalArgumentException
- If rowStart or colStart are not within the matrix.IllegalArgumentException
- If the values slice, with upper left corner at the specified location, does not fit completely within this matrix.
-
setSliceCopy
Creates a copy of this matrix and sets a slice of the copy to the specified values. The rowStart and colStart parameters specify the upper left index location of the slice to set.- Specified by:
setSliceCopy
in interfaceDenseMatrixMixin<CMatrix,
CNumber> - Parameters:
values
- New values for the specified slice.rowStart
- Starting row index for the slice (inclusive).colStart
- Starting column index for the slice (inclusive).- Returns:
- A copy of this matrix with the given slice set to the specified values.
- Throws:
IllegalArgumentException
- If rowStart or colStart are not within the matrix.IllegalArgumentException
- If the values slice, with upper left corner at the specified location, does not fit completely within this matrix.
-
removeRow
Removes a specified row from this matrix.- Specified by:
removeRow
in interfaceMatrixManipulationsMixin<CMatrix,
CNumber> - Parameters:
rowIndex
- Index of the row to remove from this matrix.- Returns:
- a copy of this matrix with the specified row removed.
-
removeRows
Removes a specified set of rows from this matrix.- Specified by:
removeRows
in interfaceMatrixManipulationsMixin<CMatrix,
CNumber> - Parameters:
rowIndices
- The indices of the rows to remove from this matrix. Must be sorted and unique.- Returns:
- a copy of this matrix with the specified rows removed.
-
removeCol
Removes a specified column from this matrix.- Specified by:
removeCol
in interfaceMatrixManipulationsMixin<CMatrix,
CNumber> - Parameters:
colIndex
- Index of the column to remove from this matrix.- Returns:
- a copy of this matrix with the specified column removed.
-
removeCols
Removes a specified set of columns from this matrix.- Specified by:
removeCols
in interfaceMatrixManipulationsMixin<CMatrix,
CNumber> - Parameters:
colIndices
- Indices of the columns to remove from this matrix.- Returns:
- a copy of this matrix with the specified columns removed.
-
round
Rounds this matrix to the nearest whole number. If the matrix is complex, both the real and imaginary component will be rounded independently.- Specified by:
round
in interfaceTensorManipulationsMixin<CMatrix>
- Overrides:
round
in classComplexDenseTensorBase<CMatrix,
Matrix> - Returns:
- A copy of this matrix with each entry rounded to the nearest whole number.
- See Also:
-
round
Rounds a matrix to the nearest whole number. If the matrix is complex, both the real and imaginary component will be rounded independently.- Specified by:
round
in interfaceTensorManipulationsMixin<CMatrix>
- Overrides:
round
in classComplexDenseTensorBase<CMatrix,
Matrix> - Parameters:
precision
- The number of decimal places to round to. This value must be non-negative.- Returns:
- A copy of this matrix with rounded values.
- Throws:
IllegalArgumentException
- Ifprecision
is negative.- See Also:
-
roundToZero
Rounds values which are close to zero in absolute value to zero. If the matrix is complex, both the real and imaginary components will be rounded independently. By default, the values must be within 1.0*E^-12 of zero. To specify a threshold value seeroundToZero(double)
.- Specified by:
roundToZero
in interfaceTensorManipulationsMixin<CMatrix>
- Overrides:
roundToZero
in classComplexDenseTensorBase<CMatrix,
Matrix> - Returns:
- A copy of this matrix with rounded values.
- See Also:
-
roundToZero
Rounds values which are close to zero in absolute value to zero.- Specified by:
roundToZero
in interfaceTensorManipulationsMixin<CMatrix>
- Overrides:
roundToZero
in classComplexDenseTensorBase<CMatrix,
Matrix> - Parameters:
threshold
- Threshold for rounding values to zero. That is, if a value in this matrix is less than the threshold in absolute value then it will be rounded to zero. This value must be non-negative.- Returns:
- A copy of this matrix with rounded values.
- Throws:
IllegalArgumentException
- If threshold is negative.- See Also:
-
add
Computes the element-wise addition between two matrices.- Specified by:
add
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.- Specified by:
add
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.- Specified by:
add
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.- Specified by:
add
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.- Specified by:
add
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.- Specified by:
sub
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.- Specified by:
sub
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.- Specified by:
sub
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.- Specified by:
sub
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.
-
T
Computes the transpose of a tensor. Same asTensorOperationsMixin.transpose()
.
This method does NOT compute the conjugate transpose. You may be looking forH()
. -
H
Computes the hermitian transpose (i.e. the conjugate transpose) of the matrix. Same asComplexTensorMixin.hermTranspose()
.- Specified by:
H
in interfaceComplexMatrixMixin<CMatrix>
- Specified by:
H
in interfaceComplexTensorMixin<CMatrix,
Matrix> - Specified by:
H
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - Returns:
- The conjugate transpose.
-
isHermitian
public boolean isHermitian()Checks if a matrix is Hermitian. That is, if the matrix is equal to its conjugate transpose.- Specified by:
isHermitian
in interfaceComplexMatrixMixin<CMatrix>
- Returns:
- True if this matrix is Hermitian. Otherwise, returns false.
-
isAntiHermitian
public boolean isAntiHermitian()Checks if a matrix is anti-Hermitian. That is, if the matrix is equal to the negative of its conjugate transpose.- Specified by:
isAntiHermitian
in interfaceComplexMatrixMixin<CMatrix>
- Returns:
- True if this matrix is anti-symmetric. Otherwise, returns false.
-
isUnitary
public boolean isUnitary()Checks if this matrix is unitary. That is, if this matrices inverse is equal to its hermitian transpose.- Specified by:
isUnitary
in interfaceComplexMatrixMixin<CMatrix>
- Returns:
- True if this matrix it is unitary. Otherwise, returns false.
-
sub
Computes the element-wise subtraction of two tensors of the same rank.- Specified by:
sub
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.
-
addEq
Computes the element-wise addition of a matrix with a real dense matrix. The result is stored in this matrix.- Specified by:
addEq
in interfaceDenseMatrixMixin<CMatrix,
CNumber> - Parameters:
B
- The matrix to add to this matrix.
-
subEq
Computes the element-wise subtraction of this matrix with a real dense matrix. The result is stored in this matrix.- Specified by:
subEq
in interfaceDenseMatrixMixin<CMatrix,
CNumber> - Parameters:
B
- The matrix to subtract from this matrix.
-
addEq
Computes the element-wise addition of a matrix with a real sparse matrix. The result is stored in this matrix.- Specified by:
addEq
in interfaceDenseMatrixMixin<CMatrix,
CNumber> - Parameters:
B
- The sparse matrix to add to this matrix.
-
subEq
Computes the element-wise subtraction of this matrix with a real sparse matrix. The result is stored in this matrix.- Specified by:
subEq
in interfaceDenseMatrixMixin<CMatrix,
CNumber> - Parameters:
B
- The sparse matrix to subtract from this matrix.
-
mult
Computes the matrix multiplication between two matrices.- Specified by:
mult
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.- Specified by:
mult
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.- Specified by:
mult
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.- Specified by:
mult
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.- Specified by:
mult
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.- Specified by:
mult
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.- Specified by:
mult
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.- Specified by:
mult
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.- Specified by:
mult
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.- Specified by:
mult
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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())
.- Specified by:
multTranspose
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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())
.- Specified by:
multTranspose
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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())
.- Specified by:
multTranspose
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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())
.- Specified by:
multTranspose
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.- Specified by:
pow
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.- Specified by:
elemMult
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.- Specified by:
elemMult
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.- Specified by:
elemMult
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.- Specified by:
elemDiv
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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
Computes the determinant of a square matrix.- Specified by:
det
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - Returns:
- The determinant of this matrix.
- Throws:
IllegalArgumentException
- If this matrix is not square.
-
fib
Computes the Frobenius inner product of two matrices.- Specified by:
fib
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.- Specified by:
fib
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.- Specified by:
fib
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.- Specified by:
fib
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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
Sums together the columns of a matrix as if each column was a column vector.- Specified by:
sumCols
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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
Sums together the rows of a matrix as if each row was a row vector.- Specified by:
sumRows
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.- Specified by:
addToEachCol
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.- Specified by:
addToEachCol
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.- Specified by:
addToEachCol
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.- Specified by:
addToEachCol
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.- Specified by:
addToEachRow
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.- Specified by:
addToEachRow
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.- Specified by:
addToEachRow
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.- Specified by:
addToEachRow
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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
Stacks matrices along columns.
Also seeMatrixOperationsMixin.stack(Matrix, int)
andaugment(Matrix)
.- Specified by:
stack
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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
Stacks matrices along columns.
Also seeMatrixOperationsMixin.stack(Matrix, int)
andaugment(Matrix)
.- Specified by:
stack
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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
Stacks matrices along columns.
Also seeMatrixOperationsMixin.stack(Matrix, int)
andaugment(Matrix)
.- Specified by:
stack
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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
Stacks matrices along columns.
Also seeMatrixOperationsMixin.stack(Matrix, int)
andaugment(Matrix)
.- Specified by:
stack
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.
-
augment
- Specified by:
augment
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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
- Specified by:
augment
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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
- Specified by:
augment
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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
- Specified by:
augment
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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 seeMatrixOperationsMixin.stack(Vector, int)
andaugment(Vector)
.- Specified by:
stack
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, 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 seeMatrixOperationsMixin.stack(CooVector, int)
andaugment(CooVector)
.- Specified by:
stack
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, 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 seeMatrixOperationsMixin.stack(CVector, int)
andaugment(CVector)
.- Specified by:
stack
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, 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 seeMatrixOperationsMixin.stack(CooCVector, int)
andaugment(CooCVector)
.- Specified by:
stack
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, 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.
-
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)
andMatrixOperationsMixin.stack(Vector, int)
.- Specified by:
augment
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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)
andMatrixOperationsMixin.stack(CooVector, int)
.- Specified by:
augment
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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)
andMatrixOperationsMixin.stack(CVector, int)
.- Specified by:
augment
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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)
andMatrixOperationsMixin.stack(CooCVector, int)
.- Specified by:
augment
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.- Specified by:
getRow
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - Parameters:
i
- Index of row to get.- Returns:
- The specified row of this matrix.
-
getRowAsVector
Get the row of this matrix at the specified index.- Parameters:
i
- Index of row to get.- Returns:
- The specified row of this matrix as a vector.
- Throws:
ArrayIndexOutOfBoundsException
- Ifi
is less than zero or greater than/equal to the number of rows in this matrix.
-
getCol
Get the column of this matrix at the specified index.- Specified by:
getCol
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - Parameters:
j
- Index of column to get.- Returns:
- The specified column of this matrix.
-
getColAsVector
Get the column of this matrix at the specified index.- Parameters:
j
- Index of column to get.- Returns:
- The specified column of this matrix as a vector.
- Throws:
ArrayIndexOutOfBoundsException
- Ifi
is less than zero or greater than/equal to the number of rows in this matrix.
-
getSlice
Gets a specified slice of this matrix.- Specified by:
getSlice
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.- Specified by:
getColBelow
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.
-
getCol
Gets a specified column of this matrix betweenrowStart
(inclusive) androwEnd
(exclusive).- Specified by:
getCol
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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
.
-
getRowAfter
Get a specified row of this matrix at and after a specified column.- Specified by:
getRowAfter
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - 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.
-
trace
Computes the trace of this matrix. That is, the sum of elements along the principle diagonal of this matrix. Same astr()
- Specified by:
trace
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - Returns:
- The trace of this matrix.
- Throws:
IllegalArgumentException
- If this matrix is not square.
-
tr
Computes the trace of this matrix. That is, the sum of elements along the principle diagonal of this matrix. Same astrace()
- Specified by:
tr
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - Returns:
- The trace of this matrix.
- Throws:
IllegalArgumentException
- If this matrix is not square.
-
getDiag
Extracts the diagonal elements of this matrix and returns them as a vector.- Specified by:
getDiag
in interfaceMatrixOperationsMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - Returns:
- A vector containing the diagonal entries of this matrix.
-
I
Constructs an identity matrix of the specified size.- Parameters:
size
- Size of the identity matrix.- Returns:
- An identity matrix of specified size.
- Throws:
IllegalArgumentException
- If the specified size is less than 1.
-
I
Constructs an identity-like matrix of the specified shape. That is, a matrix of zeros with ones along the principle diagonal.- Parameters:
numRows
- Number of rows in the identity-like matrix.numCols
- Number of columns in the identity-like matrix.- Returns:
- An identity matrix of specified shape.
- Throws:
IllegalArgumentException
- If the specified number of rows or columns is less than 1.
-
I
Constructs an identity-like matrix of the specified shape. That is, a matrix of zeros with ones along the principle diagonal.- Parameters:
shape
- Shape of the identity-like matrix.- Returns:
- An identity matrix of specified size.
- Throws:
IllegalArgumentException
- If the specified shape is not rank 2.
-
isSquare
public boolean isSquare()Checks if this matrix is square.- Specified by:
isSquare
in interfaceMatrixPropertiesMixin
- Returns:
- True if the matrix is square (i.e. the number of rows equals the number of columns). Otherwise, returns false.
-
isVector
public boolean isVector()Checks if a matrix can be represented as a vector. That is, if a matrix has only one row or one column.- Specified by:
isVector
in interfaceMatrixPropertiesMixin
- Returns:
- True if this matrix can be represented as either a row or column vector.
-
vectorType
public int vectorType()Checks what type of vector this matrix is. i.e. not a vector, a 1x1 matrix, a row vector, or a column vector.- Specified by:
vectorType
in interfaceMatrixPropertiesMixin
- Returns:
- - If this matrix can not be represented as a vector, then returns -1.
- If this matrix is a 1x1 matrix, then returns 0.
- If this matrix is a row vector, then returns 1.
- If this matrix is a column vector, then returns 2.
-
isTriL
public boolean isTriL()Checks if this matrix is lower triangular.- Specified by:
isTriL
in interfaceMatrixPropertiesMixin
- Returns:
- True is this matrix is lower triangular. Otherwise, returns false.
-
isTriU
public boolean isTriU()Checks if this matrix is upper triangular.- Specified by:
isTriU
in interfaceMatrixPropertiesMixin
- Returns:
- True is this matrix is upper triangular. Otherwise, returns false.
-
isFullRank
public boolean isFullRank()Checks if a matrix has full rank. That is, if a matrices rank is equal to the number of rows in the matrix.- Specified by:
isFullRank
in interfaceMatrixPropertiesMixin
- Returns:
- True if this matrix has full rank. Otherwise, returns false.
-
isSingular
public boolean isSingular()Checks if a matrix is singular. That is, if the matrix is NOT invertible.
Also seeMatrixPropertiesMixin.isInvertible()
.- Specified by:
isSingular
in interfaceMatrixPropertiesMixin
- Returns:
- True if this matrix is singular. Otherwise, returns false.
-
matrixRank
public int matrixRank()Computes the rank of this matrix (i.e. the dimension of the column space of this matrix). Note that here, rank is NOT the same as a tensor rank.- Specified by:
matrixRank
in interfaceMatrixPropertiesMixin
- Returns:
- The matrix rank of this matrix.
-
addEq
Adds a complex sparse matrix to this matrix and stores the result in this matrix.- Parameters:
B
- Complex sparse matrix to add to this matrix,
-
subEq
Subtracts a complex sparse matrix from this matrix and stores the result in this matrix.- Parameters:
B
- Complex sparse matrix to subtract from this matrix,
-
swapRows
Swaps specified rows in the matrix. This is done in place.- Specified by:
swapRows
in interfaceMatrixManipulationsMixin<CMatrix,
CNumber> - Parameters:
rowIndex1
- Index of the first row to swap.rowIndex2
- Index of the second row to swap.- Returns:
- A reference to this matrix.
- Throws:
ArrayIndexOutOfBoundsException
- If either index is outside the matrix bounds.
-
swapCols
Swaps specified columns in the matrix. This is done in place.- Specified by:
swapCols
in interfaceMatrixManipulationsMixin<CMatrix,
CNumber> - Parameters:
colIndex1
- Index of the first column to swap.colIndex2
- Index of the second column to swap.- Returns:
- A reference to this matrix.
- Throws:
ArrayIndexOutOfBoundsException
- If either index is outside the matrix bounds.
-
get
Description copied from class:ComplexDenseTensorBase
Gets the element in this tensor at the specified indices.- Specified by:
get
in interfaceMatrixMixin<CMatrix,
CMatrix, CooCMatrix, CMatrix, CooCMatrix, CNumber, CVector, CVector> - Specified by:
get
in interfaceTensorOperationsMixin<CMatrix,
CMatrix, CMatrix, CMatrix, Matrix, CNumber> - Overrides:
get
in classComplexDenseTensorBase<CMatrix,
Matrix> - Parameters:
indices
- Indices of element.- Returns:
- The element at the specified indices.
-
rowToString
Gets row of matrix formatted as a human-readable String. Helper method fortoString()
method.- Parameters:
i
- Index of row to get.colStopIndex
- Stopping index for printing columns.maxList
- List of maximum string representation lengths for each column of this matrix. This is used to align columns when printing.- Returns:
- A human-readable String representation of the specified row.
-
toString
-