org.apache.commons.math3.linear

## Class SparseFieldVector<T extends FieldElement<T>>

- java.lang.Object
- - org.apache.commons.math3.linear.SparseFieldVector<T>

Type Parameters:
  `T` - the type of the field elements

All Implemented Interfaces:
  java.io.Serializable, FieldVector<T>

Deprecated.
As of version 3.1, this class is deprecated, for reasons exposed in this JIRA ticket. This class will be removed in version 4.0.

    @Deprecated
    public class SparseFieldVector<T extends FieldElement<T>>
    extends java.lang.Object
    implements FieldVector<T>, java.io.Serializable

This class implements the `FieldVector` interface with a `OpenIntToFieldHashMap` backing store.

Since:
  2.0
Version:
  $Id: SparseFieldVector.java 1416643 2012-12-03 19:37:14Z tn $
See Also:
  Serialized Form

### Field Summary

Fields
`private OpenIntToFieldHashMap<T>` `entries` Deprecated. Entries of the vector.
`private Field<T>` `field` Deprecated. Field to which the elements belong.
`private static long` `serialVersionUID` Deprecated. Serialization identifier.
`private int` `virtualSize` Deprecated. Dimension of the vector.

### Constructor Summary

Constructors
`` `SparseFieldVector(Field<T> field)` Deprecated. Build a 0-length vector.
`` `SparseFieldVector(Field<T> field, int dimension)` Deprecated. Construct a vector of zeroes.
`` `SparseFieldVector(Field<T> field, int dimension, int expectedSize)` Deprecated. Build a vector with known the sparseness (for advanced use only).
`` `SparseFieldVector(Field<T> field, T[] values)` Deprecated. Create from a Field array.
`` `SparseFieldVector(SparseFieldVector<T> v)` Deprecated. Copy constructor.
`protected` `SparseFieldVector(SparseFieldVector<T> v, int resize)` Deprecated. Build a resized vector, for use with append.

### Method Summary

Methods
`FieldVector<T>` `add(FieldVector<T> v)` Deprecated. Compute the sum of `this` and `v`.
`FieldVector<T>` `add(SparseFieldVector<T> v)` Deprecated. Optimized method to add sparse vectors.
`FieldVector<T>` `append(FieldVector<T> v)` Deprecated. Construct a vector by appending a vector to this vector.
`FieldVector<T>` `append(SparseFieldVector<T> v)` Deprecated. Construct a vector by appending a vector to this vector.
`FieldVector<T>` `append(T d)` Deprecated. Construct a vector by appending a T to this vector.
`private T[]` `buildArray(int length)` Deprecated. Build an array of elements.
`private void` `checkIndex(int index)` Deprecated. Check whether an index is valid.
`protected void` `checkVectorDimensions(int n)` Deprecated. Check if instance dimension is equal to some expected value.
`FieldVector<T>` `copy()` Deprecated. Returns a (deep) copy of this.
`T` `dotProduct(FieldVector<T> v)` Deprecated. Compute the dot product.
`FieldVector<T>` `ebeDivide(FieldVector<T> v)` Deprecated. Element-by-element division.
`FieldVector<T>` `ebeMultiply(FieldVector<T> v)` Deprecated. Element-by-element multiplication.
`boolean` `equals(java.lang.Object obj)` Deprecated.
`T[]` `getData()` Deprecated. as of 3.1, to be removed in 4.0. Please use the `toArray()` method instead.
`int` `getDimension()` Deprecated. Returns the size of the vector.
`private OpenIntToFieldHashMap<T>` `getEntries()` Deprecated. Get the entries of this instance.
`T` `getEntry(int index)` Deprecated. Returns the entry in the specified index.
`Field<T>` `getField()` Deprecated. Get the type of field elements of the vector.
`FieldVector<T>` `getSubVector(int index, int n)` Deprecated. Get a subvector from consecutive elements.
`int` `hashCode()` Deprecated.
`FieldVector<T>` `mapAdd(T d)` Deprecated. Map an addition operation to each entry.
`FieldVector<T>` `mapAddToSelf(T d)` Deprecated. Map an addition operation to each entry.
`FieldVector<T>` `mapDivide(T d)` Deprecated. Map a division operation to each entry.
`FieldVector<T>` `mapDivideToSelf(T d)` Deprecated. Map a division operation to each entry.
`FieldVector<T>` `mapInv()` Deprecated. Map the 1/x function to each entry.
`FieldVector<T>` `mapInvToSelf()` Deprecated. Map the 1/x function to each entry.
`FieldVector<T>` `mapMultiply(T d)` Deprecated. Map a multiplication operation to each entry.
`FieldVector<T>` `mapMultiplyToSelf(T d)` Deprecated. Map a multiplication operation to each entry.
`FieldVector<T>` `mapSubtract(T d)` Deprecated. Map a subtraction operation to each entry.
`FieldVector<T>` `mapSubtractToSelf(T d)` Deprecated. Map a subtraction operation to each entry.
`FieldMatrix<T>` `outerProduct(FieldVector<T> v)` Deprecated. Compute the outer product.
`FieldMatrix<T>` `outerProduct(SparseFieldVector<T> v)` Deprecated. Optimized method to compute outer product when both vectors are sparse.
`FieldVector<T>` `projection(FieldVector<T> v)` Deprecated. Find the orthogonal projection of this vector onto another vector.
`void` `set(T value)` Deprecated. Set all elements to a single value.
`void` `setEntry(int index, T value)` Deprecated. Set a single element.
`void` `setSubVector(int index, FieldVector<T> v)` Deprecated. Set a set of consecutive elements.
`FieldVector<T>` `subtract(FieldVector<T> v)` Deprecated. Compute `this` minus `v`.
`SparseFieldVector<T>` `subtract(SparseFieldVector<T> v)` Deprecated. Optimized method to compute `this` minus `v`.
`T[]` `toArray()` Deprecated. 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

