Record Class SparseDoubleVector
java.lang.Object
java.lang.Record
io.micronaut.data.model.vector.SparseDoubleVector
- Record Components:
length- The dense vector length.indices- Sorted non-zero positions.values- Non-zero values aligned withindices.
- All Implemented Interfaces:
SparseVector, Vector
@TypeDef(type=OBJECT,
converter=SparseDoubleVectorAttributeConverter.class)
public record SparseDoubleVector(int length, int[] indices, double[] values)
extends Record
implements SparseVector
Sparse
DoubleVector representation.- Since:
- 5.0.0
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionSparseDoubleVector(int length, int[] indices, double[] values) Creates a sparse double vector. -
Method Summary
Modifier and TypeMethodDescriptionbooleanIndicates whether some other object is "equal to" this one.static SparseDoubleVectorfromDense(double[] denseValues) Creates a sparse vector from dense double values.static SparseDoubleVectorfromDense(DoubleVector denseVector) Creates a sparse vector from a denseDoubleVector.getType()Return the primitive number type the vector is backed by.inthashCode()Returns a hash code value for this object.int[]indices()intlength()Returns the value of thelengthrecord component.byte[]Convert this vector to a new byte array copy.Converts this sparse vector into denseDoubleVectorform.double[]Convert this vector to a new double array copy.float[]Convert this vector to a new float array copy.toString()Returns a string representation of this record class.double[]values()Returns the value of thevaluesrecord component.Methods inherited from interface SparseVector
sizeMethods inherited from interface Vector
toSparseByteVector, toSparseDoubleVector, toSparseFloatVector
-
Constructor Details
-
SparseDoubleVector
public SparseDoubleVector(int length, int[] indices, double[] values) Creates a sparse double vector.- Parameters:
length- dense vector lengthindices- sorted non-zero indicesvalues- non-zero values aligned with indices
-
-
Method Details
-
fromDense
Creates a sparse vector from dense double values.- Parameters:
denseValues- dense values- Returns:
- sparse vector representation
-
fromDense
Creates a sparse vector from a denseDoubleVector.- Parameters:
denseVector- dense vector- Returns:
- sparse vector representation
-
indices
public int[] indices()- Specified by:
indicesin interfaceSparseVector- Returns:
- sorted non-zero indices
-
values
-
getType
-
toFloatArray
public float[] toFloatArray()Convert this vector to a new float array copy.- Specified by:
toFloatArrayin interfaceVector- Returns:
- a new float[] with the vector content
-
toDoubleArray
public double[] toDoubleArray()Convert this vector to a new double array copy.- Specified by:
toDoubleArrayin interfaceVector- Returns:
- a new double[] with the vector content
-
toByteArray
public byte[] toByteArray()Convert this vector to a new byte array copy.- Specified by:
toByteArrayin interfaceVector- Returns:
- a new byte[] with the vector content
-
toDenseVector
Converts this sparse vector into denseDoubleVectorform.- Returns:
- dense double vector
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
length
public int length()Returns the value of thelengthrecord component.- Specified by:
lengthin interfaceSparseVector- Returns:
- the value of the
lengthrecord component
-