Interface LinearAlgebraProvider<E>

Type Parameters:
E - the element type (typically Real for public API or Double for native)
All Superinterfaces:
AlgorithmProvider, AutoCloseable
All Known Subinterfaces:
LinearAlgebraBackend<E>, SparseLinearAlgebraProvider<E>
All Known Implementing Classes:
AbstractNativeCPULinearAlgebraBackend, AbstractNativeFFMBLASBackend, AbstractNativeSIMDLinearAlgebraBackend, CARMALinearAlgebraProvider, ColtBackend, CommonsMathBackend, CPUDenseLinearAlgebraProvider, CPUSparseLinearAlgebraProvider, DistributedLinearAlgebraProvider, EJMLBackend, EpistemeLinearAlgebraBackend, GRPCLinearAlgebraBackend, JBlasBackend, NativeCPULinearAlgebraComplexBackend, NativeCPULinearAlgebraRealBackend, NativeCUDADenseLinearAlgebraDoubleBackend, NativeCUDADenseLinearAlgebraFloatBackend, NativeCUDASparseLinearAlgebraDoubleBackend, NativeCUDASparseLinearAlgebraFloatBackend, NativeFFMBLASComplexBackend, NativeFFMBLASRealBackend, NativeMPFRDenseLinearAlgebraBackend, NativeMPFRSparseLinearAlgebraBackend, NativeND4JLinearAlgebraBackend, NativeOpenCLDenseLinearAlgebraDoubleBackend, NativeOpenCLDenseLinearAlgebraFloatBackend, NativeOpenCLSparseLinearAlgebraDoubleBackend, NativeOpenCLSparseLinearAlgebraFloatBackend, NativeSIMDComplexBackend, NativeSIMDRealBackend, StandardLinearAlgebraProvider, StrassenLinearAlgebraProvider

public interface LinearAlgebraProvider<E> extends AlgorithmProvider, AutoCloseable
Service provider interface for linear algebra operations.

Each provider implements only the operations it supports. Unsupported operations throw UnsupportedOperationException. The AlgorithmManager is responsible for selecting the best available provider and falling back to the next one if the selected provider does not support a given operation.

This interface is parameterized by element type E. Two main parameterizations exist in the codebase:

  • LinearAlgebraProvider<Real> — Public-facing API. Users and high-level code operate through this type.
  • LinearAlgebraProvider<Double> — Internal optimization layer. Used by native BLAS backends that operate directly on raw double arrays.
