Class GenericMatrix<E>

java.lang.Object
org.episteme.core.mathematics.linearalgebra.matrices.GenericMatrix<E>
All Implemented Interfaces:
Matrix<E>, AbelianGroup<Matrix<E>>, AbelianMonoid<Matrix<E>>, Group<Matrix<E>>, Magma<Matrix<E>>, Monoid<Matrix<E>>, Ring<Matrix<E>>, Semiring<Matrix<E>>, Set<Matrix<E>>, Module<Matrix<E>, E>
Direct Known Subclasses:
DenseMatrix, MMapMatrix, NativeRealDoubleMatrix, NativeRealFloatMatrix, RealDoubleMatrix, SIMDRealDoubleMatrix, SIMDRealFloatMatrix, SparseMatrix, TiledMatrix

public class GenericMatrix<E> extends Object implements Matrix<E>
A generic matrix implementation with smart storage and provider selection.
Since:
1.0
Author:
Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
  • Field Details

  • Constructor Details

    • GenericMatrix

      public GenericMatrix(E[][] data, Ring<E> ring)
      Creates a GenericMatrix with automatic storage selection.
    • GenericMatrix

      public GenericMatrix(MatrixStorage<E> storage, LinearAlgebraProvider<E> provider, Ring<E> ring)
      Public constructor for Providers and internal use.
  • Method Details

    • description

      public String description()
      Description copied from interface: Set
      Returns a human-readable description of this set.

      Examples:

      • "ℝ (Real Numbers)"
      • "ℤ/12ℤ (Integers modulo 12)"
      • "{1, 2, 3, 4, 5}"

      Specified by:
      description in interface Set<E>
      Returns:
      a description of this set
    • contains

      public boolean contains(Matrix<E> element)
      Description copied from interface: Set
      Tests whether this set contains the specified element.

      This is the fundamental operation of a set - membership testing.

      Specified by:
      contains in interface Set<E>
      Parameters:
      element - the element to test for membership
      Returns:
      true if this set contains the element, false otherwise
      See Also:
    • withProvider

      public GenericMatrix<E> withProvider(LinearAlgebraProvider<E> provider)
      Returns a new view of this matrix with a different provider.
    • set

      public void set(int row, int col, E value)
    • rows

      public int rows()
      Description copied from interface: Matrix
      Returns the number of rows in this matrix.
      Specified by:
      rows in interface Matrix<E>
    • cols

      public int cols()
      Description copied from interface: Matrix
      Returns the number of columns in this matrix.
      Specified by:
      cols in interface Matrix<E>
    • get

      public E get(int row, int col)
      Description copied from interface: Matrix
      Returns the element at the specified row and column.
      Specified by:
      get in interface Matrix<E>
    • add

      public Matrix<E> add(Matrix<E> other)
      Description copied from interface: Matrix
      Returns the sum of this matrix and another.
      Specified by:
      add in interface Matrix<E>
    • multiply

      public Matrix<E> multiply(Matrix<E> other)
      Description copied from interface: Matrix
      Returns the product of this matrix and another.
      Specified by:
      multiply in interface Matrix<E>
    • transpose

      public Matrix<E> transpose()
      Description copied from interface: Matrix
      Returns the transpose of this matrix.
      Specified by:
      transpose in interface Matrix<E>
    • trace

      public E trace()
      Description copied from interface: Matrix
      Returns the trace of this matrix (sum of diagonal elements).
      Specified by:
      trace in interface Matrix<E>
    • getSubMatrix

      public Matrix<E> getSubMatrix(int rowStart, int rowEnd, int colStart, int colEnd)
      Description copied from interface: Matrix
      Returns a submatrix of this matrix.
      Specified by:
      getSubMatrix in interface Matrix<E>
    • getRow

      public Vector<E> getRow(int row)
      Description copied from interface: Matrix
      Returns the row at the specified index as a vector.
      Specified by:
      getRow in interface Matrix<E>
    • getColumn

      public Vector<E> getColumn(int col)
      Description copied from interface: Matrix
      Returns the column at the specified index as a vector.
      Specified by:
      getColumn in interface Matrix<E>
    • determinant

      public E determinant()
      Description copied from interface: Matrix
      Returns the determinant of this matrix.
      Specified by:
      determinant in interface Matrix<E>
    • inverse

      public Matrix<E> inverse()
      Description copied from interface: Matrix
      Returns the multiplicative inverse of this matrix.
      Specified by:
      inverse in interface Matrix<E>
    • multiply

      public Vector<E> multiply(Vector<E> vector)
      Description copied from interface: Matrix
      Multiplies this matrix by a vector.
      Specified by:
      multiply in interface Matrix<E>
    • lu

      public LUResult<E> lu()
      Description copied from interface: Matrix
      Computes the LU decomposition of this matrix.
      Specified by:
      lu in interface Matrix<E>
    • qr

      public QRResult<E> qr()
      Description copied from interface: Matrix
      Computes the QR decomposition of this matrix.
      Specified by:
      qr in interface Matrix<E>
    • svd

      public SVDResult<E> svd()
      Description copied from interface: Matrix
      Computes the Singular Value Decomposition (SVD) of this matrix.
      Specified by:
      svd in interface Matrix<E>
    • cholesky

      public CholeskyResult<E> cholesky()
      Description copied from interface: Matrix
      Computes the Cholesky decomposition of this matrix.
      Specified by:
      cholesky in interface Matrix<E>
    • eigen

      public EigenResult<E> eigen()
      Description copied from interface: Matrix
      Computes the eigenvalue decomposition of this matrix.
      Specified by:
      eigen in interface Matrix<E>
    • negate

      public Matrix<E> negate()
      Description copied from interface: Matrix
      Returns the negation of this matrix (-this).
      Specified by:
      negate in interface Matrix<E>
    • zero

      public Matrix<E> zero()
      Description copied from interface: Matrix
      Returns the zero matrix of the same dimensions.
      Specified by:
      zero in interface AbelianMonoid<E>
      Specified by:
      zero in interface Matrix<E>
      Returns:
      the zero element
    • one

      public Matrix<E> one()
      Description copied from interface: Semiring
      Returns the multiplicative identity (one element).

      Satisfies: 1 × a = a × 1 = a for all elements a.

      Specified by:
      one in interface Semiring<E>
      Returns:
      the multiplicative identity
    • getScalarRing

      public Ring<E> getScalarRing()
      Description copied from interface: Module
      Returns the ring of scalars for this module.
      Specified by:
      getScalarRing in interface Matrix<E>
      Specified by:
      getScalarRing in interface Module<Matrix<E>, E>
      Returns:
      the scalar ring
    • scale

      public Matrix<E> scale(E scalar, Matrix<E> element)
      Description copied from interface: Module
      Scalar multiplication (r × m).
      Specified by:
      scale in interface Matrix<E>
      Specified by:
      scale in interface Module<Matrix<E>, E>
      Parameters:
      scalar - the scalar r ∈ R
      element - the module element m ∈ M
      Returns:
      r × m
    • getStorage

      public MatrixStorage<E> getStorage()
      Description copied from interface: Matrix
      Returns the underlying storage of this matrix.
      Specified by:
      getStorage in interface Matrix<E>
      Returns:
      the matrix storage
    • getProvider

      public LinearAlgebraProvider<E> getProvider()
      Description copied from interface: Matrix
      Returns the provider that created or manages this matrix.
      Specified by:
      getProvider in interface Matrix<E>
      Returns:
      the linear algebra provider
    • getField

      public Ring<E> getField()