Class ArrayFieldVector<T extends FieldElement<T>>
- java.lang.Object
-
- org.apache.commons.math4.legacy.linear.ArrayFieldVector<T>
-
- Type Parameters:
T- the type of the field elements
- All Implemented Interfaces:
Serializable,FieldVector<T>
public class ArrayFieldVector<T extends FieldElement<T>> extends Object implements FieldVector<T>, Serializable
This class implements theFieldVectorinterface with aFieldElementarray.- Since:
- 2.0
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ArrayFieldVector(int size, T preset)Construct a vector with preset values.ArrayFieldVector(Field<T> field)Build a 0-length vector.ArrayFieldVector(Field<T> field, int size)Construct a vector of zeroes.ArrayFieldVector(Field<T> field, T[] d)Construct a vector from an array, copying the input array.ArrayFieldVector(Field<T> field, T[] d, boolean copyArray)Create a new ArrayFieldVector using the input array as the underlying data array.ArrayFieldVector(Field<T> field, T[] d, int pos, int size)Construct a vector from part of a array.ArrayFieldVector(Field<T> field, T[] v1, T[] v2)Construct a vector by appending one vector to another vector.ArrayFieldVector(ArrayFieldVector<T> v)Construct a vector from another vector, using a deep copy.ArrayFieldVector(ArrayFieldVector<T> v, boolean deep)Construct a vector from another vector.ArrayFieldVector(FieldVector<T> v)Construct a vector from another vector, using a deep copy.ArrayFieldVector(FieldVector<T> v1, FieldVector<T> v2)Construct a vector by appending one vector to another vector.ArrayFieldVector(FieldVector<T> v1, T[] v2)Construct a vector by appending one vector to another vector.ArrayFieldVector(T[] d)Construct a vector from an array, copying the input array.ArrayFieldVector(T[] d, boolean copyArray)Create a new ArrayFieldVector using the input array as the underlying data array.ArrayFieldVector(T[] d, int pos, int size)Construct a vector from part of a array.ArrayFieldVector(T[] v1, FieldVector<T> v2)Construct a vector by appending one vector to another vector.ArrayFieldVector(T[] v1, T[] v2)Construct a vector by appending one vector to another vector.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ArrayFieldVector<T>add(ArrayFieldVector<T> v)Compute the sum ofthisandv.FieldVector<T>add(FieldVector<T> v)Compute the sum ofthisandv.ArrayFieldVector<T>append(ArrayFieldVector<T> v)Construct a vector by appending a vector to this vector.FieldVector<T>append(FieldVector<T> v)Construct a vector by appending a vector to this vector.FieldVector<T>append(T in)Construct a vector by appending a T to this vector.protected voidcheckVectorDimensions(int n)Check if instance dimension is equal to some expected value.protected voidcheckVectorDimensions(FieldVector<T> v)Check if instance and specified vectors have the same dimension.FieldVector<T>copy()Returns a (deep) copy of this.TdotProduct(ArrayFieldVector<T> v)Compute the dot product.TdotProduct(FieldVector<T> v)Compute the dot product.ArrayFieldVector<T>ebeDivide(ArrayFieldVector<T> v)Element-by-element division.FieldVector<T>ebeDivide(FieldVector<T> v)Element-by-element division.ArrayFieldVector<T>ebeMultiply(ArrayFieldVector<T> v)Element-by-element multiplication.FieldVector<T>ebeMultiply(FieldVector<T> v)Element-by-element multiplication.booleanequals(Object other)Test for the equality of two vectors.T[]getDataRef()Returns a reference to the underlying data array.intgetDimension()Returns the size of the vector.TgetEntry(int index)Returns the entry in the specified index.Field<T>getField()Get the type of field elements of the vector.FieldVector<T>getSubVector(int index, int n)Get a subvector from consecutive elements.inthashCode()Get a hashCode for the real vector.FieldVector<T>mapAdd(T d)Map an addition operation to each entry.FieldVector<T>mapAddToSelf(T d)Map an addition operation to each entry.FieldVector<T>mapDivide(T d)Map a division operation to each entry.FieldVector<T>mapDivideToSelf(T d)Map a division operation to each entry.FieldVector<T>mapInv()Map the 1/x function to each entry.FieldVector<T>mapInvToSelf()Map the 1/x function to each entry.FieldVector<T>mapMultiply(T d)Map a multiplication operation to each entry.FieldVector<T>mapMultiplyToSelf(T d)Map a multiplication operation to each entry.FieldVector<T>mapSubtract(T d)Map a subtraction operation to each entry.FieldVector<T>mapSubtractToSelf(T d)Map a subtraction operation to each entry.FieldMatrix<T>outerProduct(ArrayFieldVector<T> v)Compute the outer product.FieldMatrix<T>outerProduct(FieldVector<T> v)Compute the outer product.ArrayFieldVector<T>projection(ArrayFieldVector<T> v)Find the orthogonal projection of this vector onto another vector.FieldVector<T>projection(FieldVector<T> v)Find the orthogonal projection of this vector onto another vector.voidset(int index, ArrayFieldVector<T> v)Set a set of consecutive elements.voidset(T value)Set all elements to a single value.voidsetEntry(int index, T value)Set a single element.voidsetSubVector(int index, FieldVector<T> v)Set a set of consecutive elements.ArrayFieldVector<T>subtract(ArrayFieldVector<T> v)Computethisminusv.FieldVector<T>subtract(FieldVector<T> v)Computethisminusv.T[]toArray()Convert the vector to a T array.TwalkInDefaultOrder(FieldVectorChangingVisitor<T> visitor)Visits (and possibly alters) all entries of this vector in default order (increasing index).TwalkInDefaultOrder(FieldVectorChangingVisitor<T> visitor, int start, int end)Visits (and possibly alters) some entries of this vector in default order (increasing index).TwalkInDefaultOrder(FieldVectorPreservingVisitor<T> visitor)Visits (but does not alter) all entries of this vector in default order (increasing index).TwalkInDefaultOrder(FieldVectorPreservingVisitor<T> visitor, int start, int end)Visits (but does not alter) some entries of this vector in default order (increasing index).TwalkInOptimizedOrder(FieldVectorChangingVisitor<T> visitor)Visits (and possibly alters) all entries of this vector in optimized order.TwalkInOptimizedOrder(FieldVectorChangingVisitor<T> visitor, int start, int end)Visits (and possibly change) some entries of this vector in optimized order.TwalkInOptimizedOrder(FieldVectorPreservingVisitor<T> visitor)Visits (but does not alter) all entries of this vector in optimized order.TwalkInOptimizedOrder(FieldVectorPreservingVisitor<T> visitor, int start, int end)Visits (but does not alter) some entries of this vector in optimized order.
-
-
-
Constructor Detail
-
ArrayFieldVector
public ArrayFieldVector(Field<T> field)
Build a 0-length vector. Zero-length vectors may be used to initialize construction of vectors by data gathering. We start with zero-length and use either theArrayFieldVector(FieldVector, FieldVector)constructor or one of theappendmethods (add(FieldVector)orappend(ArrayFieldVector)) to gather data into this vector.- Parameters:
field- field to which the elements belong
-
ArrayFieldVector
public ArrayFieldVector(Field<T> field, int size)
Construct a vector of zeroes.- Parameters:
field- Field to which the elements belong.size- Size of the vector.
-
ArrayFieldVector
public ArrayFieldVector(int size, T preset)
Construct a vector with preset values.- Parameters:
size- Size of the vector.preset- All entries will be set with this value.
-
ArrayFieldVector
public ArrayFieldVector(T[] d) throws NullArgumentException, ZeroException
Construct a vector from an array, copying the input array. This constructor needs a non-emptydarray to retrieve the field from its first element. This implies it cannot build 0 length vectors. To build vectors from any size, one should use theArrayFieldVector(Field, FieldElement[])constructor.- Parameters:
d- Array.- Throws:
NullArgumentException- ifdisnull.ZeroException- ifdis empty.- See Also:
ArrayFieldVector(Field, FieldElement[])
-
ArrayFieldVector
public ArrayFieldVector(Field<T> field, T[] d) throws NullArgumentException
Construct a vector from an array, copying the input array.- Parameters:
field- Field to which the elements belong.d- Array.- Throws:
NullArgumentException- ifdisnull.- See Also:
ArrayFieldVector(FieldElement[])
-
ArrayFieldVector
public ArrayFieldVector(T[] d, boolean copyArray) throws NullArgumentException, ZeroException
Create a new ArrayFieldVector using the input array as the underlying data array. If an array is built specially in order to be embedded in a ArrayFieldVector 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. This constructor needs a non-emptydarray to retrieve the field from its first element. This implies it cannot build 0 length vectors. To build vectors from any size, one should use theArrayFieldVector(Field, FieldElement[], boolean)constructor.- Parameters:
d- Data for the new vector.copyArray- Iftrue, the input array will be copied, otherwise it will be referenced.- Throws:
NullArgumentException- ifdisnull.ZeroException- ifdis empty.- See Also:
ArrayFieldVector(FieldElement[]),ArrayFieldVector(Field, FieldElement[], boolean)
-
ArrayFieldVector
public ArrayFieldVector(Field<T> field, T[] d, boolean copyArray) throws NullArgumentException
Create a new ArrayFieldVector using the input array as the underlying data array. If an array is built specially in order to be embedded in a ArrayFieldVector 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:
field- Field to which the elements belong.d- Data for the new vector.copyArray- Iftrue, the input array will be copied, otherwise it will be referenced.- Throws:
NullArgumentException- ifdisnull.- See Also:
ArrayFieldVector(FieldElement[], boolean)
-
ArrayFieldVector
public ArrayFieldVector(T[] d, int pos, int size) throws NullArgumentException, NumberIsTooLargeException
Construct a vector from part of a array.- Parameters:
d- Array.pos- Position of the first entry.size- Number of entries to copy.- Throws:
NullArgumentException- ifdisnull.NumberIsTooLargeException- if the size ofdis less thanpos + size.
-
ArrayFieldVector
public ArrayFieldVector(Field<T> field, T[] d, int pos, int size) throws NullArgumentException, NumberIsTooLargeException
Construct a vector from part of a array.- Parameters:
field- Field to which the elements belong.d- Array.pos- Position of the first entry.size- Number of entries to copy.- Throws:
NullArgumentException- ifdisnull.NumberIsTooLargeException- if the size ofdis less thanpos + size.
-
ArrayFieldVector
public ArrayFieldVector(FieldVector<T> v) throws NullArgumentException
Construct a vector from another vector, using a deep copy.- Parameters:
v- Vector to copy.- Throws:
NullArgumentException- ifvisnull.
-
ArrayFieldVector
public ArrayFieldVector(ArrayFieldVector<T> v) throws NullArgumentException
Construct a vector from another vector, using a deep copy.- Parameters:
v- Vector to copy.- Throws:
NullArgumentException- ifvisnull.
-
ArrayFieldVector
public ArrayFieldVector(ArrayFieldVector<T> v, boolean deep) throws NullArgumentException
Construct a vector from another vector.- Parameters:
v- Vector to copy.deep- Iftrueperform a deep copy, otherwise perform a shallow copy- Throws:
NullArgumentException- ifvisnull.
-
ArrayFieldVector
public ArrayFieldVector(FieldVector<T> v1, FieldVector<T> v2) throws NullArgumentException
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).- Throws:
NullArgumentException- ifv1orv2isnull.- Since:
- 3.2
-
ArrayFieldVector
public ArrayFieldVector(FieldVector<T> v1, T[] v2) throws NullArgumentException
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).- Throws:
NullArgumentException- ifv1orv2isnull.- Since:
- 3.2
-
ArrayFieldVector
public ArrayFieldVector(T[] v1, FieldVector<T> v2) throws NullArgumentException
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).- Throws:
NullArgumentException- ifv1orv2isnull.- Since:
- 3.2
-
ArrayFieldVector
public ArrayFieldVector(T[] v1, T[] v2) throws NullArgumentException, ZeroException
Construct a vector by appending one vector to another vector. This constructor needs at least one non-empty array to retrieve the field from its first element. This implies it cannot build 0 length vectors. To build vectors from any size, one should use theArrayFieldVector(Field, FieldElement[], FieldElement[])constructor.- 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).- Throws:
NullArgumentException- ifv1orv2isnull.ZeroException- if both arrays are empty.- See Also:
ArrayFieldVector(Field, FieldElement[], FieldElement[])
-
ArrayFieldVector
public ArrayFieldVector(Field<T> field, T[] v1, T[] v2) throws NullArgumentException, ZeroException
Construct a vector by appending one vector to another vector.- Parameters:
field- Field to which the elements belong.v1- First vector (will be put in front of the new vector).v2- Second vector (will be put at back of the new vector).- Throws:
NullArgumentException- ifv1orv2isnull.ZeroException- if both arrays are empty.- See Also:
ArrayFieldVector(FieldElement[], FieldElement[])
-
-
Method Detail
-
getField
public Field<T> getField()
Get the type of field elements of the vector.- Specified by:
getFieldin interfaceFieldVector<T extends FieldElement<T>>- Returns:
- type of field elements of the vector
-
copy
public FieldVector<T> copy()
Returns a (deep) copy of this.- Specified by:
copyin interfaceFieldVector<T extends FieldElement<T>>- Returns:
- vector copy
-
add
public FieldVector<T> add(FieldVector<T> v) throws DimensionMismatchException
Compute the sum ofthisandv.- Specified by:
addin interfaceFieldVector<T extends FieldElement<T>>- Parameters:
v- vector to be added- Returns:
this + v- Throws:
DimensionMismatchException- ifvis not the same size asthis
-
add
public ArrayFieldVector<T> add(ArrayFieldVector<T> v) throws DimensionMismatchException
Compute the sum ofthisandv.- Parameters:
v- vector to be added- Returns:
this + v- Throws:
DimensionMismatchException- ifvis not the same size asthis
-
subtract
public FieldVector<T> subtract(FieldVector<T> v) throws DimensionMismatchException
Computethisminusv.- Specified by:
subtractin interfaceFieldVector<T extends FieldElement<T>>- Parameters:
v- vector to be subtracted- Returns:
this - v- Throws:
DimensionMismatchException- ifvis not the same size asthis
-
subtract
public ArrayFieldVector<T> subtract(ArrayFieldVector<T> v) throws DimensionMismatchException
Computethisminusv.- Parameters:
v- vector to be subtracted- Returns:
this - v- Throws:
DimensionMismatchException- ifvis not the same size asthis
-
mapAdd
public FieldVector<T> mapAdd(T d) throws NullArgumentException
Map an addition operation to each entry.- Specified by:
mapAddin interfaceFieldVector<T extends FieldElement<T>>- Parameters:
d- value to be added to each entry- Returns:
this + d- Throws:
NullArgumentException- ifdisnull.
-
mapAddToSelf
public FieldVector<T> mapAddToSelf(T d) throws NullArgumentException
Map an addition operation to each entry.The instance is changed by this method.
- Specified by:
mapAddToSelfin interfaceFieldVector<T extends FieldElement<T>>- Parameters:
d- value to be added to each entry- Returns:
- for convenience, return
this - Throws:
NullArgumentException- ifdisnull.
-
mapSubtract
public FieldVector<T> mapSubtract(T d) throws NullArgumentException
Map a subtraction operation to each entry.- Specified by:
mapSubtractin interfaceFieldVector<T extends FieldElement<T>>- Parameters:
d- value to be subtracted to each entry- Returns:
this - d- Throws:
NullArgumentException- ifdisnull
-
mapSubtractToSelf
public FieldVector<T> mapSubtractToSelf(T d) throws NullArgumentException
Map a subtraction operation to each entry.The instance is changed by this method.
- Specified by:
mapSubtractToSelfin interfaceFieldVector<T extends FieldElement<T>>- Parameters:
d- value to be subtracted to each entry- Returns:
- for convenience, return
this - Throws:
NullArgumentException- ifdisnull
-
mapMultiply
public FieldVector<T> mapMultiply(T d) throws NullArgumentException
Map a multiplication operation to each entry.- Specified by:
mapMultiplyin interfaceFieldVector<T extends FieldElement<T>>- Parameters:
d- value to multiply all entries by- Returns:
this * d- Throws:
NullArgumentException- ifdisnull.
-
mapMultiplyToSelf
public FieldVector<T> mapMultiplyToSelf(T d) throws NullArgumentException
Map a multiplication operation to each entry.The instance is changed by this method.
- Specified by:
mapMultiplyToSelfin interfaceFieldVector<T extends FieldElement<T>>- Parameters:
d- value to multiply all entries by- Returns:
- for convenience, return
this - Throws:
NullArgumentException- ifdisnull.
-
mapDivide
public FieldVector<T> mapDivide(T d) throws NullArgumentException, MathArithmeticException
Map a division operation to each entry.- Specified by:
mapDividein interfaceFieldVector<T extends FieldElement<T>>- Parameters:
d- value to divide all entries by- Returns:
this / d- Throws:
NullArgumentException- ifdisnull.MathArithmeticException- ifdis zero.
-
mapDivideToSelf
public FieldVector<T> mapDivideToSelf(T d) throws NullArgumentException, MathArithmeticException
Map a division operation to each entry.The instance is changed by this method.
- Specified by:
mapDivideToSelfin interfaceFieldVector<T extends FieldElement<T>>- Parameters:
d- value to divide all entries by- Returns:
- for convenience, return
this - Throws:
NullArgumentException- ifdisnull.MathArithmeticException- ifdis zero.
-
mapInv
public FieldVector<T> mapInv() throws MathArithmeticException
Map the 1/x function to each entry.- Specified by:
mapInvin interfaceFieldVector<T extends FieldElement<T>>- Returns:
- a vector containing the result of applying the function to each entry.
- Throws:
MathArithmeticException- if one of the entries is zero.
-
mapInvToSelf
public FieldVector<T> mapInvToSelf() throws MathArithmeticException
Map the 1/x function to each entry.The instance is changed by this method.
- Specified by:
mapInvToSelfin interfaceFieldVector<T extends FieldElement<T>>- Returns:
- for convenience, return
this - Throws:
MathArithmeticException- if one of the entries is zero.
-
ebeMultiply
public FieldVector<T> ebeMultiply(FieldVector<T> v) throws DimensionMismatchException
Element-by-element multiplication.- Specified by:
ebeMultiplyin interfaceFieldVector<T extends FieldElement<T>>- Parameters:
v- vector by which instance elements must be multiplied- Returns:
- a vector containing
this[i] * v[i]for alli - Throws:
DimensionMismatchException- ifvis not the same size asthis
-
ebeMultiply
public ArrayFieldVector<T> ebeMultiply(ArrayFieldVector<T> v) throws DimensionMismatchException
Element-by-element multiplication.- Parameters:
v- vector by which instance elements must be multiplied- Returns:
- a vector containing
this[i] * v[i]for alli - Throws:
DimensionMismatchException- ifvis not the same size asthis
-
ebeDivide
public FieldVector<T> ebeDivide(FieldVector<T> v) throws DimensionMismatchException, MathArithmeticException
Element-by-element division.- Specified by:
ebeDividein interfaceFieldVector<T extends FieldElement<T>>- Parameters:
v- vector by which instance elements must be divided- Returns:
- a vector containing
this[i] / v[i]for alli - Throws:
DimensionMismatchException- ifvis not the same size asthisMathArithmeticException- if one entry ofvis zero.
-
ebeDivide
public ArrayFieldVector<T> ebeDivide(ArrayFieldVector<T> v) throws DimensionMismatchException, MathArithmeticException
Element-by-element division.- Parameters:
v- vector by which instance elements must be divided- Returns:
- a vector containing
this[i] / v[i]for alli - Throws:
DimensionMismatchException- ifvis not the same size asthisMathArithmeticException- if one entry ofvis zero.
-
getDataRef
public T[] getDataRef()
Returns a reference to the underlying data array.Does not make a fresh copy of the underlying data.
- Returns:
- array of entries
-
dotProduct
public T dotProduct(FieldVector<T> v) throws DimensionMismatchException
Compute the dot product.- Specified by:
dotProductin interfaceFieldVector<T extends FieldElement<T>>- Parameters:
v- vector with which dot product should be computed- Returns:
- the scalar dot product of
thisandv - Throws:
DimensionMismatchException- ifvis not the same size asthis
-
dotProduct
public T dotProduct(ArrayFieldVector<T> v) throws DimensionMismatchException
Compute the dot product.- Parameters:
v- vector with which dot product should be computed- Returns:
- the scalar dot product of
thisandv - Throws:
DimensionMismatchException- ifvis not the same size asthis
-
projection
public FieldVector<T> projection(FieldVector<T> v) throws DimensionMismatchException, MathArithmeticException
Find the orthogonal projection of this vector onto another vector.- Specified by:
projectionin interfaceFieldVector<T extends FieldElement<T>>- Parameters:
v- vector onto whichthismust be projected- Returns:
- projection of
thisontov - Throws:
DimensionMismatchException- ifvis not the same size asthisMathArithmeticException- ifvis the null vector.
-
projection
public ArrayFieldVector<T> projection(ArrayFieldVector<T> v) throws DimensionMismatchException, MathArithmeticException
Find the orthogonal projection of this vector onto another vector.- Parameters:
v- vector onto whichthismust be projected- Returns:
- projection of
thisontov - Throws:
DimensionMismatchException- ifvis not the same size asthisMathArithmeticException- ifvis the null vector.
-
outerProduct
public FieldMatrix<T> outerProduct(FieldVector<T> v)
Compute the outer product.- Specified by:
outerProductin interfaceFieldVector<T extends FieldElement<T>>- Parameters:
v- vector with which outer product should be computed- Returns:
- the matrix outer product between instance and v
-
outerProduct
public FieldMatrix<T> outerProduct(ArrayFieldVector<T> v)
Compute the outer product.- Parameters:
v- vector with which outer product should be computed- Returns:
- the matrix outer product between instance and v
-
getEntry
public T getEntry(int index)
Returns the entry in the specified index.- Specified by:
getEntryin interfaceFieldVector<T extends FieldElement<T>>- Parameters:
index- Index location of entry to be fetched.- Returns:
- the vector entry at
index. - See Also:
FieldVector.setEntry(int, FieldElement)
-
getDimension
public int getDimension()
Returns the size of the vector.- Specified by:
getDimensionin interfaceFieldVector<T extends FieldElement<T>>- Returns:
- size
-
append
public FieldVector<T> append(FieldVector<T> v)
Construct a vector by appending a vector to this vector.- Specified by:
appendin interfaceFieldVector<T extends FieldElement<T>>- Parameters:
v- vector to append to this one.- Returns:
- a new vector
-
append
public ArrayFieldVector<T> append(ArrayFieldVector<T> 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 FieldVector<T> append(T in)
Construct a vector by appending a T to this vector.- Specified by:
appendin interfaceFieldVector<T extends FieldElement<T>>- Parameters:
in- T to append.- Returns:
- a new vector
-
getSubVector
public FieldVector<T> getSubVector(int index, int n) throws OutOfRangeException, NotPositiveException
Get a subvector from consecutive elements.- Specified by:
getSubVectorin interfaceFieldVector<T extends FieldElement<T>>- 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 if not positive.
-
setEntry
public void setEntry(int index, T value)
Set a single element.- Specified by:
setEntryin interfaceFieldVector<T extends FieldElement<T>>- Parameters:
index- element index.value- new value for the element.- See Also:
FieldVector.getEntry(int)
-
setSubVector
public void setSubVector(int index, FieldVector<T> v) throws OutOfRangeException
Set a set of consecutive elements.- Specified by:
setSubVectorin interfaceFieldVector<T extends FieldElement<T>>- Parameters:
index- index of first element to be set.v- vector containing the values to set.- Throws:
OutOfRangeException- if the index is not valid.
-
set
public void set(int index, ArrayFieldVector<T> 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 invalid.
-
set
public void set(T value)
Set all elements to a single value.- Specified by:
setin interfaceFieldVector<T extends FieldElement<T>>- Parameters:
value- single value to set for all elements
-
toArray
public T[] toArray()
Convert the vector to a T array.The array is independent from vector data, it's elements are copied.
- Specified by:
toArrayin interfaceFieldVector<T extends FieldElement<T>>- Returns:
- array containing a copy of vector elements
-
checkVectorDimensions
protected void checkVectorDimensions(FieldVector<T> v) throws DimensionMismatchException
Check if instance and specified vectors have the same dimension.- Parameters:
v- vector to compare instance with- Throws:
DimensionMismatchException- if the vectors do not have the same dimensions
-
checkVectorDimensions
protected void checkVectorDimensions(int n) throws DimensionMismatchException
Check if instance dimension is equal to some expected value.- Parameters:
n- Expected dimension.- Throws:
DimensionMismatchException- if the dimension is not equal to the size ofthisvector.
-
walkInDefaultOrder
public T walkInDefaultOrder(FieldVectorPreservingVisitor<T> visitor)
Visits (but does not alter) all entries of this vector in default order (increasing index).- Parameters:
visitor- the visitor to be used to process the entries of this vector- Returns:
- the value returned by
FieldVectorPreservingVisitor.end()at the end of the walk - Since:
- 3.3
-
walkInDefaultOrder
public T walkInDefaultOrder(FieldVectorPreservingVisitor<T> visitor, int start, int end) throws NumberIsTooSmallException, OutOfRangeException
Visits (but does not alter) some entries of this vector in default order (increasing index).- 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
FieldVectorPreservingVisitor.end()at the end of the walk - Throws:
NumberIsTooSmallException- ifend < start.OutOfRangeException- if the indices are not valid.- Since:
- 3.3
-
walkInOptimizedOrder
public T walkInOptimizedOrder(FieldVectorPreservingVisitor<T> 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.- Parameters:
visitor- the visitor to be used to process the entries of this vector- Returns:
- the value returned by
FieldVectorPreservingVisitor.end()at the end of the walk - Since:
- 3.3
-
walkInOptimizedOrder
public T walkInOptimizedOrder(FieldVectorPreservingVisitor<T> 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.- 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
FieldVectorPreservingVisitor.end()at the end of the walk - Throws:
NumberIsTooSmallException- ifend < start.OutOfRangeException- if the indices are not valid.- Since:
- 3.3
-
walkInDefaultOrder
public T walkInDefaultOrder(FieldVectorChangingVisitor<T> visitor)
Visits (and possibly alters) all entries of this vector in default order (increasing index).- Parameters:
visitor- the visitor to be used to process and modify the entries of this vector- Returns:
- the value returned by
FieldVectorChangingVisitor.end()at the end of the walk - Since:
- 3.3
-
walkInDefaultOrder
public T walkInDefaultOrder(FieldVectorChangingVisitor<T> visitor, int start, int end) throws NumberIsTooSmallException, OutOfRangeException
Visits (and possibly alters) some entries of this vector in default order (increasing index).- 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
FieldVectorChangingVisitor.end()at the end of the walk - Throws:
NumberIsTooSmallException- ifend < start.OutOfRangeException- if the indices are not valid.- Since:
- 3.3
-
walkInOptimizedOrder
public T walkInOptimizedOrder(FieldVectorChangingVisitor<T> 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.- Parameters:
visitor- the visitor to be used to process the entries of this vector- Returns:
- the value returned by
FieldVectorChangingVisitor.end()at the end of the walk - Since:
- 3.3
-
walkInOptimizedOrder
public T walkInOptimizedOrder(FieldVectorChangingVisitor<T> 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.- 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
FieldVectorChangingVisitor.end()at the end of the walk - Throws:
NumberIsTooSmallException- ifend < start.OutOfRangeException- if the indices are not valid.- Since:
- 3.3
-
-