#### serialVersionUID

    private static final long serialVersionUID

Deprecated.
Serialization identifier.

See Also:
  Constant Field Values

#### field

    private final Field<T extends FieldElement<T>> field

Deprecated.
Field to which the elements belong.

#### entries

    private final OpenIntToFieldHashMap<T extends FieldElement<T>> entries

Deprecated.
Entries of the vector.

#### virtualSize

    private final int virtualSize

Deprecated.
Dimension of the vector.

### Constructor Detail

#### SparseFieldVector

    public SparseFieldVector(Field<T> field)

Deprecated.
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 the `SparseFieldVector(SparseFieldVector, int)` constructor or one of the `append` method (`append(FieldVector)` or `append(SparseFieldVector)`) to gather data into this vector.

Parameters:
  `field` - Field to which the elements belong.

#### SparseFieldVector

    public SparseFieldVector(Field<T> field,
                     int dimension)

Deprecated.
Construct a vector of zeroes.

Parameters:
  `field` - Field to which the elements belong.
  `dimension` - Size of the vector.

#### SparseFieldVector

    protected SparseFieldVector(SparseFieldVector<T> v,
                     int resize)

Deprecated.
Build a resized vector, for use with append.

Parameters:
  `v` - Original vector
  `resize` - Amount to add.

#### SparseFieldVector

    public SparseFieldVector(Field<T> field,
                     int dimension,
                     int expectedSize)

Deprecated.
Build a vector with known the sparseness (for advanced use only).

Parameters:
  `field` - Field to which the elements belong.
  `dimension` - Size of the vector.
  `expectedSize` - Expected number of non-zero entries.

#### SparseFieldVector

    public SparseFieldVector(Field<T> field,
                     T[] values)

Deprecated.
Create from a Field array. Only non-zero entries will be stored.

Parameters:
  `field` - Field to which the elements belong.
  `values` - Set of values to create from.

#### SparseFieldVector

    public SparseFieldVector(SparseFieldVector<T> v)

Deprecated.
Copy constructor.

Parameters:
  `v` - Instance to copy.

### Method Detail

#### getEntries

    private OpenIntToFieldHashMap<T> getEntries()

Deprecated.
Get the entries of this instance.

Returns:
  the entries of this instance

#### add

    public FieldVector<T> add(SparseFieldVector<T> v)
                                               throws DimensionMismatchException

Deprecated.
Optimized method to add sparse vectors.

