|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.commons.math.linear.AbstractRealVector
public abstract class AbstractRealVector
This class provides default basic implementations for many methods in the
RealVector interface.
| Nested Class Summary | |
|---|---|
protected class |
AbstractRealVector.EntryImpl
An entry in the vector. |
protected class |
AbstractRealVector.SparseEntryIterator
This class should rare be used, but is here to provide a default implementation of sparseIterator(), which is implemented by walking over the entries, skipping those whose values are the default one. |
| Nested classes/interfaces inherited from interface org.apache.commons.math.linear.RealVector |
|---|
RealVector.Entry |
| Constructor Summary | |
|---|---|
AbstractRealVector()
|
|
| Method Summary | |
|---|---|
RealVector |
add(double[] v)
Compute the sum of this vector and v. |
RealVector |
add(RealVector v)
Compute the sum of this vector and v. |
protected void |
checkIndex(int index)
Check if an index is valid. |
protected void |
checkVectorDimensions(int n)
Check if instance dimension is equal to some expected value. |
protected void |
checkVectorDimensions(RealVector v)
Check if instance and specified vectors have the same dimension. |
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. |
Iterator<RealVector.Entry> |
iterator()
Generic dense iterator. |
RealVector |
map(UnivariateRealFunction function)
Acts as if implemented as: |
RealVector |
mapAbs()
Map the Math.abs(double) function to each entry. |
RealVector |
mapAbsToSelf()
Map the Math.abs(double) function to each entry. |
RealVector |
mapAcos()
Map the Math.acos(double) function to each entry. |
RealVector |
mapAcosToSelf()
Map the Math.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 the Math.asin(double) function to each entry. |
RealVector |
mapAsinToSelf()
Map the Math.asin(double) function to each entry. |
RealVector |
mapAtan()
Map the Math.atan(double) function to each entry. |
RealVector |
mapAtanToSelf()
Map the Math.atan(double) function to each entry. |
RealVector |
mapCbrt()
Map the Math.cbrt(double) function to each entry. |
RealVector |
mapCbrtToSelf()
Map the Math.cbrt(double) function to each entry. |
RealVector |
mapCeil()
Map the Math.ceil(double) function to each entry. |
RealVector |
mapCeilToSelf()
Map the Math.ceil(double) function to each entry. |
RealVector |
mapCos()
Map the Math.cos(double) function to each entry. |
RealVector |
mapCosh()
Map the Math.cosh(double) function to each entry. |
RealVector |
mapCoshToSelf()
Map the Math.cosh(double) function to each entry. |
RealVector |
mapCosToSelf()
Map the Math.cos(double) function to each entry. |
RealVector |
mapDivide(double d)
Divide each entry. |
RealVector |
mapDivideToSelf(double d)
Divide each entry. |
RealVector |
mapExp()
Map the Math.exp(double) function to each entry. |
RealVector |
mapExpm1()
Map the Math.expm1(double) function to each entry. |
RealVector |
mapExpm1ToSelf()
Map the Math.expm1(double) function to each entry. |
RealVector |
mapExpToSelf()
Map Math.exp(double) operation to each entry. |
RealVector |
mapFloor()
Map the Math.floor(double) function to each entry. |
RealVector |
mapFloorToSelf()
Map the Math.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 the Math.log(double) function to each entry. |
RealVector |
mapLog10()
Map the Math.log10(double) function to each entry. |
RealVector |
mapLog10ToSelf()
Map the Math.log10(double) function to each entry. |
RealVector |
mapLog1p()
Map the Math.log1p(double) function to each entry. |
RealVector |
mapLog1pToSelf()
Map the Math.log1p(double) function to each entry. |
RealVector |
mapLogToSelf()
Map the Math.log(double) function to each entry. |
RealVector |
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 the Math.rint(double) function to each entry. |
RealVector |
mapRintToSelf()
Map the Math.rint(double) function to each entry. |
RealVector |
mapSignum()
Map the Math.signum(double) function to each entry. |
RealVector |
mapSignumToSelf()
Map the Math.signum(double) function to each entry. |
RealVector |
mapSin()
Map the Math.sin(double) function to each entry. |
RealVector |
mapSinh()
Map the Math.sinh(double) function to each entry. |
RealVector |
mapSinhToSelf()
Map the Math.sinh(double) function to each entry. |
RealVector |
mapSinToSelf()
Map the Math.sin(double) function to each entry. |
RealVector |
mapSqrt()
Map the Math.sqrt(double) function to each entry. |
RealVector |
mapSqrtToSelf()
Map the Math.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 the Math.tan(double) function to each entry. |
RealVector |
mapTanh()
Map the Math.tanh(double) function to each entry. |
RealVector |
mapTanhToSelf()
Map the Math.tanh(double) function to each entry. |
RealVector |
mapTanToSelf()
Map the Math.tan(double) function to each entry. |
RealVector |
mapToSelf(UnivariateRealFunction function)
Acts as if it is implemented as: |
RealVector |
mapUlp()
Map the Math.ulp(double) function to each entry. |
RealVector |
mapUlpToSelf()
Map the Math.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. |
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)
Subtract v from this vector. |
RealVector |
subtract(RealVector v)
Subtract v 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 |
|---|
clone, equals, finalize, 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 |
| Constructor Detail |
|---|
public AbstractRealVector()
| Method Detail |
|---|
protected void checkVectorDimensions(RealVector v)
v - vector to compare instance with
DimensionMismatchException - if the vectors do not
have the same dimension
protected void checkVectorDimensions(int n)
throws DimensionMismatchException
n - expected dimension.
DimensionMismatchException - if the dimension is
inconsistent with vector size
protected void checkIndex(int index)
throws MatrixIndexException
index - index to check
MatrixIndexException - if index is not valid
public void setSubVector(int index,
RealVector v)
throws MatrixIndexException
setSubVector in interface RealVectorindex - index of first element to be set.v - vector containing the values to set.
MatrixIndexExceptionRealVector.setSubVector(int, double[])
public void setSubVector(int index,
double[] v)
throws MatrixIndexException
setSubVector in interface RealVectorindex - index of first element to be set.v - vector containing the values to set.
MatrixIndexExceptionRealVector.setSubVector(int, RealVector)
public RealVector add(double[] v)
throws IllegalArgumentException
v.
add in interface RealVectorv - Vector to be added.
this + v.
DimensionMismatchException - if v is not the same size as this vector.
IllegalArgumentException
public RealVector add(RealVector v)
throws IllegalArgumentException
v.
add in interface RealVectorv - Vector to be added.
this + v.
DimensionMismatchException - if v is not the same size as this vector.
IllegalArgumentException
public RealVector subtract(double[] v)
throws IllegalArgumentException
v from this vector.
subtract in interface RealVectorv - Vector to be subtracted.
this - v.
DimensionMismatchException - if v is not the same size as this vector.
IllegalArgumentException
public RealVector subtract(RealVector v)
throws IllegalArgumentException
v from this vector.
subtract in interface RealVectorv - Vector to be subtracted.
this - v.
DimensionMismatchException - if v is not the same size as this vector.
IllegalArgumentExceptionpublic RealVector mapAdd(double d)
mapAdd in interface RealVectord - Value to be added to each entry.
this + d.public RealVector mapAddToSelf(double d)
mapAddToSelf in interface RealVectord - Value to be added to each entry.
this.public abstract AbstractRealVector copy()
copy in interface RealVector
public double dotProduct(double[] v)
throws IllegalArgumentException
dotProduct in interface RealVectorv - vector with which dot product should be computed
DimensionMismatchException - if v is not the same size as this vector.
IllegalArgumentException
public double dotProduct(RealVector v)
throws IllegalArgumentException
dotProduct in interface RealVectorv - vector with which dot product should be computed
DimensionMismatchException - if v is not the same size as this vector.
IllegalArgumentException
public RealVector ebeDivide(double[] v)
throws IllegalArgumentException
ebeDivide in interface RealVectorv - vector by which instance elements must be divided
DimensionMismatchException - if v is not the same size as this vector.
IllegalArgumentException
public RealVector ebeMultiply(double[] v)
throws IllegalArgumentException
ebeMultiply in interface RealVectorv - vector by which instance elements must be multiplied
DimensionMismatchException - if v is not the same size as this vector.
IllegalArgumentException
public double getDistance(RealVector v)
throws IllegalArgumentException
This method computes the distance consistent with the L2 norm, i.e. the square root of the sum of elements differences, or euclidian distance.
getDistance in interface RealVectorv - vector to which distance is requested
DimensionMismatchException - if v is not the same size as this vector.
IllegalArgumentExceptionRealVector.getL1Distance(RealVector),
RealVector.getLInfDistance(RealVector),
RealVector.getNorm()public double getNorm()
The L2 norm is the root of the sum of the squared elements.
getNorm in interface RealVectorRealVector.getL1Norm(),
RealVector.getLInfNorm(),
RealVector.getDistance(RealVector)public double getL1Norm()
The L1 norm is the sum of the absolute values of elements.
getL1Norm in interface RealVectorRealVector.getNorm(),
RealVector.getLInfNorm(),
RealVector.getL1Distance(RealVector)public double getLInfNorm()
The L∞ norm is the max of the absolute values of elements.
getLInfNorm in interface RealVectorRealVector.getNorm(),
RealVector.getL1Norm(),
RealVector.getLInfDistance(RealVector)
public double getDistance(double[] v)
throws IllegalArgumentException
This method computes the distance consistent with the L2 norm, i.e. the square root of the sum of elements differences, or euclidian distance.
getDistance in interface RealVectorv - vector to which distance is requested
DimensionMismatchException - if v is not the same size as this vector.
IllegalArgumentExceptionRealVector.getL1Distance(double[]),
RealVector.getLInfDistance(double[]),
RealVector.getNorm()
public double getL1Distance(RealVector v)
throws IllegalArgumentException
This method computes the distance consistent with L1 norm, i.e. the sum of the absolute values of elements differences.
getL1Distance in interface RealVectorv - vector to which distance is requested
DimensionMismatchException - if v is not the same size as this vector.
IllegalArgumentExceptionRealVector.getDistance(RealVector),
RealVector.getLInfDistance(RealVector),
RealVector.getL1Norm()
public double getL1Distance(double[] v)
throws IllegalArgumentException
This method computes the distance consistent with L1 norm, i.e. the sum of the absolute values of elements differences.
getL1Distance in interface RealVectorv - vector to which distance is requested
DimensionMismatchException - if v is not the same size as this vector.
IllegalArgumentExceptionRealVector.getDistance(double[]),
RealVector.getLInfDistance(double[]),
RealVector.getL1Norm()
public double getLInfDistance(RealVector v)
throws IllegalArgumentException
This method computes the distance consistent with L∞ norm, i.e. the max of the absolute values of elements differences.
getLInfDistance in interface RealVectorv - vector to which distance is requested
DimensionMismatchException - if v is not the same size as this vector.
IllegalArgumentExceptionRealVector.getDistance(RealVector),
RealVector.getL1Distance(RealVector),
RealVector.getLInfNorm()
public double getLInfDistance(double[] v)
throws IllegalArgumentException
This method computes the distance consistent with L∞ norm, i.e. the max of the absolute values of elements differences.
getLInfDistance in interface RealVectorv - vector to which distance is requested
DimensionMismatchException - if v is not the same size as this vector.
IllegalArgumentExceptionRealVector.getDistance(double[]),
RealVector.getL1Distance(double[]),
RealVector.getLInfNorm()public int getMinIndex()
public double getMinValue()
public int getMaxIndex()
public double getMaxValue()
public RealVector mapAbs()
Math.abs(double) function to each entry.
mapAbs in interface RealVectorpublic RealVector mapAbsToSelf()
Math.abs(double) function to each entry.
The instance is changed by this method.
mapAbsToSelf in interface RealVectorpublic RealVector mapAcos()
Math.acos(double) function to each entry.
mapAcos in interface RealVectorpublic RealVector mapAcosToSelf()
Math.acos(double) function to each entry.
The instance is changed by this method.
mapAcosToSelf in interface RealVectorpublic RealVector mapAsin()
Math.asin(double) function to each entry.
mapAsin in interface RealVectorpublic RealVector mapAsinToSelf()
Math.asin(double) function to each entry.
The instance is changed by this method.
mapAsinToSelf in interface RealVectorpublic RealVector mapAtan()
Math.atan(double) function to each entry.
mapAtan in interface RealVectorpublic RealVector mapAtanToSelf()
Math.atan(double) function to each entry.
The instance is changed by this method.
mapAtanToSelf in interface RealVectorpublic RealVector mapCbrt()
Math.cbrt(double) function to each entry.
mapCbrt in interface RealVectorpublic RealVector mapCbrtToSelf()
Math.cbrt(double) function to each entry.
The instance is changed by this method.
mapCbrtToSelf in interface RealVectorpublic RealVector mapCeil()
Math.ceil(double) function to each entry.
mapCeil in interface RealVectorpublic RealVector mapCeilToSelf()
Math.ceil(double) function to each entry.
The instance is changed by this method.
mapCeilToSelf in interface RealVectorpublic RealVector mapCos()
Math.cos(double) function to each entry.
mapCos in interface RealVectorpublic RealVector mapCosToSelf()
Math.cos(double) function to each entry.
The instance is changed by this method.
mapCosToSelf in interface RealVectorpublic RealVector mapCosh()
Math.cosh(double) function to each entry.
mapCosh in interface RealVectorpublic RealVector mapCoshToSelf()
Math.cosh(double) function to each entry.
The instance is changed by this method.
mapCoshToSelf in interface RealVectorpublic RealVector mapDivide(double d)
mapDivide in interface RealVectord - Value to divide by.
this / d.public RealVector mapDivideToSelf(double d)
mapDivideToSelf in interface RealVectord - Value to divide by.
this.public RealVector mapExp()
Math.exp(double) function to each entry.
mapExp in interface RealVectorpublic RealVector mapExpToSelf()
Math.exp(double) operation to each entry.
The instance is changed in-place.
mapExpToSelf in interface RealVectorpublic RealVector mapExpm1()
Math.expm1(double) function to each entry.
mapExpm1 in interface RealVectorpublic RealVector mapExpm1ToSelf()
Math.expm1(double) function to each entry.
The instance is changed by this method.
mapExpm1ToSelf in interface RealVectorpublic RealVector mapFloor()
Math.floor(double) function to each entry.
mapFloor in interface RealVectorpublic RealVector mapFloorToSelf()
Math.floor(double) function to each entry.
The instance is changed by this method.
mapFloorToSelf in interface RealVectorpublic RealVector mapInv()
mapInv in interface RealVectorpublic RealVector mapInvToSelf()
The instance is changed by this method.
mapInvToSelf in interface RealVectorpublic RealVector mapLog()
Math.log(double) function to each entry.
mapLog in interface RealVectorpublic RealVector mapLogToSelf()
Math.log(double) function to each entry.
The instance is changed by this method.
mapLogToSelf in interface RealVectorpublic RealVector mapLog10()
Math.log10(double) function to each entry.
mapLog10 in interface RealVectorpublic RealVector mapLog10ToSelf()
Math.log10(double) function to each entry.
The instance is changed by this method.
mapLog10ToSelf in interface RealVectorpublic RealVector mapLog1p()
Math.log1p(double) function to each entry.
mapLog1p in interface RealVectorpublic RealVector mapLog1pToSelf()
Math.log1p(double) function to each entry.
The instance is changed by this method.
mapLog1pToSelf in interface RealVectorpublic RealVector mapMultiply(double d)
mapMultiply in interface RealVectord - Multiplication factor.
this * d.public RealVector mapMultiplyToSelf(double d)
mapMultiplyToSelf in interface RealVectord - Multiplication factor.
this.public RealVector mapPow(double d)
mapPow in interface RealVectord - Operator value.
public RealVector mapPowToSelf(double d)
mapPowToSelf in interface RealVectord - Operator value.
public RealVector mapRint()
Math.rint(double) function to each entry.
mapRint in interface RealVectorpublic RealVector mapRintToSelf()
Math.rint(double) function to each entry.
The instance is changed by this method.
mapRintToSelf in interface RealVectorpublic RealVector mapSignum()
Math.signum(double) function to each entry.
mapSignum in interface RealVectorpublic RealVector mapSignumToSelf()
Math.signum(double) function to each entry.
The instance is changed by this method.
mapSignumToSelf in interface RealVectorpublic RealVector mapSin()
Math.sin(double) function to each entry.
mapSin in interface RealVectorpublic RealVector mapSinToSelf()
Math.sin(double) function to each entry.
The instance is changed by this method.
mapSinToSelf in interface RealVectorpublic RealVector mapSinh()
Math.sinh(double) function to each entry.
mapSinh in interface RealVectorpublic RealVector mapSinhToSelf()
Math.sinh(double) function to each entry.
The instance is changed by this method.
mapSinhToSelf in interface RealVectorpublic RealVector mapSqrt()
Math.sqrt(double) function to each entry.
mapSqrt in interface RealVectorpublic RealVector mapSqrtToSelf()
Math.sqrt(double) function to each entry.
The instance is changed by this method.
mapSqrtToSelf in interface RealVectorpublic RealVector mapSubtract(double d)
mapSubtract in interface RealVectord - Value to be subtracted.
this - d.public RealVector mapSubtractToSelf(double d)
mapSubtractToSelf in interface RealVectord - Value to be subtracted.
this.public RealVector mapTan()
Math.tan(double) function to each entry.
mapTan in interface RealVectorpublic RealVector mapTanToSelf()
Math.tan(double) function to each entry.
The instance is changed by this method.
mapTanToSelf in interface RealVectorpublic RealVector mapTanh()
Math.tanh(double) function to each entry.
mapTanh in interface RealVectorpublic RealVector mapTanhToSelf()
Math.tanh(double) function to each entry.
The instance is changed by this method.
mapTanhToSelf in interface RealVectorpublic RealVector mapUlp()
Math.ulp(double) function to each entry.
mapUlp in interface RealVectorpublic RealVector mapUlpToSelf()
Math.ulp(double) function to each entry.
The instance is changed by this method.
mapUlpToSelf in interface RealVector
public RealMatrix outerProduct(RealVector v)
throws IllegalArgumentException
outerProduct in interface RealVectorv - vector with which outer product should be computed
DimensionMismatchException - if v is not the same size as this vector.
IllegalArgumentException
public RealMatrix outerProduct(double[] v)
throws IllegalArgumentException
outerProduct in interface RealVectorv - vector with which outer product should be computed
DimensionMismatchException - if v is not the same size as this vector.
IllegalArgumentException
public RealVector projection(double[] v)
throws IllegalArgumentException
projection in interface RealVectorv - vector onto which instance must be projected
DimensionMismatchException - if v is not the same size as this vector.
IllegalArgumentExceptionpublic void set(double value)
set in interface RealVectorvalue - single value to set for all elementspublic double[] toArray()
The array is independent from vector data, it's elements are copied.
toArray in interface RealVectorpublic double[] getData()
getData in interface RealVectorpublic RealVector unitVector()
The instance is not changed by this method.
unitVector in interface RealVectorpublic void unitize()
The instance itself is changed by this method.
unitize in interface RealVectorpublic Iterator<RealVector.Entry> sparseIterator()
RealVector.iterator().
sparseIterator in interface RealVectorpublic Iterator<RealVector.Entry> iterator()
iterator in interface RealVector
public RealVector map(UnivariateRealFunction function)
throws FunctionEvaluationException
return copy().map(function);
map in interface RealVectorfunction - Function to apply to each entry.
FunctionEvaluationException - if the function throws it.
public RealVector mapToSelf(UnivariateRealFunction function)
throws FunctionEvaluationException
Entry e = null; for(Iteratorit = iterator(); it.hasNext(); e = it.next()) { e.setValue(function.value(e.getValue())); }
mapToSelf in interface RealVectorfunction - Function to apply to each entry.
FunctionEvaluationException - if the function throws it.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||