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, numRows
Fields inherited from class org.flag4j.arrays.backend.semiring_arrays.AbstractDenseSemiringTensor
zeroElement
Fields inherited from class org.flag4j.arrays.backend.AbstractTensor
data, rank, shape
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractDenseRingMatrix
(Shape shape, V[] data) Creates a tensor with the specified data and shape. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks if two sparse CSR ring matrices are element-wise equal within the following tolerance for two entriesx
andy
:boolean
Checks if two matrices are element-wise equal within the tolerance specified byrelTol
andabsTol
.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 exchangingaxis1
andaxis2
.boolean
Checks if the matrix is "close" to an identity matrix.boolean
Checks if a matrix is Hermitian.double
norm
(int p, int q) Computes the p-norm of this vector.Computes the element-wise difference of two matrices.void
Computes 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, tr
Methods 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, tensorTr
Methods inherited from class org.flag4j.arrays.backend.AbstractTensor
getData, getRank, getShape, makeLikeTensor, reshape, sameShape, totalEntries
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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, vectorType
Methods 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, sum
Methods 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:
sub
in 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:
sub
in 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 andb
do not have the same shape.
-
H
Computes the conjugate transpose of a tensor by conjugating and exchangingaxis1
andaxis2
.- Specified by:
H
in 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 eitheraxis1
oraxis2
are 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:
H
in 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 lengthN
which is a permutation of{0, 1, 2, ..., N-1}
.- Returns:
- The conjugate transpose of this tensor with its axes permuted by the
axes
array. - Throws:
IndexOutOfBoundsException
- If any element ofaxes
is out of bounds for the rank of this tensor.IllegalArgumentException
- Ifaxes
is 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:
isHermitian
in interfaceMatrixMixin<T extends AbstractDenseRingMatrix<T,
U, V>, T extends AbstractDenseRingMatrix<T, U, V>, U extends AbstractDenseRingVector<U, T, V>, V extends Ring<V>> - Overrides:
isHermitian
in classAbstractDenseSemiringMatrix<T extends AbstractDenseRingMatrix<T,
U, V>, U extends AbstractDenseRingVector<U, T, V>, V extends Ring<V>> - Returns:
true
if this matrix is Hermitian;false
otherwise.
-
isCloseToIdentity
public boolean isCloseToIdentity()Checks if the matrix is "close" to an identity matrix. Two entriesx
andy
are considered "close" if they satisfy the following:|x-y| <= (1E-08 + 1E-05*|y|)
- Returns:
true
if 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 entriesx
andy
:
To specify the relative and absolute tolerances use|x-y| <= (1e-08 + 1e-05*|y|)
allClose(AbstractDenseRingMatrix, double, double)
- Returns:
true
if this matrix andb
element-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 byrelTol
andabsTol
. Two elementsx
andy
are 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:
true
if thesrc1
matrix is the same shape as thesrc2
matrix and all data are 'close', i.e. elementsa
andb
at 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
-p
value in the p-norm.- Returns:
- The Euclidean norm of this vector.
-