|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface RealVector
Interface defining a real-valued vector with basic algebraic operations.
vector element indexing is 0-based -- e.g., getEntry(0)
returns the first element of the vector.
The various mapXxx
and mapXxxToSelf
methods operate
on vectors element-wise, i.e. they perform the same operation (adding a scalar,
applying a function ...) on each element in turn. The mapXxx
versions create a new vector to hold the result and do not change the instance.
The mapXxxToSelf
versions use the instance itself to store the
results, so the instance is changed by these methods. In both cases, the result
vector is returned by the methods, this allows to use the fluent API
style, like this:
RealVector result = v.mapAddToSelf(3.0).mapTanToSelf().mapSquareToSelf();
Method Summary | |
---|---|
RealVector |
add(double[] v)
Compute the sum of this and v. |
RealVector |
add(RealVector v)
Compute the sum of this and v. |
RealVector |
append(double d)
Construct a vector by appending a double to this vector. |
RealVector |
append(double[] a)
Construct a vector by appending a double array to this vector. |
RealVector |
append(RealVector v)
Construct a vector by appending a vector to this vector. |
RealVector |
copy()
Returns a (deep) copy of this. |
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 |
ebeDivide(RealVector v)
Element-by-element division. |
RealVector |
ebeMultiply(double[] v)
Element-by-element multiplication. |
RealVector |
ebeMultiply(RealVector v)
Element-by-element multiplication. |
double[] |
getData()
Returns vector entries as a double array. |
int |
getDimension()
Returns the size of the vector. |
double |
getDistance(double[] v)
Distance between two vectors. |
double |
getDistance(RealVector v)
Distance between two vectors. |
double |
getEntry(int index)
Returns the entry in the specified index. |
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. |
double |
getNorm()
Returns the L2 norm of the vector. |
RealVector |
getSubVector(int index,
int n)
Get a subvector from consecutive elements. |
boolean |
isInfinite()
Returns true if any coordinate of this vector is infinite and none are NaN; false otherwise |
boolean |
isNaN()
Returns true if any coordinate of this vector is NaN; false otherwise |
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)
Map an addition operation to each entry. |
RealVector |
mapAddToSelf(double d)
Map an addition operation 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)
Map a division operation to each entry. |
RealVector |
mapDivideToSelf(double d)
Map a division operation to 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 the Math.exp(double) function 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)
Map a multiplication operation to each entry. |
RealVector |
mapMultiplyToSelf(double d)
Map a multiplication operation to 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)
Map a subtraction operation to each entry. |
RealVector |
mapSubtractToSelf(double d)
Map a subtraction operation to 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 |
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. |
RealVector |
projection(RealVector v)
Find the orthogonal projection of this vector onto another vector. |
void |
set(double value)
Set all elements to a single value. |
void |
setEntry(int index,
double value)
Set a single element. |
void |
setSubVector(int index,
double[] v)
Set a set of consecutive elements. |
void |
setSubVector(int index,
RealVector v)
Set a set of consecutive elements. |
RealVector |
subtract(double[] v)
Compute this minus v. |
RealVector |
subtract(RealVector v)
Compute this minus v. |
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. |
Method Detail |
---|
RealVector copy()
RealVector add(RealVector v) throws IllegalArgumentException
v
- vector to be added
IllegalArgumentException
- if v is not the same size as thisRealVector add(double[] v) throws IllegalArgumentException
v
- vector to be added
IllegalArgumentException
- if v is not the same size as thisRealVector subtract(RealVector v) throws IllegalArgumentException
v
- vector to be subtracted
IllegalArgumentException
- if v is not the same size as thisRealVector subtract(double[] v) throws IllegalArgumentException
v
- vector to be subtracted
IllegalArgumentException
- if v is not the same size as thisRealVector mapAdd(double d)
d
- value to be added to each entry
RealVector mapAddToSelf(double d)
The instance is changed by this method.
d
- value to be added to each entry
RealVector mapSubtract(double d)
d
- value to be subtracted to each entry
RealVector mapSubtractToSelf(double d)
The instance is changed by this method.
d
- value to be subtracted to each entry
RealVector mapMultiply(double d)
d
- value to multiply all entries by
RealVector mapMultiplyToSelf(double d)
The instance is changed by this method.
d
- value to multiply all entries by
RealVector mapDivide(double d)
d
- value to divide all entries by
RealVector mapDivideToSelf(double d)
The instance is changed by this method.
d
- value to divide all entries by
RealVector mapPow(double d)
d
- value to raise all entries to
RealVector mapPowToSelf(double d)
The instance is changed by this method.
d
- value to raise all entries to
RealVector mapExp()
Math.exp(double)
function to each entry.
RealVector mapExpToSelf()
Math.exp(double)
function to each entry.
The instance is changed by this method.
RealVector mapExpm1()
Math.expm1(double)
function to each entry.
RealVector mapExpm1ToSelf()
Math.expm1(double)
function to each entry.
The instance is changed by this method.
RealVector mapLog()
Math.log(double)
function to each entry.
RealVector mapLogToSelf()
Math.log(double)
function to each entry.
The instance is changed by this method.
RealVector mapLog10()
Math.log10(double)
function to each entry.
RealVector mapLog10ToSelf()
Math.log10(double)
function to each entry.
The instance is changed by this method.
RealVector mapLog1p()
Math.log1p(double)
function to each entry.
RealVector mapLog1pToSelf()
Math.log1p(double)
function to each entry.
The instance is changed by this method.
RealVector mapCosh()
Math.cosh(double)
function to each entry.
RealVector mapCoshToSelf()
Math.cosh(double)
function to each entry.
The instance is changed by this method.
RealVector mapSinh()
Math.sinh(double)
function to each entry.
RealVector mapSinhToSelf()
Math.sinh(double)
function to each entry.
The instance is changed by this method.
RealVector mapTanh()
Math.tanh(double)
function to each entry.
RealVector mapTanhToSelf()
Math.tanh(double)
function to each entry.
The instance is changed by this method.
RealVector mapCos()
Math.cos(double)
function to each entry.
RealVector mapCosToSelf()
Math.cos(double)
function to each entry.
The instance is changed by this method.
RealVector mapSin()
Math.sin(double)
function to each entry.
RealVector mapSinToSelf()
Math.sin(double)
function to each entry.
The instance is changed by this method.
RealVector mapTan()
Math.tan(double)
function to each entry.
RealVector mapTanToSelf()
Math.tan(double)
function to each entry.
The instance is changed by this method.
RealVector mapAcos()
Math.acos(double)
function to each entry.
RealVector mapAcosToSelf()
Math.acos(double)
function to each entry.
The instance is changed by this method.
RealVector mapAsin()
Math.asin(double)
function to each entry.
RealVector mapAsinToSelf()
Math.asin(double)
function to each entry.
The instance is changed by this method.
RealVector mapAtan()
Math.atan(double)
function to each entry.
RealVector mapAtanToSelf()
Math.atan(double)
function to each entry.
The instance is changed by this method.
RealVector mapInv()
RealVector mapInvToSelf()
The instance is changed by this method.
RealVector mapAbs()
Math.abs(double)
function to each entry.
RealVector mapAbsToSelf()
Math.abs(double)
function to each entry.
The instance is changed by this method.
RealVector mapSqrt()
Math.sqrt(double)
function to each entry.
RealVector mapSqrtToSelf()
Math.sqrt(double)
function to each entry.
The instance is changed by this method.
RealVector mapCbrt()
Math.cbrt(double)
function to each entry.
RealVector mapCbrtToSelf()
Math.cbrt(double)
function to each entry.
The instance is changed by this method.
RealVector mapCeil()
Math.ceil(double)
function to each entry.
RealVector mapCeilToSelf()
Math.ceil(double)
function to each entry.
The instance is changed by this method.
RealVector mapFloor()
Math.floor(double)
function to each entry.
RealVector mapFloorToSelf()
Math.floor(double)
function to each entry.
The instance is changed by this method.
RealVector mapRint()
Math.rint(double)
function to each entry.
RealVector mapRintToSelf()
Math.rint(double)
function to each entry.
The instance is changed by this method.
RealVector mapSignum()
Math.signum(double)
function to each entry.
RealVector mapSignumToSelf()
Math.signum(double)
function to each entry.
The instance is changed by this method.
RealVector mapUlp()
Math.ulp(double)
function to each entry.
RealVector mapUlpToSelf()
Math.ulp(double)
function to each entry.
The instance is changed by this method.
RealVector ebeMultiply(RealVector v) throws IllegalArgumentException
v
- vector by which instance elements must be multiplied
IllegalArgumentException
- if v is not the same size as thisRealVector ebeMultiply(double[] v) throws IllegalArgumentException
v
- vector by which instance elements must be multiplied
IllegalArgumentException
- if v is not the same size as thisRealVector ebeDivide(RealVector v) throws IllegalArgumentException
v
- vector by which instance elements must be divided
IllegalArgumentException
- if v is not the same size as thisRealVector ebeDivide(double[] v) throws IllegalArgumentException
v
- vector by which instance elements must be divided
IllegalArgumentException
- if v is not the same size as thisdouble[] getData()
double dotProduct(RealVector v) throws IllegalArgumentException
v
- vector with which dot product should be computed
IllegalArgumentException
- if v is not the same size as thisdouble dotProduct(double[] v) throws IllegalArgumentException
v
- vector with which dot product should be computed
IllegalArgumentException
- if v is not the same size as thisdouble getNorm()
The L2 norm is the root of the sum of the squared elements.
getL1Norm()
,
getLInfNorm()
,
getDistance(RealVector)
double getL1Norm()
The L1 norm is the sum of the absolute values of elements.
getNorm()
,
getLInfNorm()
,
getL1Distance(RealVector)
double getLInfNorm()
The L∞ norm is the max of the absolute values of elements.
getNorm()
,
getL1Norm()
,
getLInfDistance(RealVector)
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.
v
- vector to which distance is requested
IllegalArgumentException
- if v is not the same size as thisgetL1Distance(RealVector)
,
getLInfDistance(RealVector)
,
getNorm()
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.
v
- vector to which distance is requested
IllegalArgumentException
- if v is not the same size as thisgetL1Distance(double[])
,
getLInfDistance(double[])
,
getNorm()
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.
v
- vector to which distance is requested
IllegalArgumentException
- if v is not the same size as thisgetDistance(RealVector)
,
getLInfDistance(RealVector)
,
getL1Norm()
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.
v
- vector to which distance is requested
IllegalArgumentException
- if v is not the same size as thisgetDistance(double[])
,
getLInfDistance(double[])
,
getL1Norm()
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.
v
- vector to which distance is requested
IllegalArgumentException
- if v is not the same size as thisgetDistance(RealVector)
,
getL1Distance(RealVector)
,
getLInfNorm()
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.
v
- vector to which distance is requested
IllegalArgumentException
- if v is not the same size as thisgetDistance(double[])
,
getL1Distance(double[])
,
getLInfNorm()
RealVector unitVector()
The instance is not changed by this method.
ArithmeticException
- if the norm is nullvoid unitize()
The instance itself is changed by this method.
ArithmeticException
- if the norm is nullRealVector projection(RealVector v) throws IllegalArgumentException
v
- vector onto which instance must be projected
IllegalArgumentException
- if v is not the same size as thisRealVector projection(double[] v) throws IllegalArgumentException
v
- vector onto which instance must be projected
IllegalArgumentException
- if v is not the same size as thisRealMatrix outerProduct(RealVector v) throws IllegalArgumentException
v
- vector with which outer product should be computed
IllegalArgumentException
- if v is not the same size as thisRealMatrix outerProduct(double[] v) throws IllegalArgumentException
v
- vector with which outer product should be computed
IllegalArgumentException
- if v is not the same size as thisdouble getEntry(int index) throws MatrixIndexException
The index start at 0 and must be lesser than the size,
otherwise a MatrixIndexException
is thrown.
index
- index location of entry to be fetched
MatrixIndexException
- if the index is not validsetEntry(int, double)
void setEntry(int index, double value) throws MatrixIndexException
index
- element index.value
- new value for the element.
MatrixIndexException
- if the index is
inconsistent with vector sizegetEntry(int)
int getDimension()
RealVector append(RealVector v)
v
- vector to append to this one.
RealVector append(double d)
d
- double to append.
RealVector append(double[] a)
a
- double array to append.
RealVector getSubVector(int index, int n) throws MatrixIndexException
index
- index of first element.n
- number of elements to be retrieved.
MatrixIndexException
- if the index is
inconsistent with vector sizevoid setSubVector(int index, RealVector v) throws MatrixIndexException
index
- index of first element to be set.v
- vector containing the values to set.
MatrixIndexException
- if the index is
inconsistent with vector sizesetSubVector(int, double[])
void setSubVector(int index, double[] v) throws MatrixIndexException
index
- index of first element to be set.v
- vector containing the values to set.
MatrixIndexException
- if the index is
inconsistent with vector sizesetSubVector(int, RealVector)
void set(double value)
value
- single value to set for all elementsdouble[] toArray()
The array is independent from vector data, it's elements are copied.
boolean isNaN()
boolean isInfinite()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |