## org.apache.commons.math.linear
Interface RealVector

All Known Subinterfaces:
  SparseRealVector

All Known Implementing Classes:
  AbstractRealVector, ArrayRealVector, OpenMapRealVector

    public interface RealVector

Interface defining a real-valued vector with basic algebraic operations.

vector element indexing is 0-based -- e.g., `getEntry(0)` returns the first element of the vector.

The various `mapXxx` and `mapXxxToSelf` methods operate on vectors element-wise, i.e. they perform the same operation (adding a scalar, applying a function ...) on each element in turn. The `mapXxx` versions create a new vector to hold the result and do not change the instance. The `mapXxxToSelf` versions use the instance itself to store the results, so the instance is changed by these methods. In both cases, the result vector is returned by the methods, this allows to use the fluent API style, like this:

       RealVector result = v.mapAddToSelf(3.0).mapTanToSelf().mapSquareToSelf();

Since:
  2.0
Version:
  $Revision: 902214 $ $Date: 2010-01-22 13:40:28 -0500 (Fri, 22 Jan 2010) $

Nested Class Summary
`static class` `RealVector.Entry` Class representing a modifiable entry in the vector.

Method Summary
`RealVector` `add(double[] v)` Compute the sum of this and v.
`RealVector` `add(RealVector v)` Compute the sum of this and v.
`RealVector` `append(double d)` Construct a vector by appending a double to this vector.
`RealVector` `append(double[] a)` Construct a vector by appending a double array to this vector.
`RealVector` `append(RealVector v)` Construct a vector by appending a vector to this vector.
`RealVector` `copy()` Returns a (deep) copy of this.
`double` `dotProduct(double[] v)` Compute the dot product.
`double` `dotProduct(RealVector v)` Compute the dot product.
`RealVector` `ebeDivide(double[] v)` Element-by-element division.
`RealVector` `ebeDivide(RealVector v)` Element-by-element division.
`RealVector` `ebeMultiply(double[] v)` Element-by-element multiplication.
`RealVector` `ebeMultiply(RealVector v)` Element-by-element multiplication.
`double[]` `getData()` Returns vector entries as a double array.
`int` `getDimension()` Returns the size of the vector.
`double` `getDistance(double[] v)` Distance between two vectors.
`double` `getDistance(RealVector v)` Distance between two vectors.
`double` `getEntry(int index)` Returns the entry in the specified index.
`double` `getL1Distance(double[] v)` Distance between two vectors.
`double` `getL1Distance(RealVector v)` Distance between two vectors.
`double` `getL1Norm()` Returns the L1 norm of the vector.
`double` `getLInfDistance(double[] v)` Distance between two vectors.
`double` `getLInfDistance(RealVector v)` Distance between two vectors.
`double` `getLInfNorm()` Returns the L∞ norm of the vector.
`double` `getNorm()` Returns the L2 norm of the vector.
`RealVector` `getSubVector(int index, int n)` Get a subvector from consecutive elements.
`boolean` `isInfinite()` Returns true if any coordinate of this vector is infinite and none are NaN; false otherwise
`boolean` `isNaN()` Returns true if any coordinate of this vector is NaN; false otherwise
`java.util.Iterator<RealVector.Entry>` `iterator()` Generic dense iterator - starts with index == zero, and hasNext() == true until index == getDimension();
`RealVector` `map(UnivariateRealFunction function)` Acts as if implemented as: return copy().map(function);
`RealVector` `mapAbs()` Map the `Math.abs(double)` function to each entry.
`RealVector` `mapAbsToSelf()` Map the `Math.abs(double)` function to each entry.
`RealVector` `mapAcos()` Map the `Math.acos(double)` function to each entry.
`RealVector` `mapAcosToSelf()` Map the `Math.acos(double)` function to each entry.
`RealVector` `mapAdd(double d)` Map an addition operation to each entry.
`RealVector` `mapAddToSelf(double d)` Map an addition operation to each entry.
`RealVector` `mapAsin()` Map the `Math.asin(double)` function to each entry.
`RealVector` `mapAsinToSelf()` Map the `Math.asin(double)` function to each entry.
`RealVector` `mapAtan()` Map the `Math.atan(double)` function to each entry.
`RealVector` `mapAtanToSelf()` Map the `Math.atan(double)` function to each entry.
`RealVector` `mapCbrt()` Map the `Math.cbrt(double)` function to each entry.
`RealVector` `mapCbrtToSelf()` Map the `Math.cbrt(double)` function to each entry.
`RealVector` `mapCeil()` Map the `Math.ceil(double)` function to each entry.
`RealVector` `mapCeilToSelf()` Map the `Math.ceil(double)` function to each entry.
`RealVector` `mapCos()` Map the `Math.cos(double)` function to each entry.
`RealVector` `mapCosh()` Map the `Math.cosh(double)` function to each entry.
`RealVector` `mapCoshToSelf()` Map the `Math.cosh(double)` function to each entry.
`RealVector` `mapCosToSelf()` Map the `Math.cos(double)` function to each entry.
`RealVector` `mapDivide(double d)` Map a division operation to each entry.
`RealVector` `mapDivideToSelf(double d)` Map a division operation to each entry.
`RealVector` `mapExp()` Map the `Math.exp(double)` function to each entry.
`RealVector` `mapExpm1()` Map the `Math.expm1(double)` function to each entry.
`RealVector` `mapExpm1ToSelf()` Map the `Math.expm1(double)` function to each entry.
`RealVector` `mapExpToSelf()` Map the `Math.exp(double)` function to each entry.
`RealVector` `mapFloor()` Map the `Math.floor(double)` function to each entry.
`RealVector` `mapFloorToSelf()` Map the `Math.floor(double)` function to each entry.
`RealVector` `mapInv()` Map the 1/x function to each entry.
`RealVector` `mapInvToSelf()` Map the 1/x function to each entry.
`RealVector` `mapLog()` Map the `Math.log(double)` function to each entry.
`RealVector` `mapLog10()` Map the `Math.log10(double)` function to each entry.
`RealVector` `mapLog10ToSelf()` Map the `Math.log10(double)` function to each entry.
`RealVector` `mapLog1p()` Map the `Math.log1p(double)` function to each entry.
`RealVector` `mapLog1pToSelf()` Map the `Math.log1p(double)` function to each entry.
`RealVector` `mapLogToSelf()` Map the `Math.log(double)` function to each entry.
`RealVector` `mapMultiply(double d)` Map a multiplication operation to each entry.
`RealVector` `mapMultiplyToSelf(double d)` Map a multiplication operation to each entry.
`RealVector` `mapPow(double d)` Map a power operation to each entry.
`RealVector` `mapPowToSelf(double d)` Map a power operation to each entry.
`RealVector` `mapRint()` Map the `Math.rint(double)` function to each entry.
`RealVector` `mapRintToSelf()` Map the `Math.rint(double)` function to each entry.
`RealVector` `mapSignum()` Map the `Math.signum(double)` function to each entry.
`RealVector` `mapSignumToSelf()` Map the `Math.signum(double)` function to each entry.
`RealVector` `mapSin()` Map the `Math.sin(double)` function to each entry.
`RealVector` `mapSinh()` Map the `Math.sinh(double)` function to each entry.
`RealVector` `mapSinhToSelf()` Map the `Math.sinh(double)` function to each entry.
`RealVector` `mapSinToSelf()` Map the `Math.sin(double)` function to each entry.
`RealVector` `mapSqrt()` Map the `Math.sqrt(double)` function to each entry.
`RealVector` `mapSqrtToSelf()` Map the `Math.sqrt(double)` function to each entry.
`RealVector` `mapSubtract(double d)` Map a subtraction operation to each entry.
`RealVector` `mapSubtractToSelf(double d)` Map a subtraction operation to each entry.
`RealVector` `mapTan()` Map the `Math.tan(double)` function to each entry.
`RealVector` `mapTanh()` Map the `Math.tanh(double)` function to each entry.
`RealVector` `mapTanhToSelf()` Map the `Math.tanh(double)` function to each entry.
`RealVector` `mapTanToSelf()` Map the `Math.tan(double)` function to each entry.
`RealVector` `mapToSelf(UnivariateRealFunction function)` Acts as if it is implemented as: Entry e = null; for(Iterator<Entry> it = iterator(); it.hasNext(); e = it.next()) { e.setValue(function.value(e.getValue())); }
`RealVector` `mapUlp()` Map the `Math.ulp(double)` function to each entry.
`RealVector` `mapUlpToSelf()` Map the `Math.ulp(double)` function to each entry.
`RealMatrix` `outerProduct(double[] v)` Compute the outer product.
`RealMatrix` `outerProduct(RealVector v)` Compute the outer product.
`RealVector` `projection(double[] v)` Find the orthogonal projection of this vector onto another vector.
`RealVector` `projection(RealVector v)` Find the orthogonal projection of this vector onto another vector.
`void` `set(double value)` Set all elements to a single value.
`void` `setEntry(int index, double value)` Set a single element.
`void` `setSubVector(int index, double[] v)` Set a set of consecutive elements.
`void` `setSubVector(int index, RealVector v)` Set a set of consecutive elements.
`java.util.Iterator<RealVector.Entry>` `sparseIterator()` Specialized implementations may choose to not iterate over all dimensions, either because those values are unset, or are equal to defaultValue(), or are small enough to be ignored for the purposes of iteration.
`RealVector` `subtract(double[] v)` Compute this minus v.
`RealVector` `subtract(RealVector v)` Compute this minus v.
`double[]` `toArray()` Convert the vector to a double array.
`void` `unitize()` Converts this vector into a unit vector.
`RealVector` `unitVector()` Creates a unit vector pointing in the direction of this vector.

