Class AbstractRealVector
- java.lang.Object
-
- org.apache.commons.math.linear.AbstractRealVector
-
- All Implemented Interfaces:
RealVector
- Direct Known Subclasses:
ArrayRealVector,OpenMapRealVector
public abstract class AbstractRealVector extends java.lang.Object implements RealVector
This class provides default basic implementations for many methods in theRealVectorinterface.- Since:
- 2.1
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.commons.math.linear.RealVector
RealVector.Entry
-
-
Constructor Summary
Constructors Constructor Description AbstractRealVector()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description RealVectoradd(double[] v)Compute the sum of this vector andv.RealVectoradd(RealVector v)Compute the sum of this vector andv.abstract AbstractRealVectorcopy()Returns a (deep) copy of this vector.doubledotProduct(double[] v)Compute the dot product.doubledotProduct(RealVector v)Compute the dot product.RealVectorebeDivide(double[] v)Element-by-element division.RealVectorebeMultiply(double[] v)Element-by-element multiplication.double[]getData()Returns vector entries as a double array.doublegetDistance(double[] v)Distance between two vectors.doublegetDistance(RealVector v)Distance between two vectors.doublegetL1Distance(double[] 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(RealVector v)Distance between two vectors.doublegetLInfNorm()Returns the L∞ norm of the vector.intgetMaxIndex()Get the index of the maximum entry.doublegetMaxValue()Get the value of the maximum entry.intgetMinIndex()Get the index of the minimum entry.doublegetMinValue()Get the value of the minimum entry.doublegetNorm()Returns the L2 norm of the vector.java.util.Iterator<RealVector.Entry>iterator()Generic dense iterator.RealVectormap(UnivariateRealFunction function)Acts as if implemented as:RealVectormapAbs()Map theMath.abs(double)function to each entry.RealVectormapAbsToSelf()Map theMath.abs(double)function to each entry.RealVectormapAcos()Map theMath.acos(double)function to each entry.RealVectormapAcosToSelf()Map theMath.acos(double)function to each entry.RealVectormapAdd(double d)Add a value to each entry.RealVectormapAddToSelf(double d)Add a value to each entry.RealVectormapAsin()Map theMath.asin(double)function to each entry.RealVectormapAsinToSelf()Map theMath.asin(double)function to each entry.RealVectormapAtan()Map theMath.atan(double)function to each entry.RealVectormapAtanToSelf()Map theMath.atan(double)function to each entry.RealVectormapCbrt()Map theMath.cbrt(double)function to each entry.RealVectormapCbrtToSelf()Map theMath.cbrt(double)function to each entry.RealVectormapCeil()Map theMath.ceil(double)function to each entry.RealVectormapCeilToSelf()Map theMath.ceil(double)function to each entry.RealVectormapCos()Map theMath.cos(double)function to each entry.RealVectormapCosh()Map theMath.cosh(double)function to each entry.RealVectormapCoshToSelf()Map theMath.cosh(double)function to each entry.RealVectormapCosToSelf()Map theMath.cos(double)function to each entry.RealVectormapDivide(double d)Divide each entry.RealVectormapDivideToSelf(double d)Divide each entry.RealVectormapExp()Map theMath.exp(double)function to each entry.RealVectormapExpm1()Map theMath.expm1(double)function to each entry.RealVectormapExpm1ToSelf()Map theMath.expm1(double)function to each entry.RealVectormapExpToSelf()MapMath.exp(double)operation to each entry.RealVectormapFloor()Map theMath.floor(double)function to each entry.RealVectormapFloorToSelf()Map theMath.floor(double)function to each entry.RealVectormapInv()Map the 1/x function to each entry.RealVectormapInvToSelf()Map the 1/x function to each entry.RealVectormapLog()Map theMath.log(double)function to each entry.RealVectormapLog10()Map theMath.log10(double)function to each entry.RealVectormapLog10ToSelf()Map theMath.log10(double)function to each entry.RealVectormapLog1p()Map theMath.log1p(double)function to each entry.RealVectormapLog1pToSelf()Map theMath.log1p(double)function to each entry.RealVectormapLogToSelf()Map theMath.log(double)function to each entry.RealVectormapMultiply(double d)Multiply each entry.RealVectormapMultiplyToSelf(double d)Multiply each entry.RealVectormapPow(double d)Map a power operation to each entry.RealVectormapPowToSelf(double d)Map a power operation to each entry.RealVectormapRint()Map theMath.rint(double)function to each entry.RealVectormapRintToSelf()Map theMath.rint(double)function to each entry.RealVectormapSignum()Map theMath.signum(double)function to each entry.RealVectormapSignumToSelf()Map theMath.signum(double)function to each entry.RealVectormapSin()Map theMath.sin(double)function to each entry.RealVectormapSinh()Map theMath.sinh(double)function to each entry.RealVectormapSinhToSelf()Map theMath.sinh(double)function to each entry.RealVectormapSinToSelf()Map theMath.sin(double)function to each entry.RealVectormapSqrt()Map theMath.sqrt(double)function to each entry.RealVectormapSqrtToSelf()Map theMath.sqrt(double)function to each entry.RealVectormapSubtract(double d)Subtract a value from each entry.RealVectormapSubtractToSelf(double d)Subtract a value from each entry.RealVectormapTan()Map theMath.tan(double)function to each entry.RealVectormapTanh()Map theMath.tanh(double)function to each entry.RealVectormapTanhToSelf()Map theMath.tanh(double)function to each entry.RealVectormapTanToSelf()Map theMath.tan(double)function to each entry.RealVectormapToSelf(UnivariateRealFunction function)Acts as if it is implemented as:RealVectormapUlp()Map theMath.ulp(double)function to each entry.RealVectormapUlpToSelf()Map theMath.ulp(double)function to each entry.RealMatrixouterProduct(double[] 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.voidset(double value)Set all elements to a single value.voidsetSubVector(int index, double[] v)Set a set of consecutive elements.voidsetSubVector(int index, RealVector v)Set a set of consecutive elements.java.util.Iterator<RealVector.Entry>sparseIterator()Specialized implementations may choose to not iterate over all dimensions, either because those values are unset, or are equal to defaultValue(), or are small enough to be ignored for the purposes of iteration.RealVectorsubtract(double[] v)Subtractvfrom this vector.RealVectorsubtract(RealVector v)Subtractvfrom this vector.double[]toArray()Convert the vector to a double array.voidunitize()Converts this vector into a unit vector.RealVectorunitVector()Creates a unit vector pointing in the direction of this vector.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.commons.math.linear.RealVector
append, append, append, ebeDivide, ebeMultiply, getDimension, getEntry, getSubVector, isInfinite, isNaN, projection, setEntry
-
-
-
-
Method Detail
-
setSubVector
public void setSubVector(int index, RealVector v) throws MatrixIndexExceptionSet a set of consecutive elements.- Specified by:
setSubVectorin interfaceRealVector- Parameters:
index- index of first element to be set.v- vector containing the values to set.- Throws:
MatrixIndexException- See Also:
RealVector.setSubVector(int, double[])
-
setSubVector
public void setSubVector(int index, double[] v) throws MatrixIndexExceptionSet a set of consecutive elements.- Specified by:
setSubVectorin interfaceRealVector- Parameters:
index- index of first element to be set.v- vector containing the values to set.- Throws:
MatrixIndexException- See Also:
RealVector.setSubVector(int, RealVector)
-
add
public RealVector add(double[] v) throws java.lang.IllegalArgumentException
Compute the sum of this vector andv.- Specified by:
addin interfaceRealVector- 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(RealVector v) throws java.lang.IllegalArgumentException
Compute the sum of this vector andv.- Specified by:
addin interfaceRealVector- Parameters:
v- Vector to be added.- 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- 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(RealVector v) throws java.lang.IllegalArgumentException
Subtractvfrom this vector.- Specified by:
subtractin interfaceRealVector- Parameters:
v- Vector to be subtracted.- Returns:
this-v.- Throws:
DimensionMismatchException- ifvis not the same size as this vector.java.lang.IllegalArgumentException
-
mapAdd
public RealVector mapAdd(double d)
Add a value to each entry.- Specified by:
mapAddin interfaceRealVector- Parameters:
d- Value to be added to each entry.- Returns:
this+d.
-
mapAddToSelf
public RealVector mapAddToSelf(double d)
Add a value to each entry. The instance is changed in-place.- Specified by:
mapAddToSelfin interfaceRealVector- Parameters:
d- Value to be added to each entry.- Returns:
this.
-
copy
public abstract AbstractRealVector copy()
Returns a (deep) copy of this vector.- Specified by:
copyin interfaceRealVector- Returns:
- a vector copy.
-
dotProduct
public double dotProduct(double[] v) throws java.lang.IllegalArgumentExceptionCompute the dot product.- Specified by:
dotProductin interfaceRealVector- 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(RealVector v) throws java.lang.IllegalArgumentException
Compute the dot product.- Specified by:
dotProductin interfaceRealVector- 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
-
ebeDivide
public RealVector ebeDivide(double[] 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
-
ebeMultiply
public RealVector ebeMultiply(double[] 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
-
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- 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()
-
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- 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- 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- Returns:
- norm
- See Also:
RealVector.getNorm(),RealVector.getL1Norm(),RealVector.getLInfDistance(RealVector)
-
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- 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()
-
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- 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- 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()
-
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- 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- 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()
-
getMinIndex
public int getMinIndex()
Get the index of the minimum entry.- Returns:
- index of the minimum entry or -1 if vector length is 0 or all entries are NaN
-
getMinValue
public double getMinValue()
Get the value of the minimum entry.- Returns:
- value of the minimum entry or NaN if all entries are NaN
-
getMaxIndex
public int getMaxIndex()
Get the index of the maximum entry.- Returns:
- index of the maximum entry or -1 if vector length is 0 or all entries are NaN
-
getMaxValue
public double getMaxValue()
Get the value of the maximum entry.- Returns:
- value of the maximum entry or NaN if all entries are NaN
-
mapAbs
public RealVector mapAbs()
Map theMath.abs(double)function to each entry.- Specified by:
mapAbsin interfaceRealVector- Returns:
- a vector containing the result of applying the function to each entry
-
mapAbsToSelf
public RealVector mapAbsToSelf()
Map theMath.abs(double)function to each entry.The instance is changed by this method.
- Specified by:
mapAbsToSelfin interfaceRealVector- Returns:
- for convenience, return this
-
mapAcos
public RealVector mapAcos()
Map theMath.acos(double)function to each entry.- Specified by:
mapAcosin interfaceRealVector- Returns:
- a vector containing the result of applying the function to each entry
-
mapAcosToSelf
public RealVector mapAcosToSelf()
Map theMath.acos(double)function to each entry.The instance is changed by this method.
- Specified by:
mapAcosToSelfin interfaceRealVector- Returns:
- for convenience, return this
-
mapAsin
public RealVector mapAsin()
Map theMath.asin(double)function to each entry.- Specified by:
mapAsinin interfaceRealVector- Returns:
- a vector containing the result of applying the function to each entry
-
mapAsinToSelf
public RealVector mapAsinToSelf()
Map theMath.asin(double)function to each entry.The instance is changed by this method.
- Specified by:
mapAsinToSelfin interfaceRealVector- Returns:
- for convenience, return this
-
mapAtan
public RealVector mapAtan()
Map theMath.atan(double)function to each entry.- Specified by:
mapAtanin interfaceRealVector- Returns:
- a vector containing the result of applying the function to each entry
-
mapAtanToSelf
public RealVector mapAtanToSelf()
Map theMath.atan(double)function to each entry.The instance is changed by this method.
- Specified by:
mapAtanToSelfin interfaceRealVector- Returns:
- for convenience, return this
-
mapCbrt
public RealVector mapCbrt()
Map theMath.cbrt(double)function to each entry.- Specified by:
mapCbrtin interfaceRealVector- Returns:
- a vector containing the result of applying the function to each entry
-
mapCbrtToSelf
public RealVector mapCbrtToSelf()
Map theMath.cbrt(double)function to each entry.The instance is changed by this method.
- Specified by:
mapCbrtToSelfin interfaceRealVector- Returns:
- for convenience, return this
-
mapCeil
public RealVector mapCeil()
Map theMath.ceil(double)function to each entry.- Specified by:
mapCeilin interfaceRealVector- Returns:
- a vector containing the result of applying the function to each entry
-
mapCeilToSelf
public RealVector mapCeilToSelf()
Map theMath.ceil(double)function to each entry.The instance is changed by this method.
- Specified by:
mapCeilToSelfin interfaceRealVector- Returns:
- for convenience, return this
-
mapCos
public RealVector mapCos()
Map theMath.cos(double)function to each entry.- Specified by:
mapCosin interfaceRealVector- Returns:
- a vector containing the result of applying the function to each entry
-
mapCosToSelf
public RealVector mapCosToSelf()
Map theMath.cos(double)function to each entry.The instance is changed by this method.
- Specified by:
mapCosToSelfin interfaceRealVector- Returns:
- for convenience, return this
-
mapCosh
public RealVector mapCosh()
Map theMath.cosh(double)function to each entry.- Specified by:
mapCoshin interfaceRealVector- Returns:
- a vector containing the result of applying the function to each entry
-
mapCoshToSelf
public RealVector mapCoshToSelf()
Map theMath.cosh(double)function to each entry.The instance is changed by this method.
- Specified by:
mapCoshToSelfin interfaceRealVector- Returns:
- for convenience, return this
-
mapDivide
public RealVector mapDivide(double d)
Divide each entry.- Specified by:
mapDividein interfaceRealVector- Parameters:
d- Value to divide by.- Returns:
this/d.
-
mapDivideToSelf
public RealVector mapDivideToSelf(double d)
Divide each entry. The instance is changed in-place.- Specified by:
mapDivideToSelfin interfaceRealVector- Parameters:
d- Value to divide by.- Returns:
this.
-
mapExp
public RealVector mapExp()
Map theMath.exp(double)function to each entry.- Specified by:
mapExpin interfaceRealVector- Returns:
- a mapped copy of the vector.
-
mapExpToSelf
public RealVector mapExpToSelf()
MapMath.exp(double)operation to each entry. The instance is changed in-place.- Specified by:
mapExpToSelfin interfaceRealVector- Returns:
- the mapped vector.
-
mapExpm1
public RealVector mapExpm1()
Map theMath.expm1(double)function to each entry.- Specified by:
mapExpm1in interfaceRealVector- Returns:
- a vector containing the result of applying the function to each entry
-
mapExpm1ToSelf
public RealVector mapExpm1ToSelf()
Map theMath.expm1(double)function to each entry.The instance is changed by this method.
- Specified by:
mapExpm1ToSelfin interfaceRealVector- Returns:
- for convenience, return this
-
mapFloor
public RealVector mapFloor()
Map theMath.floor(double)function to each entry.- Specified by:
mapFloorin interfaceRealVector- Returns:
- a vector containing the result of applying the function to each entry
-
mapFloorToSelf
public RealVector mapFloorToSelf()
Map theMath.floor(double)function to each entry.The instance is changed by this method.
- Specified by:
mapFloorToSelfin interfaceRealVector- Returns:
- for convenience, return this
-
mapInv
public RealVector mapInv()
Map the 1/x function to each entry.- Specified by:
mapInvin interfaceRealVector- Returns:
- a vector containing the result of applying the function to each entry
-
mapInvToSelf
public RealVector mapInvToSelf()
Map the 1/x function to each entry.The instance is changed by this method.
- Specified by:
mapInvToSelfin interfaceRealVector- Returns:
- for convenience, return this
-
mapLog
public RealVector mapLog()
Map theMath.log(double)function to each entry.- Specified by:
mapLogin interfaceRealVector- Returns:
- a vector containing the result of applying the function to each entry
-
mapLogToSelf
public RealVector mapLogToSelf()
Map theMath.log(double)function to each entry.The instance is changed by this method.
- Specified by:
mapLogToSelfin interfaceRealVector- Returns:
- for convenience, return this
-
mapLog10
public RealVector mapLog10()
Map theMath.log10(double)function to each entry.- Specified by:
mapLog10in interfaceRealVector- Returns:
- a vector containing the result of applying the function to each entry
-
mapLog10ToSelf
public RealVector mapLog10ToSelf()
Map theMath.log10(double)function to each entry.The instance is changed by this method.
- Specified by:
mapLog10ToSelfin interfaceRealVector- Returns:
- for convenience, return this
-
mapLog1p
public RealVector mapLog1p()
Map theMath.log1p(double)function to each entry.- Specified by:
mapLog1pin interfaceRealVector- Returns:
- a vector containing the result of applying the function to each entry
-
mapLog1pToSelf
public RealVector mapLog1pToSelf()
Map theMath.log1p(double)function to each entry.The instance is changed by this method.
- Specified by:
mapLog1pToSelfin interfaceRealVector- Returns:
- for convenience, return this
-
mapMultiply
public RealVector mapMultiply(double d)
Multiply each entry.- Specified by:
mapMultiplyin interfaceRealVector- Parameters:
d- Multiplication factor.- Returns:
this*d.
-
mapMultiplyToSelf
public RealVector mapMultiplyToSelf(double d)
Multiply each entry. The instance is changed in-place.- Specified by:
mapMultiplyToSelfin interfaceRealVector- Parameters:
d- Multiplication factor.- Returns:
this.
-
mapPow
public RealVector mapPow(double d)
Map a power operation to each entry.- Specified by:
mapPowin interfaceRealVector- Parameters:
d- Operator value.- Returns:
- a mapped copy of the vector.
-
mapPowToSelf
public RealVector mapPowToSelf(double d)
Map a power operation to each entry. The instance is changed in-place.- Specified by:
mapPowToSelfin interfaceRealVector- Parameters:
d- Operator value.- Returns:
- the mapped vector.
-
mapRint
public RealVector mapRint()
Map theMath.rint(double)function to each entry.- Specified by:
mapRintin interfaceRealVector- Returns:
- a vector containing the result of applying the function to each entry
-
mapRintToSelf
public RealVector mapRintToSelf()
Map theMath.rint(double)function to each entry.The instance is changed by this method.
- Specified by:
mapRintToSelfin interfaceRealVector- Returns:
- for convenience, return this
-
mapSignum
public RealVector mapSignum()
Map theMath.signum(double)function to each entry.- Specified by:
mapSignumin interfaceRealVector- Returns:
- a vector containing the result of applying the function to each entry
-
mapSignumToSelf
public RealVector mapSignumToSelf()
Map theMath.signum(double)function to each entry.The instance is changed by this method.
- Specified by:
mapSignumToSelfin interfaceRealVector- Returns:
- for convenience, return this
-
mapSin
public RealVector mapSin()
Map theMath.sin(double)function to each entry.- Specified by:
mapSinin interfaceRealVector- Returns:
- a vector containing the result of applying the function to each entry
-
mapSinToSelf
public RealVector mapSinToSelf()
Map theMath.sin(double)function to each entry.The instance is changed by this method.
- Specified by:
mapSinToSelfin interfaceRealVector- Returns:
- for convenience, return this
-
mapSinh
public RealVector mapSinh()
Map theMath.sinh(double)function to each entry.- Specified by:
mapSinhin interfaceRealVector- Returns:
- a vector containing the result of applying the function to each entry
-
mapSinhToSelf
public RealVector mapSinhToSelf()
Map theMath.sinh(double)function to each entry.The instance is changed by this method.
- Specified by:
mapSinhToSelfin interfaceRealVector- Returns:
- for convenience, return this
-
mapSqrt
public RealVector mapSqrt()
Map theMath.sqrt(double)function to each entry.- Specified by:
mapSqrtin interfaceRealVector- Returns:
- a vector containing the result of applying the function to each entry
-
mapSqrtToSelf
public RealVector mapSqrtToSelf()
Map theMath.sqrt(double)function to each entry.The instance is changed by this method.
- Specified by:
mapSqrtToSelfin interfaceRealVector- Returns:
- for convenience, return this
-
mapSubtract
public RealVector mapSubtract(double d)
Subtract a value from each entry.- Specified by:
mapSubtractin interfaceRealVector- Parameters:
d- Value to be subtracted.- Returns:
this-d.
-
mapSubtractToSelf
public RealVector mapSubtractToSelf(double d)
Subtract a value from each entry. The instance is changed in-place.- Specified by:
mapSubtractToSelfin interfaceRealVector- Parameters:
d- Value to be subtracted.- Returns:
this.
-
mapTan
public RealVector mapTan()
Map theMath.tan(double)function to each entry.- Specified by:
mapTanin interfaceRealVector- Returns:
- a vector containing the result of applying the function to each entry
-
mapTanToSelf
public RealVector mapTanToSelf()
Map theMath.tan(double)function to each entry.The instance is changed by this method.
- Specified by:
mapTanToSelfin interfaceRealVector- Returns:
- for convenience, return this
-
mapTanh
public RealVector mapTanh()
Map theMath.tanh(double)function to each entry.- Specified by:
mapTanhin interfaceRealVector- Returns:
- a vector containing the result of applying the function to each entry
-
mapTanhToSelf
public RealVector mapTanhToSelf()
Map theMath.tanh(double)function to each entry.The instance is changed by this method.
- Specified by:
mapTanhToSelfin interfaceRealVector- Returns:
- for convenience, return this
-
mapUlp
public RealVector mapUlp()
Map theMath.ulp(double)function to each entry.- Specified by:
mapUlpin interfaceRealVector- Returns:
- a vector containing the result of applying the function to each entry
-
mapUlpToSelf
public RealVector mapUlpToSelf()
Map theMath.ulp(double)function to each entry.The instance is changed by this method.
- Specified by:
mapUlpToSelfin interfaceRealVector- Returns:
- for convenience, return this
-
outerProduct
public RealMatrix outerProduct(RealVector v) throws java.lang.IllegalArgumentException
Compute the outer product.- Specified by:
outerProductin interfaceRealVector- 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(double[] v) throws java.lang.IllegalArgumentException
Compute the outer product.- Specified by:
outerProductin interfaceRealVector- 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
-
projection
public RealVector projection(double[] v) throws java.lang.IllegalArgumentException
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
- Throws:
DimensionMismatchException- ifvis not the same size as this vector.java.lang.IllegalArgumentException
-
set
public void set(double value)
Set all elements to a single value.- Specified by:
setin interfaceRealVector- 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- Returns:
- array containing a copy of vector elements
-
getData
public double[] getData()
Returns vector entries as a double array.- Specified by:
getDatain interfaceRealVector- Returns:
- double array of entries
-
unitVector
public RealVector unitVector()
Creates a unit vector pointing in the direction of this vector.The instance is not changed by this method.
- Specified by:
unitVectorin interfaceRealVector- Returns:
- a unit vector pointing in direction of this vector
-
unitize
public void unitize()
Converts this vector into a unit vector.The instance itself is changed by this method.
- Specified by:
unitizein interfaceRealVector
-
sparseIterator
public java.util.Iterator<RealVector.Entry> sparseIterator()
Specialized implementations may choose to not iterate over all dimensions, either because those values are unset, or are equal to defaultValue(), or are small enough to be ignored for the purposes of iteration. No guarantees are made about order of iteration. In dense implementations, this method will often delegate toRealVector.iterator().- Specified by:
sparseIteratorin interfaceRealVector- Returns:
- a sparse iterator
-
iterator
public java.util.Iterator<RealVector.Entry> iterator()
Generic dense iterator. It iterates in increasing order of the vector index.- Specified by:
iteratorin interfaceRealVector- Returns:
- a dense iterator
-
map
public RealVector map(UnivariateRealFunction function) throws FunctionEvaluationException
Acts as if implemented as:return copy().map(function);
- Specified by:
mapin interfaceRealVector- Parameters:
function- Function to apply to each entry.- Returns:
- a new vector.
- Throws:
FunctionEvaluationException- if the function throws it.
-
mapToSelf
public RealVector mapToSelf(UnivariateRealFunction function) throws FunctionEvaluationException
Acts as if it is implemented as:Entry e = null; for(Iterator
it = iterator(); it.hasNext(); e = it.next()) { e.setValue(function.value(e.getValue())); } - Specified by:
mapToSelfin interfaceRealVector- Parameters:
function- Function to apply to each entry.- Returns:
- this vector.
- Throws:
FunctionEvaluationException- if the function throws it.
-
-