VectorType
- Type of Vector created by this factory.public abstract class VectorFactory<VectorType extends Vector>
extends java.lang.Object
implements java.io.Serializable
Vector
objects.Modifier and Type | Field and Description |
---|---|
protected static VectorFactory<? extends Vector> |
DEFAULT_DENSE_INSTANCE
The default
VectorFactory instance. |
protected static SparseVectorFactory<? extends Vector> |
DEFAULT_SPARSE_INSTANCE
The default SparseVectorFactory instance.
|
Modifier | Constructor and Description |
---|---|
protected |
VectorFactory()
Creates a new
VectorFactory . |
Modifier and Type | Method and Description |
---|---|
VectorType |
copyArray(double[] values)
Copies the values from the array into the Vector
|
VectorType |
copyArray(int dimensionality,
int[] indices,
double[] values)
Creates a new vector of the given dimensionality by setting the values
at the given indices.
|
VectorType |
copyMap(int dimensionality,
java.util.Map<java.lang.Integer,? extends java.lang.Number> map)
Creates a vector from the given map of indices to values.
|
VectorType |
copyValues(java.util.Collection<? extends java.lang.Number> values)
Copies the values from the given Collection.
|
VectorType |
copyValues(double... values)
Copies the values from the given doubles into a Vector
|
abstract VectorType |
copyVector(Vector m)
Creates a deep copy new Vector given another, argument is unchanged
|
VectorType |
createGaussianRandom(int dimensionality,
java.util.Random random)
Creates a vector with random values sampled from a Gaussian distribution
with mean 0 and variance 1.
|
VectorType |
createUniformRandom(int dim,
double min,
double max,
java.util.Random random)
Creates a Vector with random values for the entries, uniformly
distributed between "min" and "max"
|
VectorType |
createUniformRandom(int dimensionality,
java.util.Random random)
Creates a vector with random values for the entries uniformly sampled
between 0 and 1.
|
abstract VectorType |
createVector(int dim)
Creates an empty Vector of the specified dimension, all elements
must be all zeros!
|
VectorType |
createVector(int dimensionality,
double initialValue)
Creates a Vector with the given initial value for all elements.
|
Vector1D |
createVector1D()
Creates a one-dimensional zero vector: (0.0).
|
abstract Vector1D |
createVector1D(double x)
Creates a one-dimensional vector with the given x coordinate: (x).
|
Vector2D |
createVector2D()
Creates a two-dimensional zero vector: (0.0, 0.0).
|
abstract Vector2D |
createVector2D(double x,
double y)
Creates a two-dimensional vector with the given x and y coordinates:
(x, y).
|
Vector3D |
createVector3D()
Creates a three-dimensional zero vector: (0.0, 0.0, 0.0).
|
abstract Vector3D |
createVector3D(double x,
double y,
double z)
Creates a three-dimensional vector with the given x, y, and z
coordinates: (x, y, z).
|
abstract VectorType |
createVectorCapacity(int dimensionality,
int initialCapacity)
Creates a new, empty vector with the given dimensionality and expected
number of nonzero elements.
|
abstract MatrixFactory<?> |
getAssociatedMatrixFactory()
Gets the matrix factory implementation associated with this vector
factory.
|
static VectorFactory<? extends Vector> |
getDefault()
Gets the default implementation of the
VectorFactory . |
static VectorFactory<? extends Vector> |
getDenseDefault()
Gets the default implementation of
VectorFactory for dense
vectors. |
static SparseVectorFactory<? extends Vector> |
getSparseDefault()
Gets the default implementation of the
SparseVectorFactory . |
protected static final VectorFactory<? extends Vector> DEFAULT_DENSE_INSTANCE
VectorFactory
instance.protected static final SparseVectorFactory<? extends Vector> DEFAULT_SPARSE_INSTANCE
public static VectorFactory<? extends Vector> getDefault()
VectorFactory
.VectorFactory
implementation.public static VectorFactory<? extends Vector> getDenseDefault()
VectorFactory
for dense
vectors.public static SparseVectorFactory<? extends Vector> getSparseDefault()
SparseVectorFactory
.SparseVectorFactory
implementation.public abstract VectorType copyVector(Vector m)
m
- Vector to copypublic VectorType copyArray(double[] values)
values
- Values to copypublic VectorType copyValues(double... values)
values
- Values to copypublic VectorType copyValues(java.util.Collection<? extends java.lang.Number> values)
values
- Values to create a vector from. Cannot be null and cannot contain
null values.public abstract VectorType createVector(int dim)
dim
- number of elements in the Vectorpublic Vector1D createVector1D()
public abstract Vector1D createVector1D(double x)
x
- The x coordinate.public Vector2D createVector2D()
public abstract Vector2D createVector2D(double x, double y)
x
- The x coordinate.y
- The y coordinate.public Vector3D createVector3D()
public abstract Vector3D createVector3D(double x, double y, double z)
x
- The x coordinate.y
- The y coordinate.z
- The z coordinate.public abstract VectorType createVectorCapacity(int dimensionality, int initialCapacity)
dimensionality
- The dimensionality for the vector to create.initialCapacity
- The expected initial number of nonzero elements of the vector to
create.public VectorType createUniformRandom(int dimensionality, java.util.Random random)
dimensionality
- The number of dimensions in the vector.random
- The random number generator to use.public VectorType createUniformRandom(int dim, double min, double max, java.util.Random random)
dim
- number of elements in the Vectormin
- minimum range of the uniform distributionmax
- maximum range of the uniform distributionrandom
- The random number generator.public VectorType createGaussianRandom(int dimensionality, java.util.Random random)
dimensionality
- The number of dimensions in the vector.random
- The random number generator to use.public VectorType createVector(int dimensionality, double initialValue)
dimensionality
- The number of elements for the vector.initialValue
- Initial value to set all elements topublic VectorType copyArray(int dimensionality, int[] indices, double[] values)
dimensionality
- The dimensionality of the vector to create.indices
- The array of indices of values to set. Must be the same length as
the values array. The indices must be between 0 and the
dimensionality - 1.values
- The array of values to set. Must be the same length as the indices
array.public VectorType copyMap(int dimensionality, java.util.Map<java.lang.Integer,? extends java.lang.Number> map)
dimensionality
- The dimensionality of the vector. Cannot be negative.map
- The map of indices to values to fill in the vector. All indices
must be 0-based and between 0 (inclusive) and dimensionality
(exclusive). Cannot be null.public abstract MatrixFactory<?> getAssociatedMatrixFactory()