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 theRealVectorinterface with a double array.- Since:
 - 2.0
 - See Also:
 - Serialized Form
 
 
- 
- 
Nested Class Summary
- 
Nested classes/interfaces inherited from interface org.apache.commons.math.linear.RealVector
RealVector.Entry 
 - 
 
- 
Constructor Summary
Constructors Constructor Description ArrayRealVector()Build a 0-length vector.ArrayRealVector(double[] d)Construct a vector from an array, copying the input array.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(double[] v1, ArrayRealVector v2)Construct a vector by appending one vector to another vector.ArrayRealVector(int size)Construct a (size)-length vector of zeros.ArrayRealVector(int size, double preset)Construct an (size)-length vector with preset values.ArrayRealVector(java.lang.Double[] d)Construct a vector from an array.ArrayRealVector(java.lang.Double[] d, int pos, int size)Construct a vector from part of a Double arrayArrayRealVector(ArrayRealVector v)Construct a vector from another vector, using a deep copy.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, ArrayRealVector 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(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RealVectoradd(double[] v)Compute the sum of this vector andv.ArrayRealVectoradd(ArrayRealVector v)Compute the sum of this and v.RealVectoradd(RealVector v)Compute the sum of this vector andv.RealVectorappend(double in)Construct a vector by appending a double to this vector.RealVectorappend(double[] in)Construct a vector by appending a double array to this vector.ArrayRealVectorappend(ArrayRealVector v)Construct a vector by appending a vector to this vector.RealVectorappend(RealVector v)Construct a vector by appending a vector to this vector.AbstractRealVectorcopy()Returns a (deep) copy of this vector.doubledotProduct(double[] v)Compute the dot product.doubledotProduct(ArrayRealVector v)Compute the dot product.doubledotProduct(RealVector v)Compute the dot product.RealVectorebeDivide(double[] v)Element-by-element division.ArrayRealVectorebeDivide(ArrayRealVector v)Element-by-element division.RealVectorebeDivide(RealVector v)Element-by-element division.RealVectorebeMultiply(double[] v)Element-by-element multiplication.ArrayRealVectorebeMultiply(ArrayRealVector v)Element-by-element multiplication.RealVectorebeMultiply(RealVector v)Element-by-element multiplication.booleanequals(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.intgetDimension()Returns the size of the vector.doublegetDistance(double[] v)Distance between two vectors.doublegetDistance(ArrayRealVector v)Distance between two vectors.doublegetDistance(RealVector v)Distance between two vectors.doublegetEntry(int index)Returns the entry in the specified index.doublegetL1Distance(double[] v)Distance between two vectors.doublegetL1Distance(ArrayRealVector v)Distance between two vectors.doublegetL1Distance(RealVector v)Distance between two vectors.doublegetL1Norm()Returns the L1 norm of the vector.doublegetLInfDistance(double[] v)Distance between two vectors.doublegetLInfDistance(ArrayRealVector v)Distance between two vectors.doublegetLInfDistance(RealVector v)Distance between two vectors.doublegetLInfNorm()Returns the L∞ norm of the vector.doublegetNorm()Returns the L2 norm of the vector.RealVectorgetSubVector(int index, int n)Get a subvector from consecutive elements.inthashCode()Get a hashCode for the real vector.booleanisInfinite()Returns true if any coordinate of this vector is infinite and none are NaN; false otherwisebooleanisNaN()Returns true if any coordinate of this vector is NaN; false otherwiseRealVectormapAbsToSelf()Map theMath.abs(double)function to each entry.RealVectormapAcosToSelf()Map theMath.acos(double)function to each entry.RealVectormapAddToSelf(double d)Add a value to each entry.RealVectormapAsinToSelf()Map theMath.asin(double)function to each entry.RealVectormapAtanToSelf()Map theMath.atan(double)function to each entry.RealVectormapCbrtToSelf()Map theMath.cbrt(double)function to each entry.RealVectormapCeilToSelf()Map theMath.ceil(double)function to each entry.RealVectormapCoshToSelf()Map theMath.cosh(double)function to each entry.RealVectormapCosToSelf()Map theMath.cos(double)function to each entry.RealVectormapDivideToSelf(double d)Divide each entry.RealVectormapExpm1ToSelf()Map theMath.expm1(double)function to each entry.RealVectormapExpToSelf()MapMath.exp(double)operation to each entry.RealVectormapFloorToSelf()Map theMath.floor(double)function to each entry.RealVectormapInvToSelf()Map the 1/x function to each entry.RealVectormapLog10ToSelf()Map theMath.log10(double)function to each entry.RealVectormapLog1pToSelf()Map theMath.log1p(double)function to each entry.RealVectormapLogToSelf()Map theMath.log(double)function to each entry.RealVectormapMultiplyToSelf(double d)Multiply each entry.RealVectormapPowToSelf(double d)Map a power operation to each entry.RealVectormapRintToSelf()Map theMath.rint(double)function to each entry.RealVectormapSignumToSelf()Map theMath.signum(double)function to each entry.RealVectormapSinhToSelf()Map theMath.sinh(double)function to each entry.RealVectormapSinToSelf()Map theMath.sin(double)function to each entry.RealVectormapSqrtToSelf()Map theMath.sqrt(double)function to each entry.RealVectormapSubtractToSelf(double d)Subtract a value from each entry.RealVectormapTanhToSelf()Map theMath.tanh(double)function to each entry.RealVectormapTanToSelf()Map theMath.tan(double)function to each entry.RealVectormapUlpToSelf()Map theMath.ulp(double)function to each entry.RealMatrixouterProduct(double[] v)Compute the outer product.RealMatrixouterProduct(ArrayRealVector v)Compute the outer product.RealMatrixouterProduct(RealVector v)Compute the outer product.RealVectorprojection(double[] v)Find the orthogonal projection of this vector onto another vector.ArrayRealVectorprojection(ArrayRealVector v)Find the orthogonal projection of this vector onto another vector.RealVectorprojection(RealVector v)Find the orthogonal projection of this vector onto another vector.voidset(double value)Set all elements to a single value.voidset(int index, ArrayRealVector v)Set a set of consecutive elements.voidsetEntry(int index, double value)Set a single element.voidsetSubVector(int index, double[] v)Set a set of consecutive elements.voidsetSubVector(int index, RealVector v)Set a set of consecutive elements.RealVectorsubtract(double[] v)Subtractvfrom this vector.ArrayRealVectorsubtract(ArrayRealVector v)Compute this minus v.RealVectorsubtract(RealVector v)Subtractvfrom this vector.double[]toArray()Convert the vector to a double array.java.lang.StringtoString()voidunitize()Converts this vector into a unit vector.RealVectorunitVector()Creates a unit vector pointing in the direction of this vector.- 
Methods inherited from class org.apache.commons.math.linear.AbstractRealVector
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 
 - 
 
 - 
 
- 
- 
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 theappendmethod (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 vectorpreset- 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
copyArraymay be set tofalse- Parameters:
 d- data for new vectorcopyArray- 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 entrysize- 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 entrysize- 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 copydeep- 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:
 copyin interfaceRealVector- Specified by:
 copyin classAbstractRealVector- Returns:
 - a vector copy.
 
 
- 
add
public RealVector add(RealVector v) throws java.lang.IllegalArgumentException
Compute the sum of this vector andv.- Specified by:
 addin interfaceRealVector- Overrides:
 addin classAbstractRealVector- Parameters:
 v- Vector to be added.- Returns:
 this+v.- Throws:
 DimensionMismatchException- ifvis 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 andv.- Specified by:
 addin interfaceRealVector- Overrides:
 addin classAbstractRealVector- Parameters:
 v- Vector to be added.- Returns:
 this+v.- Throws:
 DimensionMismatchException- ifvis 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
Subtractvfrom this vector.- Specified by:
 subtractin interfaceRealVector- Overrides:
 subtractin classAbstractRealVector- Parameters:
 v- Vector to be subtracted.- Returns:
 this-v.- Throws:
 DimensionMismatchException- ifvis not the same size as this vector.java.lang.IllegalArgumentException
 
- 
subtract
public RealVector subtract(double[] v) throws java.lang.IllegalArgumentException
Subtractvfrom this vector.- Specified by:
 subtractin interfaceRealVector- Overrides:
 subtractin classAbstractRealVector- Parameters:
 v- Vector to be subtracted.- Returns:
 this-v.- Throws:
 DimensionMismatchException- ifvis 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:
 mapAddToSelfin interfaceRealVector- Overrides:
 mapAddToSelfin classAbstractRealVector- 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:
 mapSubtractToSelfin interfaceRealVector- Overrides:
 mapSubtractToSelfin classAbstractRealVector- 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:
 mapMultiplyToSelfin interfaceRealVector- Overrides:
 mapMultiplyToSelfin classAbstractRealVector- Parameters:
 d- Multiplication factor.- Returns:
 this.
 
- 
mapDivideToSelf
public RealVector mapDivideToSelf(double d)
Divide each entry. The instance is changed in-place.- Specified by:
 mapDivideToSelfin interfaceRealVector- Overrides:
 mapDivideToSelfin classAbstractRealVector- 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:
 mapPowToSelfin interfaceRealVector- Overrides:
 mapPowToSelfin classAbstractRealVector- Parameters:
 d- Operator value.- Returns:
 - the mapped vector.
 
 
- 
mapExpToSelf
public RealVector mapExpToSelf()
MapMath.exp(double)operation to each entry. The instance is changed in-place.- Specified by:
 mapExpToSelfin interfaceRealVector- Overrides:
 mapExpToSelfin classAbstractRealVector- Returns:
 - the mapped vector.
 
 
- 
mapExpm1ToSelf
public RealVector mapExpm1ToSelf()
Map theMath.expm1(double)function to each entry.The instance is changed by this method.
- Specified by:
 mapExpm1ToSelfin interfaceRealVector- Overrides:
 mapExpm1ToSelfin classAbstractRealVector- Returns:
 - for convenience, return this
 
 
- 
mapLogToSelf
public RealVector mapLogToSelf()
Map theMath.log(double)function to each entry.The instance is changed by this method.
- Specified by:
 mapLogToSelfin interfaceRealVector- Overrides:
 mapLogToSelfin classAbstractRealVector- Returns:
 - for convenience, return this
 
 
- 
mapLog10ToSelf
public RealVector mapLog10ToSelf()
Map theMath.log10(double)function to each entry.The instance is changed by this method.
- Specified by:
 mapLog10ToSelfin interfaceRealVector- Overrides:
 mapLog10ToSelfin classAbstractRealVector- Returns:
 - for convenience, return this
 
 
- 
mapLog1pToSelf
public RealVector mapLog1pToSelf()
Map theMath.log1p(double)function to each entry.The instance is changed by this method.
- Specified by:
 mapLog1pToSelfin interfaceRealVector- Overrides:
 mapLog1pToSelfin classAbstractRealVector- Returns:
 - for convenience, return this
 
 
- 
mapCoshToSelf
public RealVector mapCoshToSelf()
Map theMath.cosh(double)function to each entry.The instance is changed by this method.
- Specified by:
 mapCoshToSelfin interfaceRealVector- Overrides:
 mapCoshToSelfin classAbstractRealVector- Returns:
 - for convenience, return this
 
 
- 
mapSinhToSelf
public RealVector mapSinhToSelf()
Map theMath.sinh(double)function to each entry.The instance is changed by this method.
- Specified by:
 mapSinhToSelfin interfaceRealVector- Overrides:
 mapSinhToSelfin classAbstractRealVector- Returns:
 - for convenience, return this
 
 
- 
mapTanhToSelf
public RealVector mapTanhToSelf()
Map theMath.tanh(double)function to each entry.The instance is changed by this method.
- Specified by:
 mapTanhToSelfin interfaceRealVector- Overrides:
 mapTanhToSelfin classAbstractRealVector- Returns:
 - for convenience, return this
 
 
- 
mapCosToSelf
public RealVector mapCosToSelf()
Map theMath.cos(double)function to each entry.The instance is changed by this method.
- Specified by:
 mapCosToSelfin interfaceRealVector- Overrides:
 mapCosToSelfin classAbstractRealVector- Returns:
 - for convenience, return this
 
 
- 
mapSinToSelf
public RealVector mapSinToSelf()
Map theMath.sin(double)function to each entry.The instance is changed by this method.
- Specified by:
 mapSinToSelfin interfaceRealVector- Overrides:
 mapSinToSelfin classAbstractRealVector- Returns:
 - for convenience, return this
 
 
- 
mapTanToSelf
public RealVector mapTanToSelf()
Map theMath.tan(double)function to each entry.The instance is changed by this method.
- Specified by:
 mapTanToSelfin interfaceRealVector- Overrides:
 mapTanToSelfin classAbstractRealVector- Returns:
 - for convenience, return this
 
 
- 
mapAcosToSelf
public RealVector mapAcosToSelf()
Map theMath.acos(double)function to each entry.The instance is changed by this method.
- Specified by:
 mapAcosToSelfin interfaceRealVector- Overrides:
 mapAcosToSelfin classAbstractRealVector- Returns:
 - for convenience, return this
 
 
- 
mapAsinToSelf
public RealVector mapAsinToSelf()
Map theMath.asin(double)function to each entry.The instance is changed by this method.
- Specified by:
 mapAsinToSelfin interfaceRealVector- Overrides:
 mapAsinToSelfin classAbstractRealVector- Returns:
 - for convenience, return this
 
 
- 
mapAtanToSelf
public RealVector mapAtanToSelf()
Map theMath.atan(double)function to each entry.The instance is changed by this method.
- Specified by:
 mapAtanToSelfin interfaceRealVector- Overrides:
 mapAtanToSelfin classAbstractRealVector- 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:
 mapInvToSelfin interfaceRealVector- Overrides:
 mapInvToSelfin classAbstractRealVector- Returns:
 - for convenience, return this
 
 
- 
mapAbsToSelf
public RealVector mapAbsToSelf()
Map theMath.abs(double)function to each entry.The instance is changed by this method.
- Specified by:
 mapAbsToSelfin interfaceRealVector- Overrides:
 mapAbsToSelfin classAbstractRealVector- Returns:
 - for convenience, return this
 
 
- 
mapSqrtToSelf
public RealVector mapSqrtToSelf()
Map theMath.sqrt(double)function to each entry.The instance is changed by this method.
- Specified by:
 mapSqrtToSelfin interfaceRealVector- Overrides:
 mapSqrtToSelfin classAbstractRealVector- Returns:
 - for convenience, return this
 
 
- 
mapCbrtToSelf
public RealVector mapCbrtToSelf()
Map theMath.cbrt(double)function to each entry.The instance is changed by this method.
- Specified by:
 mapCbrtToSelfin interfaceRealVector- Overrides:
 mapCbrtToSelfin classAbstractRealVector- Returns:
 - for convenience, return this
 
 
- 
mapCeilToSelf
public RealVector mapCeilToSelf()
Map theMath.ceil(double)function to each entry.The instance is changed by this method.
- Specified by:
 mapCeilToSelfin interfaceRealVector- Overrides:
 mapCeilToSelfin classAbstractRealVector- Returns:
 - for convenience, return this
 
 
- 
mapFloorToSelf
public RealVector mapFloorToSelf()
Map theMath.floor(double)function to each entry.The instance is changed by this method.
- Specified by:
 mapFloorToSelfin interfaceRealVector- Overrides:
 mapFloorToSelfin classAbstractRealVector- Returns:
 - for convenience, return this
 
 
- 
mapRintToSelf
public RealVector mapRintToSelf()
Map theMath.rint(double)function to each entry.The instance is changed by this method.
- Specified by:
 mapRintToSelfin interfaceRealVector- Overrides:
 mapRintToSelfin classAbstractRealVector- Returns:
 - for convenience, return this
 
 
- 
mapSignumToSelf
public RealVector mapSignumToSelf()
Map theMath.signum(double)function to each entry.The instance is changed by this method.
- Specified by:
 mapSignumToSelfin interfaceRealVector- Overrides:
 mapSignumToSelfin classAbstractRealVector- Returns:
 - for convenience, return this
 
 
- 
mapUlpToSelf
public RealVector mapUlpToSelf()
Map theMath.ulp(double)function to each entry.The instance is changed by this method.
- Specified by:
 mapUlpToSelfin interfaceRealVector- Overrides:
 mapUlpToSelfin classAbstractRealVector- Returns:
 - for convenience, return this
 
 
- 
ebeMultiply
public RealVector ebeMultiply(RealVector v) throws java.lang.IllegalArgumentException
Element-by-element multiplication.- Specified by:
 ebeMultiplyin interfaceRealVector- Parameters:
 v- vector by which instance elements must be multiplied- Returns:
 - a vector containing this[i] * v[i] for all i
 - Throws:
 DimensionMismatchException- ifvis 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:
 ebeMultiplyin interfaceRealVector- Overrides:
 ebeMultiplyin classAbstractRealVector- Parameters:
 v- vector by which instance elements must be multiplied- Returns:
 - a vector containing this[i] * v[i] for all i
 - Throws:
 DimensionMismatchException- ifvis 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:
 ebeDividein interfaceRealVector- Parameters:
 v- vector by which instance elements must be divided- Returns:
 - a vector containing this[i] / v[i] for all i
 - Throws:
 DimensionMismatchException- ifvis 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:
 ebeDividein interfaceRealVector- Overrides:
 ebeDividein classAbstractRealVector- Parameters:
 v- vector by which instance elements must be divided- Returns:
 - a vector containing this[i] / v[i] for all i
 - Throws:
 DimensionMismatchException- ifvis 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:
 getDatain interfaceRealVector- Overrides:
 getDatain classAbstractRealVector- 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:
 dotProductin interfaceRealVector- Overrides:
 dotProductin classAbstractRealVector- Parameters:
 v- vector with which dot product should be computed- Returns:
 - the scalar dot product between instance and v
 - Throws:
 DimensionMismatchException- ifvis not the same size as this vector.java.lang.IllegalArgumentException
 
- 
dotProduct
public double dotProduct(double[] v) throws java.lang.IllegalArgumentExceptionCompute the dot product.- Specified by:
 dotProductin interfaceRealVector- Overrides:
 dotProductin classAbstractRealVector- Parameters:
 v- vector with which dot product should be computed- Returns:
 - the scalar dot product between instance and v
 - Throws:
 DimensionMismatchException- ifvis 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:
 getNormin interfaceRealVector- Overrides:
 getNormin classAbstractRealVector- 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:
 getL1Normin interfaceRealVector- Overrides:
 getL1Normin classAbstractRealVector- 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:
 getLInfNormin interfaceRealVector- Overrides:
 getLInfNormin classAbstractRealVector- 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:
 getDistancein interfaceRealVector- Overrides:
 getDistancein classAbstractRealVector- Parameters:
 v- vector to which distance is requested- Returns:
 - distance between two vectors.
 - Throws:
 DimensionMismatchException- ifvis 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.IllegalArgumentExceptionDistance 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:
 getDistancein interfaceRealVector- Overrides:
 getDistancein classAbstractRealVector- Parameters:
 v- vector to which distance is requested- Returns:
 - distance between two vectors.
 - Throws:
 DimensionMismatchException- ifvis 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:
 getL1Distancein interfaceRealVector- Overrides:
 getL1Distancein classAbstractRealVector- Parameters:
 v- vector to which distance is requested- Returns:
 - distance between two vectors.
 - Throws:
 DimensionMismatchException- ifvis 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.IllegalArgumentExceptionDistance 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:
 getL1Distancein interfaceRealVector- Overrides:
 getL1Distancein classAbstractRealVector- Parameters:
 v- vector to which distance is requested- Returns:
 - distance between two vectors.
 - Throws:
 DimensionMismatchException- ifvis 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:
 getLInfDistancein interfaceRealVector- Overrides:
 getLInfDistancein classAbstractRealVector- Parameters:
 v- vector to which distance is requested- Returns:
 - distance between two vectors.
 - Throws:
 DimensionMismatchException- ifvis 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.IllegalArgumentExceptionDistance 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:
 getLInfDistancein interfaceRealVector- Overrides:
 getLInfDistancein classAbstractRealVector- Parameters:
 v- vector to which distance is requested- Returns:
 - distance between two vectors.
 - Throws:
 DimensionMismatchException- ifvis 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:
 unitVectorin interfaceRealVector- Overrides:
 unitVectorin classAbstractRealVector- 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.ArithmeticExceptionConverts this vector into a unit vector.The instance itself is changed by this method.
- Specified by:
 unitizein interfaceRealVector- Overrides:
 unitizein classAbstractRealVector- 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:
 projectionin interfaceRealVector- 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:
 projectionin interfaceRealVector- Overrides:
 projectionin classAbstractRealVector- 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:
 outerProductin interfaceRealVector- Overrides:
 outerProductin classAbstractRealVector- Parameters:
 v- vector with which outer product should be computed- Returns:
 - the square matrix outer product between instance and v
 - Throws:
 DimensionMismatchException- ifvis 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:
 outerProductin interfaceRealVector- Overrides:
 outerProductin classAbstractRealVector- Parameters:
 v- vector with which outer product should be computed- Returns:
 - the square matrix outer product between instance and v
 - Throws:
 DimensionMismatchException- ifvis not the same size as this vector.java.lang.IllegalArgumentException
 
- 
getEntry
public double getEntry(int index) throws MatrixIndexExceptionReturns the entry in the specified index.- Specified by:
 getEntryin interfaceRealVector- 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:
 getDimensionin interfaceRealVector- Returns:
 - size
 
 
- 
append
public RealVector append(RealVector v)
Construct a vector by appending a vector to this vector.- Specified by:
 appendin interfaceRealVector- 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:
 appendin interfaceRealVector- 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:
 appendin interfaceRealVector- 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:
 getSubVectorin interfaceRealVector- 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:
 setEntryin interfaceRealVector- 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:
 setSubVectorin interfaceRealVector- Overrides:
 setSubVectorin classAbstractRealVector- 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:
 setSubVectorin interfaceRealVector- Overrides:
 setSubVectorin classAbstractRealVector- 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 MatrixIndexExceptionSet 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:
 setin interfaceRealVector- Overrides:
 setin classAbstractRealVector- 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:
 toArrayin interfaceRealVector- Overrides:
 toArrayin classAbstractRealVector- Returns:
 - array containing a copy of vector elements
 
 
- 
toString
public java.lang.String toString()
- Overrides:
 toStringin classjava.lang.Object
 
- 
isNaN
public boolean isNaN()
Returns true if any coordinate of this vector is NaN; false otherwise- Specified by:
 isNaNin interfaceRealVector- 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:
 isInfinitein interfaceRealVector- 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.NaNcoordinates 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 toDouble.NaN, the real vector is equal to a vector with allDouble.NaNcoordinates.- Overrides:
 equalsin classjava.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:
 hashCodein classjava.lang.Object- Returns:
 - a hash code value for this object
 
 
 - 
 
 -