Class Vector
java.lang.Object
org.hansken.plugin.extraction.api.Vector
An opaque vector of floating point values.
- Author:
- Netherlands Forensic Institute
- 
Method SummaryModifier and TypeMethodDescriptionbyte[]asBinary()Returns the binary representation of the Vector.static VectorasVector(byte[] bytes) Creates a vector from a binary representation.booleaninthashCode()static Vectorof(float... values) Creates a Vector from an array of floating point values.static Vectorof(Collection<Float> values) Creates a Vector from a collection of numbers.static VectorCreates a Vector from a base64 encoded string.intsize()Returns the number of dimensions of the vector.toBase64()Returns a base64 encoded string of the Vector.toString()float[]values()Returns the values of the Vector as an array of floats.
- 
Method Details- 
ofCreates a Vector from an array of floating point values.- Parameters:
- values- the values to use
- Returns:
- a vector
 
- 
ofCreates a Vector from a collection of numbers. Note that all numbers are converted to floats internally, so loss of precision may occur when doubles or longs are offered.- Parameters:
- values- the values to use
- Returns:
- a vector
 
- 
ofBase64Creates a Vector from a base64 encoded string.- Parameters:
- base64- the base64 encoded string to use
- Returns:
- a vector
 
- 
asVectorCreates a vector from a binary representation.Vector.asBinary()can be used to obtain a binary representation. Note that this directly sets the internal state of the Vector, use {code asVector(bytes.clone()} to store a safe, immutable copy.- Parameters:
- bytes- the bytes to convert to a vector.
- Returns:
- a vector
 
- 
asBinarypublic byte[] asBinary()Returns the binary representation of the Vector.Vector.asVector(byte[])can be used to convert the binary representation back to the original vector. The format of the returned bytes is a sequence of the floating point values of the vector, stored as big-endian IEEE 754 encoded 32-bit floating point values. Note that this exposes the internal state of the Vector, use {code asBinary().clone()} to obtain a safely mutable copy.- Returns:
- a binary representation of the vector.
 
- 
sizepublic int size()Returns the number of dimensions of the vector.- Returns:
- the number of dimensions of the vector.
 
- 
valuespublic float[] values()Returns the values of the Vector as an array of floats.- Returns:
- the values of the Vector as an array of floats.
 
- 
toBase64Returns a base64 encoded string of the Vector.Vector.ofBase64()can be used to convert the return base64 encoded string back to a Vector.- Returns:
- a base64 encoded string of the Vector.
 
- 
toString
- 
hashCodepublic int hashCode()
- 
equals
 
-