org.apache.commons.math.linear

## Class ArrayRealVector

- java.lang.Object
- - org.apache.commons.math.linear.AbstractRealVector
  - - org.apache.commons.math.linear.ArrayRealVector

All Implemented Interfaces:
  java.io.Serializable, RealVector

    public class ArrayRealVector
    extends AbstractRealVector
    implements java.io.Serializable

This class implements the `RealVector` interface with a double array.

Since:
  2.0
Version:
  $Revision: 1003993 $ $Date: 2010-10-03 18:39:16 +0200 (dim. 03 oct. 2010) $
See Also:
  Serialized Form

### Nested Class Summary

### Nested classes/interfaces inherited from class org.apache.commons.math.linear.AbstractRealVector

`AbstractRealVector.EntryImpl, AbstractRealVector.SparseEntryIterator`

### Nested classes/interfaces inherited from interface org.apache.commons.math.linear.RealVector

`RealVector.Entry`

### Field Summary

Fields
`protected double[]` `data` Entries of the vector.
`private static RealVectorFormat` `DEFAULT_FORMAT` Default format.
`private static long` `serialVersionUID` Serializable version identifier.

### Constructor Summary

Constructors
Constructor and Description
`ArrayRealVector()` Build a 0-length vector.
`ArrayRealVector(ArrayRealVector v)` Construct a vector from another vector, using a deep copy.
`ArrayRealVector(ArrayRealVector v1, ArrayRealVector v2)` Construct a vector by appending one vector to another vector.
`ArrayRealVector(ArrayRealVector v, boolean deep)` Construct a vector from another vector.
`ArrayRealVector(ArrayRealVector v1, double[] v2)` Construct a vector by appending one vector to another vector.
`ArrayRealVector(ArrayRealVector v1, RealVector v2)` Construct a vector by appending one vector to another vector.
`ArrayRealVector(double[] d)` Construct a vector from an array, copying the input array.
`ArrayRealVector(java.lang.Double[] d)` Construct a vector from an array.
`ArrayRealVector(double[] v1, ArrayRealVector v2)` Construct a vector by appending one vector to another vector.
`ArrayRealVector(double[] d, boolean copyArray)` Create a new ArrayRealVector using the input array as the underlying data array.
`ArrayRealVector(double[] v1, double[] v2)` Construct a vector by appending one vector to another vector.
`ArrayRealVector(double[] d, int pos, int size)` Construct a vector from part of a array.
`ArrayRealVector(java.lang.Double[] d, int pos, int size)` Construct a vector from part of a Double array
`ArrayRealVector(int size)` Construct a (size)-length vector of zeros.
`ArrayRealVector(int size, double preset)` Construct an (size)-length vector with preset values.
`ArrayRealVector(RealVector v)` Construct a vector from another vector, using a deep copy.
`ArrayRealVector(RealVector v1, ArrayRealVector v2)` Construct a vector by appending one vector to another vector.

### Method Summary

