Class AbstractDenseRingMatrix<T extends AbstractDenseRingMatrix<T,U,V>,U extends AbstractDenseRingVector<U,T,V>,V extends Ring<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:
  • Constructor Details

    • AbstractDenseRingMatrix

      protected AbstractDenseRingMatrix(Shape shape, V[] data)
      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

      public T sub(T b)
      Computes the element-wise difference of two matrices.
      Specified by:
      sub in interface MatrixMixin<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 interface TensorOverRing<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

      public void subEq(T b)
      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 and b do not have the same shape.
    • H

      public T H(int axis1, int axis2)
      Computes the conjugate transpose of a tensor by conjugating and exchanging axis1 and axis2.
      Specified by:
      H in interface TensorOverRing<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 either axis1 or axis2 are out of bounds for the rank of this tensor.
      See Also:
    • H

      public T H(int... axes)
      Computes the conjugate transpose of this tensor. That is, conjugates and permutes the axes of this tensor so that it matches the permutation specified by axes.
      Specified by:
      H in interface TensorOverRing<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 rank N, then this must be an array of length N 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 of axes is out of bounds for the rank of this tensor.
      IllegalArgumentException - If axes 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 interface MatrixMixin<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 class AbstractDenseSemiringMatrix<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 entries x and y 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, otherwise false.
    • allClose

      public boolean allClose(T b)
      Checks if two sparse CSR ring matrices are element-wise equal within the following tolerance for two entries x and y:
      
        |x-y| <= (1e-08 + 1e-05*|y|)
       
      To specify the relative and absolute tolerances use allClose(AbstractDenseRingMatrix, double, double)
      Returns:
      true if this matrix and b element-wise equal within the tolerance |x-y| <= (1e-08 + 1e-05*|y|).
      See Also:
    • allClose

      public boolean allClose(T b, double relRol, double absTol)
      Checks if two matrices are element-wise equal within the tolerance specified by relTol and absTol. Two elements x and y 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 the src1 matrix is the same shape as the src2 matrix and all data are 'close', i.e. elements a and b at the same positions in the two matrices respectively satisfy |a-b| <= (absTol + relTol*|b|). Otherwise, returns false.
      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.