Method Detail

### mapToSelf

    RealVector mapToSelf(UnivariateRealFunction function)
                         throws FunctionEvaluationException

  Acts as if it is implemented as: Entry e = null; for(Iterator<Entry> it = iterator(); it.hasNext(); e = it.next()) { e.setValue(function.value(e.getValue())); }

  Parameters:
    `function` - to apply to each successive entry
  Returns:
    this vector
  Throws:
    `FunctionEvaluationException` - if function throws it on application to any entry

### map

    RealVector map(UnivariateRealFunction function)
                   throws FunctionEvaluationException

  Acts as if implemented as: return copy().map(function);

  Parameters:
    `function` - to apply to each successive entry
  Returns:
    a new vector
  Throws:
    `FunctionEvaluationException` - if function throws it on application to any entry

### iterator

    java.util.Iterator<RealVector.Entry> iterator()

  Generic dense iterator - starts with index == zero, and hasNext() == true until index == getDimension();

  Returns:
    a dense iterator

### sparseIterator

    java.util.Iterator<RealVector.Entry> sparseIterator()

  Specialized implementations may choose to not iterate over all dimensions, either because those values are unset, or are equal to defaultValue(), or are small enough to be ignored for the purposes of iteration. No guarantees are made about order of iteration. In dense implementations, this method will often delegate to `iterator()`

  Returns:
    a sparse iterator

### copy

    RealVector copy()

  Returns a (deep) copy of this.

  Returns:
    vector copy

### add

    RealVector add(RealVector v)
                   throws java.lang.IllegalArgumentException

  Compute the sum of this and v.

  Parameters:
    `v` - vector to be added
  Returns:
    this + v
  Throws:
    `java.lang.IllegalArgumentException` - if v is not the same size as this

### add

    RealVector add(double[] v)
                   throws java.lang.IllegalArgumentException

  Compute the sum of this and v.

  Parameters:
    `v` - vector to be added
  Returns:
    this + v
  Throws:
    `java.lang.IllegalArgumentException` - if v is not the same size as this

### subtract

    RealVector subtract(RealVector v)
                        throws java.lang.IllegalArgumentException

  Compute this minus v.

  Parameters:
    `v` - vector to be subtracted
  Returns:
    this + v
  Throws:
    `java.lang.IllegalArgumentException` - if v is not the same size as this

### subtract

    RealVector subtract(double[] v)
                        throws java.lang.IllegalArgumentException

  Compute this minus v.

  Parameters:
    `v` - vector to be subtracted
  Returns:
    this + v
  Throws:
    `java.lang.IllegalArgumentException` - if v is not the same size as this

### mapAdd

    RealVector mapAdd(double d)

  Map an addition operation to each entry.

  Parameters:
    `d` - value to be added to each entry
  Returns:
    this + d

