|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.math.linear.ArrayFieldVector<T>
T
- the type of the field elementspublic class ArrayFieldVector<T extends FieldElement<T>>
This class implements the FieldVector
interface with a FieldElement
array.
Field Summary | |
---|---|
protected T[] |
data
Entries of the vector. |
Constructor Summary | |
---|---|
ArrayFieldVector(ArrayFieldVector<T> v)
Construct a vector from another vector, using a deep copy. |
|
ArrayFieldVector(ArrayFieldVector<T> v1,
ArrayFieldVector<T> v2)
Construct a vector by appending one vector to another vector. |
|
ArrayFieldVector(ArrayFieldVector<T> v,
boolean deep)
Construct a vector from another vector. |
|
ArrayFieldVector(ArrayFieldVector<T> v1,
T[] v2)
Construct a vector by appending one vector to another vector. |
|
ArrayFieldVector(Field<T> field)
Build a 0-length vector. |
|
ArrayFieldVector(Field<T> field,
int size)
Construct a (size)-length vector of zeros. |
|
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[] v1,
T[] v2)
Construct a vector by appending one vector to another vector. |
|
ArrayFieldVector(FieldVector<T> v)
Construct a vector from another vector, using a deep copy. |
|
ArrayFieldVector(int size,
T preset)
Construct an (size)-length vector with preset values. |
|
ArrayFieldVector(T[] d)
Construct a vector from an array, copying the input array. |
|
ArrayFieldVector(T[] v1,
ArrayFieldVector<T> v2)
Construct a vector by appending one vector to another vector. |
|
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,
T[] v2)
Construct a vector by appending one vector to another vector. |
Method Summary | |
---|---|
ArrayFieldVector<T> |
add(ArrayFieldVector<T> v)
Compute the sum of this and v. |
FieldVector<T> |
add(FieldVector<T> v)
Compute the sum of this and v. |
FieldVector<T> |
add(T[] v)
Compute the sum of this and v. |
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. |
FieldVector<T> |
append(T[] in)
Construct a vector by appending a T array to this vector. |
protected void |
checkVectorDimensions(FieldVector<T> v)
Check if instance and specified vectors have the same dimension. |
protected void |
checkVectorDimensions(int n)
Check if instance dimension is equal to some expected value. |
FieldVector<T> |
copy()
Returns a (deep) copy of this. |
T |
dotProduct(ArrayFieldVector<T> v)
Compute the dot product. |
T |
dotProduct(FieldVector<T> v)
Compute the dot product. |
T |
dotProduct(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. |
FieldVector<T> |
ebeDivide(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. |
FieldVector<T> |
ebeMultiply(T[] v)
Element-by-element multiplication. |
boolean |
equals(Object other)
Test for the equality of two real vectors. |
T[] |
getData()
Returns vector entries as a T array. |
T[] |
getDataRef()
Returns a reference to the underlying data array. |
int |
getDimension()
Returns the size of the vector. |
T |
getEntry(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. |
int |
hashCode()
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. |
FieldMatrix<T> |
outerProduct(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. |
FieldVector<T> |
projection(T[] v)
Find the orthogonal projection of this vector onto another vector. |
void |
set(int index,
ArrayFieldVector<T> v)
Set a set of consecutive elements. |
void |
set(T value)
Set all elements to a single value. |
void |
setEntry(int index,
T value)
Set a single element. |
void |
setSubVector(int index,
FieldVector<T> v)
Set a set of consecutive elements. |
void |
setSubVector(int index,
T[] v)
Set a set of consecutive elements. |
ArrayFieldVector<T> |
subtract(ArrayFieldVector<T> v)
Compute this minus v. |
FieldVector<T> |
subtract(FieldVector<T> v)
Compute this minus v. |
FieldVector<T> |
subtract(T[] v)
Compute this minus v. |
T[] |
toArray()
Convert the vector to a T array. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected T extends FieldElement<T>[] data
Constructor Detail |
---|
public ArrayFieldVector(Field<T> field)
Zero-length vectors may be used to initialized construction of vectors
by data gathering. We start with zero-length and use either the ArrayFieldVector(ArrayFieldVector, ArrayFieldVector)
constructor
or one of the append
methods (append(FieldElement[])
,
add(FieldVector)
, append(ArrayFieldVector)
) to gather data
into this vector.
field
- field to which the elements belongpublic ArrayFieldVector(Field<T> field, int size)
field
- field to which the elements belongsize
- size of the vectorpublic ArrayFieldVector(int size, T preset)
size
- size of the vectorpreset
- fill the vector with this scalar valuepublic ArrayFieldVector(T[] d) throws IllegalArgumentException
This constructor needs a non-empty d
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 the ArrayFieldVector(Field, FieldElement[])
constructor.
d
- array of Ts.
IllegalArgumentException
- if d
is emptyArrayFieldVector(Field, FieldElement[])
public ArrayFieldVector(Field<T> field, T[] d)
field
- field to which the elements belongd
- array of Ts.ArrayFieldVector(FieldElement[])
public ArrayFieldVector(T[] d, boolean copyArray) throws NullPointerException, IllegalArgumentException
If an array is built specially in order to be embedded in a
ArrayFieldVector and not used directly, the
This constructor needs a non-empty
copyArray
may be
set to false
d
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 the ArrayFieldVector(Field, FieldElement[], boolean)
constructor.
d
- data for new vectorcopyArray
- if true, the input array will be copied, otherwise
it will be referenced
IllegalArgumentException
- if d
is empty
NullPointerException
- if d
is nullArrayFieldVector(FieldElement[])
,
ArrayFieldVector(Field, FieldElement[], boolean)
public ArrayFieldVector(Field<T> field, T[] d, boolean copyArray)
If an array is built specially in order to be embedded in a
ArrayFieldVector and not used directly, the
copyArray
may be
set to false
field
- field to which the elements belongd
- data for new vectorcopyArray
- if true, the input array will be copied, otherwise
it will be referencedArrayFieldVector(FieldElement[], boolean)
public ArrayFieldVector(T[] d, int pos, int size)
d
- array of Ts.pos
- position of first entrysize
- number of entries to copypublic ArrayFieldVector(FieldVector<T> v)
v
- vector to copypublic ArrayFieldVector(ArrayFieldVector<T> v)
v
- vector to copypublic ArrayFieldVector(ArrayFieldVector<T> v, boolean deep)
v
- vector to copydeep
- if true perform a deep copy otherwise perform a shallow copypublic ArrayFieldVector(ArrayFieldVector<T> v1, ArrayFieldVector<T> v2)
v1
- first vector (will be put in front of the new vector)v2
- second vector (will be put at back of the new vector)public ArrayFieldVector(ArrayFieldVector<T> v1, T[] v2)
v1
- first vector (will be put in front of the new vector)v2
- second vector (will be put at back of the new vector)public ArrayFieldVector(T[] v1, ArrayFieldVector<T> v2)
v1
- first vector (will be put in front of the new vector)v2
- second vector (will be put at back of the new vector)public ArrayFieldVector(T[] v1, T[] v2)
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 the ArrayFieldVector(Field, FieldElement[], FieldElement[])
constructor.
v1
- first vector (will be put in front of the new vector)v2
- second vector (will be put at back of the new vector)
IllegalArgumentException
- if both vectors are emptyArrayFieldVector(Field, FieldElement[], FieldElement[])
public ArrayFieldVector(Field<T> field, T[] v1, T[] v2)
field
- field to which the elements belongv1
- first vector (will be put in front of the new vector)v2
- second vector (will be put at back of the new vector)ArrayFieldVector(FieldElement[], FieldElement[])
Method Detail |
---|
public Field<T> getField()
getField
in interface FieldVector<T extends FieldElement<T>>
public FieldVector<T> copy()
copy
in interface FieldVector<T extends FieldElement<T>>
public FieldVector<T> add(FieldVector<T> v) throws IllegalArgumentException
add
in interface FieldVector<T extends FieldElement<T>>
v
- vector to be added
IllegalArgumentException
- if v is not the same size as thispublic FieldVector<T> add(T[] v) throws IllegalArgumentException
add
in interface FieldVector<T extends FieldElement<T>>
v
- vector to be added
IllegalArgumentException
- if v is not the same size as thispublic ArrayFieldVector<T> add(ArrayFieldVector<T> v) throws IllegalArgumentException
v
- vector to be added
IllegalArgumentException
- if v is not the same size as thispublic FieldVector<T> subtract(FieldVector<T> v) throws IllegalArgumentException
subtract
in interface FieldVector<T extends FieldElement<T>>
v
- vector to be subtracted
IllegalArgumentException
- if v is not the same size as thispublic FieldVector<T> subtract(T[] v) throws IllegalArgumentException
subtract
in interface FieldVector<T extends FieldElement<T>>
v
- vector to be subtracted
IllegalArgumentException
- if v is not the same size as thispublic ArrayFieldVector<T> subtract(ArrayFieldVector<T> v) throws IllegalArgumentException
v
- vector to be subtracted
IllegalArgumentException
- if v is not the same size as thispublic FieldVector<T> mapAdd(T d)
mapAdd
in interface FieldVector<T extends FieldElement<T>>
d
- value to be added to each entry
public FieldVector<T> mapAddToSelf(T d)
The instance is changed by this method.
mapAddToSelf
in interface FieldVector<T extends FieldElement<T>>
d
- value to be added to each entry
public FieldVector<T> mapSubtract(T d)
mapSubtract
in interface FieldVector<T extends FieldElement<T>>
d
- value to be subtracted to each entry
public FieldVector<T> mapSubtractToSelf(T d)
The instance is changed by this method.
mapSubtractToSelf
in interface FieldVector<T extends FieldElement<T>>
d
- value to be subtracted to each entry
public FieldVector<T> mapMultiply(T d)
mapMultiply
in interface FieldVector<T extends FieldElement<T>>
d
- value to multiply all entries by
public FieldVector<T> mapMultiplyToSelf(T d)
The instance is changed by this method.
mapMultiplyToSelf
in interface FieldVector<T extends FieldElement<T>>
d
- value to multiply all entries by
public FieldVector<T> mapDivide(T d)
mapDivide
in interface FieldVector<T extends FieldElement<T>>
d
- value to divide all entries by
public FieldVector<T> mapDivideToSelf(T d)
The instance is changed by this method.
mapDivideToSelf
in interface FieldVector<T extends FieldElement<T>>
d
- value to divide all entries by
public FieldVector<T> mapInv()
mapInv
in interface FieldVector<T extends FieldElement<T>>
public FieldVector<T> mapInvToSelf()
The instance is changed by this method.
mapInvToSelf
in interface FieldVector<T extends FieldElement<T>>
public FieldVector<T> ebeMultiply(FieldVector<T> v) throws IllegalArgumentException
ebeMultiply
in interface FieldVector<T extends FieldElement<T>>
v
- vector by which instance elements must be multiplied
IllegalArgumentException
- if v is not the same size as thispublic FieldVector<T> ebeMultiply(T[] v) throws IllegalArgumentException
ebeMultiply
in interface FieldVector<T extends FieldElement<T>>
v
- vector by which instance elements must be multiplied
IllegalArgumentException
- if v is not the same size as thispublic ArrayFieldVector<T> ebeMultiply(ArrayFieldVector<T> v) throws IllegalArgumentException
v
- vector by which instance elements must be multiplied
IllegalArgumentException
- if v is not the same size as thispublic FieldVector<T> ebeDivide(FieldVector<T> v) throws IllegalArgumentException
ebeDivide
in interface FieldVector<T extends FieldElement<T>>
v
- vector by which instance elements must be divided
IllegalArgumentException
- if v is not the same size as thispublic FieldVector<T> ebeDivide(T[] v) throws IllegalArgumentException
ebeDivide
in interface FieldVector<T extends FieldElement<T>>
v
- vector by which instance elements must be divided
IllegalArgumentException
- if v is not the same size as thispublic ArrayFieldVector<T> ebeDivide(ArrayFieldVector<T> v) throws IllegalArgumentException
v
- vector by which instance elements must be divided
IllegalArgumentException
- if v is not the same size as thispublic T[] getData()
getData
in interface FieldVector<T extends FieldElement<T>>
public T[] getDataRef()
Does not make a fresh copy of the underlying data.
public T dotProduct(FieldVector<T> v) throws IllegalArgumentException
dotProduct
in interface FieldVector<T extends FieldElement<T>>
v
- vector with which dot product should be computed
IllegalArgumentException
- if v is not the same size as thispublic T dotProduct(T[] v) throws IllegalArgumentException
dotProduct
in interface FieldVector<T extends FieldElement<T>>
v
- vector with which dot product should be computed
IllegalArgumentException
- if v is not the same size as thispublic T dotProduct(ArrayFieldVector<T> v) throws IllegalArgumentException
v
- vector with which dot product should be computed
IllegalArgumentException
- if v is not the same size as thispublic FieldVector<T> projection(FieldVector<T> v)
projection
in interface FieldVector<T extends FieldElement<T>>
v
- vector onto which instance must be projected
public FieldVector<T> projection(T[] v)
projection
in interface FieldVector<T extends FieldElement<T>>
v
- vector onto which instance must be projected
public ArrayFieldVector<T> projection(ArrayFieldVector<T> v)
v
- vector onto which instance must be projected
IllegalArgumentException
- if v is not the same size as thispublic FieldMatrix<T> outerProduct(FieldVector<T> v) throws IllegalArgumentException
outerProduct
in interface FieldVector<T extends FieldElement<T>>
v
- vector with which outer product should be computed
IllegalArgumentException
- if v is not the same size as thispublic FieldMatrix<T> outerProduct(ArrayFieldVector<T> v) throws IllegalArgumentException
v
- vector with which outer product should be computed
IllegalArgumentException
- if v is not the same size as thispublic FieldMatrix<T> outerProduct(T[] v) throws IllegalArgumentException
outerProduct
in interface FieldVector<T extends FieldElement<T>>
v
- vector with which outer product should be computed
IllegalArgumentException
- if v is not the same size as thispublic T getEntry(int index) throws MatrixIndexException
The index start at 0 and must be lesser than the size,
otherwise a MatrixIndexException
is thrown.
getEntry
in interface FieldVector<T extends FieldElement<T>>
index
- index location of entry to be fetched
MatrixIndexException
- if the index is not validFieldVector.setEntry(int, FieldElement)
public int getDimension()
getDimension
in interface FieldVector<T extends FieldElement<T>>
public FieldVector<T> append(FieldVector<T> v)
append
in interface FieldVector<T extends FieldElement<T>>
v
- vector to append to this one.
public ArrayFieldVector<T> append(ArrayFieldVector<T> v)
v
- vector to append to this one.
public FieldVector<T> append(T in)
append
in interface FieldVector<T extends FieldElement<T>>
in
- T to append.
public FieldVector<T> append(T[] in)
append
in interface FieldVector<T extends FieldElement<T>>
in
- T array to append.
public FieldVector<T> getSubVector(int index, int n)
getSubVector
in interface FieldVector<T extends FieldElement<T>>
index
- index of first element.n
- number of elements to be retrieved.
public void setEntry(int index, T value)
setEntry
in interface FieldVector<T extends FieldElement<T>>
index
- element index.value
- new value for the element.FieldVector.getEntry(int)
public void setSubVector(int index, FieldVector<T> v)
setSubVector
in interface FieldVector<T extends FieldElement<T>>
index
- index of first element to be set.v
- vector containing the values to set.FieldVector.setSubVector(int, FieldElement[])
public void setSubVector(int index, T[] v)
setSubVector
in interface FieldVector<T extends FieldElement<T>>
index
- index of first element to be set.v
- vector containing the values to set.FieldVector.setSubVector(int, FieldVector)
public void set(int index, ArrayFieldVector<T> 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 sizepublic void set(T value)
set
in interface FieldVector<T extends FieldElement<T>>
value
- single value to set for all elementspublic T[] toArray()
The array is independent from vector data, it's elements are copied.
toArray
in interface FieldVector<T extends FieldElement<T>>
protected void checkVectorDimensions(FieldVector<T> v) throws IllegalArgumentException
v
- vector to compare instance with
IllegalArgumentException
- if the vectors do not
have the same dimensionprotected void checkVectorDimensions(int n) throws IllegalArgumentException
n
- expected dimension.
IllegalArgumentException
- if the dimension is
inconsistent with vector sizepublic boolean equals(Object other)
If all coordinates of two real vectors are exactly the same, and none are
Double.NaN
, the two real vectors are considered to be equal.
NaN
coordinates 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 to Double.NaN
, the real vector is equal to
a vector with all Double.NaN
coordinates.
equals
in class Object
other
- Object to test for equality to this
public int hashCode()
All NaN values have the same hash code.
hashCode
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |