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 theRealVector
interface.- 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 RealVector
add(double[] v)
Compute the sum of this vector andv
.RealVector
add(RealVector v)
Compute the sum of this vector andv
.abstract AbstractRealVector
copy()
Returns a (deep) copy of this vector.double
dotProduct(double[] v)
Compute the dot product.double
dotProduct(RealVector v)
Compute the dot product.RealVector
ebeDivide(double[] v)
Element-by-element division.RealVector
ebeMultiply(double[] v)
Element-by-element multiplication.double[]
getData()
Returns vector entries as a double array.double
getDistance(double[] v)
Distance between two vectors.double
getDistance(RealVector v)
Distance between two vectors.double
getL1Distance(double[] v)
Distance between two vectors.double
getL1Distance(RealVector v)
Distance between two vectors.double
getL1Norm()
Returns the L1 norm of the vector.double
getLInfDistance(double[] v)
Distance between two vectors.double
getLInfDistance(RealVector v)
Distance between two vectors.double
getLInfNorm()
Returns the L∞ norm of the vector.int
getMaxIndex()
Get the index of the maximum entry.double
getMaxValue()
Get the value of the maximum entry.int
getMinIndex()
Get the index of the minimum entry.double
getMinValue()
Get the value of the minimum entry.double
getNorm()
Returns the L2 norm of the vector.java.util.Iterator<RealVector.Entry>
iterator()
Generic dense iterator.RealVector
map(UnivariateRealFunction function)
Acts as if implemented as:RealVector
mapAbs()
Map theMath.abs(double)
function to each entry.RealVector
mapAbsToSelf()
Map theMath.abs(double)
function to each entry.RealVector
mapAcos()
Map theMath.acos(double)
function to each entry.RealVector
mapAcosToSelf()
Map theMath.acos(double)
function to each entry.RealVector
mapAdd(double d)
Add a value to each entry.RealVector
mapAddToSelf(double d)
Add a value to each entry.RealVector
mapAsin()
Map theMath.asin(double)
function to each entry.RealVector
mapAsinToSelf()
Map theMath.asin(double)
function to each entry.RealVector
mapAtan()
Map theMath.atan(double)
function to each entry.RealVector
mapAtanToSelf()
Map theMath.atan(double)
function to each entry.RealVector
mapCbrt()
Map theMath.cbrt(double)
function to each entry.RealVector
mapCbrtToSelf()
Map theMath.cbrt(double)
function to each entry.RealVector
mapCeil()
Map theMath.ceil(double)
function to each entry.RealVector
mapCeilToSelf()
Map theMath.ceil(double)
function to each entry.RealVector
mapCos()
Map theMath.cos(double)
function to each entry.RealVector
mapCosh()
Map theMath.cosh(double)
function to each entry.RealVector
mapCoshToSelf()
Map theMath.cosh(double)
function to each entry.RealVector
mapCosToSelf()
Map theMath.cos(double)
function to each entry.RealVector
mapDivide(double d)
Divide each entry.RealVector
mapDivideToSelf(double d)
Divide each entry.RealVector
mapExp()
Map theMath.exp(double)
function to each entry.RealVector
mapExpm1()
Map theMath.expm1(double)
function to each entry.RealVector
mapExpm1ToSelf()
Map theMath.expm1(double)
function to each entry.RealVector
mapExpToSelf()
MapMath.exp(double)
operation to each entry.RealVector
mapFloor()
Map theMath.floor(double)
function to each entry.RealVector
mapFloorToSelf()
Map theMath.floor(double)
function to each entry.RealVector
mapInv()
Map the 1/x function to each entry.RealVector
mapInvToSelf()
Map the 1/x function to each entry.RealVector
mapLog()
Map theMath.log(double)
function to each entry.RealVector
mapLog10()
Map theMath.log10(double)
function to each entry.RealVector
mapLog10ToSelf()
Map theMath.log10(double)
function to each entry.RealVector
mapLog1p()
Map theMath.log1p(double)
function to each entry.RealVector
mapLog1pToSelf()
Map theMath.log1p(double)
function to each entry.RealVector
mapLogToSelf()
Map theMath.log(double)
function to each entry.RealVector
mapMultiply(double d)
Multiply each entry.RealVector
mapMultiplyToSelf(double d)
Multiply each entry.RealVector
mapPow(double d)
Map a power operation to each entry.RealVector
mapPowToSelf(double d)
Map a power operation to each entry.RealVector
mapRint()
Map theMath.rint(double)
function to each entry.RealVector
mapRintToSelf()
Map theMath.rint(double)
function to each entry.RealVector
mapSignum()
Map theMath.signum(double)
function to each entry.RealVector
mapSignumToSelf()
Map theMath.signum(double)
function to each entry.RealVector
mapSin()
Map theMath.sin(double)
function to each entry.RealVector
mapSinh()
Map theMath.sinh(double)
function to each entry.RealVector
mapSinhToSelf()
Map theMath.sinh(double)
function to each entry.RealVector
mapSinToSelf()
Map theMath.sin(double)
function to each entry.RealVector
mapSqrt()
Map theMath.sqrt(double)
function to each entry.RealVector
mapSqrtToSelf()
Map theMath.sqrt(double)
function to each entry.RealVector
mapSubtract(double d)
Subtract a value from each entry.RealVector
mapSubtractToSelf(double d)
Subtract a value from each entry.RealVector
mapTan()
Map theMath.tan(double)
function to each entry.RealVector
mapTanh()
Map theMath.tanh(double)
function to each entry.RealVector
mapTanhToSelf()
Map theMath.tanh(double)
function to each entry.RealVector
mapTanToSelf()
Map theMath.tan(double)
function to each entry.RealVector
mapToSelf(UnivariateRealFunction function)
Acts as if it is implemented as:RealVector
mapUlp()
Map theMath.ulp(double)
function to each entry.RealVector
mapUlpToSelf()
Map theMath.ulp(double)
function to each entry.RealMatrix
outerProduct(double[] v)
Compute the outer product.RealMatrix
outerProduct(RealVector v)
Compute the outer product.RealVector
projection(double[] v)
Find the orthogonal projection of this vector onto another vector.void
set(double value)
Set all elements to a single value.void
setSubVector(int index, double[] v)
Set a set of consecutive elements.void
setSubVector(int index, RealVector v)
Set a set of consecutive elements.java.util.Iterator<RealVector.Entry>
sparseIterator()
Specialized implementations may choose to not iterate over all dimensions, either because those values are unset, or are equal to defaultValue(), or are small enough to be ignored for the purposes of iteration.RealVector
subtract(double[] v)
Subtractv
from this vector.RealVector
subtract(RealVector v)
Subtractv
from this vector.double[]
toArray()
Convert the vector to a double array.void
unitize()
Converts this vector into a unit vector.RealVector
unitVector()
Creates a unit vector pointing in the direction of this vector.-
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 MatrixIndexException
Set a set of consecutive elements.- Specified by:
setSubVector
in 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 MatrixIndexException
Set a set of consecutive elements.- Specified by:
setSubVector
in 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:
add
in interfaceRealVector
- Parameters:
v
- Vector to be added.- Returns:
this
+v
.- Throws:
DimensionMismatchException
- ifv
is 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:
add
in interfaceRealVector
- Parameters:
v
- Vector to be added.- Returns:
this
+v
.- Throws:
DimensionMismatchException
- ifv
is not the same size as this vector.java.lang.IllegalArgumentException
-
subtract
public RealVector subtract(double[] v) throws java.lang.IllegalArgumentException
Subtractv
from this vector.- Specified by:
subtract
in interfaceRealVector
- Parameters:
v
- Vector to be subtracted.- Returns:
this
-v
.- Throws:
DimensionMismatchException
- ifv
is not the same size as this vector.java.lang.IllegalArgumentException
-
subtract
public RealVector subtract(RealVector v) throws java.lang.IllegalArgumentException
Subtractv
from this vector.- Specified by:
subtract
in interfaceRealVector
- Parameters:
v
- Vector to be subtracted.- Returns:
this
-v
.- Throws:
DimensionMismatchException
- ifv
is not the same size as this vector.java.lang.IllegalArgumentException
-
mapAdd
public RealVector mapAdd(double d)
Add a value to each entry.- Specified by:
mapAdd
in 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:
mapAddToSelf
in 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:
copy
in interfaceRealVector
- Returns:
- a vector copy.
-
dotProduct
public double dotProduct(double[] v) throws java.lang.IllegalArgumentException
Compute the dot product.- Specified by:
dotProduct
in interfaceRealVector
- Parameters:
v
- vector with which dot product should be computed- Returns:
- the scalar dot product between instance and v
- Throws:
DimensionMismatchException
- ifv
is 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:
dotProduct
in interfaceRealVector
- Parameters:
v
- vector with which dot product should be computed- Returns:
- the scalar dot product between instance and v
- Throws:
DimensionMismatchException
- ifv
is not the same size as this vector.java.lang.IllegalArgumentException
-
ebeDivide
public RealVector ebeDivide(double[] v) throws java.lang.IllegalArgumentException
Element-by-element division.- Specified by:
ebeDivide
in interfaceRealVector
- Parameters:
v
- vector by which instance elements must be divided- Returns:
- a vector containing this[i] / v[i] for all i
- Throws:
DimensionMismatchException
- ifv
is not the same size as this vector.java.lang.IllegalArgumentException
-
ebeMultiply
public RealVector ebeMultiply(double[] v) throws java.lang.IllegalArgumentException
Element-by-element multiplication.- Specified by:
ebeMultiply
in interfaceRealVector
- Parameters:
v
- vector by which instance elements must be multiplied- Returns:
- a vector containing this[i] * v[i] for all i
- Throws:
DimensionMismatchException
- ifv
is 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:
getDistance
in interfaceRealVector
- Parameters:
v
- vector to which distance is requested- Returns:
- distance between two vectors.
- Throws:
DimensionMismatchException
- ifv
is 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:
getNorm
in 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:
getL1Norm
in 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:
getLInfNorm
in interfaceRealVector
- Returns:
- norm
- See Also:
RealVector.getNorm()
,RealVector.getL1Norm()
,RealVector.getLInfDistance(RealVector)
-
getDistance
public double getDistance(double[] v) throws java.lang.IllegalArgumentException
Distance between two vectors.This method computes the distance consistent with the L2 norm, i.e. the square root of the sum of elements differences, or euclidian distance.
- Specified by:
getDistance
in interfaceRealVector
- Parameters:
v
- vector to which distance is requested- Returns:
- distance between two vectors.
- Throws:
DimensionMismatchException
- ifv
is 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:
getL1Distance
in interfaceRealVector
- Parameters:
v
- vector to which distance is requested- Returns:
- distance between two vectors.
- Throws:
DimensionMismatchException
- ifv
is not the same size as this vector.java.lang.IllegalArgumentException
- See Also:
RealVector.getDistance(RealVector)
,RealVector.getLInfDistance(RealVector)
,RealVector.getL1Norm()
-
getL1Distance
public double getL1Distance(double[] v) throws java.lang.IllegalArgumentException
Distance between two vectors.This method computes the distance consistent with L1 norm, i.e. the sum of the absolute values of elements differences.
- Specified by:
getL1Distance
in interfaceRealVector
- Parameters:
v
- vector to which distance is requested- Returns:
- distance between two vectors.
- Throws:
DimensionMismatchException
- ifv
is 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:
getLInfDistance
in interfaceRealVector
- Parameters:
v
- vector to which distance is requested- Returns:
- distance between two vectors.
- Throws:
DimensionMismatchException
- ifv
is not the same size as this vector.java.lang.IllegalArgumentException
- See Also:
RealVector.getDistance(RealVector)
,RealVector.getL1Distance(RealVector)
,RealVector.getLInfNorm()
-
getLInfDistance
public double getLInfDistance(double[] v) throws java.lang.IllegalArgumentException
Distance between two vectors.This method computes the distance consistent with L∞ norm, i.e. the max of the absolute values of elements differences.
- Specified by:
getLInfDistance
in interfaceRealVector
- Parameters:
v
- vector to which distance is requested- Returns:
- distance between two vectors.
- Throws:
DimensionMismatchException
- ifv
is 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:
mapAbs
in 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:
mapAbsToSelf
in interfaceRealVector
- Returns:
- for convenience, return this
-
mapAcos
public RealVector mapAcos()
Map theMath.acos(double)
function to each entry.- Specified by:
mapAcos
in 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:
mapAcosToSelf
in interfaceRealVector
- Returns:
- for convenience, return this
-
mapAsin
public RealVector mapAsin()
Map theMath.asin(double)
function to each entry.- Specified by:
mapAsin
in 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:
mapAsinToSelf
in interfaceRealVector
- Returns:
- for convenience, return this
-
mapAtan
public RealVector mapAtan()
Map theMath.atan(double)
function to each entry.- Specified by:
mapAtan
in 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:
mapAtanToSelf
in interfaceRealVector
- Returns:
- for convenience, return this
-
mapCbrt
public RealVector mapCbrt()
Map theMath.cbrt(double)
function to each entry.- Specified by:
mapCbrt
in 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:
mapCbrtToSelf
in interfaceRealVector
- Returns:
- for convenience, return this
-
mapCeil
public RealVector mapCeil()
Map theMath.ceil(double)
function to each entry.- Specified by:
mapCeil
in 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:
mapCeilToSelf
in interfaceRealVector
- Returns:
- for convenience, return this
-
mapCos
public RealVector mapCos()
Map theMath.cos(double)
function to each entry.- Specified by:
mapCos
in 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:
mapCosToSelf
in interfaceRealVector
- Returns:
- for convenience, return this
-
mapCosh
public RealVector mapCosh()
Map theMath.cosh(double)
function to each entry.- Specified by:
mapCosh
in 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:
mapCoshToSelf
in interfaceRealVector
- Returns:
- for convenience, return this
-
mapDivide
public RealVector mapDivide(double d)
Divide each entry.- Specified by:
mapDivide
in 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:
mapDivideToSelf
in interfaceRealVector
- Parameters:
d
- Value to divide by.- Returns:
this
.
-
mapExp
public RealVector mapExp()
Map theMath.exp(double)
function to each entry.- Specified by:
mapExp
in 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:
mapExpToSelf
in interfaceRealVector
- Returns:
- the mapped vector.
-
mapExpm1
public RealVector mapExpm1()
Map theMath.expm1(double)
function to each entry.- Specified by:
mapExpm1
in 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:
mapExpm1ToSelf
in interfaceRealVector
- Returns:
- for convenience, return this
-
mapFloor
public RealVector mapFloor()
Map theMath.floor(double)
function to each entry.- Specified by:
mapFloor
in 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:
mapFloorToSelf
in interfaceRealVector
- Returns:
- for convenience, return this
-
mapInv
public RealVector mapInv()
Map the 1/x function to each entry.- Specified by:
mapInv
in 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:
mapInvToSelf
in interfaceRealVector
- Returns:
- for convenience, return this
-
mapLog
public RealVector mapLog()
Map theMath.log(double)
function to each entry.- Specified by:
mapLog
in 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:
mapLogToSelf
in interfaceRealVector
- Returns:
- for convenience, return this
-
mapLog10
public RealVector mapLog10()
Map theMath.log10(double)
function to each entry.- Specified by:
mapLog10
in 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:
mapLog10ToSelf
in interfaceRealVector
- Returns:
- for convenience, return this
-
mapLog1p
public RealVector mapLog1p()
Map theMath.log1p(double)
function to each entry.- Specified by:
mapLog1p
in 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:
mapLog1pToSelf
in interfaceRealVector
- Returns:
- for convenience, return this
-
mapMultiply
public RealVector mapMultiply(double d)
Multiply each entry.- Specified by:
mapMultiply
in 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:
mapMultiplyToSelf
in interfaceRealVector
- Parameters:
d
- Multiplication factor.- Returns:
this
.
-
mapPow
public RealVector mapPow(double d)
Map a power operation to each entry.- Specified by:
mapPow
in 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:
mapPowToSelf
in interfaceRealVector
- Parameters:
d
- Operator value.- Returns:
- the mapped vector.
-
mapRint
public RealVector mapRint()
Map theMath.rint(double)
function to each entry.- Specified by:
mapRint
in 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:
mapRintToSelf
in interfaceRealVector
- Returns:
- for convenience, return this
-
mapSignum
public RealVector mapSignum()
Map theMath.signum(double)
function to each entry.- Specified by:
mapSignum
in 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:
mapSignumToSelf
in interfaceRealVector
- Returns:
- for convenience, return this
-
mapSin
public RealVector mapSin()
Map theMath.sin(double)
function to each entry.- Specified by:
mapSin
in 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:
mapSinToSelf
in interfaceRealVector
- Returns:
- for convenience, return this
-
mapSinh
public RealVector mapSinh()
Map theMath.sinh(double)
function to each entry.- Specified by:
mapSinh
in 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:
mapSinhToSelf
in interfaceRealVector
- Returns:
- for convenience, return this
-
mapSqrt
public RealVector mapSqrt()
Map theMath.sqrt(double)
function to each entry.- Specified by:
mapSqrt
in 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:
mapSqrtToSelf
in interfaceRealVector
- Returns:
- for convenience, return this
-
mapSubtract
public RealVector mapSubtract(double d)
Subtract a value from each entry.- Specified by:
mapSubtract
in 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:
mapSubtractToSelf
in interfaceRealVector
- Parameters:
d
- Value to be subtracted.- Returns:
this
.
-
mapTan
public RealVector mapTan()
Map theMath.tan(double)
function to each entry.- Specified by:
mapTan
in 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:
mapTanToSelf
in interfaceRealVector
- Returns:
- for convenience, return this
-
mapTanh
public RealVector mapTanh()
Map theMath.tanh(double)
function to each entry.- Specified by:
mapTanh
in 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:
mapTanhToSelf
in interfaceRealVector
- Returns:
- for convenience, return this
-
mapUlp
public RealVector mapUlp()
Map theMath.ulp(double)
function to each entry.- Specified by:
mapUlp
in 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:
mapUlpToSelf
in interfaceRealVector
- Returns:
- for convenience, return this
-
outerProduct
public RealMatrix outerProduct(RealVector v) throws java.lang.IllegalArgumentException
Compute the outer product.- Specified by:
outerProduct
in interfaceRealVector
- Parameters:
v
- vector with which outer product should be computed- Returns:
- the square matrix outer product between instance and v
- Throws:
DimensionMismatchException
- ifv
is 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:
outerProduct
in interfaceRealVector
- Parameters:
v
- vector with which outer product should be computed- Returns:
- the square matrix outer product between instance and v
- Throws:
DimensionMismatchException
- ifv
is 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:
projection
in interfaceRealVector
- Parameters:
v
- vector onto which instance must be projected- Returns:
- projection of the instance onto v
- Throws:
DimensionMismatchException
- ifv
is 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:
set
in 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:
toArray
in interfaceRealVector
- Returns:
- array containing a copy of vector elements
-
getData
public double[] getData()
Returns vector entries as a double array.- Specified by:
getData
in 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:
unitVector
in 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:
unitize
in 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:
sparseIterator
in 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:
iterator
in interfaceRealVector
- Returns:
- a dense iterator
-
map
public RealVector map(UnivariateRealFunction function) throws FunctionEvaluationException
Acts as if implemented as:return copy().map(function);
- Specified by:
map
in 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:
mapToSelf
in interfaceRealVector
- Parameters:
function
- Function to apply to each entry.- Returns:
- this vector.
- Throws:
FunctionEvaluationException
- if the function throws it.
-
-