public class ScaledDoubleVector extends Object implements DoubleVector
DoubleVectors that scales every value in a given
DoubleVector by some non zero scale.
Note that this automatically computes the scaling of a ScaledDoubleVector so that backing vector is scaled only once, thus
preventing any recursive calls to scaling.| Constructor and Description |
|---|
ScaledDoubleVector(DoubleVector vector,
double scale)
Creates a new
ScaledDoubleVector that decorates a given DoubleVector by scaling each value in vector by scale. |
| 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.
|
DoubleVector |
getBackingVector()
Returns the vector whose values are scaled by this instance
|
double |
getScalar()
Returns the scalar multiple used by this instance to change the values of
the backing vector
|
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 ScaledDoubleVector(DoubleVector vector, double scale)
ScaledDoubleVector that decorates a given DoubleVector by scaling each value in vector by scale.public double add(int index,
double delta)
add in interface DoubleVectorindex - index to change.delta - the amount to change by.public double get(int index)
get in interface DoubleVectorindex - index to retrieve.public DoubleVector getBackingVector()
public double getScalar()
public Double getValue(int index)
Double.getValue in interface DoubleVectorgetValue in interface Vector<Double>index - index to retrieve.public void set(int index,
double value)
set in interface DoubleVectorindex - index to set.value - value to set in the vector.public void set(int index,
Number value)
public double magnitude()
public int length()
Vector.public double[] toArray()
toArray in interface DoubleVectordouble array of this vector.Copyright © 2012. All Rights Reserved.