Methods
`ArrayRealVector` `add(ArrayRealVector v)` Compute the sum of this and v.
`RealVector` `add(double[] v)` Compute the sum of this vector and `v`.
`RealVector` `add(RealVector v)` Compute the sum of this vector and `v`.
`ArrayRealVector` `append(ArrayRealVector v)` Construct a vector by appending a vector to this vector.
`RealVector` `append(double in)` Construct a vector by appending a double to this vector.
`RealVector` `append(double[] in)` 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.
`protected void` `checkVectorDimensions(int n)` Check if instance dimension is equal to some expected value.
`protected void` `checkVectorDimensions(RealVector v)` Check if instance and specified vectors have the same dimension.
`AbstractRealVector` `copy()` Returns a (deep) copy of this vector.
`double` `dotProduct(ArrayRealVector v)` Compute the dot product.
`double` `dotProduct(double[] v)` Compute the dot product.
`double` `dotProduct(RealVector v)` Compute the dot product.
`ArrayRealVector` `ebeDivide(ArrayRealVector v)` Element-by-element division.
`RealVector` `ebeDivide(double[] v)` Element-by-element division.
`RealVector` `ebeDivide(RealVector v)` Element-by-element division.
`ArrayRealVector` `ebeMultiply(ArrayRealVector v)` Element-by-element multiplication.
`RealVector` `ebeMultiply(double[] v)` Element-by-element multiplication.
`RealVector` `ebeMultiply(RealVector v)` Element-by-element multiplication.
`boolean` `equals(java.lang.Object other)` Test for the equality of two real vectors.
`double[]` `getData()` Returns vector entries as a double array.
`double[]` `getDataRef()` Returns a reference to the underlying data array.
`int` `getDimension()` Returns the size of the vector.
`double` `getDistance(ArrayRealVector v)` Distance between two vectors.
`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(ArrayRealVector v)` Distance between two vectors.
`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(ArrayRealVector v)` Distance between two vectors.
`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.
`int` `hashCode()` Get a hashCode for the real vector.
`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
`RealVector` `mapAbsToSelf()` Map the `Math.abs(double)` function to each entry.
`RealVector` `mapAcosToSelf()` Map the `Math.acos(double)` function to each entry.
`RealVector` `mapAddToSelf(double d)` Add a value to each entry.
`RealVector` `mapAsinToSelf()` Map the `Math.asin(double)` function to each entry.
`RealVector` `mapAtanToSelf()` Map the `Math.atan(double)` function to each entry.
`RealVector` `mapCbrtToSelf()` Map the `Math.cbrt(double)` function to each entry.
`RealVector` `mapCeilToSelf()` Map the `Math.ceil(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` `mapDivideToSelf(double d)` Divide each entry.
`RealVector` `mapExpm1ToSelf()` Map the `Math.expm1(double)` function to each entry.
`RealVector` `mapExpToSelf()` Map `Math.exp(double)` operation to each entry.
`RealVector` `mapFloorToSelf()` Map the `Math.floor(double)` function to each entry.
`RealVector` `mapInvToSelf()` Map the 1/x function to each entry.
`RealVector` `mapLog10ToSelf()` Map the `Math.log10(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` `mapMultiplyToSelf(double d)` Multiply each entry.
`RealVector` `mapPowToSelf(double d)` Map a power operation to each entry.
`RealVector` `mapRintToSelf()` Map the `Math.rint(double)` function to each entry.
`RealVector` `mapSignumToSelf()` Map the `Math.signum(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` `mapSqrtToSelf()` Map the `Math.sqrt(double)` function to each entry.
`RealVector` `mapSubtractToSelf(double d)` Subtract a value from 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` `mapUlpToSelf()` Map the `Math.ulp(double)` function to each entry.
`RealMatrix` `outerProduct(ArrayRealVector v)` Compute the outer product.
`RealMatrix` `outerProduct(double[] v)` Compute the outer product.
`RealMatrix` `outerProduct(RealVector v)` Compute the outer product.
`ArrayRealVector` `projection(ArrayRealVector v)` Find the orthogonal projection of this vector onto another vector.
`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` `set(int index, ArrayRealVector v)` Set a set of consecutive elements.
`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.
`ArrayRealVector` `subtract(ArrayRealVector v)` Compute this minus v.
`RealVector` `subtract(double[] v)` Subtract `v` from this vector.
`RealVector` `subtract(RealVector v)` Subtract `v` from this vector.
`double[]` `toArray()` Convert the vector to a double array.
`java.lang.String` `toString()`
`void` `unitize()` Converts this vector into a unit vector.
`RealVector` `unitVector()` Creates a unit vector pointing in the direction of this vector.

### Methods inherited from class org.apache.commons.math.linear.AbstractRealVector

`checkIndex, getMaxIndex, getMaxValue, getMinIndex, getMinValue, iterator, map, mapAbs, mapAcos, mapAdd, mapAsin, mapAtan, mapCbrt, mapCeil, mapCos, mapCosh, mapDivide, mapExp, mapExpm1, mapFloor, mapInv, mapLog, mapLog10, mapLog1p, mapMultiply, mapPow, mapRint, mapSignum, mapSin, mapSinh, mapSqrt, mapSubtract, mapTan, mapTanh, mapToSelf, mapUlp, sparseIterator`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Field Detail

#### serialVersionUID

    private static final long serialVersionUID

Serializable version identifier.

See Also:
  Constant Field Values

#### DEFAULT_FORMAT

    private static final RealVectorFormat DEFAULT_FORMAT

Default format.

#### data

    protected double[] data

Entries of the vector.

### Constructor Detail

#### ArrayRealVector

    public ArrayRealVector()

Build a 0-length vector.

Zero-length vectors may be used to initialized construction of vectors by data gathering. We start with zero-length and use either the `ArrayRealVector(ArrayRealVector, ArrayRealVector)` constructor or one of the `append` method (`append(double)`, `append(double[])`, `append(ArrayRealVector)`) to gather data into this vector.

#### ArrayRealVector

    public ArrayRealVector(int size)

Construct a (size)-length vector of zeros.

Parameters:
  `size` - size of the vector

#### ArrayRealVector

    public ArrayRealVector(int size,
                   double preset)