Parameters:
  `v` - Vector to add.
Returns:
  `this + v`.
Throws:
  `DimensionMismatchException` - if `v` is not the same size as `this`.

#### append

    public FieldVector<T> append(SparseFieldVector<T> v)

Deprecated.
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(FieldVector<T> v)

Deprecated.
Construct a vector by appending a vector to this vector.

Specified by:
  `append` in interface `FieldVector<T extends FieldElement<T>>`
Parameters:
  `v` - vector to append to this one.
Returns:
  a new vector

#### append

    public FieldVector<T> append(T d)

Deprecated.
Construct a vector by appending a T to this vector.

Specified by:
  `append` in interface `FieldVector<T extends FieldElement<T>>`
Parameters:
  `d` - T to append.
Returns:
  a new vector

#### copy

    public FieldVector<T> copy()

Deprecated.
Returns a (deep) copy of this.

Specified by:
  `copy` in interface `FieldVector<T extends FieldElement<T>>`
Returns:
  vector copy

#### dotProduct

    public T dotProduct(FieldVector<T> v)
                                         throws DimensionMismatchException

Deprecated.
Compute the dot product.

Specified by:
  `dotProduct` in interface `FieldVector<T extends FieldElement<T>>`
Parameters:
  `v` - vector with which dot product should be computed
Returns:
  the scalar dot product of `this` and `v`
Throws:
  `DimensionMismatchException` - if `v` is not the same size as `this`

#### ebeDivide

    public FieldVector<T> ebeDivide(FieldVector<T> v)
                                                     throws DimensionMismatchException,
                                                            MathArithmeticException

Deprecated.
Element-by-element division.

Specified by:
  `ebeDivide` in interface `FieldVector<T extends FieldElement<T>>`
Parameters:
  `v` - vector by which instance elements must be divided
Returns:
  a vector containing `this[i] / v[i]` for all `i`
Throws:
  `DimensionMismatchException` - if `v` is not the same size as `this`
  `MathArithmeticException` - if one entry of `v` is zero.

#### ebeMultiply

    public FieldVector<T> ebeMultiply(FieldVector<T> v)
                                                       throws DimensionMismatchException

Deprecated.
Element-by-element multiplication.

Specified by:
  `ebeMultiply` in interface `FieldVector<T extends FieldElement<T>>`
Parameters:
  `v` - vector by which instance elements must be multiplied
Returns:
  a vector containing `this[i] * v[i]` for all `i`
Throws:
  `DimensionMismatchException` - if `v` is not the same size as `this`

#### getData

    @Deprecated
    public T[] getData()

Deprecated. as of 3.1, to be removed in 4.0. Please use the `toArray()` method instead.
Returns vector entries as a T array.

Specified by:
  `getData` in interface `FieldVector<T extends FieldElement<T>>`
Returns:
  T array of entries

#### getDimension

    public int getDimension()

Deprecated.
Returns the size of the vector.

Specified by:
  `getDimension` in interface `FieldVector<T extends FieldElement<T>>`
Returns:
  size

#### getEntry

    public T getEntry(int index)
                                       throws OutOfRangeException

Deprecated.
Returns the entry in the specified index.

Specified by:
  `getEntry` in interface `FieldVector<T extends FieldElement<T>>`
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:
  `FieldVector.setEntry(int, FieldElement)`

#### getField

    public Field<T> getField()

Deprecated.
Get the type of field elements of the vector.

Specified by:
  `getField` in interface `FieldVector<T extends FieldElement<T>>`
Returns:
  type of field elements of the vector

#### getSubVector

    public FieldVector<T> getSubVector(int index,
                              int n)
                                                        throws OutOfRangeException,
                                                               NotPositiveException

Deprecated.
Get a subvector from consecutive elements.

