Class NativeRealDoubleMatrixStorage
java.lang.Object
org.episteme.nativ.mathematics.linearalgebra.matrices.storage.NativeRealDoubleMatrixStorage
- All Implemented Interfaces:
AutoCloseable, MatrixStorage<Real>, RealDoubleMatrixStorage, NativeSegmentProxy
public class NativeRealDoubleMatrixStorage
extends Object
implements RealDoubleMatrixStorage, NativeSegmentProxy, AutoCloseable
A dense matrix backed by off-heap native memory for 64-bit Reals.
This class provides zero-copy access for native libraries (BLAS, LAPACK) via Project Panama's Foreign Function invalid input: '&' Memory API.
-
Constructor Summary
ConstructorsConstructorDescriptionNativeRealDoubleMatrixStorage(int rows, int cols) NativeRealDoubleMatrixStorage(int rows, int cols, Arena arena) NativeRealDoubleMatrixStorage(MemorySegment data, int rows, int cols, Arena arena) -
Method Summary
Modifier and TypeMethodDescriptionarena()Returns the Arena managing the lifecycle of the segment.clone()Creates a deep copy of this storage.voidclose()Closes the storage and releases any native resources if applicable.intcols()Returns the number of columns.get(int row, int col) Returns the element at the specified position.Returns a DoubleBuffer view of the storage data.doublegetDouble(int row, int col) Gets the value at the specified position as a primitive double.intreshape(int newRows, int newCols) introws()Returns the number of rows.segment()Returns the underlying native memory segment.voidSets the element at the specified position.voidsetAll(double[] values) voidsetDouble(int row, int col, double value) Sets the value at the specified position as a primitive double.longdouble[]toArray()double[]Copies the underlying data to a new double array.Methods inherited from class Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface NativeSegmentProxy
isAliveMethods inherited from interface RealDoubleMatrixStorage
getData
-
Constructor Details
-
NativeRealDoubleMatrixStorage
-
NativeRealDoubleMatrixStorage
public NativeRealDoubleMatrixStorage(int rows, int cols) -
NativeRealDoubleMatrixStorage
-
-
Method Details
-
segment
Description copied from interface:NativeSegmentProxyReturns the underlying native memory segment.- Specified by:
segmentin interfaceNativeSegmentProxy
-
arena
Description copied from interface:NativeSegmentProxyReturns the Arena managing the lifecycle of the segment.- Specified by:
arenain interfaceNativeSegmentProxy
-
rows
public int rows()Description copied from interface:MatrixStorageReturns the number of rows.- Specified by:
rowsin interfaceMatrixStorage<Real>- Returns:
- the row count
-
cols
public int cols()Description copied from interface:MatrixStorageReturns the number of columns.- Specified by:
colsin interfaceMatrixStorage<Real>- Returns:
- the column count
-
get
Description copied from interface:MatrixStorageReturns the element at the specified position.- Specified by:
getin interfaceMatrixStorage<Real>- Parameters:
row- the row indexcol- the column index- Returns:
- the element at [row, col]
-
set
Description copied from interface:MatrixStorageSets the element at the specified position.- Specified by:
setin interfaceMatrixStorage<Real>- Parameters:
row- the row indexcol- the column indexvalue- the value to set
-
getBuffer
Description copied from interface:RealDoubleMatrixStorageReturns a DoubleBuffer view of the storage data.- Specified by:
getBufferin interfaceRealDoubleMatrixStorage
-
toDoubleArray
public double[] toDoubleArray()Description copied from interface:RealDoubleMatrixStorageCopies the underlying data to a new double array.- Specified by:
toDoubleArrayin interfaceRealDoubleMatrixStorage
-
clone
Description copied from interface:MatrixStorageCreates a deep copy of this storage.- Specified by:
clonein interfaceMatrixStorage<Real>- Overrides:
clonein classObject- Returns:
- a clone of this storage
-
sizeBytes
public long sizeBytes() -
getDouble
public double getDouble(int row, int col) Description copied from interface:RealDoubleMatrixStorageGets the value at the specified position as a primitive double.- Specified by:
getDoublein interfaceRealDoubleMatrixStorage
-
setDouble
public void setDouble(int row, int col, double value) Description copied from interface:RealDoubleMatrixStorageSets the value at the specified position as a primitive double.- Specified by:
setDoublein interfaceRealDoubleMatrixStorage
-
setAll
public void setAll(double[] values) -
toArray
public double[] toArray() -
leadingDimension
public int leadingDimension() -
reshape
-
transpose
-
close
public void close()Description copied from interface:RealDoubleMatrixStorageCloses the storage and releases any native resources if applicable.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceRealDoubleMatrixStorage
-