Construct an (size)-length vector with preset values.

Parameters:
  `size` - size of the vector
  `preset` - fill the vector with this scalar value

#### ArrayRealVector

    public ArrayRealVector(double[] d)

Construct a vector from an array, copying the input array.

Parameters:
  `d` - array of doubles.

#### ArrayRealVector

    public ArrayRealVector(double[] d,
                   boolean copyArray)

Create a new ArrayRealVector using the input array as the underlying data array.

If an array is built specially in order to be embedded in a ArrayRealVector and not used directly, the `copyArray` may be set to `false</code. This will prevent the copying and improve performance as no new array will be built and no data will be copied.</p>`

Parameters:
  `d` - data for new vector
  `copyArray` - if true, the input array will be copied, otherwise it will be referenced
See Also:
  `ArrayRealVector(double[])`

#### ArrayRealVector

    public ArrayRealVector(double[] d,
                   int pos,
                   int size)

Construct a vector from part of a array.

Parameters:
  `d` - array of doubles.
  `pos` - position of first entry
  `size` - number of entries to copy

#### ArrayRealVector

    public ArrayRealVector(java.lang.Double[] d)

Construct a vector from an array.

Parameters:
  `d` - array of Doubles.

#### ArrayRealVector

    public ArrayRealVector(java.lang.Double[] d,
                   int pos,
                   int size)

Construct a vector from part of a Double array

Parameters:
  `d` - array of Doubles.
  `pos` - position of first entry
  `size` - number of entries to copy

#### ArrayRealVector

    public ArrayRealVector(RealVector v)

Construct a vector from another vector, using a deep copy.

Parameters:
  `v` - vector to copy

#### ArrayRealVector

    public ArrayRealVector(ArrayRealVector v)

Construct a vector from another vector, using a deep copy.

Parameters:
  `v` - vector to copy

#### ArrayRealVector

    public ArrayRealVector(ArrayRealVector v,
                   boolean deep)

Construct a vector from another vector.

Parameters:
  `v` - vector to copy
  `deep` - if true perform a deep copy otherwise perform a shallow copy

#### ArrayRealVector

    public ArrayRealVector(ArrayRealVector v1,
                   ArrayRealVector v2)

Construct a vector by appending one vector to another vector.

Parameters:
  `v1` - first vector (will be put in front of the new vector)
  `v2` - second vector (will be put at back of the new vector)

#### ArrayRealVector

    public ArrayRealVector(ArrayRealVector v1,
                   RealVector v2)

Construct a vector by appending one vector to another vector.

Parameters:
  `v1` - first vector (will be put in front of the new vector)
  `v2` - second vector (will be put at back of the new vector)

#### ArrayRealVector

    public ArrayRealVector(RealVector v1,
                   ArrayRealVector v2)

Construct a vector by appending one vector to another vector.

Parameters:
  `v1` - first vector (will be put in front of the new vector)
  `v2` - second vector (will be put at back of the new vector)

#### ArrayRealVector

    public ArrayRealVector(ArrayRealVector v1,
                   double[] v2)

Construct a vector by appending one vector to another vector.

Parameters:
  `v1` - first vector (will be put in front of the new vector)
  `v2` - second vector (will be put at back of the new vector)

#### ArrayRealVector

    public ArrayRealVector(double[] v1,
                   ArrayRealVector v2)

Construct a vector by appending one vector to another vector.

Parameters:
  `v1` - first vector (will be put in front of the new vector)
  `v2` - second vector (will be put at back of the new vector)

#### ArrayRealVector

    public ArrayRealVector(double[] v1,
                   double[] v2)

Construct a vector by appending one vector to another vector.

Parameters:
  `v1` - first vector (will be put in front of the new vector)
  `v2` - second vector (will be put at back of the new vector)

### Method Detail

#### copy

    public AbstractRealVector copy()

Returns a (deep) copy of this vector.

Specified by:
  `copy` in interface `RealVector`
Specified by:
  `copy` in class `AbstractRealVector`
Returns:
  a vector copy.

#### add

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

Compute the sum of this vector and `v`.

Specified by:
  `add` in interface `RealVector`
Overrides:
  `add` in class `AbstractRealVector`
Parameters:
  `v` - Vector to be added.
Returns:
  `this` + `v`.
Throws:
  `DimensionMismatchException` - if `v` is not the same size as this vector.
  `java.lang.IllegalArgumentException`

#### add

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

Compute the sum of this vector and `v`.

Specified by:
  `add` in interface `RealVector`
Overrides:
  `add` in class `AbstractRealVector`
Parameters:
  `v` - Vector to be added.