Specified by:
  `getSubVector` in interface `FieldVector<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.

#### mapAdd

    public FieldVector<T> mapAdd(T d)
                                                  throws NullArgumentException

Deprecated.
Map an addition operation to each entry.

Specified by:
  `mapAdd` in interface `FieldVector<T extends FieldElement<T>>`
Parameters:
  `d` - value to be added to each entry
Returns:
  `this + d`
Throws:
  `NullArgumentException` - if `d` is `null`.

#### mapAddToSelf

    public FieldVector<T> mapAddToSelf(T d)
                                                        throws NullArgumentException

Deprecated.
Map an addition operation to each entry.

The instance is changed by this method.

Specified by:
  `mapAddToSelf` in interface `FieldVector<T extends FieldElement<T>>`
Parameters:
  `d` - value to be added to each entry
Returns:
  for convenience, return `this`
Throws:
  `NullArgumentException` - if `d` is `null`.

#### mapDivide

    public FieldVector<T> mapDivide(T d)
                                                     throws NullArgumentException,
                                                            MathArithmeticException

Deprecated.
Map a division operation to each entry.

Specified by:
  `mapDivide` in interface `FieldVector<T extends FieldElement<T>>`
Parameters:
  `d` - value to divide all entries by
Returns:
  `this / d`
Throws:
  `NullArgumentException` - if `d` is `null`.
  `MathArithmeticException` - if `d` is zero.

#### mapDivideToSelf

    public FieldVector<T> mapDivideToSelf(T d)
                                                           throws NullArgumentException,
                                                                  MathArithmeticException

Deprecated.
Map a division operation to each entry.

The instance is changed by this method.

Specified by:
  `mapDivideToSelf` in interface `FieldVector<T extends FieldElement<T>>`
Parameters:
  `d` - value to divide all entries by
Returns:
  for convenience, return `this`
Throws:
  `NullArgumentException` - if `d` is `null`.
  `MathArithmeticException` - if `d` is zero.

#### mapInv

    public FieldVector<T> mapInv()
                                                  throws MathArithmeticException

Deprecated.
Map the 1/x function to each entry.

Specified by:
  `mapInv` in interface `FieldVector<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

Deprecated.
Map the 1/x function to each entry.

The instance is changed by this method.

Specified by:
  `mapInvToSelf` in interface `FieldVector<T extends FieldElement<T>>`
Returns:
  for convenience, return `this`
Throws:
  `MathArithmeticException` - if one of the entries is zero.

#### mapMultiply

    public FieldVector<T> mapMultiply(T d)
                                                       throws NullArgumentException

Deprecated.
Map a multiplication operation to each entry.

Specified by:
  `mapMultiply` in interface `FieldVector<T extends FieldElement<T>>`
Parameters:
  `d` - value to multiply all entries by
Returns:
  `this * d`
Throws:
  `NullArgumentException` - if `d` is `null`.

#### mapMultiplyToSelf

    public FieldVector<T> mapMultiplyToSelf(T d)
                                                             throws NullArgumentException

Deprecated.
Map a multiplication operation to each entry.

The instance is changed by this method.

Specified by:
  `mapMultiplyToSelf` in interface `FieldVector<T extends FieldElement<T>>`
Parameters:
  `d` - value to multiply all entries by
Returns:
  for convenience, return `this`
Throws:
  `NullArgumentException` - if `d` is `null`.

#### mapSubtract

    public FieldVector<T> mapSubtract(T d)
                                                       throws NullArgumentException

Deprecated.
Map a subtraction operation to each entry.

Specified by:
  `mapSubtract` in interface `FieldVector<T extends FieldElement<T>>`
Parameters:
  `d` - value to be subtracted to each entry
Returns:
  `this - d`
Throws:
  `NullArgumentException` - if `d` is `null`

#### mapSubtractToSelf

    public FieldVector<T> mapSubtractToSelf(T d)
                                                             throws NullArgumentException

Deprecated.
Map a subtraction operation to each entry.

The instance is changed by this method.

Specified by:
  `mapSubtractToSelf` in interface `FieldVector<T extends FieldElement<T>>`
Parameters:
  `d` - value to be subtracted to each entry
Returns:
  for convenience, return `this`
Throws:
  `NullArgumentException` - if `d` is `null`

#### outerProduct

    public FieldMatrix<T> outerProduct(SparseFieldVector<T> v)

Deprecated.
Optimized method to compute outer product when both vectors are sparse.

Parameters:
  `v` - vector with which outer product should be computed
Returns:
  the matrix outer product between instance and v

