T
- the type of the field elementspublic class ArrayFieldVector<T extends FieldElement<T>> extends Object implements FieldVector<T>, Serializable
FieldVector
interface with a FieldElement
array.Constructor and Description |
---|
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> fieldIn)
Build a 0-length vector.
|
ArrayFieldVector(Field<T> fieldIn,
int size)
Construct a vector of zeroes.
|
ArrayFieldVector(Field<T> fieldIn,
T[] d)
Construct a vector from an array, copying the input array.
|
ArrayFieldVector(Field<T> fieldIn,
T[] d,
boolean copyArray)
Create a new ArrayFieldVector using the input array as the underlying
data array.
|
ArrayFieldVector(Field<T> fieldIn,
T[] d,
int pos,
int size)
Construct a vector from part of a array.
|
ArrayFieldVector(Field<T> fieldIn,
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 a 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.
|
Modifier and Type | Method and Description |
---|---|
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 . |
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 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.
|
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.
|
boolean |
equals(Object other)
Test for the equality of two vectors.
|
T[] |
getData()
Returns the vector data (copy).
|
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.
|
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.
|
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.
|
ArrayFieldVector<T> |
subtract(ArrayFieldVector<T> v)
Compute
this minus v . |
FieldVector<T> |
subtract(FieldVector<T> v)
Compute
this minus v . |
T[] |
toArray()
Convert the vector to a T array.
|
public ArrayFieldVector(Field<T> fieldIn)
ArrayFieldVector(ArrayFieldVector, ArrayFieldVector)
constructor
or one of the append
methods (add(FieldVector)
or append(ArrayFieldVector)
) to gather
data into this vector.fieldIn
- field to which the elements belongpublic ArrayFieldVector(Field<T> fieldIn, int size)
fieldIn
- Field to which the elements belong.size
- Size of the vector.public ArrayFieldVector(int size, T preset)
size
- Size of the vector.preset
- All entries will be set with this value.public ArrayFieldVector(T[] d)
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.NullArgumentException
- if d
is null
.ZeroException
- if d
is empty.ArrayFieldVector(Field, FieldElement[])
public ArrayFieldVector(Field<T> fieldIn, T[] d)
fieldIn
- Field to which the elements belong.d
- Array.NullArgumentException
- if d
is null
.ArrayFieldVector(FieldElement[])
public ArrayFieldVector(T[] d, boolean copyArray)
copyArray
may be
set to false
. 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-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[], boolean)
constructor.d
- Data for the new vector.copyArray
- If true
, the input array will be copied,
otherwise it will be referenced.NullArgumentException
- if d
is null
.ZeroException
- if d
is empty.ArrayFieldVector(FieldElement[])
,
ArrayFieldVector(Field, FieldElement[], boolean)
public ArrayFieldVector(Field<T> fieldIn, T[] d, boolean copyArray)
copyArray
may be
set to false
. This will prevent the copying and improve
performance as no new array will be built and no data will be copied.fieldIn
- Field to which the elements belong.d
- Data for the new vector.copyArray
- If true
, the input array will be copied,
otherwise it will be referenced.NullArgumentException
- if d
is null
.ArrayFieldVector(FieldElement[], boolean)
public ArrayFieldVector(T[] d, int pos, int size)
d
- Array.pos
- Position of the first entry.size
- Number of entries to copy.NullArgumentException
- if d
is null
.NumberIsTooLargeException
- if the size of d
is less
than pos + size
.public ArrayFieldVector(Field<T> fieldIn, T[] d, int pos, int size)
fieldIn
- Field to which the elements belong.d
- Array.pos
- Position of the first entry.size
- Number of entries to copy.NullArgumentException
- if d
is null
.NumberIsTooLargeException
- if the size of d
is less
than pos + size
.public ArrayFieldVector(FieldVector<T> v)
v
- Vector to copy.NullArgumentException
- if v
is null
.public ArrayFieldVector(ArrayFieldVector<T> v)
v
- Vector to copy.NullArgumentException
- if v
is null
.public ArrayFieldVector(ArrayFieldVector<T> v, boolean deep)
v
- Vector to copy.deep
- If true
perform a deep copy, otherwise perform
a shallow copyNullArgumentException
- if v
is null
.public 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).NullArgumentException
- if v1
or v2
is null
.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).NullArgumentException
- if v1
or v2
is null
.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).NullArgumentException
- if v1
or v2
is null
.public ArrayFieldVector(T[] v1, T[] v2)
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).NullArgumentException
- if v1
or v2
is null
.ZeroException
- if both arrays are empty.ArrayFieldVector(Field, FieldElement[], FieldElement[])
public ArrayFieldVector(Field<T> fieldIn, T[] v1, T[] v2)
fieldIn
- 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).NullArgumentException
- if v1
or v2
is null
.ZeroException
- if both arrays are empty.ArrayFieldVector(FieldElement[], FieldElement[])
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)
this
and v
.add
in interface FieldVector<T extends FieldElement<T>>
v
- vector to be addedthis + v
public ArrayFieldVector<T> add(ArrayFieldVector<T> v)
this
and v
.v
- vector to be addedthis + v
DimensionMismatchException
- if v
is not the same size as this
public FieldVector<T> subtract(FieldVector<T> v)
this
minus v
.subtract
in interface FieldVector<T extends FieldElement<T>>
v
- vector to be subtractedthis - v
public ArrayFieldVector<T> subtract(ArrayFieldVector<T> v)
this
minus v
.v
- vector to be subtractedthis - v
DimensionMismatchException
- if v
is not the same size as this
public FieldVector<T> mapAdd(T d)
mapAdd
in interface FieldVector<T extends FieldElement<T>>
d
- value to be added to each entrythis + d
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 entrythis
public FieldVector<T> mapSubtract(T d)
mapSubtract
in interface FieldVector<T extends FieldElement<T>>
d
- value to be subtracted to each entrythis - d
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 entrythis
public FieldVector<T> mapMultiply(T d)
mapMultiply
in interface FieldVector<T extends FieldElement<T>>
d
- value to multiply all entries bythis * d
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 bythis
public FieldVector<T> mapDivide(T d)
mapDivide
in interface FieldVector<T extends FieldElement<T>>
d
- value to divide all entries bythis / d
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 bythis
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>>
this
public FieldVector<T> ebeMultiply(FieldVector<T> v)
ebeMultiply
in interface FieldVector<T extends FieldElement<T>>
v
- vector by which instance elements must be multipliedthis[i] * v[i]
for all i
public ArrayFieldVector<T> ebeMultiply(ArrayFieldVector<T> v)
v
- vector by which instance elements must be multipliedthis[i] * v[i]
for all i
DimensionMismatchException
- if v
is not the same size as this
public FieldVector<T> ebeDivide(FieldVector<T> v)
ebeDivide
in interface FieldVector<T extends FieldElement<T>>
v
- vector by which instance elements must be dividedthis[i] / v[i]
for all i
public ArrayFieldVector<T> ebeDivide(ArrayFieldVector<T> v)
v
- vector by which instance elements must be dividedthis[i] / v[i]
for all i
DimensionMismatchException
- if v
is not the same size as this
MathArithmeticException
- if one entry of v
is zero.public T[] getData()
public T[] getDataRef()
Does not make a fresh copy of the underlying data.
public T dotProduct(FieldVector<T> v)
dotProduct
in interface FieldVector<T extends FieldElement<T>>
v
- vector with which dot product should be computedthis
and v
public T dotProduct(ArrayFieldVector<T> v)
v
- vector with which dot product should be computedthis
and v
DimensionMismatchException
- if v
is not the same size as this
public FieldVector<T> projection(FieldVector<T> v)
projection
in interface FieldVector<T extends FieldElement<T>>
v
- vector onto which this
must be projectedthis
onto v
public ArrayFieldVector<T> projection(ArrayFieldVector<T> v)
v
- vector onto which this
must be projectedthis
onto v
DimensionMismatchException
- if v
is not the same size as this
MathArithmeticException
- if v
is the null vector.public FieldMatrix<T> outerProduct(FieldVector<T> v)
outerProduct
in interface FieldVector<T extends FieldElement<T>>
v
- vector with which outer product should be computedpublic FieldMatrix<T> outerProduct(ArrayFieldVector<T> v)
v
- vector with which outer product should be computedpublic T getEntry(int index)
getEntry
in interface FieldVector<T extends FieldElement<T>>
index
- Index location of entry to be fetched.index
.FieldVector.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> 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.public void set(int index, ArrayFieldVector<T> v)
index
- index of first element to be set.v
- vector containing the values to set.OutOfRangeException
- if the index is invalid.public 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)
v
- vector to compare instance withDimensionMismatchException
- if the vectors do not
have the same dimensionsprotected void checkVectorDimensions(int n)
n
- Expected dimension.DimensionMismatchException
- if the dimension is not equal to the
size of this
vector.public boolean equals(Object other)
Copyright © 2018 CNES. All Rights Reserved.