Class ArrayRealVector
- java.lang.Object
-
- org.apache.commons.math4.legacy.linear.RealVector
-
- org.apache.commons.math4.legacy.linear.ArrayRealVector
-
- All Implemented Interfaces:
Serializable
public class ArrayRealVector extends RealVector implements Serializable
This class implements theRealVectorinterface with a double array.- Since:
- 2.0
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.commons.math4.legacy.linear.RealVector
RealVector.Entry, RealVector.SparseEntryIterator
-
-
Constructor Summary
Constructors Constructor Description ArrayRealVector()Build a 0-length vector.ArrayRealVector(double[] d)Construct a vector from an array, copying the input array.ArrayRealVector(double[] d, boolean copyArray)Create a new ArrayRealVector using the input array as the underlying data array.ArrayRealVector(double[] v1, double[] v2)Construct a vector by appending one vector to another vector.ArrayRealVector(double[] d, int pos, int size)Construct a vector from part of a array.ArrayRealVector(double[] v1, ArrayRealVector v2)Construct a vector by appending one vector to another vector.ArrayRealVector(int size)Construct a vector of zeroes.ArrayRealVector(int size, double preset)Construct a vector with preset values.ArrayRealVector(Double[] d)Construct a vector from an array.ArrayRealVector(Double[] d, int pos, int size)Construct a vector from part of an array.ArrayRealVector(ArrayRealVector v)Construct a vector from another vector, using a deep copy.ArrayRealVector(ArrayRealVector v, boolean deep)Construct a vector from another vector.ArrayRealVector(ArrayRealVector v1, double[] v2)Construct a vector by appending one vector to another vector.ArrayRealVector(ArrayRealVector v1, ArrayRealVector v2)Construct a vector by appending one vector to another vector.ArrayRealVector(ArrayRealVector v1, RealVector v2)Construct a vector by appending one vector to another vector.ArrayRealVector(RealVector v)Construct a vector from another vector, using a deep copy.ArrayRealVector(RealVector v1, ArrayRealVector v2)Construct a vector by appending one vector to another vector.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ArrayRealVectoradd(RealVector v)Compute the sum of this vector andv.voidaddToEntry(int index, double increment)Change an entry at the specified index.RealVectorappend(double in)Construct a new vector by appending a double to this vector.ArrayRealVectorappend(ArrayRealVector v)Construct a vector by appending a vector to this vector.RealVectorappend(RealVector v)Construct a new vector by appending a vector to this vector.protected voidcheckVectorDimensions(int n)Check if instance dimension is equal to some expected value.protected voidcheckVectorDimensions(RealVector v)Check if instance and specified vectors have the same dimension.ArrayRealVectorcombine(double a, double b, RealVector y)Returns a new vector representinga * this + b * y, the linear combination ofthisandy.ArrayRealVectorcombineToSelf(double a, double b, RealVector y)Updatesthiswith the linear combination ofthisandy.ArrayRealVectorcopy()Returns a (deep) copy of this vector.doubledotProduct(RealVector v)Compute the dot product of this vector withv.ArrayRealVectorebeDivide(RealVector v)Element-by-element division.ArrayRealVectorebeMultiply(RealVector v)Element-by-element multiplication.booleanequals(Object other)Test for the equality of two real vectors.double[]getDataRef()Get a reference to the underlying data array.intgetDimension()Returns the size of the vector.doublegetDistance(RealVector v)Distance between two vectors.doublegetEntry(int index)Return the entry at the specified index.doublegetL1Distance(RealVector v)Distance between two vectors.doublegetL1Norm()Returns the L1 norm of the vector.doublegetLInfDistance(RealVector v)Distance between two vectors.doublegetLInfNorm()Returns the L∞ norm of the vector.doublegetNorm()Returns the L2 norm of the vector.RealVectorgetSubVector(int index, int n)Get a subvector from consecutive elements.inthashCode().booleanisInfinite()Check whether any coordinate of this vector is infinite and none areNaN.booleanisNaN()Check if any coordinate of this vector isNaN.ArrayRealVectormap(UnivariateFunction function)Acts as if implemented as:RealVectormapAddToSelf(double d)Add a value to each entry.RealVectormapDivideToSelf(double d)Divide each entry by the argument.RealVectormapMultiplyToSelf(double d)Multiply each entry.RealVectormapSubtractToSelf(double d)Subtract a value from each entry.ArrayRealVectormapToSelf(UnivariateFunction function)Acts as if it is implemented as:Entry e = null; for(Iterator<Entry> it = iterator(); it.hasNext(); e = it.next()) { e.setValue(function.value(e.getValue())); }Entries of this vector are modified in-place by this method.RealMatrixouterProduct(RealVector v)Compute the outer product.voidset(double value)Set all elements to a single value.voidsetEntry(int index, double value)Set a single element.voidsetSubVector(int index, double[] v)Set a set of consecutive elements.voidsetSubVector(int index, RealVector v)Set a sequence of consecutive elements.ArrayRealVectorsubtract(RealVector v)Subtractvfrom this vector.double[]toArray()Convert the vector to an array ofdoubles.StringtoString()doublewalkInDefaultOrder(RealVectorChangingVisitor visitor)Visits (and possibly alters) all entries of this vector in default order (increasing index).doublewalkInDefaultOrder(RealVectorChangingVisitor visitor, int start, int end)Visits (and possibly alters) some entries of this vector in default order (increasing index).doublewalkInDefaultOrder(RealVectorPreservingVisitor visitor)Visits (but does not alter) all entries of this vector in default order (increasing index).doublewalkInDefaultOrder(RealVectorPreservingVisitor visitor, int start, int end)Visits (but does not alter) some entries of this vector in default order (increasing index).doublewalkInOptimizedOrder(RealVectorChangingVisitor visitor)Visits (and possibly alters) all entries of this vector in optimized order.doublewalkInOptimizedOrder(RealVectorChangingVisitor visitor, int start, int end)Visits (and possibly change) some entries of this vector in optimized order.doublewalkInOptimizedOrder(RealVectorPreservingVisitor visitor)Visits (but does not alter) all entries of this vector in optimized order.doublewalkInOptimizedOrder(RealVectorPreservingVisitor visitor, int start, int end)Visits (but does not alter) some entries of this vector in optimized order.-
Methods inherited from class org.apache.commons.math4.legacy.linear.RealVector
checkIndex, checkIndices, cosine, getMaxIndex, getMaxValue, getMinIndex, getMinValue, iterator, mapAdd, mapDivide, mapMultiply, mapSubtract, projection, sparseIterator, unitize, unitVector, unmodifiableRealVector
-
-
-
-
Constructor Detail
-
ArrayRealVector
public ArrayRealVector()
Build a 0-length vector. Zero-length vectors may be used to initialized construction of vectors by data gathering. We start with zero-length and use either theArrayRealVector(ArrayRealVector, ArrayRealVector)constructor or one of theappendmethod (append(double),append(ArrayRealVector)) to gather data into this vector.
-
ArrayRealVector
public ArrayRealVector(int size)
Construct a vector of zeroes.- Parameters:
size- Size of the vector.
-
ArrayRealVector
public ArrayRealVector(int size, double preset)
Construct a vector with preset values.- Parameters:
size- Size of the vectorpreset- All entries will be set with this value.
-
ArrayRealVector
public ArrayRealVector(double[] d)
Construct a vector from an array, copying the input array.- Parameters:
d- Array.
-
ArrayRealVector
public ArrayRealVector(double[] d, boolean copyArray) throws NullArgumentException
Create a new ArrayRealVector using the input array as the underlying data array. If an array is built specially in order to be embedded in a ArrayRealVector and not used directly, thecopyArraymay be set tofalse. This will prevent the copying and improve performance as no new array will be built and no data will be copied.- Parameters:
d- Data for the new vector.copyArray- iftrue, the input array will be copied, otherwise it will be referenced.- Throws:
NullArgumentException- ifdisnull.- See Also:
ArrayRealVector(double[])
-
ArrayRealVector
public ArrayRealVector(double[] d, int pos, int size) throws NullArgumentException, NumberIsTooLargeException
Construct a vector from part of a array.- Parameters:
d- Array.pos- Position of first entry.size- Number of entries to copy.- Throws:
NullArgumentException- ifdisnull.NumberIsTooLargeException- if the size ofdis less thanpos + size.
-
ArrayRealVector
public ArrayRealVector(Double[] d)
Construct a vector from an array.- Parameters:
d- Array ofDoubles.
-
ArrayRealVector
public ArrayRealVector(Double[] d, int pos, int size) throws NullArgumentException, NumberIsTooLargeException
Construct a vector from part of an array.- Parameters:
d- Array.pos- Position of first entry.size- Number of entries to copy.- Throws:
NullArgumentException- ifdisnull.NumberIsTooLargeException- if the size ofdis less thanpos + size.
-
ArrayRealVector
public ArrayRealVector(RealVector v) throws NullArgumentException
Construct a vector from another vector, using a deep copy.- Parameters:
v- vector to copy.- Throws:
NullArgumentException- ifvisnull.
-
ArrayRealVector
public ArrayRealVector(ArrayRealVector v) throws NullArgumentException
Construct a vector from another vector, using a deep copy.- Parameters:
v- Vector to copy.- Throws:
NullArgumentException- ifvisnull.
-
ArrayRealVector
public ArrayRealVector(ArrayRealVector v, boolean deep)
Construct a vector from another vector.- Parameters:
v- Vector to copy.deep- Iftrueperform a deep copy, otherwise perform a shallow copy.
-
ArrayRealVector
public ArrayRealVector(ArrayRealVector v1, ArrayRealVector v2)
Construct a vector by appending one vector to another vector.- Parameters:
v1- First vector (will be put in front of the new vector).v2- Second vector (will be put at back of the new vector).
-
ArrayRealVector
public ArrayRealVector(ArrayRealVector v1, RealVector v2)
Construct a vector by appending one vector to another vector.- Parameters:
v1- First vector (will be put in front of the new vector).v2- Second vector (will be put at back of the new vector).
-
ArrayRealVector
public ArrayRealVector(RealVector v1, ArrayRealVector v2)
Construct a vector by appending one vector to another vector.- Parameters:
v1- First vector (will be put in front of the new vector).v2- Second vector (will be put at back of the new vector).
-
ArrayRealVector
public ArrayRealVector(ArrayRealVector v1, double[] v2)
Construct a vector by appending one vector to another vector.- Parameters:
v1- First vector (will be put in front of the new vector).v2- Second vector (will be put at back of the new vector).
-
ArrayRealVector
public ArrayRealVector(double[] v1, ArrayRealVector v2)
Construct a vector by appending one vector to another vector.- Parameters:
v1- First vector (will be put in front of the new vector).v2- Second vector (will be put at back of the new vector).
-
ArrayRealVector
public ArrayRealVector(double[] v1, double[] v2)
Construct a vector by appending one vector to another vector.- Parameters:
v1- first vector (will be put in front of the new vector)v2- second vector (will be put at back of the new vector)
-
-
Method Detail
-
copy
public ArrayRealVector copy()
Returns a (deep) copy of this vector.- Specified by:
copyin classRealVector- Returns:
- a vector copy.
-
add
public ArrayRealVector add(RealVector v) throws DimensionMismatchException
Compute the sum of this vector andv. Returns a new vector. Does not change instance data.- Overrides:
addin classRealVector- Parameters:
v- Vector to be added.- Returns:
this+v.- Throws:
DimensionMismatchException- ifvis not the same size asthisvector.
-
subtract
public ArrayRealVector subtract(RealVector v) throws DimensionMismatchException
Subtractvfrom this vector. Returns a new vector. Does not change instance data.- Overrides:
subtractin classRealVector- Parameters:
v- Vector to be subtracted.- Returns:
this-v.- Throws:
DimensionMismatchException- ifvis not the same size asthisvector.
-
map
public ArrayRealVector map(UnivariateFunction function)
Acts as if implemented as:return copy().mapToSelf(function);
Returns a new vector. Does not change instance data.- Overrides:
mapin classRealVector- Parameters:
function- Function to apply to each entry.- Returns:
- a new vector.
-
mapToSelf
public ArrayRealVector mapToSelf(UnivariateFunction function)
Acts as if it is implemented as:Entry e = null; for(Iterator<Entry> it = iterator(); it.hasNext(); e = it.next()) { e.setValue(function.value(e.getValue())); }Entries of this vector are modified in-place by this method.- Overrides:
mapToSelfin classRealVector- Parameters:
function- Function to apply to each entry.- Returns:
- a reference to this vector.
-
mapAddToSelf
public RealVector mapAddToSelf(double d)
Add a value to each entry. The instance is changed in-place.- Overrides:
mapAddToSelfin classRealVector- Parameters:
d- Value to be added to each entry.- Returns:
this.
-
mapSubtractToSelf
public RealVector mapSubtractToSelf(double d)
Subtract a value from each entry. The instance is changed in-place.- Overrides:
mapSubtractToSelfin classRealVector- Parameters:
d- Value to be subtracted.- Returns:
this.
-
mapMultiplyToSelf
public RealVector mapMultiplyToSelf(double d)
Multiply each entry. The instance is changed in-place.- Overrides:
mapMultiplyToSelfin classRealVector- Parameters:
d- Multiplication factor.- Returns:
this.
-
mapDivideToSelf
public RealVector mapDivideToSelf(double d)
Divide each entry by the argument. The instance is changed in-place.- Overrides:
mapDivideToSelfin classRealVector- Parameters:
d- Value to divide by.- Returns:
this.
-
ebeMultiply
public ArrayRealVector ebeMultiply(RealVector v) throws DimensionMismatchException
Element-by-element multiplication.- Specified by:
ebeMultiplyin classRealVector- 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 asthisvector.
-
ebeDivide
public ArrayRealVector ebeDivide(RealVector v) throws DimensionMismatchException
Element-by-element division.- Specified by:
ebeDividein classRealVector- 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 asthisvector.
-
getDataRef
public double[] getDataRef()
Get a reference to the underlying data array. This method does not make a fresh copy of the underlying data.- Returns:
- the array of entries.
-
dotProduct
public double dotProduct(RealVector v) throws DimensionMismatchException
Compute the dot product of this vector withv.- Overrides:
dotProductin classRealVector- Parameters:
v- Vector with which dot product should be computed- Returns:
- the scalar dot product between this instance and
v. - Throws:
DimensionMismatchException- ifvis not the same size asthisvector.
-
getNorm
public double getNorm()
Returns the L2 norm of the vector.The L2 norm is the root of the sum of the squared elements.
- Overrides:
getNormin classRealVector- Returns:
- the 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 the elements.
- Overrides:
getL1Normin classRealVector- Returns:
- the 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 the elements.
- Overrides:
getLInfNormin classRealVector- Returns:
- the norm.
- See Also:
RealVector.getNorm(),RealVector.getL1Norm(),RealVector.getLInfDistance(RealVector)
-
getDistance
public double getDistance(RealVector v) throws DimensionMismatchException
Distance between two vectors.This method computes the distance consistent with the L2 norm, i.e. the square root of the sum of element differences, or Euclidean distance.
- Overrides:
getDistancein classRealVector- Parameters:
v- Vector to which distance is requested.- Returns:
- the distance between two vectors.
- Throws:
DimensionMismatchException- ifvis not the same size asthisvector.- See Also:
RealVector.getL1Distance(RealVector),RealVector.getLInfDistance(RealVector),RealVector.getNorm()
-
getL1Distance
public double getL1Distance(RealVector v) throws DimensionMismatchException
Distance between two vectors.This method computes the distance consistent with L1 norm, i.e. the sum of the absolute values of the elements differences.
- Overrides:
getL1Distancein classRealVector- Parameters:
v- Vector to which distance is requested.- Returns:
- the distance between two vectors.
- Throws:
DimensionMismatchException- ifvis not the same size asthisvector.
-
getLInfDistance
public double getLInfDistance(RealVector v) throws DimensionMismatchException
Distance between two vectors.This method computes the distance consistent with L∞ norm, i.e. the max of the absolute values of element differences.
- Overrides:
getLInfDistancein classRealVector- Parameters:
v- Vector to which distance is requested.- Returns:
- the distance between two vectors.
- Throws:
DimensionMismatchException- ifvis not the same size asthisvector.- See Also:
RealVector.getDistance(RealVector),RealVector.getL1Distance(RealVector),RealVector.getLInfNorm()
-
outerProduct
public RealMatrix outerProduct(RealVector v)
Compute the outer product.- Overrides:
outerProductin classRealVector- Parameters:
v- Vector with which outer product should be computed.- Returns:
- the matrix outer product between this instance and
v.
-
getEntry
public double getEntry(int index) throws OutOfRangeException
Return the entry at the specified index.- Specified by:
getEntryin classRealVector- Parameters:
index- Index location of entry to be fetched.- Returns:
- the vector entry at
index. - Throws:
OutOfRangeException- if the index is not valid.- See Also:
RealVector.setEntry(int, double)
-
getDimension
public int getDimension()
Returns the size of the vector.- Specified by:
getDimensionin classRealVector- Returns:
- the size of this vector.
-
append
public RealVector append(RealVector v)
Construct a new vector by appending a vector to this vector.- Specified by:
appendin classRealVector- Parameters:
v- vector to append to this one.- Returns:
- a new vector.
-
append
public ArrayRealVector append(ArrayRealVector v)
Construct a vector by appending a vector to this vector.- Parameters:
v- Vector to append to this one.- Returns:
- a new vector.
-
append
public RealVector append(double in)
Construct a new vector by appending a double to this vector.- Specified by:
appendin classRealVector- Parameters:
in- double to append.- Returns:
- a new vector.
-
getSubVector
public RealVector getSubVector(int index, int n) throws OutOfRangeException, NotPositiveException
Get a subvector from consecutive elements.- Specified by:
getSubVectorin classRealVector- Parameters:
index- index of first element.n- number of elements to be retrieved.- Returns:
- a vector containing n elements.
- Throws:
OutOfRangeException- if the index is not valid.NotPositiveException- if the number of elements is not positive.
-
setEntry
public void setEntry(int index, double value) throws OutOfRangeException
Set a single element.- Specified by:
setEntryin classRealVector- Parameters:
index- element index.value- new value for the element.- Throws:
OutOfRangeException- if the index is not valid.- See Also:
RealVector.getEntry(int)
-
addToEntry
public void addToEntry(int index, double increment) throws OutOfRangeException
Change an entry at the specified index.- Overrides:
addToEntryin classRealVector- Parameters:
index- Index location of entry to be set.increment- Value to add to the vector entry.- Throws:
OutOfRangeException- if the index is not valid.
-
setSubVector
public void setSubVector(int index, RealVector v) throws OutOfRangeException
Set a sequence of consecutive elements.- Specified by:
setSubVectorin classRealVector- Parameters:
index- index of first element to be set.v- vector containing the values to set.- Throws:
OutOfRangeException- if the index is not valid.
-
setSubVector
public void setSubVector(int index, double[] v) throws OutOfRangeException
Set a set of consecutive elements.- Parameters:
index- Index of first element to be set.v- Vector containing the values to set.- Throws:
OutOfRangeException- if the index is inconsistent with the vector size.
-
set
public void set(double value)
Set all elements to a single value.- Overrides:
setin classRealVector- Parameters:
value- Single value to set for all elements.
-
toArray
public double[] toArray()
Convert the vector to an array ofdoubles. The array is independent from this vector data: the elements are copied.- Overrides:
toArrayin classRealVector- Returns:
- an array containing a copy of the vector elements.
-
checkVectorDimensions
protected void checkVectorDimensions(RealVector v) throws DimensionMismatchException
Check if instance and specified vectors have the same dimension.- Overrides:
checkVectorDimensionsin classRealVector- Parameters:
v- Vector to compare instance with.- Throws:
DimensionMismatchException- if the vectors do not have the same dimension.
-
checkVectorDimensions
protected void checkVectorDimensions(int n) throws DimensionMismatchException
Check if instance dimension is equal to some expected value.- Overrides:
checkVectorDimensionsin classRealVector- Parameters:
n- Expected dimension.- Throws:
DimensionMismatchException- if the dimension is inconsistent with vector size.
-
isNaN
public boolean isNaN()
Check if any coordinate of this vector isNaN.- Specified by:
isNaNin classRealVector- Returns:
trueif any coordinate of this vector isNaN,falseotherwise.
-
isInfinite
public boolean isInfinite()
Check whether any coordinate of this vector is infinite and none areNaN.- Specified by:
isInfinitein classRealVector- Returns:
trueif any coordinate of this vector is infinite and none areNaN,falseotherwise.
-
equals
public boolean equals(Object other)
Test for the equality of two real vectors. If all coordinates of two real vectors are exactly the same, and none are
NaN, the two real vectors are considered to be equal.NaNcoordinates are considered to affect globally the vector and be equals to each other - i.e, if either (or all) coordinates of the real vector are equal toNaN, the real vector is equal to a vector with allNaNcoordinates.This method must be overridden by concrete subclasses of
RealVector(the current implementation throws an exception).- Overrides:
equalsin classRealVector- Parameters:
other- Object to test for equality.- Returns:
trueif two vector objects are equal,falseifotheris null, not an instance ofRealVector, or not equal to thisRealVectorinstance.
-
hashCode
public int hashCode()
. This method must be overridden by concrete subclasses ofRealVector(current implementation throws an exception). AllNaNvalues have the same hash code.- Overrides:
hashCodein classRealVector
-
combine
public ArrayRealVector combine(double a, double b, RealVector y) throws DimensionMismatchException
Returns a new vector representinga * this + b * y, the linear combination ofthisandy. Returns a new vector. Does not change instance data.- Overrides:
combinein classRealVector- Parameters:
a- Coefficient ofthis.b- Coefficient ofy.y- Vector with whichthisis linearly combined.- Returns:
- a vector containing
a * this[i] + b * y[i]for alli. - Throws:
DimensionMismatchException- ifyis not the same size asthisvector.
-
combineToSelf
public ArrayRealVector combineToSelf(double a, double b, RealVector y) throws DimensionMismatchException
Updatesthiswith the linear combination ofthisandy.- Overrides:
combineToSelfin classRealVector- Parameters:
a- Weight ofthis.b- Weight ofy.y- Vector with whichthisis linearly combined.- Returns:
this, with components equal toa * this[i] + b * y[i]for alli.- Throws:
DimensionMismatchException- ifyis not the same size asthisvector.
-
walkInDefaultOrder
public double walkInDefaultOrder(RealVectorPreservingVisitor visitor)
Visits (but does not alter) all entries of this vector in default order (increasing index).- Overrides:
walkInDefaultOrderin classRealVector- Parameters:
visitor- the visitor to be used to process the entries of this vector- Returns:
- the value returned by
RealVectorPreservingVisitor.end()at the end of the walk
-
walkInDefaultOrder
public double walkInDefaultOrder(RealVectorPreservingVisitor visitor, int start, int end) throws NumberIsTooSmallException, OutOfRangeException
Visits (but does not alter) some entries of this vector in default order (increasing index).- Overrides:
walkInDefaultOrderin classRealVector- Parameters:
visitor- visitor to be used to process the entries of this vectorstart- the index of the first entry to be visitedend- the index of the last entry to be visited (inclusive)- Returns:
- the value returned by
RealVectorPreservingVisitor.end()at the end of the walk - Throws:
NumberIsTooSmallException- ifend < start.OutOfRangeException- if the indices are not valid.
-
walkInOptimizedOrder
public double walkInOptimizedOrder(RealVectorPreservingVisitor visitor)
Visits (but does not alter) all entries of this vector in optimized order. The order in which the entries are visited is selected so as to lead to the most efficient implementation; it might depend on the concrete implementation of this abstract class. In this implementation, the optimized order is the default order.- Overrides:
walkInOptimizedOrderin classRealVector- Parameters:
visitor- the visitor to be used to process the entries of this vector- Returns:
- the value returned by
RealVectorPreservingVisitor.end()at the end of the walk
-
walkInOptimizedOrder
public double walkInOptimizedOrder(RealVectorPreservingVisitor visitor, int start, int end) throws NumberIsTooSmallException, OutOfRangeException
Visits (but does not alter) some entries of this vector in optimized order. The order in which the entries are visited is selected so as to lead to the most efficient implementation; it might depend on the concrete implementation of this abstract class. In this implementation, the optimized order is the default order.- Overrides:
walkInOptimizedOrderin classRealVector- Parameters:
visitor- visitor to be used to process the entries of this vectorstart- the index of the first entry to be visitedend- the index of the last entry to be visited (inclusive)- Returns:
- the value returned by
RealVectorPreservingVisitor.end()at the end of the walk - Throws:
NumberIsTooSmallException- ifend < start.OutOfRangeException- if the indices are not valid.
-
walkInDefaultOrder
public double walkInDefaultOrder(RealVectorChangingVisitor visitor)
Visits (and possibly alters) all entries of this vector in default order (increasing index).- Overrides:
walkInDefaultOrderin classRealVector- Parameters:
visitor- the visitor to be used to process and modify the entries of this vector- Returns:
- the value returned by
RealVectorChangingVisitor.end()at the end of the walk
-
walkInDefaultOrder
public double walkInDefaultOrder(RealVectorChangingVisitor visitor, int start, int end) throws NumberIsTooSmallException, OutOfRangeException
Visits (and possibly alters) some entries of this vector in default order (increasing index).- Overrides:
walkInDefaultOrderin classRealVector- Parameters:
visitor- visitor to be used to process the entries of this vectorstart- the index of the first entry to be visitedend- the index of the last entry to be visited (inclusive)- Returns:
- the value returned by
RealVectorChangingVisitor.end()at the end of the walk - Throws:
NumberIsTooSmallException- ifend < start.OutOfRangeException- if the indices are not valid.
-
walkInOptimizedOrder
public double walkInOptimizedOrder(RealVectorChangingVisitor visitor)
Visits (and possibly alters) all entries of this vector in optimized order. The order in which the entries are visited is selected so as to lead to the most efficient implementation; it might depend on the concrete implementation of this abstract class. In this implementation, the optimized order is the default order.- Overrides:
walkInOptimizedOrderin classRealVector- Parameters:
visitor- the visitor to be used to process the entries of this vector- Returns:
- the value returned by
RealVectorChangingVisitor.end()at the end of the walk
-
walkInOptimizedOrder
public double walkInOptimizedOrder(RealVectorChangingVisitor visitor, int start, int end) throws NumberIsTooSmallException, OutOfRangeException
Visits (and possibly change) some entries of this vector in optimized order. The order in which the entries are visited is selected so as to lead to the most efficient implementation; it might depend on the concrete implementation of this abstract class. In this implementation, the optimized order is the default order.- Overrides:
walkInOptimizedOrderin classRealVector- Parameters:
visitor- visitor to be used to process the entries of this vectorstart- the index of the first entry to be visitedend- the index of the last entry to be visited (inclusive)- Returns:
- the value returned by
RealVectorChangingVisitor.end()at the end of the walk - Throws:
NumberIsTooSmallException- ifend < start.OutOfRangeException- if the indices are not valid.
-
-