|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.lmu.ifi.dbs.elki.math.linearalgebra.Vector
public class Vector
Provides a vector object that encapsulates an m x 1 - matrix object.
Field Summary | |
---|---|
protected double[] |
elements
Array for internal storage of elements. |
private static long |
serialVersionUID
Serial version |
Constructor Summary | |
---|---|
Vector(double... values)
Construct a vector from a given array. |
|
Vector(int m)
Provides an m x 1 vector. |
Method Summary | |
---|---|
private void |
checkDimensions(Vector v)
Check if this.getDimensionality() == v.getDimensionality(). |
Vector |
clone()
Clone the Vector object. |
Vector |
copy()
Returns a copy of this vector. |
boolean |
equals(Object obj)
|
double |
euclideanLength()
Returns the length of this vector. |
double |
get(int i)
Returns the value at the specified row. |
double |
get(int i,
int j)
Get a single element. |
double[] |
getArrayCopy()
Copy the internal two-dimensional array. |
double[] |
getArrayRef()
Access the internal two-dimensional array. |
int |
getColumnDimensionality()
Returns the dimensionality of the columns of this matrix. |
Vector |
getColumnVector(int i)
Returns the i th column of this matrix as vector. |
int |
getDimensionality()
Returns the dimensionality of this vector. |
int |
getRowDimensionality()
Returns the dimensionality of the rows of this matrix. |
int |
hashCode()
|
Vector |
increment(int i,
int j,
double s)
Increments a single element. |
Vector |
inverseVector()
Inverts every element of the vector. |
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 |
Vector |
normalize()
Normalizes this vector to the length of 1.0. |
double |
normF()
Frobenius norm |
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 |
double |
scalarProduct(Vector v)
Returns the scalar product of this vector and the specified vector v. |
Vector |
set(int i,
double value)
Sets the value at the specified row. |
Vector |
set(int i,
int j,
double s)
Set a single element. |
void |
setZero()
Reset the Vector to 0. |
Vector |
sqrtVector()
Square roots every element of the vector. |
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 |
String |
toString()
Returns a string representation of this vector. |
String |
toStringNoWhitespace()
Returns a string representation of this vector without adding extra whitespace |
Matrix |
transpose()
Matrix transpose. |
Matrix |
transposeTimes(Matrix B)
Linear algebraic matrix multiplication, AT * B |
double |
transposeTimes(Vector B)
Linear algebraic matrix multiplication, AT * B |
static Vector |
unitVector(int dimensionality,
int i)
Returns the ith unit vector of the specified dimensionality. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final long serialVersionUID
protected final double[] elements
Constructor Detail |
---|
public Vector(double... values)
values
- array of doublespublic Vector(int m)
m
- the number of rowsMethod Detail |
---|
public static final Vector randomNormalizedVector(int dimensionality)
dimensionality
- dimensionality
public static final Vector unitVector(int dimensionality, int i)
dimensionality
- the dimensionality of the vectori
- the index
public final Vector copy()
copy
in interface MatrixLike<Vector>
public Vector clone()
clone
in interface MatrixLike<Vector>
clone
in class Object
public final double[] getArrayRef()
public final double[] getArrayCopy()
public final int getDimensionality()
public final int getRowDimensionality()
MatrixLike
getRowDimensionality
in interface MatrixLike<Vector>
public final int getColumnDimensionality()
MatrixLike
getColumnDimensionality
in interface MatrixLike<Vector>
public final double get(int i)
i
- the row index
public final double get(int i, int j)
MatrixLike
get
in interface MatrixLike<Vector>
i
- Row index.j
- Column index.
public final Vector set(int i, double value)
i
- the row indexvalue
- the value to be set
public final Vector set(int i, int j, double s)
MatrixLike
set
in interface MatrixLike<Vector>
i
- Row index.j
- Column index.s
- A(i,j).public final Vector increment(int i, int j, double s)
MatrixLike
increment
in interface MatrixLike<Vector>
i
- the row indexj
- the column indexs
- the increment value: A(i,j) = A(i.j) + s.public final Vector getColumnVector(int i)
MatrixLike
i
th column of this matrix as vector.
getColumnVector
in interface MatrixLike<Vector>
i
- the index of the column to be returned
i
th column of this matrixpublic final Matrix transpose()
MatrixLike
transpose
in interface MatrixLike<Vector>
public final Vector plus(Vector v)
plus
in interface MatrixLike<Vector>
v
- the vector to be added
public final Vector plusTimes(Vector v, double s)
plusTimes
in interface MatrixLike<Vector>
v
- the vector to be addeds
- the scalar
public final Vector plusEquals(Vector B)
plusEquals
in interface MatrixLike<Vector>
B
- another matrix
public final Vector plusTimesEquals(Vector B, double s)
plusTimesEquals
in interface MatrixLike<Vector>
B
- another matrixs
- Scalar
public final Vector plusEquals(double d)
d
- Value to add
public final Vector minus(Vector v)
minus
in interface MatrixLike<Vector>
v
- the vector to be subtracted from this vector
public final Vector minusTimes(Vector v, double s)
minusTimes
in interface MatrixLike<Vector>
v
- the vector to be subtracted from this vectors
- the scaling factor
public final Vector minusEquals(Vector B)
minusEquals
in interface MatrixLike<Vector>
B
- another matrix
public final Vector minusTimesEquals(Vector B, double s)
minusTimesEquals
in interface MatrixLike<Vector>
B
- another matrixs
- Scalar
public final Vector minusEquals(double d)
d
- Value to subtract
public final Vector times(double s)
times
in interface MatrixLike<Vector>
s
- the scalar to be multiplied
public final Vector timesEquals(double s)
timesEquals
in interface MatrixLike<Vector>
s
- scalar
public final Matrix times(Matrix B)
B
- another matrix
IllegalArgumentException
- Matrix inner dimensions must agree.public final Matrix transposeTimes(Matrix B)
B
- another matrix
IllegalArgumentException
- Matrix inner dimensions must agree.public final double transposeTimes(Vector B)
B
- another vector
IllegalArgumentException
- Matrix inner dimensions must agree.public final Matrix timesTranspose(Matrix B)
B
- another matrix
IllegalArgumentException
- Matrix inner dimensions must agree.public final double scalarProduct(Vector v)
v
- the vector
public final Vector inverseVector()
public final Vector sqrtVector()
public final double euclideanLength()
public double normF()
public final Vector normalize()
public final Vector projection(Matrix v)
v
- the subspace matrix
IllegalArgumentException
- if this matrix is no row vector, i.e. this
matrix has more than one column or this matrix and v have different
length of rowsprivate final void checkDimensions(Vector v)
IllegalArgumentException
- if the dimensions do not agreepublic int hashCode()
hashCode
in class Object
public boolean equals(Object obj)
equals
in class Object
public final String toString()
toString
in class Object
public final String toStringNoWhitespace()
public void setZero()
|
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |