Class AbstractDenseRingMatrix<T extends AbstractDenseRingMatrix<T,U,V>,U extends AbstractDenseRingVector<U,T,V>,V extends Ring<V>>
java.lang.Object
org.flag4j.arrays.backend.AbstractTensor<T,V[],V>
org.flag4j.arrays.backend.semiring_arrays.AbstractDenseSemiringTensor<T,V>
org.flag4j.arrays.backend.semiring_arrays.AbstractDenseSemiringMatrix<T,U,V>
org.flag4j.arrays.backend.ring_arrays.AbstractDenseRingMatrix<T,U,V>
- Type Parameters:
T- The type of this matrix.U- The type of the vector which is of similar type to<T>.V- The type of the arrays the data of the matrix belong to.
- All Implemented Interfaces:
Serializable,MatrixMixin<T,,T, U, V> RingTensorMixin<T,,T, V> TensorOverRing<T,,T, V[], V> SemiringTensorMixin<T,,T, V> TensorOverSemiring<T,T, V[], V>
- Direct Known Subclasses:
AbstractDenseFieldMatrix,RingMatrix
public abstract class AbstractDenseRingMatrix<T extends AbstractDenseRingMatrix<T,U,V>,U extends AbstractDenseRingVector<U,T,V>,V extends Ring<V>>
extends AbstractDenseSemiringMatrix<T,U,V>
implements RingTensorMixin<T,T,V>, MatrixMixin<T,T,U,V>
The base class for all dense matrices whose elements are members of a
Ring.- See Also:
-
Field Summary
Fields inherited from class org.flag4j.arrays.backend.semiring_arrays.AbstractDenseSemiringMatrix
numCols, numRowsFields inherited from class org.flag4j.arrays.backend.semiring_arrays.AbstractDenseSemiringTensor
zeroElementFields inherited from class org.flag4j.arrays.backend.AbstractTensor
data, rank, shape -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractDenseRingMatrix(Shape shape, V[] data) Creates a tensor with the specified data and shape. -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if two sparse CSR ring matrices are element-wise equal within the following tolerance for two entriesxandy:booleanChecks if two matrices are element-wise equal within the tolerance specified byrelTolandabsTol.H(int... axes) Computes the conjugate transpose of this tensor.H(int axis1, int axis2) Computes the conjugate transpose of a tensor by conjugating and exchangingaxis1andaxis2.booleanChecks if the matrix is "close" to an identity matrix.booleanChecks if a matrix is Hermitian.doublenorm(int p, int q) Computes the p-norm of this vector.Computes the element-wise difference of two matrices.voidComputes the element-wise difference between two matrices of the same shape and stores the result in this matrix.Methods inherited from class org.flag4j.arrays.backend.semiring_arrays.AbstractDenseSemiringMatrix
augment, augment, dataLength, flatten, flatten, get, getCol, getDiag, getRow, getSlice, getTriL, getTriU, H, isI, isOrthogonal, isSymmetric, isTriL, isTriU, makeLikeCooMatrix, makeLikeCsrMatrix, makeLikeVector, makeLikeVector, mult, mult, multTranspose, numCols, numRows, removeCol, removeCols, removeRow, removeRows, set, setCol, setCol, setRow, setRow, setSlice, setSliceCopy, setValues, stack, swapCols, swapRows, T, toCoo, toCoo, toCsr, toCsr, toTensor, toTensor, toVector, trMethods inherited from class org.flag4j.arrays.backend.semiring_arrays.AbstractDenseSemiringTensor
add, addEq, argmax, argmin, copy, elemMult, get, getZeroElement, makeLikeCooTensor, max, min, reshape, set, setZeroElement, T, T, tensorDot, tensorTrMethods inherited from class org.flag4j.arrays.backend.AbstractTensor
getData, getRank, getShape, makeLikeTensor, reshape, sameShape, totalEntriesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.flag4j.arrays.backend.MatrixMixin
accept, add, augment, augment, copy, dataLength, div, elemMult, fib, get, getCol, getCol, getDiag, getDiag, getRow, getRow, getShape, getSlice, getTriL, getTriL, getTriU, getTriU, H, isDiag, isI, isOrthogonal, isSquare, isSymmetric, isTri, isTriL, isTriU, isVector, mult, mult, multTranspose, numCols, numRows, removeCol, removeCols, removeRow, removeRows, set, setCol, setRow, setSliceCopy, stack, stack, swapCols, swapRows, T, toVector, tr, trace, vectorTypeMethods inherited from interface org.flag4j.arrays.backend.ring_arrays.RingTensorMixin
add, addEq, argmax, argmaxAbs, argmin, argminAbs, conj, isOnes, isZeros, makeEmptyDataArray, max, maxAbs, min, minAbs, mult, multEq, norm, norm, prod, sub, subEq, sumMethods inherited from interface org.flag4j.arrays.backend.ring_arrays.TensorOverRing
abs, H
-
Constructor Details
-
AbstractDenseRingMatrix
Creates a tensor with the specified data and shape.- Parameters:
shape- Shape of this tensor.data- Entries of this tensor. If this tensor is dense, this specifies all data within the tensor. If this tensor is sparse, this specifies only the non-zero data of the tensor.
-
-
Method Details
-
sub
Computes the element-wise difference of two matrices.- Specified by:
subin interfaceMatrixMixin<T extends AbstractDenseRingMatrix<T,U, V>, T extends AbstractDenseRingMatrix<T, U, V>, U extends AbstractDenseRingVector<U, T, V>, V extends Ring<V>> - Specified by:
subin interfaceTensorOverRing<T extends AbstractDenseRingMatrix<T,U, V>, T extends AbstractDenseRingMatrix<T, U, V>, V extends Ring<V>[], V extends Ring<V>> - Parameters:
b- Second matrix in the element-wise difference.- Returns:
- The element-wise difference of this matrix and
b.
-
subEq
Computes the element-wise difference between two matrices of the same shape and stores the result in this matrix.- Parameters:
b- Second matrix in the element-wise difference.- Throws:
TensorShapeException- If this matrix andbdo not have the same shape.
-
H
Computes the conjugate transpose of a tensor by conjugating and exchangingaxis1andaxis2.- Specified by:
Hin interfaceTensorOverRing<T extends AbstractDenseRingMatrix<T,U, V>, T extends AbstractDenseRingMatrix<T, U, V>, V extends Ring<V>[], V extends Ring<V>> - Parameters:
axis1- First axis to exchange and conjugate.axis2- Second axis to exchange and conjugate.- Returns:
- The conjugate transpose of this tensor according to the specified axes.
- Throws:
IndexOutOfBoundsException- If eitheraxis1oraxis2are out of bounds for the rank of this tensor.- See Also:
-
H
Computes the conjugate transpose of this tensor. That is, conjugates and permutes the axes of this tensor so that it matches the permutation specified byaxes.- Specified by:
Hin interfaceTensorOverRing<T extends AbstractDenseRingMatrix<T,U, V>, T extends AbstractDenseRingMatrix<T, U, V>, V extends Ring<V>[], V extends Ring<V>> - Parameters:
axes- Permutation of tensor axis. If the tensor has rankN, then this must be an array of lengthNwhich is a permutation of{0, 1, 2, ..., N-1}.- Returns:
- The conjugate transpose of this tensor with its axes permuted by the
axesarray. - Throws:
IndexOutOfBoundsException- If any element ofaxesis out of bounds for the rank of this tensor.IllegalArgumentException- Ifaxesis not a permutation of{1, 2, 3, ... N-1}.- See Also:
-
isHermitian
public boolean isHermitian()Checks if a matrix is Hermitian. That is, if the matrix is square and equal to its conjugate transpose.- Specified by:
isHermitianin interfaceMatrixMixin<T extends AbstractDenseRingMatrix<T,U, V>, T extends AbstractDenseRingMatrix<T, U, V>, U extends AbstractDenseRingVector<U, T, V>, V extends Ring<V>> - Overrides:
isHermitianin classAbstractDenseSemiringMatrix<T extends AbstractDenseRingMatrix<T,U, V>, U extends AbstractDenseRingVector<U, T, V>, V extends Ring<V>> - Returns:
trueif this matrix is Hermitian;falseotherwise.
-
isCloseToIdentity
public boolean isCloseToIdentity()Checks if the matrix is "close" to an identity matrix. Two entriesxandyare considered "close" if they satisfy the following:|x-y| <= (1E-08 + 1E-05*|y|)- Returns:
trueif the matrix is approximately an identity matrix, otherwisefalse.
-
allClose
Checks if two sparse CSR ring matrices are element-wise equal within the following tolerance for two entriesxandy:
To specify the relative and absolute tolerances use|x-y| <= (1e-08 + 1e-05*|y|)allClose(AbstractDenseRingMatrix, double, double)- Returns:
trueif this matrix andbelement-wise equal within the tolerance|x-y| <= (1e-08 + 1e-05*|y|).- See Also:
-
allClose
Checks if two matrices are element-wise equal within the tolerance specified byrelTolandabsTol. Two elementsxandyare considered "close" if they satisfy the following:|x-y| <= (absTol + relTol*|y|)- Parameters:
b- Matrix to compare to this matrix.absTol- Absolute tolerance.relTol- Relative tolerance.- Returns:
trueif thesrc1matrix is the same shape as thesrc2matrix and all data are 'close', i.e. elementsaandbat the same positions in the two matrices respectively satisfy|a-b| <= (absTol + relTol*|b|). Otherwise, returnsfalse.- See Also:
-
norm
public double norm(int p, int q) Computes the p-norm of this vector.- Parameters:
p-pvalue in the p-norm.- Returns:
- The Euclidean norm of this vector.
-