### mapAddToSelf

    RealVector mapAddToSelf(double d)

  Map an addition operation to each entry.

  The instance is changed by this method.

  Parameters:
    `d` - value to be added to each entry
  Returns:
    for convenience, return this

### mapSubtract

    RealVector mapSubtract(double d)

  Map a subtraction operation to each entry.

  Parameters:
    `d` - value to be subtracted to each entry
  Returns:
    this - d

### mapSubtractToSelf

    RealVector mapSubtractToSelf(double d)

  Map a subtraction operation to each entry.

  The instance is changed by this method.

  Parameters:
    `d` - value to be subtracted to each entry
  Returns:
    for convenience, return this

### mapMultiply

    RealVector mapMultiply(double d)

  Map a multiplication operation to each entry.

  Parameters:
    `d` - value to multiply all entries by
  Returns:
    this * d

### mapMultiplyToSelf

    RealVector mapMultiplyToSelf(double d)

  Map a multiplication operation to each entry.

  The instance is changed by this method.

  Parameters:
    `d` - value to multiply all entries by
  Returns:
    for convenience, return this

### mapDivide

    RealVector mapDivide(double d)

  Map a division operation to each entry.

  Parameters:
    `d` - value to divide all entries by
  Returns:
    this / d

### mapDivideToSelf

    RealVector mapDivideToSelf(double d)

  Map a division operation to each entry.

  The instance is changed by this method.

  Parameters:
    `d` - value to divide all entries by
  Returns:
    for convenience, return this

### mapPow

    RealVector mapPow(double d)

  Map a power operation to each entry.

  Parameters:
    `d` - value to raise all entries to
  Returns:
    this ^ d

### mapPowToSelf

    RealVector mapPowToSelf(double d)

  Map a power operation to each entry.

  The instance is changed by this method.

  Parameters:
    `d` - value to raise all entries to
  Returns:
    for convenience, return this

### mapExp

    RealVector mapExp()

  Map the `Math.exp(double)` function to each entry.

  Returns:
    a vector containing the result of applying the function to each entry

### mapExpToSelf

    RealVector mapExpToSelf()

  Map the `Math.exp(double)` function to each entry.

  The instance is changed by this method.

  Returns:
    for convenience, return this

### mapExpm1

    RealVector mapExpm1()

  Map the `Math.expm1(double)` function to each entry.

  Returns:
    a vector containing the result of applying the function to each entry

### mapExpm1ToSelf

    RealVector mapExpm1ToSelf()

  Map the `Math.expm1(double)` function to each entry.

  The instance is changed by this method.

  Returns:
    for convenience, return this

### mapLog

    RealVector mapLog()

  Map the `Math.log(double)` function to each entry.

  Returns:
    a vector containing the result of applying the function to each entry

### mapLogToSelf

    RealVector mapLogToSelf()

  Map the `Math.log(double)` function to each entry.

  The instance is changed by this method.

  Returns:
    for convenience, return this

### mapLog10

    RealVector mapLog10()

  Map the `Math.log10(double)` function to each entry.

  Returns:
    a vector containing the result of applying the function to each entry

### mapLog10ToSelf

    RealVector mapLog10ToSelf()

  Map the `Math.log10(double)` function to each entry.

  The instance is changed by this method.

  Returns:
    for convenience, return this

### mapLog1p

    RealVector mapLog1p()

  Map the `Math.log1p(double)` function to each entry.

  Returns:
    a vector containing the result of applying the function to each entry

### mapLog1pToSelf

    RealVector mapLog1pToSelf()

  Map the `Math.log1p(double)` function to each entry.

  The instance is changed by this method.

  Returns:
    for convenience, return this

### mapCosh

    RealVector mapCosh()

  Map the `Math.cosh(double)` function to each entry.

  Returns:
    a vector containing the result of applying the function to each entry

### mapCoshToSelf

    RealVector mapCoshToSelf()

  Map the `Math.cosh(double)` function to each entry.

  The instance is changed by this method.

  Returns:
    for convenience, return this

### mapSinh

    RealVector mapSinh()

  Map the `Math.sinh(double)` function to each entry.

  Returns:
    a vector containing the result of applying the function to each entry

