Top Description Fields Constructors Methods
org.apache.commons.math3.linear

public Class ArrayFieldVector<T extends FieldElement<T>>

extends Object
implements FieldVector<T extends FieldElement<T>>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.apache.commons.math3.linear.FieldVector
Type Parameters
<T>
the type of the field elements
Imports
java.io.Serializable, java.util.Arrays, org.apache.commons.math3.Field, .FieldElement, org.apache.commons.math3.exception.DimensionMismatchException, .MathArithmeticException, .NotPositiveException, .NullArgumentException, .NumberIsTooLargeException, .NumberIsTooSmallException, .OutOfRangeException, .ZeroException, org.apache.commons.math3.exception.util.LocalizedFormats, org.apache.commons.math3.util.MathArrays, .MathUtils

This class implements the FieldVector interface with a FieldElement array.
Since
2.0

Field Summary

Modifier and TypeField and Description
private T[]
data

Entries of the vector.

private final Field<T>
field

Field to which the elements belong.

private static final long
serialVersionUID

Serializable version identifier.

Constructor Summary

AccessConstructor and Description
public
ArrayFieldVector(final Field<T>
field to which the elements belong
field
)

Build a 0-length vector.

public
ArrayFieldVector(Field<T>
Field to which the elements belong.
field
,
int
Size of the vector.
size
)

Construct a vector of zeroes.

public
ArrayFieldVector(int
Size of the vector.
size
,
T
All entries will be set with this value.
preset
)

Construct a vector with preset values.

public
ArrayFieldVector(T[]
Array.
d
)

Construct a vector from an array, copying the input array.

public
ArrayFieldVector(Field<T>
Field to which the elements belong.
field
,
T[]
Array.
d
)

Construct a vector from an array, copying the input array.

public
ArrayFieldVector(T[]
Data for the new vector.
d
,
boolean
If true, the input array will be copied, otherwise it will be referenced.
copyArray
)

Create a new ArrayFieldVector using the input array as the underlying data array.

public
ArrayFieldVector(Field<T>
Field to which the elements belong.
field
,
T[]
Data for the new vector.
d
,
boolean
If true, the input array will be copied, otherwise it will be referenced.
copyArray
)

Create a new ArrayFieldVector using the input array as the underlying data array.

public
ArrayFieldVector(T[]
Array.
d
,
int
Position of the first entry.
pos
,
int
Number of entries to copy.
size
)

Construct a vector from part of a array.

public
ArrayFieldVector(Field<T>
Field to which the elements belong.
field
,
T[]
Array.
d
,
int
Position of the first entry.
pos
,
int
Number of entries to copy.
size
)

Construct a vector from part of a array.

public
ArrayFieldVector(FieldVector<T>
Vector to copy.
v
)

Construct a vector from another vector, using a deep copy.

public
ArrayFieldVector(ArrayFieldVector<T>
Vector to copy.
v
)

Construct a vector from another vector, using a deep copy.

public
ArrayFieldVector(ArrayFieldVector<T>
Vector to copy.
v
,
boolean
If true perform a deep copy, otherwise perform a shallow copy
deep
)

Construct a vector from another vector.

public
ArrayFieldVector(ArrayFieldVector<T>
First vector (will be put in front of the new vector).
v1
,
ArrayFieldVector<T>
Second vector (will be put at back of the new vector).
v2
)
Deprecated as of 3.2, replaced by ArrayFieldVector(FieldVector, FieldVector)

Construct a vector by appending one vector to another vector.

public
ArrayFieldVector(FieldVector<T>
First vector (will be put in front of the new vector).
v1
,
FieldVector<T>
Second vector (will be put at back of the new vector).
v2
)

Construct a vector by appending one vector to another vector.

public
ArrayFieldVector(ArrayFieldVector<T>
First vector (will be put in front of the new vector).
v1
,
T[]
Second vector (will be put at back of the new vector).
v2
)
Deprecated as of 3.2, replaced by ArrayFieldVector(FieldVector, FieldElement[])

Construct a vector by appending one vector to another vector.

public
ArrayFieldVector(FieldVector<T>
First vector (will be put in front of the new vector).
v1
,
T[]
Second vector (will be put at back of the new vector).
v2
)

Construct a vector by appending one vector to another vector.

public
ArrayFieldVector(T[]
First vector (will be put in front of the new vector).
v1
,
ArrayFieldVector<T>
Second vector (will be put at back of the new vector).
v2
)
Deprecated as of 3.2, replaced by ArrayFieldVector(FieldElement[], FieldVector)

Construct a vector by appending one vector to another vector.

public
ArrayFieldVector(T[]
First vector (will be put in front of the new vector).
v1
,
FieldVector<T>
Second vector (will be put at back of the new vector).
v2
)

Construct a vector by appending one vector to another vector.

public
ArrayFieldVector(T[]
First vector (will be put in front of the new vector).
v1
,
T[]
Second vector (will be put at back of the new vector).
v2
)

Construct a vector by appending one vector to another vector.

public
ArrayFieldVector(Field<T>
Field to which the elements belong.
field
,
T[]
First vector (will be put in front of the new vector).
v1
,
T[]
Second vector (will be put at back of the new vector).
v2
)

Construct a vector by appending one vector to another vector.

Method Summary

Modifier and TypeMethod and Description
public FieldVector<T>
add(FieldVector<T>
vector to be added
v
)

Implements org.apache.commons.math3.linear.FieldVector.add.

Compute the sum of this and v.

public ArrayFieldVector<T>

Returns:

this + v
add
(ArrayFieldVector<T>
vector to be added
v
)

Compute the sum of this and v.

public FieldVector<T>
append(FieldVector<T>
vector to append to this one.
v
)

Implements org.apache.commons.math3.linear.FieldVector.append, org.apache.commons.math3.linear.FieldVector.append.

Construct a vector by appending a vector to this vector.

public ArrayFieldVector<T>

Returns:

a new vector
append
(ArrayFieldVector<T>
vector to append to this one.
v
)

Implements org.apache.commons.math3.linear.FieldVector.append.

Construct a vector by appending a vector to this vector.

public FieldVector<T>
append(T
T to append.
in
)

Implements org.apache.commons.math3.linear.FieldVector.append.

Construct a vector by appending a T to this vector.

private void
checkIndex(final int
Index to check.
index
)

Check if an index is valid.

private void
checkIndices(final int
the index of the first entry of the subvector
start
,
final int
the index of the last entry of the subvector (inclusive)
end
)

Checks that the indices of a subvector are valid.

protected void
checkVectorDimensions(FieldVector<T>
vector to compare instance with
v
)

Check if instance and specified vectors have the same dimension.

protected void
checkVectorDimensions(int
Expected dimension.
n
)

Check if instance dimension is equal to some expected value.

public FieldVector<T>
copy()

Implements org.apache.commons.math3.linear.FieldVector.copy.

Returns a (deep) copy of this.

public T
dotProduct(FieldVector<T>
vector with which dot product should be computed
v
)

Implements org.apache.commons.math3.linear.FieldVector.dotProduct.

Compute the dot product.

public T

Returns:

the scalar dot product of this and v
dotProduct
(ArrayFieldVector<T>
vector with which dot product should be computed
v
)

Compute the dot product.

public FieldVector<T>
ebeDivide(FieldVector<T>
vector by which instance elements must be divided
v
)

Implements org.apache.commons.math3.linear.FieldVector.ebeDivide.

Element-by-element division.

public ArrayFieldVector<T>

Returns:

a vector containing this[i] / v[i] for all i
ebeDivide
(ArrayFieldVector<T>
vector by which instance elements must be divided
v
)

Element-by-element division.

public FieldVector<T>
ebeMultiply(FieldVector<T>
vector by which instance elements must be multiplied
v
)

Implements org.apache.commons.math3.linear.FieldVector.ebeMultiply.

Element-by-element multiplication.

public ArrayFieldVector<T>

Returns:

a vector containing this[i] * v[i] for all i
ebeMultiply
(ArrayFieldVector<T>
vector by which instance elements must be multiplied
v
)

Element-by-element multiplication.

public boolean

Returns:

true if two vector objects are equal, false otherwise.
equals
(Object
Object to test for equality.
other
)

Overrides java.lang.Object.equals.

Test for the equality of two vectors.

public T[]
getData()

Implements org.apache.commons.math3.linear.FieldVector.getData.

Returns vector entries as a T array.

public T[]

Returns:

array of entries
getDataRef
()

Returns a reference to the underlying data array.

public int
getDimension()

Implements org.apache.commons.math3.linear.FieldVector.getDimension.

Returns the size of the vector.

public T
getEntry(int
Index location of entry to be fetched.
index
)

Implements org.apache.commons.math3.linear.FieldVector.getEntry.

Returns the entry in the specified index.

public Field<T>
getField()

Implements org.apache.commons.math3.linear.FieldVector.getField.

Get the type of field elements of the vector.

public FieldVector<T>
getSubVector(int
index of first element.
index
,
int
number of elements to be retrieved.
n
)

Implements org.apache.commons.math3.linear.FieldVector.getSubVector.

Get a subvector from consecutive elements.

public int

Returns:

a hash code value for this object
hashCode
()

Overrides java.lang.Object.hashCode.

Get a hashCode for the real vector.

public FieldVector<T>
mapAdd(T
value to be added to each entry
d
)

Implements org.apache.commons.math3.linear.FieldVector.mapAdd.

Map an addition operation to each entry.

public FieldVector<T>
mapAddToSelf(T
value to be added to each entry
d
)

Implements org.apache.commons.math3.linear.FieldVector.mapAddToSelf.

Map an addition operation to each entry.

public FieldVector<T>
mapDivide(T
value to divide all entries by
d
)

Implements org.apache.commons.math3.linear.FieldVector.mapDivide.

Map a division operation to each entry.

public FieldVector<T>
mapDivideToSelf(T
value to divide all entries by
d
)

Implements org.apache.commons.math3.linear.FieldVector.mapDivideToSelf.

Map a division operation to each entry.

public FieldVector<T>
mapInv()

Implements org.apache.commons.math3.linear.FieldVector.mapInv.

Map the 1/x function to each entry.

public FieldVector<T>
mapInvToSelf()

Implements org.apache.commons.math3.linear.FieldVector.mapInvToSelf.

Map the 1/x function to each entry.

public FieldVector<T>
mapMultiply(T
value to multiply all entries by
d
)

Implements org.apache.commons.math3.linear.FieldVector.mapMultiply.

Map a multiplication operation to each entry.

public FieldVector<T>
mapMultiplyToSelf(T
value to multiply all entries by
d
)

Implements org.apache.commons.math3.linear.FieldVector.mapMultiplyToSelf.

Map a multiplication operation to each entry.

public FieldVector<T>
mapSubtract(T
value to be subtracted to each entry
d
)

Implements org.apache.commons.math3.linear.FieldVector.mapSubtract.

Map a subtraction operation to each entry.

public FieldVector<T>
mapSubtractToSelf(T
value to be subtracted to each entry
d
)

Implements org.apache.commons.math3.linear.FieldVector.mapSubtractToSelf.

Map a subtraction operation to each entry.

public FieldMatrix<T>
outerProduct(FieldVector<T>
vector with which outer product should be computed
v
)

Implements org.apache.commons.math3.linear.FieldVector.outerProduct.

Compute the outer product.

public FieldMatrix<T>

Returns:

the matrix outer product between instance and v
outerProduct
(ArrayFieldVector<T>
vector with which outer product should be computed
v
)

Compute the outer product.

public FieldVector<T>
projection(FieldVector<T>
vector onto which this must be projected
v
)

Implements org.apache.commons.math3.linear.FieldVector.projection.

Find the orthogonal projection of this vector onto another vector.

public ArrayFieldVector<T>

Returns:

projection of this onto v
projection
(ArrayFieldVector<T>
vector onto which this must be projected
v
)