Returns:
  `this` + `v`.
Throws:
  `DimensionMismatchException` - if `v` is not the same size as this vector.
  `java.lang.IllegalArgumentException`

#### add

    public ArrayRealVector add(ArrayRealVector 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

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

Subtract `v` from this vector.

Specified by:
  `subtract` in interface `RealVector`
Overrides:
  `subtract` in class `AbstractRealVector`
Parameters:
  `v` - Vector to be subtracted.
Returns:
  `this` - `v`.
Throws:
  `DimensionMismatchException` - if `v` is not the same size as this vector.
  `java.lang.IllegalArgumentException`

#### subtract

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

Subtract `v` from this vector.

Specified by:
  `subtract` in interface `RealVector`
Overrides:
  `subtract` in class `AbstractRealVector`
Parameters:
  `v` - Vector to be subtracted.
Returns:
  `this` - `v`.
Throws:
  `DimensionMismatchException` - if `v` is not the same size as this vector.
  `java.lang.IllegalArgumentException`

#### subtract

    public ArrayRealVector subtract(ArrayRealVector 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

#### mapAddToSelf

    public RealVector mapAddToSelf(double d)

Add a value to each entry. The instance is changed in-place.

Specified by:
  `mapAddToSelf` in interface `RealVector`
Overrides:
  `mapAddToSelf` in class `AbstractRealVector`
Parameters:
  `d` - Value to be added to each entry.
Returns:
  `this`.

#### mapSubtractToSelf

    public RealVector mapSubtractToSelf(double d)

Subtract a value from each entry. The instance is changed in-place.

Specified by:
  `mapSubtractToSelf` in interface `RealVector`
Overrides:
  `mapSubtractToSelf` in class `AbstractRealVector`
Parameters:
  `d` - Value to be subtracted.
Returns:
  `this`.

#### mapMultiplyToSelf

    public RealVector mapMultiplyToSelf(double d)

Multiply each entry. The instance is changed in-place.

Specified by:
  `mapMultiplyToSelf` in interface `RealVector`
Overrides:
  `mapMultiplyToSelf` in class `AbstractRealVector`
Parameters:
  `d` - Multiplication factor.
Returns:
  `this`.

#### mapDivideToSelf

    public RealVector mapDivideToSelf(double d)

Divide each entry. The instance is changed in-place.

Specified by:
  `mapDivideToSelf` in interface `RealVector`
Overrides:
  `mapDivideToSelf` in class `AbstractRealVector`
Parameters:
  `d` - Value to divide by.
Returns:
  `this`.

#### mapPowToSelf

    public RealVector mapPowToSelf(double d)

Map a power operation to each entry. The instance is changed in-place.

Specified by:
  `mapPowToSelf` in interface `RealVector`
Overrides:
  `mapPowToSelf` in class `AbstractRealVector`
Parameters:
  `d` - Operator value.
Returns:
  the mapped vector.

#### mapExpToSelf

    public RealVector mapExpToSelf()

Map `Math.exp(double)` operation to each entry. The instance is changed in-place.

Specified by:
  `mapExpToSelf` in interface `RealVector`
Overrides:
  `mapExpToSelf` in class `AbstractRealVector`
Returns:
  the mapped vector.

#### mapExpm1ToSelf

    public RealVector mapExpm1ToSelf()

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

The instance is changed by this method.

Specified by:
  `mapExpm1ToSelf` in interface `RealVector`
Overrides:
  `mapExpm1ToSelf` in class `AbstractRealVector`
Returns:
  for convenience, return this

#### mapLogToSelf

    public RealVector mapLogToSelf()

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

The instance is changed by this method.

Specified by:
  `mapLogToSelf` in interface `RealVector`
Overrides:
  `mapLogToSelf` in class `AbstractRealVector`
Returns:
  for convenience, return this

#### mapLog10ToSelf

    public RealVector mapLog10ToSelf()

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

The instance is changed by this method.

Specified by:
  `mapLog10ToSelf` in interface `RealVector`
Overrides:
  `mapLog10ToSelf` in class `AbstractRealVector`
Returns:
  for convenience, return this

#### mapLog1pToSelf

    public RealVector mapLog1pToSelf()

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

The instance is changed by this method.

Specified by:
  `mapLog1pToSelf` in interface `RealVector`
Overrides:
  `mapLog1pToSelf` in class `AbstractRealVector`
Returns:
  for convenience, return this

#### mapCoshToSelf

    public RealVector mapCoshToSelf()

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

The instance is changed by this method.

Specified by:
  `mapCoshToSelf` in interface `RealVector`
Overrides:
  `mapCoshToSelf` in class `AbstractRealVector`
Returns:
  for convenience, return this

#### mapSinhToSelf

    public RealVector mapSinhToSelf()

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

The instance is changed by this method.

Specified by:
  `mapSinhToSelf` in interface `RealVector`
Overrides:
  `mapSinhToSelf` in class `AbstractRealVector`
Returns:
  for convenience, return this

#### mapTanhToSelf

    public RealVector mapTanhToSelf()

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

The instance is changed by this method.

Specified by:
  `mapTanhToSelf` in interface `RealVector`
Overrides:
  `mapTanhToSelf` in class `AbstractRealVector`
Returns:
  for convenience, return this

#### mapCosToSelf

    public RealVector mapCosToSelf()

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

The instance is changed by this method.

Specified by:
  `mapCosToSelf` in interface `RealVector`
Overrides:
  `mapCosToSelf` in class `AbstractRealVector`
Returns:
  for convenience, return this

#### mapSinToSelf

    public RealVector mapSinToSelf()

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

The instance is changed by this method.

Specified by:
  `mapSinToSelf` in interface `RealVector`
Overrides:
  `mapSinToSelf` in class `AbstractRealVector`
Returns:
  for convenience, return this

#### mapTanToSelf

    public RealVector mapTanToSelf()

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

The instance is changed by this method.

Specified by:
  `mapTanToSelf` in interface `RealVector`
Overrides:
  `mapTanToSelf` in class `AbstractRealVector`
Returns:
  for convenience, return this

#### mapAcosToSelf

    public RealVector mapAcosToSelf()

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

The instance is changed by this method.

Specified by:
  `mapAcosToSelf` in interface `RealVector`
Overrides:
  `mapAcosToSelf` in class `AbstractRealVector`
Returns:
  for convenience, return this

#### mapAsinToSelf

    public RealVector mapAsinToSelf()

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

The instance is changed by this method.

Specified by:
  `mapAsinToSelf` in interface `RealVector`
Overrides:
  `mapAsinToSelf` in class `AbstractRealVector`
Returns:
  for convenience, return this

#### mapAtanToSelf

    public RealVector mapAtanToSelf()

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

The instance is changed by this method.

Specified by:
  `mapAtanToSelf` in interface `RealVector`
Overrides:
  `mapAtanToSelf` in class `AbstractRealVector`
Returns:
  for convenience, return this

#### mapInvToSelf

    public RealVector mapInvToSelf()

Map the 1/x function to each entry.

The instance is changed by this method.

Specified by:
  `mapInvToSelf` in interface `RealVector`
Overrides:
  `mapInvToSelf` in class `AbstractRealVector`
Returns:
  for convenience, return this

#### mapAbsToSelf

    public RealVector mapAbsToSelf()

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

The instance is changed by this method.

Specified by:
  `mapAbsToSelf` in interface `RealVector`
Overrides:
  `mapAbsToSelf` in class `AbstractRealVector`
Returns:
  for convenience, return this

#### mapSqrtToSelf

    public RealVector mapSqrtToSelf()

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

The instance is changed by this method.

Specified by:
  `mapSqrtToSelf` in interface `RealVector`
Overrides:
  `mapSqrtToSelf` in class `AbstractRealVector`
Returns:
  for convenience, return this

#### mapCbrtToSelf

    public RealVector mapCbrtToSelf()

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

The instance is changed by this method.

Specified by:
  `mapCbrtToSelf` in interface `RealVector`
Overrides:
  `mapCbrtToSelf` in class `AbstractRealVector`
Returns:
  for convenience, return this

#### mapCeilToSelf

    public RealVector mapCeilToSelf()

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

The instance is changed by this method.

Specified by:
  `mapCeilToSelf` in interface `RealVector`
Overrides:
  `mapCeilToSelf` in class `AbstractRealVector`
Returns:
  for convenience, return this

#### mapFloorToSelf

    public RealVector mapFloorToSelf()

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

The instance is changed by this method.

Specified by:
  `mapFloorToSelf` in interface `RealVector`
Overrides:
  `mapFloorToSelf` in class `AbstractRealVector`
Returns:
  for convenience, return this

#### mapRintToSelf

    public RealVector mapRintToSelf()

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

The instance is changed by this method.

Specified by:
  `mapRintToSelf` in interface `RealVector`
Overrides:
  `mapRintToSelf` in class `AbstractRealVector`
Returns:
  for convenience, return this

#### mapSignumToSelf

    public RealVector mapSignumToSelf()

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

The instance is changed by this method.

Specified by:
  `mapSignumToSelf` in interface `RealVector`
Overrides:
  `mapSignumToSelf` in class `AbstractRealVector`
Returns:
  for convenience, return this

#### mapUlpToSelf

    public RealVector mapUlpToSelf()

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

The instance is changed by this method.

Specified by:
  `mapUlpToSelf` in interface `RealVector`
Overrides:
  `mapUlpToSelf` in class `AbstractRealVector`
Returns:
  for convenience, return this

#### ebeMultiply

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

Element-by-element multiplication.

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

#### ebeMultiply

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

Element-by-element multiplication.

Specified by:
  `ebeMultiply` in interface `RealVector`
Overrides:
  `ebeMultiply` in class `AbstractRealVector`
Parameters:
  `v` - vector by which instance elements must be multiplied
Returns:
  a vector containing this[i] * v[i] for all i
Throws:
  `DimensionMismatchException` - if `v` is not the same size as this vector.
  `java.lang.IllegalArgumentException`

#### ebeMultiply

    public ArrayRealVector ebeMultiply(ArrayRealVector 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

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

Element-by-element division.

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

#### ebeDivide

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

Element-by-element division.

Specified by:
  `ebeDivide` in interface `RealVector`
Overrides:
  `ebeDivide` in class `AbstractRealVector`
Parameters:
  `v` - vector by which instance elements must be divided
Returns:
  a vector containing this[i] / v[i] for all i
Throws:
  `DimensionMismatchException` - if `v` is not the same size as this vector.
  `java.lang.IllegalArgumentException`

#### ebeDivide

    public ArrayRealVector ebeDivide(ArrayRealVector 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

    public double[] getData()

Returns vector entries as a double array.

Specified by:
  `getData` in interface `RealVector`
Overrides:
  `getData` in class `AbstractRealVector`
Returns:
  double array of entries

#### getDataRef

    public double[] getDataRef()

Returns a reference to the underlying data array.

Does not make a fresh copy of the underlying data.

Returns:
  array of entries

#### dotProduct

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

Compute the dot product.

Specified by:
  `dotProduct` in interface `RealVector`
Overrides:
  `dotProduct` in class `AbstractRealVector`
Parameters:
  `v` - vector with which dot product should be computed
Returns:
  the scalar dot product between instance and v
Throws:
  `DimensionMismatchException` - if `v` is not the same size as this vector.
  `java.lang.IllegalArgumentException`

#### dotProduct

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

Compute the dot product.

Specified by:
  `dotProduct` in interface `RealVector`
Overrides:
  `dotProduct` in class `AbstractRealVector`
Parameters:
  `v` - vector with which dot product should be computed
Returns:
  the scalar dot product between instance and v
Throws:
  `DimensionMismatchException` - if `v` is not the same size as this vector.
  `java.lang.IllegalArgumentException`

#### dotProduct

    public double dotProduct(ArrayRealVector 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

    public double getNorm()

Returns the L2 norm of the vector.

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

Specified by:
  `getNorm` in interface `RealVector`
Overrides:
  `getNorm` in class `AbstractRealVector`
Returns:
  norm
See Also:
  `RealVector.getL1Norm()`, `RealVector.getLInfNorm()`, `RealVector.getDistance(RealVector)`

#### getL1Norm

    public double getL1Norm()

Returns the L1 norm of the vector.

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

Specified by:
  `getL1Norm` in interface `RealVector`
Overrides:
  `getL1Norm` in class `AbstractRealVector`
Returns:
  norm
See Also:
  `RealVector.getNorm()`, `RealVector.getLInfNorm()`, `RealVector.getL1Distance(RealVector)`

#### getLInfNorm

    public double getLInfNorm()

Returns the L∞ norm of the vector.

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

Specified by:
  `getLInfNorm` in interface `RealVector`
Overrides:
  `getLInfNorm` in class `AbstractRealVector`
Returns:
  norm
See Also:
  `RealVector.getNorm()`, `RealVector.getL1Norm()`, `RealVector.getLInfDistance(RealVector)`

#### getDistance

    public 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.

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

#### getDistance

    public 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.

Specified by:
  `getDistance` in interface `RealVector`
Overrides:
  `getDistance` in class `AbstractRealVector`
Parameters:
  `v` - vector to which distance is requested
Returns:
  distance between two vectors.
Throws:
  `DimensionMismatchException` - if `v` is not the same size as this vector.
  `java.lang.IllegalArgumentException`
See Also:
  `RealVector.getL1Distance(double[])`, `RealVector.getLInfDistance(double[])`, `RealVector.getNorm()`

#### getDistance

    public double getDistance(ArrayRealVector 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:
  `getDistance(RealVector)`, `getL1Distance(ArrayRealVector)`, `getLInfDistance(ArrayRealVector)`, `getNorm()`

#### getL1Distance

    public 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.

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

#### getL1Distance

    public 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.

Specified by:
  `getL1Distance` in interface `RealVector`
Overrides:
  `getL1Distance` in class `AbstractRealVector`
Parameters:
  `v` - vector to which distance is requested
Returns:
  distance between two vectors.
Throws:
  `DimensionMismatchException` - if `v` is not the same size as this vector.
  `java.lang.IllegalArgumentException`
See Also:
  `RealVector.getDistance(double[])`, `RealVector.getLInfDistance(double[])`, `RealVector.getL1Norm()`

#### getL1Distance

    public double getL1Distance(ArrayRealVector 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)`, `getL1Distance(ArrayRealVector)`, `getLInfDistance(ArrayRealVector)`, `getNorm()`

#### getLInfDistance

    public 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.

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

#### getLInfDistance

    public 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.

Specified by:
  `getLInfDistance` in interface `RealVector`
Overrides:
  `getLInfDistance` in class `AbstractRealVector`
Parameters:
  `v` - vector to which distance is requested
Returns:
  distance between two vectors.
Throws:
  `DimensionMismatchException` - if `v` is not the same size as this vector.
  `java.lang.IllegalArgumentException`
See Also:
  `RealVector.getDistance(double[])`, `RealVector.getL1Distance(double[])`, `RealVector.getLInfNorm()`

#### getLInfDistance

    public double getLInfDistance(ArrayRealVector 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(ArrayRealVector)`, `getLInfDistance(ArrayRealVector)`, `getNorm()`

#### unitVector

    public RealVector unitVector()
                          throws java.lang.ArithmeticException

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

The instance is not changed by this method.

Specified by:
  `unitVector` in interface `RealVector`
Overrides:
  `unitVector` in class `AbstractRealVector`
Returns:
  a unit vector pointing in direction of this vector
Throws:
  `java.lang.ArithmeticException` - if the norm is null

#### unitize

    public void unitize()
                 throws java.lang.ArithmeticException

Converts this vector into a unit vector.

The instance itself is changed by this method.

Specified by:
  `unitize` in interface `RealVector`
Overrides:
  `unitize` in class `AbstractRealVector`
Throws:
  `java.lang.ArithmeticException` - if the norm is zero.

#### projection

    public RealVector projection(RealVector v)

Find the orthogonal projection of this vector onto another vector.

Specified by:
  `projection` in interface `RealVector`
Parameters:
  `v` - vector onto which instance must be projected
Returns:
  projection of the instance onto v

#### projection

    public RealVector projection(double[] v)

Find the orthogonal projection of this vector onto another vector.

Specified by:
  `projection` in interface `RealVector`
Overrides:
  `projection` in class `AbstractRealVector`
Parameters:
  `v` - vector onto which instance must be projected
Returns:
  projection of the instance onto v

#### projection

    public ArrayRealVector projection(ArrayRealVector v)

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

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

Compute the outer product.

Specified by:
  `outerProduct` in interface `RealVector`
Overrides:
  `outerProduct` in class `AbstractRealVector`
Parameters:
  `v` - vector with which outer product should be computed
Returns:
  the square matrix outer product between instance and v
Throws:
  `DimensionMismatchException` - if `v` is not the same size as this vector.
  `java.lang.IllegalArgumentException`

#### outerProduct

    public RealMatrix outerProduct(ArrayRealVector 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

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

Compute the outer product.

Specified by:
  `outerProduct` in interface `RealVector`
Overrides:
  `outerProduct` in class `AbstractRealVector`
Parameters:
  `v` - vector with which outer product should be computed
Returns:
  the square matrix outer product between instance and v
Throws:
  `DimensionMismatchException` - if `v` is not the same size as this vector.
  `java.lang.IllegalArgumentException`

#### getEntry

    public double getEntry(int index)
                    throws MatrixIndexException

Returns the entry in the specified index.

Specified by:
  `getEntry` in interface `RealVector`
Parameters:
  `index` - Index location of entry to be fetched.
Returns:
  the vector entry at `index`.
Throws:
  `MatrixIndexException`
See Also:
  `RealVector.setEntry(int, double)`

#### getDimension

    public int getDimension()

Returns the size of the vector.

Specified by:
  `getDimension` in interface `RealVector`
Returns:
  size

#### append

    public RealVector append(RealVector v)

Construct a vector by appending a vector to this vector.

Specified by:
  `append` in interface `RealVector`
Parameters:
  `v` - vector to append to this one.
Returns:
  a new vector

#### append

    public ArrayRealVector append(ArrayRealVector v)

Construct a vector by appending a vector to this vector.

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

#### append

    public RealVector append(double in)

Construct a vector by appending a double to this vector.

Specified by:
  `append` in interface `RealVector`
Parameters:
  `in` - double to append.
Returns:
  a new vector

#### append

    public RealVector append(double[] in)

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

Specified by:
  `append` in interface `RealVector`
Parameters:
  `in` - double array to append.
Returns:
  a new vector

#### getSubVector

    public RealVector getSubVector(int index,
                          int n)

Get a subvector from consecutive elements.

Specified by:
  `getSubVector` in interface `RealVector`
Parameters:
  `index` - index of first element.
  `n` - number of elements to be retrieved.
Returns:
  a vector containing n elements.

#### setEntry

    public void setEntry(int index,
                double value)

Set a single element.

Specified by:
  `setEntry` in interface `RealVector`
Parameters:
  `index` - element index.
  `value` - new value for the element.
See Also:
  `RealVector.getEntry(int)`

#### setSubVector

    public void setSubVector(int index,
                    RealVector v)

Set a set of consecutive elements.

Specified by:
  `setSubVector` in interface `RealVector`
Overrides:
  `setSubVector` in class `AbstractRealVector`
Parameters:
  `index` - index of first element to be set.
  `v` - vector containing the values to set.
See Also:
  `RealVector.setSubVector(int, double[])`

#### setSubVector

    public void setSubVector(int index,
                    double[] v)

Set a set of consecutive elements.

Specified by:
  `setSubVector` in interface `RealVector`
Overrides:
  `setSubVector` in class `AbstractRealVector`
Parameters:
  `index` - index of first element to be set.
  `v` - vector containing the values to set.
See Also:
  `RealVector.setSubVector(int, RealVector)`

#### set

    public void set(int index,
           ArrayRealVector 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

#### set

    public void set(double value)

Set all elements to a single value.

Specified by:
  `set` in interface `RealVector`
Overrides:
  `set` in class `AbstractRealVector`
Parameters:
  `value` - single value to set for all elements

#### toArray

    public double[] toArray()

Convert the vector to a double array.

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

Specified by:
  `toArray` in interface `RealVector`
Overrides:
  `toArray` in class `AbstractRealVector`
Returns:
  array containing a copy of vector elements

#### toString

    public java.lang.String toString()

Overrides:
  `toString` in class `java.lang.Object`

#### checkVectorDimensions

    protected void checkVectorDimensions(RealVector v)
                                  throws java.lang.IllegalArgumentException

Check if instance and specified vectors have the same dimension.

Overrides:
  `checkVectorDimensions` in class `AbstractRealVector`
Parameters:
  `v` - vector to compare instance with
Throws:
  `java.lang.IllegalArgumentException` - if the vectors do not have the same dimension

#### checkVectorDimensions

    protected void checkVectorDimensions(int n)
                                  throws java.lang.IllegalArgumentException

Check if instance dimension is equal to some expected value.

Overrides:
  `checkVectorDimensions` in class `AbstractRealVector`
Parameters:
  `n` - expected dimension.
Throws:
  `java.lang.IllegalArgumentException` - if the dimension is inconsistent with vector size

#### isNaN

    public boolean isNaN()

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

Specified by:
  `isNaN` in interface `RealVector`
Returns:
  true if any coordinate of this vector is NaN; false otherwise

#### isInfinite

    public boolean isInfinite()

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

Specified by:
  `isInfinite` in interface `RealVector`
Returns:
  true if any coordinate of this vector is infinite and none are NaN; false otherwise

#### equals

    public boolean equals(java.lang.Object other)

Test for the equality of two real vectors.

If all coordinates of two real vectors are exactly the same, and none are `Double.NaN`, the two real vectors are considered to be equal.

`NaN` coordinates are considered to affect globally the vector and be equals to each other - i.e, if either (or all) coordinates of the real vector are equal to `Double.NaN`, the real vector is equal to a vector with all `Double.NaN` coordinates.

Overrides:
  `equals` in class `java.lang.Object`
Parameters:
  `other` - Object to test for equality to this
Returns:
  true if two vector objects are equal, false if object is null, not an instance of RealVector, or not equal to this RealVector instance

#### hashCode

    public int hashCode()

Get a hashCode for the real vector.

All NaN values have the same hash code.

Overrides:
  `hashCode` in class `java.lang.Object`
Returns:
  a hash code value for this object