#### outerProduct

    public FieldMatrix<T> outerProduct(FieldVector<T> v)

Deprecated.
Compute the outer product.

Specified by:
  `outerProduct` in interface `FieldVector<T extends FieldElement<T>>`
Parameters:
  `v` - vector with which outer product should be computed
Returns:
  the matrix outer product between instance and v

#### projection

    public FieldVector<T> projection(FieldVector<T> v)
                                                      throws DimensionMismatchException,
                                                             MathArithmeticException

Deprecated.
Find the orthogonal projection of this vector onto another vector.

Specified by:
  `projection` in interface `FieldVector<T extends FieldElement<T>>`
Parameters:
  `v` - vector onto which `this` must be projected
Returns:
  projection of `this` onto `v`
Throws:
  `DimensionMismatchException` - if `v` is not the same size as `this`
  `MathArithmeticException` - if `v` is the null vector.

#### set

    public void set(T value)

Deprecated.
Set all elements to a single value.

Specified by:
  `set` in interface `FieldVector<T extends FieldElement<T>>`
Parameters:
  `value` - single value to set for all elements

#### setEntry

    public void setEntry(int index,
                T value)
                  throws OutOfRangeException

Deprecated.
Set a single element.

Specified by:
  `setEntry` in interface `FieldVector<T extends FieldElement<T>>`
Parameters:
  `index` - element index.
  `value` - new value for the element.
Throws:
  `OutOfRangeException` - if the index is not valid.
See Also:
  `FieldVector.getEntry(int)`

#### setSubVector

    public void setSubVector(int index,
                    FieldVector<T> v)
                      throws OutOfRangeException

Deprecated.
Set a set of consecutive elements.

Specified by:
  `setSubVector` in interface `FieldVector<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.

#### subtract

    public SparseFieldVector<T> subtract(SparseFieldVector<T> v)
                                                          throws DimensionMismatchException

Deprecated.
Optimized method to compute `this` minus `v`.

Parameters:
  `v` - vector to be subtracted
Returns:
  `this - v`
Throws:
  `DimensionMismatchException` - if `v` is not the same size as `this`.

#### subtract

    public FieldVector<T> subtract(FieldVector<T> v)
                                                    throws DimensionMismatchException

Deprecated.
Compute `this` minus `v`.

Specified by:
  `subtract` in interface `FieldVector<T extends FieldElement<T>>`
Parameters:
  `v` - vector to be subtracted
Returns:
  `this - v`
Throws:
  `DimensionMismatchException` - if `v` is not the same size as `this`

#### toArray

    public T[] toArray()

Deprecated.
Convert the vector to a T array.

The array is independent from vector data, it's elements are copied.

Specified by:
  `toArray` in interface `FieldVector<T extends FieldElement<T>>`
Returns:
  array containing a copy of vector elements

#### checkIndex

    private void checkIndex(int index)
                     throws OutOfRangeException

Deprecated.
Check whether an index is valid.

Parameters:
  `index` - Index to check.
Throws:
  `OutOfRangeException` - if the index is not valid.

#### checkVectorDimensions

    protected void checkVectorDimensions(int n)
                                  throws DimensionMismatchException

Deprecated.
Check if instance dimension is equal to some expected value.

Parameters:
  `n` - Expected dimension.
Throws:
  `DimensionMismatchException` - if the dimensions do not match.

#### add

    public FieldVector<T> add(FieldVector<T> v)
                                               throws DimensionMismatchException

Deprecated.
Compute the sum of `this` and `v`.

Specified by:
  `add` in interface `FieldVector<T extends FieldElement<T>>`
Parameters:
  `v` - vector to be added
Returns:
  `this + v`
Throws:
  `DimensionMismatchException` - if `v` is not the same size as `this`

#### buildArray

    private T[] buildArray(int length)

Deprecated.
Build an array of elements.

Parameters:
  `length` - Size of the array to build.
Returns:
  a new array.

#### hashCode

    public int hashCode()

Deprecated.

Overrides:
  `hashCode` in class `java.lang.Object`

#### equals

    public boolean equals(java.lang.Object obj)

Deprecated.

Overrides:
  `equals` in class `java.lang.Object`