E nvironment for Deve L oping K DD-Applications Supported by I ndex-Structures

## de.lmu.ifi.dbs.elki.math.linearalgebra Class Vector

```java.lang.Object
de.lmu.ifi.dbs.elki.math.linearalgebra.Matrix
de.lmu.ifi.dbs.elki.math.linearalgebra.Vector
```
All Implemented Interfaces:
Serializable, Cloneable

`public class Vectorextends Matrix`

Provides a vector object that encapsulates an m x 1 - matrix object.

Author:
Elke Achtert
Serialized Form

Field Summary

Fields inherited from class de.lmu.ifi.dbs.elki.math.linearalgebra.Matrix
`DELTA`

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` `copy()`
Returns a copy of this vector.
` double` `get(int i)`
Returns the value at the specified row.
` int` `getDimensionality()`
Returns the dimensionality of this vector.
` Vector` `inverseVector()`
Inverts every element of the vector.
` double` `length()`
Returns the length of this vector.
` Vector` `minus(Vector v)`
Returns this vector minus the specified vector v.
` void` `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.
`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.
` void` ```set(int i, double value)```
Sets the value at the specified row.
` 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.
` String` `toString()`
Returns a string representation of this vector.
` String` `toString(NumberFormat nf)`
Returns a string representation of this vector.
` String` `toStringNoWhitespace()`
Returns a string representation of this vector without adding extra whitespace
`static Vector` ```unitVector(int dimensionality, int i)```
Returns the ith unit vector of the specified dimensionality.

Methods inherited from class de.lmu.ifi.dbs.elki.math.linearalgebra.Matrix
`almostEquals, almostEquals, angle, appendColumns, arrayLeftDivide, arrayLeftDivideEquals, arrayRightDivide, arrayRightDivideEquals, arrayTimes, arrayTimesEquals, cheatToAvoidSingularity, chol, clone, completeBasis, completeToOrthonormalBasis, cond, constructWithCopy, det, diagonal, diagonal, dimensionInfo, distanceCov, eig, equals, euclideanNorm, exactGaussJordanElimination, get, getArray, getArrayCopy, getColumn, getColumnDimensionality, getColumnPackedCopy, getColumnVector, getDiagonal, getMatrix, getMatrix, getMatrix, getMatrix, getRow, getRowDimensionality, getRowPackedCopy, getRowVector, hashCode, identity, increment, inverse, isSymmetric, linearlyIndependent, lu, minus, minusEquals, norm1, norm2, normalizeColumns, normF, normInf, orthonormalize, plus, plusEquals, print, print, print, print, projection, qr, random, rank, read, scalarProduct, scaleColumn, scaleColumns, set, setColumn, setMatrix, setMatrix, setMatrix, setMatrix, solve, solveTranspose, svd, swapColumn, swapRow, times, timesEquals, toString, toString, toString, trace, transpose, uminus, unitMatrix, zeroMatrix`

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, wait, wait, wait`

Constructor Detail

### Vector

`public Vector(double[] values)`
Construct a vector from a given array.

Parameters:
`values` - array of doubles

### Vector

`public Vector(int m)`
Provides an m x 1 vector.

Parameters:
`m` - the number of rows
Method Detail

### get

`public double get(int i)`
Returns the value at the specified row.

Parameters:
`i` - the row index
Returns:
the value at row i

### set

```public void set(int i,
double value)```
Sets the value at the specified row.

Parameters:
`i` - the row index
`value` - the value to be set

### inverseVector

`public Vector inverseVector()`
Inverts every element of the vector.

Returns:
the resulting vector

### sqrtVector

`public Vector sqrtVector()`
Square roots every element of the vector.

Returns:
the resulting vector

### minus

`public Vector minus(Vector v)`
Returns this vector minus the specified vector v.

Parameters:
`v` - the vector to be subtracted from this vector
Returns:
this vector minus the specified vector v

### scalarProduct

`public double scalarProduct(Vector v)`
Returns the scalar product of this vector and the specified vector v.

Parameters:
`v` - the vector
Returns:
double the scalar product of this vector and v

### length

`public double length()`
Returns the length of this vector.

Returns:
the length of this vector

### getDimensionality

`public int getDimensionality()`
Returns the dimensionality of this vector.

Returns:
the dimensionality of this vector

### normalize

`public void normalize()`
Normalizes this vector to the length of 1.0.

### plus

`public Vector plus(Vector v)`
Returns a new vector which is the result of this vector plus the specified vector.

Parameters:
`v` - the vector to be added
Returns:
the resulting vector

### times

`public Vector times(double s)`
Returns a new vector which is the result of this vector multiplied by the specified scalar.

Overrides:
`times` in class `Matrix`
Parameters:
`s` - the scalar to be multiplied
Returns:
the resulting vector

### randomNormalizedVector

`public static Vector randomNormalizedVector(int dimensionality)`
Returns a randomly created vector of length 1.0

Parameters:
`dimensionality` -
Returns:
the dimensionality of the vector

### unitVector

```public static Vector unitVector(int dimensionality,
int i)```
Returns the ith unit vector of the specified dimensionality.

Parameters:
`dimensionality` - the dimensionality of the vector
`i` - the index
Returns:
the ith unit vector of the specified dimensionality

### copy

`public Vector copy()`
Returns a copy of this vector.

Overrides:
`copy` in class `Matrix`
Returns:
a copy of this vector

### toStringNoWhitespace

`public String toStringNoWhitespace()`
Returns a string representation of this vector without adding extra whitespace

Returns:
a string representation of this vector.

### toString

`public String toString()`
Returns a string representation of this vector.

Overrides:
`toString` in class `Matrix`
Returns:
a string representation of this vector.

### toString

`public String toString(NumberFormat nf)`
Returns a string representation of this vector.

Overrides:
`toString` in class `Matrix`
Parameters:
`nf` - a NumberFormat to specify the output precision
Returns:
a string representation of this vector.

### checkDimensions

`private void checkDimensions(Vector v)`
Check if this.getDimensionality() == v.getDimensionality().

Throws:
`IllegalArgumentException` - if the dimensions do not agree

 Release 0.2 (2009-07-06_1820)