
public class Vector extends Object implements NumberVector<Vector,Double>
| Modifier and Type | Field and Description |
|---|---|
protected double[] |
elements
Array for internal storage of elements.
|
| Constructor and Description |
|---|
Vector(double... values)
Construct a vector from a given array.
|
Vector(int m)
Provides an m x 1 vector.
|
| Modifier and Type | Method and Description |
|---|---|
byte |
byteValue(int dimension)
Returns the value in the specified dimension as byte.
|
Vector |
clone()
Clone the Vector object.
|
Vector |
copy()
Returns a copy of this vector.
|
double |
doubleValue(int dimension)
Returns the value in the specified dimension as double.
|
boolean |
equals(Object obj) |
double |
euclideanLength()
Returns the length of this vector.
|
float |
floatValue(int dimension)
Returns the value in the specified dimension as float.
|
double |
get(int i)
Returns the value at the specified row.
|
double[] |
getArrayCopy()
Copy the internal two-dimensional array.
|
double[] |
getArrayRef()
Access the internal two-dimensional array.
|
Vector |
getColumnVector()
Returns a Vector representing in one column and
getDimensionality() rows the values of this NumberVector of V. |
int |
getDimensionality()
Returns the dimensionality of this vector.
|
double |
getMax(int dimension)
Returns the maximum coordinate at the specified dimension.
|
double |
getMin(int dimension)
Returns the minimum coordinate at the specified dimension.
|
Double |
getValue(int dimension)
Returns the value in the specified dimension.
|
int |
hashCode() |
int |
intValue(int dimension)
Returns the value in the specified dimension as int.
|
long |
longValue(int dimension)
Returns the value in the specified dimension as long.
|
Vector |
minus(Vector v)
Returns this vector minus the specified vector v.
|
Vector |
minusEquals(double d)
Subtract a constant value from all dimensions.
|
Vector |
minusEquals(Vector B)
A = A - B
|
Vector |
minusTimes(Vector v,
double s)
Returns this vector minus the specified vector v times s.
|
Vector |
minusTimesEquals(Vector B,
double s)
A = A - s * B
|
<A> Vector |
newFeatureVector(A array,
ArrayAdapter<Double,A> adapter)
Returns a new FeatureVector of V for the given values.
|
<A> Vector |
newNumberVector(A array,
NumberArrayAdapter<?,A> adapter)
Instantiate from any number-array like object.
|
Vector |
newNumberVector(double[] values)
Returns a new NumberVector of N for the given values.
|
Vector |
normalize()
Normalizes this vector to the length of 1.0.
|
Vector |
plus(Vector v)
Returns a new vector which is the result of this vector plus the specified
vector.
|
Vector |
plusEquals(double d)
Add a constant value to all dimensions.
|
Vector |
plusEquals(Vector B)
A = A + B
|
Vector |
plusTimes(Vector v,
double s)
Returns a new vector which is the result of this vector plus the specified
vector times the given factor.
|
Vector |
plusTimesEquals(Vector B,
double s)
A = A + s * B
|
Vector |
projection(Matrix v)
Projects this row vector into the subspace formed by the specified matrix
v.
|
static Vector |
randomNormalizedVector(int dimensionality)
Returns a randomly created vector of length 1.0
|
Vector |
rotate90Equals()
Rotate vector by 90 degrees.
|
Vector |
set(int i,
double value)
Sets the value at the specified row.
|
void |
setZero()
Reset the Vector to 0.
|
short |
shortValue(int dimension)
Returns the value in the specified dimension as short.
|
Vector |
times(double s)
Returns a new vector which is the result of this vector multiplied by the
specified scalar.
|
Matrix |
times(Matrix B)
Linear algebraic matrix multiplication, A * B
|
Vector |
timesEquals(double s)
Multiply a matrix by a scalar in place, A = s*A
|
Matrix |
timesTranspose(Matrix B)
Linear algebraic matrix multiplication, A * B^T
|
Matrix |
timesTranspose(Vector B)
Linear algebraic matrix multiplication, A * B^T
|
String |
toString()
Returns a string representation of this vector.
|
String |
toStringNoWhitespace()
Returns a string representation of this vector without adding extra
whitespace
|
Matrix |
transposeTimes(Matrix B)
Linear algebraic matrix multiplication, AT * B
|
double |
transposeTimes(Vector B)
Linear algebraic matrix multiplication, AT * B
|
double |
transposeTimesTimes(Matrix B,
Vector c)
Linear algebraic matrix multiplication, aT * B * c
|
static Vector |
unitVector(int dimensionality,
int i)
Returns the ith unit vector of the specified dimensionality.
|
public Vector(double... values)
values - array of doublespublic Vector(int m)
m - the number of rowspublic static final Vector randomNormalizedVector(int dimensionality)
dimensionality - dimensionalitypublic static final Vector unitVector(int dimensionality, int i)
dimensionality - the dimensionality of the vectori - the indexpublic final Vector copy()
public final double[] getArrayRef()
public final double[] getArrayCopy()
public final int getDimensionality()
getDimensionality in interface FeatureVector<Vector,Double>getDimensionality in interface SpatialComparablepublic final double get(int i)
i - the row indexpublic final Vector set(int i, double value)
i - the row indexvalue - the value to be setpublic final Vector plus(Vector v)
v - the vector to be addedpublic final Vector plusTimes(Vector v, double s)
v - the vector to be addeds - the scalarpublic final Vector plusEquals(Vector B)
B - another matrixpublic final Vector plusTimesEquals(Vector B, double s)
B - another matrixs - Scalarpublic final Vector plusEquals(double d)
d - Value to addpublic final Vector minus(Vector v)
v - the vector to be subtracted from this vectorpublic final Vector minusTimes(Vector v, double s)
v - the vector to be subtracted from this vectors - the scaling factorpublic final Vector minusEquals(Vector B)
B - another matrixpublic final Vector minusTimesEquals(Vector B, double s)
B - another matrixs - Scalarpublic final Vector minusEquals(double d)
d - Value to subtractpublic final Vector times(double s)
s - the scalar to be multipliedpublic final Vector timesEquals(double s)
s - scalarpublic final Matrix times(Matrix B)
B - another matrixpublic final Matrix transposeTimes(Matrix B)
B - another matrixpublic final double transposeTimesTimes(Matrix B, Vector c)
B - matrixc - vector on the rightpublic final double transposeTimes(Vector B)
B - another vectorpublic final Matrix timesTranspose(Matrix B)
B - another matrixpublic final Matrix timesTranspose(Vector B)
B - another matrixpublic final double euclideanLength()
public final Vector normalize()
public final Vector projection(Matrix v)
v - the subspace matrixpublic final String toString()
public final String toStringNoWhitespace()
public void setZero()
public Vector rotate90Equals()
public double getMin(int dimension)
SpatialComparablegetMin in interface SpatialComparabledimension - the dimension for which the coordinate should be returned,
where 1 ≤ dimension ≤ getDimensionality()public double getMax(int dimension)
SpatialComparablegetMax in interface SpatialComparabledimension - the dimension for which the coordinate should be returned,
where 1 ≤ dimension ≤ getDimensionality()public Double getValue(int dimension)
FeatureVectorgetValue in interface FeatureVector<Vector,Double>dimension - the desired dimension, where 1 ≤ dimension ≤
this.getDimensionality()public double doubleValue(int dimension)
NumberVectorgetValue(dim).doubleValue(), but usually this is much more
efficient due to boxing/unboxing cost.doubleValue in interface NumberVector<Vector,Double>dimension - the desired dimension, where 1 ≤ dimension ≤
this.getDimensionality()public float floatValue(int dimension)
NumberVectorgetValue(dim).floatValue(), but usually this is much more efficient
due to boxing/unboxing cost.floatValue in interface NumberVector<Vector,Double>dimension - the desired dimension, where 1 ≤ dimension ≤
this.getDimensionality()public int intValue(int dimension)
NumberVectorgetValue(dim).intValue(), but usually this is much more efficient
due to boxing/unboxing cost.intValue in interface NumberVector<Vector,Double>dimension - the desired dimension, where 1 ≤ dimension ≤
this.getDimensionality()public long longValue(int dimension)
NumberVectorgetValue(dim).longValue(), but usually this is much more efficient
due to boxing/unboxing cost.longValue in interface NumberVector<Vector,Double>dimension - the desired dimension, where 1 ≤ dimension ≤
this.getDimensionality()public short shortValue(int dimension)
NumberVectorgetValue(dim).shortValue(), but usually this is much more efficient
due to boxing/unboxing cost.shortValue in interface NumberVector<Vector,Double>dimension - the desired dimension, where 1 ≤ dimension ≤
this.getDimensionality()public byte byteValue(int dimension)
NumberVectorgetValue(dim).byteValue(), but usually this is much more efficient
due to boxing/unboxing cost.byteValue in interface NumberVector<Vector,Double>dimension - the desired dimension, where 1 ≤ dimension ≤
this.getDimensionality()public Vector getColumnVector()
NumberVectorgetDimensionality() rows the values of this NumberVector of V.getColumnVector in interface NumberVector<Vector,Double>getDimensionality() rows the values of this
NumberVector of Vpublic Vector newNumberVector(double[] values)
NumberVectornewNumberVector in interface NumberVector<Vector,Double>values - the values of the NumberVectorpublic <A> Vector newNumberVector(A array, NumberArrayAdapter<?,A> adapter)
NumberVectornewNumberVector in interface NumberVector<Vector,Double>A - Array typearray - Arrayadapter - Adapterpublic <A> Vector newFeatureVector(A array, ArrayAdapter<Double,A> adapter)
FeatureVectornewFeatureVector in interface FeatureVector<Vector,Double>A - Array typearray - the values of the featureVectoradapter - adapter class