Find the orthogonal projection of this vector onto another vector.

public void
set(int
index of first element to be set.
index
,
ArrayFieldVector<T>
vector containing the values to set.
v
)

Set a set of consecutive elements.

public void
set(T
single value to set for all elements
value
)

Implements org.apache.commons.math3.linear.FieldVector.set.

Set all elements to a single value.

public void
setEntry(int
element index.
index
,
T
new value for the element.
value
)

Implements org.apache.commons.math3.linear.FieldVector.setEntry.

Set a single element.

public void
setSubVector(int
index of first element to be set.
index
,
FieldVector<T>
vector containing the values to set.
v
)

Implements org.apache.commons.math3.linear.FieldVector.setSubVector.

Set a set of consecutive elements.

public FieldVector<T>
subtract(FieldVector<T>
vector to be subtracted
v
)

Implements org.apache.commons.math3.linear.FieldVector.subtract.

Compute this minus v.

public ArrayFieldVector<T>

Returns:

this - v
subtract
(ArrayFieldVector<T>
vector to be subtracted
v
)

Compute this minus v.

public T[]
toArray()

Implements org.apache.commons.math3.linear.FieldVector.toArray.

Convert the vector to a T array.

public T

Returns:

the value returned by FieldVectorPreservingVisitor#end() at the end of the walk
walkInDefaultOrder
(final FieldVectorPreservingVisitor<T>
the visitor to be used to process the entries of this vector
visitor
)

Visits (but does not alter) all entries of this vector in default order (increasing index).

public T

Returns:

the value returned by FieldVectorPreservingVisitor#end() at the end of the walk
walkInDefaultOrder
(final FieldVectorPreservingVisitor<T>
visitor to be used to process the entries of this vector
visitor
,
final int
the index of the first entry to be visited
start
,
final int
the index of the last entry to be visited (inclusive)
end
)

Visits (but does not alter) some entries of this vector in default order (increasing index).

public T

Returns:

the value returned by FieldVectorChangingVisitor#end() at the end of the walk
walkInDefaultOrder
(final FieldVectorChangingVisitor<T>
the visitor to be used to process and modify the entries of this vector
visitor
)

Visits (and possibly alters) all entries of this vector in default order (increasing index).

public T

Returns:

the value returned by FieldVectorChangingVisitor#end() at the end of the walk
walkInDefaultOrder
(final FieldVectorChangingVisitor<T>
visitor to be used to process the entries of this vector
visitor
,
final int
the index of the first entry to be visited
start
,
final int
the index of the last entry to be visited (inclusive)
end
)

Visits (and possibly alters) some entries of this vector in default order (increasing index).

public T

Returns:

the value returned by FieldVectorPreservingVisitor#end() at the end of the walk
walkInOptimizedOrder
(final FieldVectorPreservingVisitor<T>
the visitor to be used to process the entries of this vector
visitor
)

Visits (but does not alter) all entries of this vector in optimized order.

public T

Returns:

the value returned by FieldVectorPreservingVisitor#end() at the end of the walk
walkInOptimizedOrder
(final FieldVectorPreservingVisitor<T>
visitor to be used to process the entries of this vector
visitor
,
final int
the index of the first entry to be visited
start
,
final int
the index of the last entry to be visited (inclusive)
end
)

Visits (but does not alter) some entries of this vector in optimized order.

public T

Returns:

the value returned by FieldVectorChangingVisitor#end() at the end of the walk
walkInOptimizedOrder
(final FieldVectorChangingVisitor<T>
the visitor to be used to process the entries of this vector
visitor
)

Visits (and possibly alters) all entries of this vector in optimized order.

public T

Returns:

the value returned by FieldVectorChangingVisitor#end() at the end of the walk
walkInOptimizedOrder
(final FieldVectorChangingVisitor<T>
visitor to be used to process the entries of this vector
visitor
,
final int
the index of the first entry to be visited
start
,
final int
the index of the last entry to be visited (inclusive)
end
)

Visits (and possibly change) some entries of this vector in optimized order.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait