public class DenseDynamicMagnitudeVector extends Object implements DoubleVector, Serializable
Vector
where all values are held in memory. The underlying
implementation is simply an array of doubles. This implementation updates
the magnitude everytime a value is modified. This can be a benefit if the
vector regularly needs the magnitude to be computed but also has minor
changes to it between each computation. Constructor and Description |
---|
DenseDynamicMagnitudeVector(double[] vector)
Create a
DenseDynamicMagnitudeVector taking the values given by vector . |
DenseDynamicMagnitudeVector(DoubleVector v)
Create a
DenseDynamicMagnitudeVector by copying the values from
another Vector . |
DenseDynamicMagnitudeVector(int vectorLength)
Create an
DenseDynamicMagnitudeVector with all values starting at 0 with
the given length. |
Modifier and Type | Method and Description |
---|---|
double |
add(int index,
double delta)
Changes the value in this vector by a specified amount (optional
operation).
|
double |
get(int index)
Returns the value of this vector at the given index.
|
Double |
getValue(int index)
Returns the value of the vector at the given index as a
Double . |
int |
length()
Return the size of the
Vector . |
double |
magnitude()
Returns the magnitude of this vector
|
void |
set(int index,
double value)
Sets the length in this vector (optional operation).
|
void |
set(int index,
Number value)
Set the value in the vector (optional operation).
|
double[] |
toArray()
Returns a double array representing this vector.
|
public DenseDynamicMagnitudeVector(int vectorLength)
DenseDynamicMagnitudeVector
with all values starting at 0 with
the given length.vectorLength
- The size of the vector to create.public DenseDynamicMagnitudeVector(double[] vector)
DenseDynamicMagnitudeVector
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 DenseDynamicMagnitudeVector(DoubleVector v)
DenseDynamicMagnitudeVector
by copying the values from
another Vector
.vector
- The Vector
to copy from.public double add(int index, double delta)
add
in interface DoubleVector
index
- index to change.delta
- the amount to change by.public void set(int index, double value)
set
in interface DoubleVector
index
- index to set.value
- value to set in the vector.public void set(int index, Number value)
public double get(int index)
get
in interface DoubleVector
index
- index to retrieve.public Double getValue(int index)
Double
.getValue
in interface DoubleVector
getValue
in interface Vector<Double>
index
- index to retrieve.public double magnitude()
public double[] toArray()
toArray
in interface DoubleVector
double
array of this vector.Copyright © 2012. All Rights Reserved.