Since:
1.2
Author:
Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
  • Method Details

    • isCompatible

      default boolean isCompatible(Ring<?> ring)
      Checks if this provider is compatible with the given ring.
    • getPriority

      default int getPriority()
      Priority of this provider (higher means more preferred). Used for automatic backend selection.
      Specified by:
      getPriority in interface AlgorithmProvider
    • configure

      default void configure(Map<String,Object> properties)
      Configure the provider with context parameters.
      Parameters:
      properties - configuration map
    • add

      default Vector<E> add(Vector<E> a, Vector<E> b)
    • subtract

      default Vector<E> subtract(Vector<E> a, Vector<E> b)
    • multiply

      default Vector<E> multiply(Vector<E> vector, E scalar)
    • dot

      default E dot(Vector<E> a, Vector<E> b)
    • norm

      default E norm(Vector<E> a)
    • normalize

      default Vector<E> normalize(Vector<E> a)
      Returns the normalized vector (unit vector).
    • cross

      default Vector<E> cross(Vector<E> a, Vector<E> b)
      Returns the cross product of two 3D vectors.
    • angle

      default E angle(Vector<E> a, Vector<E> b)
      Returns the angle between two vectors in radians.
    • projection

      default Vector<E> projection(Vector<E> a, Vector<E> b)
      Returns the projection of vector a onto vector b.
    • add

      default Matrix<E> add(Matrix<E> a, Matrix<E> b)
    • subtract

      default Matrix<E> subtract(Matrix<E> a, Matrix<E> b)
    • multiply

      default Matrix<E> multiply(Matrix<E> a, Matrix<E> b)
    • multiply

      default Vector<E> multiply(Matrix<E> a, Vector<E> b)
    • inverse

      default Matrix<E> inverse(Matrix<E> a)
    • determinant

      default E determinant(Matrix<E> a)
    • solve

      default Vector<E> solve(Matrix<E> a, Vector<E> b)
    • transpose

      default Matrix<E> transpose(Matrix<E> a)
    • conjugateTranspose

      default Matrix<E> conjugateTranspose(Matrix<E> a)
    • solveTriangular

      default Vector<E> solveTriangular(Matrix<E> A, Vector<E> b, boolean upper, boolean transpose, boolean conjugate, boolean unit)
      Solves the triangular system Ax = b.
      Parameters:
      A - the triangular matrix
      b - the right-hand side vector
      upper - true if A is upper triangular, false if lower
      transpose - true if solving A^T x = b
      conjugate - true if solving A^H x = b (only if transpose is true and complex)
      unit - true if A is unit triangular (diagonal is all ones)
    • scale

      default Matrix<E> scale(E scalar, Matrix<E> a)
    • exp

      default Matrix<E> exp(Matrix<E> a)
      Computes the matrix exponential e^A.
    • rank

      default int rank(Matrix<E> a)
      Returns the rank of the matrix.
    • conditionNumber

      default E conditionNumber(Matrix<E> a)
      Returns the condition number of the matrix (L2 norm).
    • log

      default Matrix<E> log(Matrix<E> a)
    • log10

      default Matrix<E> log10(Matrix<E> a)
    • sin

      default Matrix<E> sin(Matrix<E> a)
    • cos

      default Matrix<E> cos(Matrix<E> a)
    • tan

      default Matrix<E> tan(Matrix<E> a)
    • asin

      default Matrix<E> asin(Matrix<E> a)
    • acos

      default Matrix<E> acos(Matrix<E> a)
    • atan

      default Matrix<E> atan(Matrix<E> a)
    • sinh

      default Matrix<E> sinh(Matrix<E> a)
    • cosh

      default Matrix<E> cosh(Matrix<E> a)
    • tanh

      default Matrix<E> tanh(Matrix<E> a)
    • asinh

      default Matrix<E> asinh(Matrix<E> a)
    • acosh

      default Matrix<E> acosh(Matrix<E> a)
    • atanh

      default Matrix<E> atanh(Matrix<E> a)
    • pow

      default Matrix<E> pow(Matrix<E> a, E exponent)
    • sqrt

      default Matrix<E> sqrt(Matrix<E> a)
    • cbrt

      default Matrix<E> cbrt(Matrix<E> a)
    • trace

      default E trace(Matrix<E> a)
    • qr

      default QRResult<E> qr(Matrix<E> a)
      Computes the QR decomposition of the specified matrix.
    • svd

      default SVDResult<E> svd(Matrix<E> a)
      Computes the Singular Value Decomposition (SVD) of the specified matrix.
    • eigen

      default EigenResult<E> eigen(Matrix<E> a)
      Computes the eigenvalue decomposition of the specified matrix.
    • lu

      default LUResult<E> lu(Matrix<E> a)
      Computes the LU decomposition of the specified matrix.
    • cholesky

      default CholeskyResult<E> cholesky(Matrix<E> a)
      Computes the Cholesky decomposition of the specified matrix.
    • solve

      default Vector<E> solve(LUResult<E> lu, Vector<E> b)
      Solves Ax = b using a previously computed LU decomposition.
    • solve

      default Vector<E> solve(QRResult<E> qr, Vector<E> b)
      Solves Ax = b using a previously computed QR decomposition.
    • solve

      default Vector<E> solve(CholeskyResult<E> cholesky, Vector<E> b)
      Solves Ax = b using a previously computed Cholesky decomposition.
    • score

      default double score(OperationContext context)
      Description copied from interface: AlgorithmProvider
      Scores this provider for a specific operation context.

      Higher scores indicate better suitability. Used by ProviderSelector for context-aware selection.

      Default implementation returns AlgorithmProvider.getPriority(), so existing providers behave identically without changes.

      Specified by:
      score in interface AlgorithmProvider
      Parameters:
      context - the operation context (data size, hints, etc.)
      Returns:
      suitability score (higher = better)
    • getEnvironmentInfo

      default String getEnvironmentInfo()
      Returns a string describing the execution environment (e.g., "CPU (AVX2)", "GPU (CUDA 12.0)").
    • getName

      default String getName()
      Specified by:
      getName in interface AlgorithmProvider
    • getAlgorithmType

      default String getAlgorithmType()
      Description copied from interface: AlgorithmProvider
      Returns the unique category of the algorithm.
      Specified by:
      getAlgorithmType in interface AlgorithmProvider
    • close

      default void close()
      Specified by:
      close in interface AutoCloseable