### mapSinhToSelf

    RealVector mapSinhToSelf()

  Map the `Math.sinh(double)` function to each entry.

  The instance is changed by this method.

  Returns:
    for convenience, return this

### mapTanh

    RealVector mapTanh()

  Map the `Math.tanh(double)` function to each entry.

  Returns:
    a vector containing the result of applying the function to each entry

### mapTanhToSelf

    RealVector mapTanhToSelf()

  Map the `Math.tanh(double)` function to each entry.

  The instance is changed by this method.

  Returns:
    for convenience, return this

### mapCos

    RealVector mapCos()

  Map the `Math.cos(double)` function to each entry.

  Returns:
    a vector containing the result of applying the function to each entry

### mapCosToSelf

    RealVector mapCosToSelf()

  Map the `Math.cos(double)` function to each entry.

  The instance is changed by this method.

  Returns:
    for convenience, return this

### mapSin

    RealVector mapSin()

  Map the `Math.sin(double)` function to each entry.

  Returns:
    a vector containing the result of applying the function to each entry

### mapSinToSelf

    RealVector mapSinToSelf()

  Map the `Math.sin(double)` function to each entry.

  The instance is changed by this method.

  Returns:
    for convenience, return this

### mapTan

    RealVector mapTan()

  Map the `Math.tan(double)` function to each entry.

  Returns:
    a vector containing the result of applying the function to each entry

### mapTanToSelf

    RealVector mapTanToSelf()

  Map the `Math.tan(double)` function to each entry.

  The instance is changed by this method.

  Returns:
    for convenience, return this

### mapAcos

    RealVector mapAcos()

  Map the `Math.acos(double)` function to each entry.

  Returns:
    a vector containing the result of applying the function to each entry

### mapAcosToSelf

    RealVector mapAcosToSelf()

  Map the `Math.acos(double)` function to each entry.

  The instance is changed by this method.

  Returns:
    for convenience, return this

### mapAsin

    RealVector mapAsin()

  Map the `Math.asin(double)` function to each entry.

  Returns:
    a vector containing the result of applying the function to each entry

### mapAsinToSelf

    RealVector mapAsinToSelf()

  Map the `Math.asin(double)` function to each entry.

  The instance is changed by this method.

  Returns:
    for convenience, return this

### mapAtan

    RealVector mapAtan()

  Map the `Math.atan(double)` function to each entry.

  Returns:
    a vector containing the result of applying the function to each entry

### mapAtanToSelf

    RealVector mapAtanToSelf()

  Map the `Math.atan(double)` function to each entry.

  The instance is changed by this method.

  Returns:
    for convenience, return this

### mapInv

    RealVector mapInv()

  Map the 1/x function to each entry.

  Returns:
    a vector containing the result of applying the function to each entry

### mapInvToSelf

    RealVector mapInvToSelf()

  Map the 1/x function to each entry.

  The instance is changed by this method.

  Returns:
    for convenience, return this

### mapAbs

    RealVector mapAbs()

  Map the `Math.abs(double)` function to each entry.

  Returns:
    a vector containing the result of applying the function to each entry

### mapAbsToSelf

    RealVector mapAbsToSelf()

  Map the `Math.abs(double)` function to each entry.

  The instance is changed by this method.

  Returns:
    for convenience, return this

### mapSqrt

    RealVector mapSqrt()

  Map the `Math.sqrt(double)` function to each entry.

  Returns:
    a vector containing the result of applying the function to each entry

### mapSqrtToSelf

    RealVector mapSqrtToSelf()

  Map the `Math.sqrt(double)` function to each entry.

  The instance is changed by this method.

  Returns:
    for convenience, return this

### mapCbrt

    RealVector mapCbrt()

  Map the `Math.cbrt(double)` function to each entry.

  Returns:
    a vector containing the result of applying the function to each entry

### mapCbrtToSelf

    RealVector mapCbrtToSelf()

  Map the `Math.cbrt(double)` function to each entry.

  The instance is changed by this method.

  Returns:
    for convenience, return this

### mapCeil

    RealVector mapCeil()

  Map the `Math.ceil(double)` function to each entry.

  Returns:
    a vector containing the result of applying the function to each entry

