Class NativeMPFRDenseLinearAlgebraBackend<E>
java.lang.Object
org.episteme.nativ.mathematics.linearalgebra.backends.NativeMPFRDenseLinearAlgebraBackend<E>
- All Implemented Interfaces:
AutoCloseable, LinearAlgebraProvider<E>, AlgorithmProvider, Backend, ComputeBackend, CPUBackend, NativeBackend
@AutoService({Backend.class,ComputeBackend.class,NativeBackend.class,LinearAlgebraProvider.class,CPUBackend.class})
public class NativeMPFRDenseLinearAlgebraBackend<E>
extends Object
implements LinearAlgebraProvider<E>, NativeBackend, CPUBackend
High-performance Arbitrary Precision Linear Algebra backend using libmpfr.
Binds directly to MPFR via Project Panama (FFM).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the angle between two vectors in radians.applyTranscendental(Matrix<E> a, String op, Object... args) Computes the Cholesky decomposition of the specified matrix.static voidcomplexAcos(MemorySegment resR, MemorySegment resI, MemorySegment aR, MemorySegment aI, long prec, Arena arena, ResourceTracker tracker) static voidcomplexAcosh(MemorySegment resR, MemorySegment resI, MemorySegment aR, MemorySegment aI, long prec, Arena arena, ResourceTracker tracker) static voidcomplexAsin(MemorySegment resR, MemorySegment resI, MemorySegment aR, MemorySegment aI, long prec, Arena arena, ResourceTracker tracker) static voidcomplexAsinh(MemorySegment resR, MemorySegment resI, MemorySegment aR, MemorySegment aI, long prec, Arena arena, ResourceTracker tracker) static voidcomplexAtan(MemorySegment resR, MemorySegment resI, MemorySegment aR, MemorySegment aI, long prec, Arena arena, ResourceTracker tracker) static voidcomplexAtanh(MemorySegment resR, MemorySegment resI, MemorySegment aR, MemorySegment aI, long prec, Arena arena, ResourceTracker tracker) static voidcomplexCbrt(MemorySegment resR, MemorySegment resI, MemorySegment aR, MemorySegment aI, long prec, Arena arena, ResourceTracker tracker) static voidcomplexCos(MemorySegment resR, MemorySegment resI, MemorySegment aR, MemorySegment aI, long prec, Arena arena, ResourceTracker tracker) static voidcomplexCosh(MemorySegment resR, MemorySegment resI, MemorySegment aR, MemorySegment aI, long prec, Arena arena, ResourceTracker tracker) static voidcomplexExp(MemorySegment resR, MemorySegment resI, MemorySegment aR, MemorySegment aI, long prec, Arena arena, ResourceTracker tracker) static voidcomplexLog(MemorySegment resR, MemorySegment resI, MemorySegment aR, MemorySegment aI, long prec, Arena arena, ResourceTracker tracker) static voidcomplexLog10(MemorySegment resR, MemorySegment resI, MemorySegment aR, MemorySegment aI, long prec, Arena arena, ResourceTracker tracker) static voidcomplexPow(MemorySegment resR, MemorySegment resI, MemorySegment aR, MemorySegment aI, MemorySegment eR, MemorySegment eI, long prec, Arena arena, ResourceTracker tracker) static voidcomplexSin(MemorySegment resR, MemorySegment resI, MemorySegment aR, MemorySegment aI, long prec, Arena arena, ResourceTracker tracker) static voidcomplexSinh(MemorySegment resR, MemorySegment resI, MemorySegment aR, MemorySegment aI, long prec, Arena arena, ResourceTracker tracker) static voidcomplexSqrt(MemorySegment resR, MemorySegment resI, MemorySegment aR, MemorySegment aI, long prec, Arena arena, ResourceTracker tracker) static voidcomplexTan(MemorySegment resR, MemorySegment resI, MemorySegment aR, MemorySegment aI, long prec, Arena arena, ResourceTracker tracker) static voidcomplexTanh(MemorySegment resR, MemorySegment resI, MemorySegment aR, MemorySegment aI, long prec, Arena arena, ResourceTracker tracker) Creates and returns the backend instance (or returns self if it is the backend).Creates an execution context for running operations.Returns the cross product of two 3D vectors.determinant(Matrix<E> a) Computes the eigenvalue decomposition of the specified matrix.Computes the matrix exponential e^A.Returns the type of hardware accelerator used by this backend.Returns a description of the backend.Returns a string describing the execution environment (e.g., "CPU (AVX2)", "GPU (CUDA 12.0)").static MethodHandlegetId()Returns the unique identifier for this backend (e.g., "javafx", "jmol", "cuda").Returns metadata about the provider's performance and capabilities.getName()Returns the display name for UI presentation.Returns the name of the native library this backend depends on.intPriority of this provider (higher means more preferred).getType()Returns the backend type category (e.g., "plotting", "molecular", "tensor", "math").static voidinvokeComplexOp(String function, MemorySegment rcR, MemorySegment rcI, MemorySegment raR, MemorySegment raI, long prec, Arena arena, ResourceTracker tracker) booleanChecks if the provider is available in the current environment.booleanisCompatible(Ring<?> ring) Checks if this provider is compatible with the given ring.booleanChecks if this backend is specifically disabled via a system property:"episteme.backend.disable." + getId().booleanisLoaded()Checks if the native library is loaded and available.Computes the LU decomposition of the specified matrix.Returns the normalized vector (unit vector).projection(Vector<E> a, Vector<E> b) Returns the projection of vector a onto vector b.Computes the QR decomposition of the specified matrix.doublescore(OperationContext context) Scores this provider for a specific operation context.voidshutdown()Called when the provider is no longer needed (e.g., application shutdown).solve(CholeskyResult<E> cholesky, Vector<E> b) Solves Ax = b using a previously computed Cholesky decomposition.Solves Ax = b using a previously computed LU decomposition.Solves Ax = b using a previously computed QR decomposition.solveTriangular(Matrix<E> A, Vector<E> b, boolean upper, boolean transpose, boolean conjugate, boolean unit) Solves the triangular system Ax = b.Computes the Singular Value Decomposition (SVD) of the specified matrix.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface AlgorithmProvider
descriptionMethods inherited from interface Backend
getAlgorithmProviders, getStatusMessageMethods inherited from interface CPUBackend
supportsComplexNumbers, supportsFloatingPoint, supportsParallelOpsMethods inherited from interface LinearAlgebraProvider
add, close, conditionNumber, configure, getAlgorithmType, rank, subtract
-
Constructor Details
-
NativeMPFRDenseLinearAlgebraBackend
public NativeMPFRDenseLinearAlgebraBackend()
-
-
Method Details
-
isAvailable
public boolean isAvailable()Description copied from interface:AlgorithmProviderChecks if the provider is available in the current environment.- Specified by:
isAvailablein interfaceAlgorithmProvider- Specified by:
isAvailablein interfaceBackend
-
getId
-
getName
Description copied from interface:BackendReturns the display name for UI presentation.- Specified by:
getNamein interfaceAlgorithmProvider- Specified by:
getNamein interfaceBackend- Specified by:
getNamein interfaceLinearAlgebraProvider<E>
-
getDescription
Description copied from interface:BackendReturns a description of the backend.- Specified by:
getDescriptionin interfaceBackend- Specified by:
getDescriptionin interfaceComputeBackend
-
getType
Description copied from interface:BackendReturns the backend type category (e.g., "plotting", "molecular", "tensor", "math").- Specified by:
getTypein interfaceBackend- Specified by:
getTypein interfaceComputeBackend- Specified by:
getTypein interfaceCPUBackend
-
getPriority
public int getPriority()Description copied from interface:LinearAlgebraProviderPriority of this provider (higher means more preferred). Used for automatic backend selection.- Specified by:
getPriorityin interfaceAlgorithmProvider- Specified by:
getPriorityin interfaceBackend- Specified by:
getPriorityin interfaceLinearAlgebraProvider<E>
-
getAcceleratorType
Description copied from interface:ComputeBackendReturns the type of hardware accelerator used by this backend.- Specified by:
getAcceleratorTypein interfaceComputeBackend- Specified by:
getAcceleratorTypein interfaceCPUBackend- Returns:
- the accelerator type
-
isLoaded
public boolean isLoaded()Description copied from interface:NativeBackendChecks if the native library is loaded and available.- Specified by:
isLoadedin interfaceNativeBackend- Returns:
- true if the native library has been successfully loaded
-
getNativeLibraryName
Description copied from interface:NativeBackendReturns the name of the native library this backend depends on.- Specified by:
getNativeLibraryNamein interfaceNativeBackend- Returns:
- library name (e.g., "openblas", "cuda", "fftw3")
-
createBackend
Description copied from interface:BackendCreates and returns the backend instance (or returns self if it is the backend).- Specified by:
createBackendin interfaceBackend- Specified by:
createBackendin interfaceComputeBackend- Returns:
- The backend implementation object
-
getEnvironmentInfo
Description copied from interface:LinearAlgebraProviderReturns a string describing the execution environment (e.g., "CPU (AVX2)", "GPU (CUDA 12.0)").- Specified by:
getEnvironmentInfoin interfaceLinearAlgebraProvider<E>
-
isCompatible
Description copied from interface:LinearAlgebraProviderChecks if this provider is compatible with the given ring.- Specified by:
isCompatiblein interfaceLinearAlgebraProvider<E>
-
isExplicitlyDisabled
public boolean isExplicitlyDisabled()Description copied from interface:BackendChecks if this backend is specifically disabled via a system property:"episteme.backend.disable." + getId().It also checks specialized properties like
"episteme.linearalgebra.disable." + getId().- Specified by:
isExplicitlyDisabledin interfaceBackend- Returns:
- true if explicitly disabled
-
score
Description copied from interface:AlgorithmProviderScores this provider for a specific operation context.Higher scores indicate better suitability. Used by
ProviderSelectorfor context-aware selection.Default implementation returns
AlgorithmProvider.getPriority(), so existing providers behave identically without changes.- Specified by:
scorein interfaceAlgorithmProvider- Specified by:
scorein interfaceLinearAlgebraProvider<E>- Parameters:
context- the operation context (data size, hints, etc.)- Returns:
- suitability score (higher = better)
-
createContext
Description copied from interface:ComputeBackendCreates an execution context for running operations.The context should be used within a try-with-resources block to ensure proper cleanup of resources.
- Specified by:
createContextin interfaceComputeBackend- Returns:
- new execution context
-
shutdown
public void shutdown()Description copied from interface:AlgorithmProviderCalled when the provider is no longer needed (e.g., application shutdown). Use this to release local resources or close native segments.- Specified by:
shutdownin interfaceAlgorithmProvider- Specified by:
shutdownin interfaceBackend
-
getMetadata
Description copied from interface:AlgorithmProviderReturns metadata about the provider's performance and capabilities. This can be used for advanced matching in the ProviderSelector.- Specified by:
getMetadatain interfaceAlgorithmProvider- Returns:
- a map of metadata keys and values
-
trace
-
dot
-
norm
-
multiply
-
normalize
Description copied from interface:LinearAlgebraProviderReturns the normalized vector (unit vector).- Specified by:
normalizein interfaceLinearAlgebraProvider<E>
-
cross
Description copied from interface:LinearAlgebraProviderReturns the cross product of two 3D vectors.- Specified by:
crossin interfaceLinearAlgebraProvider<E>
-
projection
Description copied from interface:LinearAlgebraProviderReturns the projection of vector a onto vector b.- Specified by:
projectionin interfaceLinearAlgebraProvider<E>
-
multiply
-
multiply
-
exp
Description copied from interface:LinearAlgebraProviderComputes the matrix exponential e^A.- Specified by:
expin interfaceLinearAlgebraProvider<E>
-
log
-
log10
-
sin
-
cos
-
tan
-
asin
-
acos
-
atan
-
sinh
-
cosh
-
tanh
-
asinh
-
acosh
-
atanh
-
sqrt
-
cbrt
-
pow
-
add
-
subtract
-
scale
-
transpose
-
conjugateTranspose
- Specified by:
conjugateTransposein interfaceLinearAlgebraProvider<E>
-
lu
Description copied from interface:LinearAlgebraProviderComputes the LU decomposition of the specified matrix.- Specified by:
luin interfaceLinearAlgebraProvider<E>
-
solve
Description copied from interface:LinearAlgebraProviderSolves Ax = b using a previously computed LU decomposition.- Specified by:
solvein interfaceLinearAlgebraProvider<E>
-
solve
Description copied from interface:LinearAlgebraProviderSolves Ax = b using a previously computed QR decomposition.- Specified by:
solvein interfaceLinearAlgebraProvider<E>
-
solve
Description copied from interface:LinearAlgebraProviderSolves Ax = b using a previously computed Cholesky decomposition.- Specified by:
solvein interfaceLinearAlgebraProvider<E>
-
applyTranscendental
-
angle
Description copied from interface:LinearAlgebraProviderReturns the angle between two vectors in radians.- Specified by:
anglein interfaceLinearAlgebraProvider<E>
-
solveTriangular
public Vector<E> solveTriangular(Matrix<E> A, Vector<E> b, boolean upper, boolean transpose, boolean conjugate, boolean unit) Description copied from interface:LinearAlgebraProviderSolves the triangular system Ax = b.- Specified by:
solveTriangularin interfaceLinearAlgebraProvider<E>- Parameters:
A- the triangular matrixb- the right-hand side vectorupper- true if A is upper triangular, false if lowertranspose- true if solving A^T x = bconjugate- 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)
-
eigen
Description copied from interface:LinearAlgebraProviderComputes the eigenvalue decomposition of the specified matrix.- Specified by:
eigenin interfaceLinearAlgebraProvider<E>
-
svd
Description copied from interface:LinearAlgebraProviderComputes the Singular Value Decomposition (SVD) of the specified matrix.- Specified by:
svdin interfaceLinearAlgebraProvider<E>
-
qr
Description copied from interface:LinearAlgebraProviderComputes the QR decomposition of the specified matrix.- Specified by:
qrin interfaceLinearAlgebraProvider<E>
-
solve
-
inverse
-
determinant
- Specified by:
determinantin interfaceLinearAlgebraProvider<E>
-
cholesky
Description copied from interface:LinearAlgebraProviderComputes the Cholesky decomposition of the specified matrix.- Specified by:
choleskyin interfaceLinearAlgebraProvider<E>
-
complexExp
public static void complexExp(MemorySegment resR, MemorySegment resI, MemorySegment aR, MemorySegment aI, long prec, Arena arena, ResourceTracker tracker) -
complexLog
public static void complexLog(MemorySegment resR, MemorySegment resI, MemorySegment aR, MemorySegment aI, long prec, Arena arena, ResourceTracker tracker) -
complexLog10
public static void complexLog10(MemorySegment resR, MemorySegment resI, MemorySegment aR, MemorySegment aI, long prec, Arena arena, ResourceTracker tracker) -
complexSin
public static void complexSin(MemorySegment resR, MemorySegment resI, MemorySegment aR, MemorySegment aI, long prec, Arena arena, ResourceTracker tracker) -
complexCos
public static void complexCos(MemorySegment resR, MemorySegment resI, MemorySegment aR, MemorySegment aI, long prec, Arena arena, ResourceTracker tracker) -
complexTan
public static void complexTan(MemorySegment resR, MemorySegment resI, MemorySegment aR, MemorySegment aI, long prec, Arena arena, ResourceTracker tracker) -
complexSinh
public static void complexSinh(MemorySegment resR, MemorySegment resI, MemorySegment aR, MemorySegment aI, long prec, Arena arena, ResourceTracker tracker) -
complexCosh
public static void complexCosh(MemorySegment resR, MemorySegment resI, MemorySegment aR, MemorySegment aI, long prec, Arena arena, ResourceTracker tracker) -
complexTanh
public static void complexTanh(MemorySegment resR, MemorySegment resI, MemorySegment aR, MemorySegment aI, long prec, Arena arena, ResourceTracker tracker) -
complexSqrt
public static void complexSqrt(MemorySegment resR, MemorySegment resI, MemorySegment aR, MemorySegment aI, long prec, Arena arena, ResourceTracker tracker) -
complexAsin
public static void complexAsin(MemorySegment resR, MemorySegment resI, MemorySegment aR, MemorySegment aI, long prec, Arena arena, ResourceTracker tracker) -
complexAcos
public static void complexAcos(MemorySegment resR, MemorySegment resI, MemorySegment aR, MemorySegment aI, long prec, Arena arena, ResourceTracker tracker) -
complexAtan
public static void complexAtan(MemorySegment resR, MemorySegment resI, MemorySegment aR, MemorySegment aI, long prec, Arena arena, ResourceTracker tracker) -
complexAsinh
public static void complexAsinh(MemorySegment resR, MemorySegment resI, MemorySegment aR, MemorySegment aI, long prec, Arena arena, ResourceTracker tracker) -
complexAcosh
public static void complexAcosh(MemorySegment resR, MemorySegment resI, MemorySegment aR, MemorySegment aI, long prec, Arena arena, ResourceTracker tracker) -
complexAtanh
public static void complexAtanh(MemorySegment resR, MemorySegment resI, MemorySegment aR, MemorySegment aI, long prec, Arena arena, ResourceTracker tracker) -
complexCbrt
public static void complexCbrt(MemorySegment resR, MemorySegment resI, MemorySegment aR, MemorySegment aI, long prec, Arena arena, ResourceTracker tracker) -
complexPow
public static void complexPow(MemorySegment resR, MemorySegment resI, MemorySegment aR, MemorySegment aI, MemorySegment eR, MemorySegment eI, long prec, Arena arena, ResourceTracker tracker) -
getHandle
-
invokeComplexOp
public static void invokeComplexOp(String function, MemorySegment rcR, MemorySegment rcI, MemorySegment raR, MemorySegment raI, long prec, Arena arena, ResourceTracker tracker)
-