public class DenseVector extends AbstractDoubleVector implements Serializable
Vector where all values are held in memory. The underlying
implementation is simply an array of doubles. | Constructor and Description |
|---|
DenseVector(double[] vector)
Create a
DenseVector taking the values given by vector. |
DenseVector(DoubleVector v)
Create a
DenseVector by copying the values from another Vector. |
DenseVector(int vectorLength)
Create an
DenseVector with all values starting at 0 with
the given length. |
| Modifier and Type | Method and Description |
|---|---|
double |
add(int index,
double delta)
Throws an
UnsupportedOperationException if called (vector is
unmodifiable). |
double |
get(int index)
Returns the value of this vector at the given index.
|
int |
length()
Return the size of the
Vector. |
double |
magnitude()
Returns the magnitude of this vector
|
void |
set(int index,
double value)
Throws an
UnsupportedOperationException if called (vector is
unmodifiable). |
double[] |
toArray()
Returns a double array representing this vector.
|
public DenseVector(int vectorLength)
DenseVector with all values starting at 0 with
the given length.vectorLength - The size of the vector to create.public DenseVector(double[] vector)
DenseVector taking the values given by vector.
The created vector contains no references to the provided array, so
changes to either will not be reflected in the other.vector - The vector values to start with.public DenseVector(DoubleVector v)
DenseVector by copying the values from another Vector.vector - The Vector to copy from.public double add(int index,
double delta)
UnsupportedOperationException if called (vector is
unmodifiable).add in interface DoubleVectoradd in class AbstractDoubleVectorindex - index to change.delta - the amount to change by.public double get(int index)
get in interface DoubleVectorindex - index to retrieve.public double magnitude()
magnitude in interface Vector<Double>magnitude in class AbstractDoubleVectorpublic void set(int index,
double value)
UnsupportedOperationException if called (vector is
unmodifiable).set in interface DoubleVectorset in class AbstractDoubleVectorindex - index to set.value - value to set in the vector.public double[] toArray()
toArray in interface DoubleVectortoArray in class AbstractDoubleVectordouble array of this vector.Copyright © 2012. All Rights Reserved.