### mapCeilToSelf

    RealVector mapCeilToSelf()

  Map the `Math.ceil(double)` function to each entry.

  The instance is changed by this method.

  Returns:
    for convenience, return this

### mapFloor

    RealVector mapFloor()

  Map the `Math.floor(double)` function to each entry.

  Returns:
    a vector containing the result of applying the function to each entry

### mapFloorToSelf

    RealVector mapFloorToSelf()

  Map the `Math.floor(double)` function to each entry.

  The instance is changed by this method.

  Returns:
    for convenience, return this

### mapRint

    RealVector mapRint()

  Map the `Math.rint(double)` function to each entry.

  Returns:
    a vector containing the result of applying the function to each entry

### mapRintToSelf

    RealVector mapRintToSelf()

  Map the `Math.rint(double)` function to each entry.

  The instance is changed by this method.

  Returns:
    for convenience, return this

### mapSignum

    RealVector mapSignum()

  Map the `Math.signum(double)` function to each entry.

  Returns:
    a vector containing the result of applying the function to each entry

### mapSignumToSelf

    RealVector mapSignumToSelf()

  Map the `Math.signum(double)` function to each entry.

  The instance is changed by this method.

  Returns:
    for convenience, return this

### mapUlp

    RealVector mapUlp()

  Map the `Math.ulp(double)` function to each entry.

  Returns:
    a vector containing the result of applying the function to each entry

### mapUlpToSelf

    RealVector mapUlpToSelf()

  Map the `Math.ulp(double)` function to each entry.

  The instance is changed by this method.

  Returns:
    for convenience, return this

### ebeMultiply

    RealVector ebeMultiply(RealVector v)
                           throws java.lang.IllegalArgumentException

  Element-by-element multiplication.

  Parameters:
    `v` - vector by which instance elements must be multiplied
  Returns:
    a vector containing this[i] * v[i] for all i
  Throws:
    `java.lang.IllegalArgumentException` - if v is not the same size as this

### ebeMultiply

    RealVector ebeMultiply(double[] v)
                           throws java.lang.IllegalArgumentException

  Element-by-element multiplication.

  Parameters:
    `v` - vector by which instance elements must be multiplied
  Returns:
    a vector containing this[i] * v[i] for all i
  Throws:
    `java.lang.IllegalArgumentException` - if v is not the same size as this

### ebeDivide

    RealVector ebeDivide(RealVector v)
                         throws java.lang.IllegalArgumentException

  Element-by-element division.

  Parameters:
    `v` - vector by which instance elements must be divided
  Returns:
    a vector containing this[i] / v[i] for all i
  Throws:
    `java.lang.IllegalArgumentException` - if v is not the same size as this

### ebeDivide

    RealVector ebeDivide(double[] v)
                         throws java.lang.IllegalArgumentException

  Element-by-element division.

  Parameters:
    `v` - vector by which instance elements must be divided
  Returns:
    a vector containing this[i] / v[i] for all i
  Throws:
    `java.lang.IllegalArgumentException` - if v is not the same size as this

### getData

    double[] getData()

  Returns vector entries as a double array.

  Returns:
    double array of entries

### dotProduct

    double dotProduct(RealVector v)
                      throws java.lang.IllegalArgumentException

  Compute the dot product.

  Parameters:
    `v` - vector with which dot product should be computed
  Returns:
    the scalar dot product between instance and v
  Throws:
    `java.lang.IllegalArgumentException` - if v is not the same size as this

### dotProduct

    double dotProduct(double[] v)
                      throws java.lang.IllegalArgumentException

  Compute the dot product.

  Parameters:
    `v` - vector with which dot product should be computed
  Returns:
    the scalar dot product between instance and v
  Throws:
    `java.lang.IllegalArgumentException` - if v is not the same size as this

### getNorm

    double getNorm()

  Returns the L2 norm of the vector.

  The L2 norm is the root of the sum of the squared elements.

  Returns:
    norm
  See Also:
    `getL1Norm()`, `getLInfNorm()`, `getDistance(RealVector)`

### getL1Norm

    double getL1Norm()

  Returns the L1 norm of the vector.

  The L1 norm is the sum of the absolute values of elements.

  Returns:
    norm
  See Also:
    `getNorm()`, `getLInfNorm()`, `getL1Distance(RealVector)`

