Class ArrayRealVector
- All Implemented Interfaces:
Serializable,RealVector
RealVector interface with a double array.- Since:
- 2.0
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.commons.math.linear.RealVector
RealVector.Entry -
Constructor Summary
ConstructorsConstructorDescriptionBuild 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(Double[] d) Construct a vector from an array.ArrayRealVector(Double[] d, int pos, int size) Construct a vector from part of a Double arrayConstruct 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.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.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
Modifier and TypeMethodDescriptionadd(double[] v) Compute the sum of this vector andv.Compute the sum of this and v.add(RealVector v) Compute the sum of this vector andv.append(double in) Construct a vector by appending a double to this vector.append(double[] in) Construct a vector by appending a double array to this vector.Construct a vector by appending a vector to this vector.append(RealVector v) Construct a vector by appending a vector to this vector.copy()Returns a (deep) copy of this vector.doubledotProduct(double[] v) Compute the dot product.doubleCompute the dot product.doubleCompute the dot product.ebeDivide(double[] v) Element-by-element division.Element-by-element division.Element-by-element division.ebeMultiply(double[] v) Element-by-element multiplication.Element-by-element multiplication.Element-by-element multiplication.booleanTest for the equality of two real vectors.double[]getData()Returns vector entries as a double array.double[]Returns a reference to the underlying data array.intReturns the size of the vector.doublegetDistance(double[] v) Distance between two vectors.doubleDistance between two vectors.doubleDistance between two vectors.doublegetEntry(int index) Returns the entry in the specified index.doublegetL1Distance(double[] v) Distance between two vectors.doubleDistance between two vectors.doubleDistance between two vectors.doubleReturns the L1 norm of the vector.doublegetLInfDistance(double[] v) Distance between two vectors.doubleDistance between two vectors.doubleDistance between two vectors.doubleReturns the L∞ norm of the vector.doublegetNorm()Returns the L2 norm of the vector.getSubVector(int index, int n) Get a subvector from consecutive elements.inthashCode()Get a hashCode for the real vector.booleanReturns 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 otherwiseMap theMath.abs(double)function to each entry.Map theMath.acos(double)function to each entry.mapAddToSelf(double d) Add a value to each entry.Map theMath.asin(double)function to each entry.Map theMath.atan(double)function to each entry.Map theMath.cbrt(double)function to each entry.Map theMath.ceil(double)function to each entry.Map theMath.cosh(double)function to each entry.Map theMath.cos(double)function to each entry.mapDivideToSelf(double d) Divide each entry.Map theMath.expm1(double)function to each entry.MapMath.exp(double)operation to each entry.Map theMath.floor(double)function to each entry.Map the 1/x function to each entry.Map theMath.log10(double)function to each entry.Map theMath.log1p(double)function to each entry.Map theMath.log(double)function to each entry.mapMultiplyToSelf(double d) Multiply each entry.mapPowToSelf(double d) Map a power operation to each entry.Map theMath.rint(double)function to each entry.Map theMath.signum(double)function to each entry.Map theMath.sinh(double)function to each entry.Map theMath.sin(double)function to each entry.Map theMath.sqrt(double)function to each entry.mapSubtractToSelf(double d) Subtract a value from each entry.Map theMath.tanh(double)function to each entry.Map theMath.tan(double)function to each entry.Map theMath.ulp(double)function to each entry.outerProduct(double[] v) Compute the outer product.Compute the outer product.Compute the outer product.projection(double[] v) Find the orthogonal projection of this vector onto another vector.Find the orthogonal projection of this vector onto another vector.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.subtract(double[] v) Subtractvfrom this vector.Compute this minus v.Subtractvfrom this vector.double[]toArray()Convert the vector to a double array.toString()voidunitize()Converts this vector into a unit vector.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 Details
-
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 tofalseinvalid input: '<'/code. This will prevent the copying and improve performance as no new array will be built and no data will be copied.- Parameters:
d- data for new vectorcopyArray- if true, the input array will be copied, otherwise it will be referenced- See Also:
-
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
Construct a vector from an array.- Parameters:
d- array of Doubles.
-
ArrayRealVector
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
Construct a vector from another vector, using a deep copy.- Parameters:
v- vector to copy
-
ArrayRealVector
Construct a vector from another vector, using a deep copy.- Parameters:
v- vector to copy
-
ArrayRealVector
Construct a vector from another vector.- Parameters:
v- vector to copydeep- if true perform a deep copy otherwise perform a shallow copy
-
ArrayRealVector
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
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
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
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
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 Details
-
copy
Returns a (deep) copy of this vector.- Specified by:
copyin interfaceRealVector- Specified by:
copyin classAbstractRealVector- Returns:
- a vector copy.
-
add
Compute the sum of this vector andv.- Specified by:
addin interfaceRealVector- Overrides:
addin classAbstractRealVector- Parameters:
v- Vector to be added.- Returns:
this+v.- Throws:
IllegalArgumentException
-
add
Compute the sum of this vector andv.- Specified by:
addin interfaceRealVector- Overrides:
addin classAbstractRealVector- Parameters:
v- Vector to be added.- Returns:
this+v.- Throws:
IllegalArgumentException
-
add
Compute the sum of this and v.- Parameters:
v- vector to be added- Returns:
- this + v
- Throws:
IllegalArgumentException- if v is not the same size as this
-
subtract
Subtractvfrom this vector.- Specified by:
subtractin interfaceRealVector- Overrides:
subtractin classAbstractRealVector- Parameters:
v- Vector to be subtracted.- Returns:
this-v.- Throws:
IllegalArgumentException
-
subtract
Subtractvfrom this vector.- Specified by:
subtractin interfaceRealVector- Overrides:
subtractin classAbstractRealVector- Parameters:
v- Vector to be subtracted.- Returns:
this-v.- Throws:
IllegalArgumentException
-
subtract
Compute this minus v.- Parameters:
v- vector to be subtracted- Returns:
- this + v
- Throws:
IllegalArgumentException- if v is not the same size as this
-
mapAddToSelf
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
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
Multiply each entry. The instance is changed in-place.- Specified by:
mapMultiplyToSelfin interfaceRealVector- Overrides:
mapMultiplyToSelfin classAbstractRealVector- Parameters:
d- Multiplication factor.- Returns:
this.
-
mapDivideToSelf
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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:
IllegalArgumentException
-
ebeMultiply
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:
IllegalArgumentException
-
ebeMultiply
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:
IllegalArgumentException- if v is not the same size as this
-
ebeDivide
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:
IllegalArgumentException
-
ebeDivide
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:
IllegalArgumentException
-
ebeDivide
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:
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
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:
IllegalArgumentException
-
dotProduct
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:
IllegalArgumentException
-
dotProduct
Compute the dot product.- Parameters:
v- vector with which dot product should be computed- Returns:
- the scalar dot product between instance and v
- Throws:
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:
-
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:
-
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:
-
getDistance
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:
IllegalArgumentException- See Also:
-
getDistance
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:
IllegalArgumentException- See Also:
-
getDistance
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:
IllegalArgumentException- if v is not the same size as this- See Also:
-
getL1Distance
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:
IllegalArgumentException- See Also:
-
getL1Distance
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:
IllegalArgumentException- See Also:
-
getL1Distance
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:
IllegalArgumentException- if v is not the same size as this- See Also:
-
getLInfDistance
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:
IllegalArgumentException- See Also:
-
getLInfDistance
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:
IllegalArgumentException- See Also:
-
getLInfDistance
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:
IllegalArgumentException- if v is not the same size as this- See Also:
-
unitVector
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:
ArithmeticException- if the norm is null
-
unitize
Converts this vector into a unit vector.The instance itself is changed by this method.
- Specified by:
unitizein interfaceRealVector- Overrides:
unitizein classAbstractRealVector- Throws:
ArithmeticException- if the norm is zero.
-
projection
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
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
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:
IllegalArgumentException- if v is not the same size as this
-
outerProduct
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:
IllegalArgumentException
-
outerProduct
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:
IllegalArgumentException- if v is not the same size as this
-
outerProduct
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:
IllegalArgumentException
-
getEntry
Returns 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:
-
getDimension
public int getDimension()Returns the size of the vector.- Specified by:
getDimensionin interfaceRealVector- Returns:
- size
-
append
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
Construct a vector by appending a vector to this vector.- Parameters:
v- vector to append to this one.- Returns:
- a new vector
-
append
Construct a vector by appending a double to this vector.- Specified by:
appendin interfaceRealVector- Parameters:
in- double to append.- Returns:
- a new vector
-
append
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
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:
-
setSubVector
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:
-
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:
-
set
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:
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
-
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
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. -
hashCode
public int hashCode()Get a hashCode for the real vector.All NaN values have the same hash code.
-