### getLInfNorm

    double getLInfNorm()

  Returns the L∞ norm of the vector.

  The L∞ norm is the max of the absolute values of elements.

  Returns:
    norm
  See Also:
    `getNorm()`, `getL1Norm()`, `getLInfDistance(RealVector)`

### getDistance

    double getDistance(RealVector v)
                       throws java.lang.IllegalArgumentException

  Distance between two vectors.

  This method computes the distance consistent with the L2 norm, i.e. the square root of the sum of elements differences, or euclidian distance.

  Parameters:
    `v` - vector to which distance is requested
  Returns:
    distance between two vectors.
  Throws:
    `java.lang.IllegalArgumentException` - if v is not the same size as this
  See Also:
    `getL1Distance(RealVector)`, `getLInfDistance(RealVector)`, `getNorm()`

### getDistance

    double getDistance(double[] v)
                       throws java.lang.IllegalArgumentException

  Distance between two vectors.

  This method computes the distance consistent with the L2 norm, i.e. the square root of the sum of elements differences, or euclidian distance.

  Parameters:
    `v` - vector to which distance is requested
  Returns:
    distance between two vectors.
  Throws:
    `java.lang.IllegalArgumentException` - if v is not the same size as this
  See Also:
    `getL1Distance(double[])`, `getLInfDistance(double[])`, `getNorm()`

### getL1Distance

    double getL1Distance(RealVector v)
                         throws java.lang.IllegalArgumentException

  Distance between two vectors.

  This method computes the distance consistent with L1 norm, i.e. the sum of the absolute values of elements differences.

  Parameters:
    `v` - vector to which distance is requested
  Returns:
    distance between two vectors.
  Throws:
    `java.lang.IllegalArgumentException` - if v is not the same size as this
  See Also:
    `getDistance(RealVector)`, `getLInfDistance(RealVector)`, `getL1Norm()`

### getL1Distance

    double getL1Distance(double[] v)
                         throws java.lang.IllegalArgumentException

  Distance between two vectors.

  This method computes the distance consistent with L1 norm, i.e. the sum of the absolute values of elements differences.

  Parameters:
    `v` - vector to which distance is requested
  Returns:
    distance between two vectors.
  Throws:
    `java.lang.IllegalArgumentException` - if v is not the same size as this
  See Also:
    `getDistance(double[])`, `getLInfDistance(double[])`, `getL1Norm()`

### getLInfDistance

    double getLInfDistance(RealVector v)
                           throws java.lang.IllegalArgumentException

  Distance between two vectors.

  This method computes the distance consistent with L∞ norm, i.e. the max of the absolute values of elements differences.

  Parameters:
    `v` - vector to which distance is requested
  Returns:
    distance between two vectors.
  Throws:
    `java.lang.IllegalArgumentException` - if v is not the same size as this
  See Also:
    `getDistance(RealVector)`, `getL1Distance(RealVector)`, `getLInfNorm()`

### getLInfDistance

    double getLInfDistance(double[] v)
                           throws java.lang.IllegalArgumentException

  Distance between two vectors.

  This method computes the distance consistent with L∞ norm, i.e. the max of the absolute values of elements differences.

  Parameters:
    `v` - vector to which distance is requested
  Returns:
    distance between two vectors.
  Throws:
    `java.lang.IllegalArgumentException` - if v is not the same size as this
  See Also:
    `getDistance(double[])`, `getL1Distance(double[])`, `getLInfNorm()`

### unitVector

    RealVector unitVector()

  Creates a unit vector pointing in the direction of this vector.

  The instance is not changed by this method.

  Returns:
    a unit vector pointing in direction of this vector
  Throws:
    `java.lang.ArithmeticException` - if the norm is null

### unitize

    void unitize()

  Converts this vector into a unit vector.

  The instance itself is changed by this method.

  Throws:
    `java.lang.ArithmeticException` - if the norm is null

### projection

    RealVector projection(RealVector v)
                          throws java.lang.IllegalArgumentException

  Find the orthogonal projection of this vector onto another vector.

  Parameters:
    `v` - vector onto which instance must be projected
  Returns:
    projection of the instance onto v
  Throws:
    `java.lang.IllegalArgumentException` - if v is not the same size as this

### projection

    RealVector projection(double[] v)
                          throws java.lang.IllegalArgumentException

  Find the orthogonal projection of this vector onto another vector.

  Parameters:
    `v` - vector onto which instance must be projected
  Returns:
    projection of the instance onto v
  Throws:
    `java.lang.IllegalArgumentException` - if v is not the same size as this

### outerProduct

    RealMatrix outerProduct(RealVector v)
                            throws java.lang.IllegalArgumentException

  Compute the outer product.

  Parameters:
    `v` - vector with which outer product should be computed
  Returns:
    the square matrix outer product between instance and v
  Throws:
    `java.lang.IllegalArgumentException` - if v is not the same size as this

### outerProduct

    RealMatrix outerProduct(double[] v)
                            throws java.lang.IllegalArgumentException

  Compute the outer product.

  Parameters:
    `v` - vector with which outer product should be computed
  Returns:
    the square matrix outer product between instance and v
  Throws:
    `java.lang.IllegalArgumentException` - if v is not the same size as this

### getEntry

    double getEntry(int index)
                    throws MatrixIndexException

  Returns the entry in the specified index.

  The index start at 0 and must be lesser than the size, otherwise a `MatrixIndexException` is thrown.

  Parameters:
    `index` - index location of entry to be fetched
  Returns:
    vector entry at index
  Throws:
    `MatrixIndexException` - if the index is not valid
  See Also:
    `setEntry(int, double)`

### setEntry

    void setEntry(int index,
                  double value)
                  throws MatrixIndexException

  Set a single element.

  Parameters:
    `index` - element index.
    `value` - new value for the element.
  Throws:
    `MatrixIndexException` - if the index is inconsistent with vector size
  See Also:
    `getEntry(int)`

### getDimension

    int getDimension()

  Returns the size of the vector.

  Returns:
    size

### append

    RealVector append(RealVector v)

  Construct a vector by appending a vector to this vector.

  Parameters:
    `v` - vector to append to this one.
  Returns:
    a new vector

### append

    RealVector append(double d)

  Construct a vector by appending a double to this vector.

  Parameters:
    `d` - double to append.
  Returns:
    a new vector

### append

    RealVector append(double[] a)

  Construct a vector by appending a double array to this vector.

  Parameters:
    `a` - double array to append.
  Returns:
    a new vector

### getSubVector

    RealVector getSubVector(int index,
                            int n)
                            throws MatrixIndexException

  Get a subvector from consecutive elements.

  Parameters:
    `index` - index of first element.
    `n` - number of elements to be retrieved.
  Returns:
    a vector containing n elements.
  Throws:
    `MatrixIndexException` - if the index is inconsistent with vector size

### setSubVector

    void setSubVector(int index,
                      RealVector v)
                      throws MatrixIndexException

  Set a set of consecutive elements.

  Parameters:
    `index` - index of first element to be set.
    `v` - vector containing the values to set.
  Throws:
    `MatrixIndexException` - if the index is inconsistent with vector size
  See Also:
    `setSubVector(int, double[])`

### setSubVector

    void setSubVector(int index,
                      double[] v)
                      throws MatrixIndexException

  Set a set of consecutive elements.

  Parameters:
    `index` - index of first element to be set.
    `v` - vector containing the values to set.
  Throws:
    `MatrixIndexException` - if the index is inconsistent with vector size
  See Also:
    `setSubVector(int, RealVector)`

### set

    void set(double value)

  Set all elements to a single value.

  Parameters:
    `value` - single value to set for all elements

### toArray

    double[] toArray()

  Convert the vector to a double array.

  The array is independent from vector data, it's elements are copied.

  Returns:
    array containing a copy of vector elements

### isNaN

    boolean isNaN()

  Returns true if any coordinate of this vector is NaN; false otherwise

  Returns:
    true if any coordinate of this vector is NaN; false otherwise

### isInfinite

    boolean isInfinite()

  Returns true if any coordinate of this vector is infinite and none are NaN; false otherwise

  Returns:
    true if any coordinate of this vector is infinite and none are NaN; false otherwise

Copyright (c) 2003-2010 Apache Software Foundation