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

public abstract Class AbstractFieldMatrix<T extends FieldElement<T>>

extends Object
implements FieldMatrix<T extends FieldElement<T>>
Class Inheritance
All Implemented Interfaces
org.apache.commons.math3.linear.FieldMatrix, org.apache.commons.math3.linear.AnyMatrix
Known Direct Subclasses
org.apache.commons.math3.linear.Array2DRowFieldMatrix, org.apache.commons.math3.linear.BlockFieldMatrix, org.apache.commons.math3.linear.SparseFieldMatrix
Type Parameters
<T>
Type of the field elements.
Imports
java.util.ArrayList, org.apache.commons.math3.Field, .FieldElement, org.apache.commons.math3.exception.DimensionMismatchException, .NoDataException, .NotPositiveException, .NotStrictlyPositiveException, .NullArgumentException, .NumberIsTooSmallException, .OutOfRangeException, org.apache.commons.math3.exception.util.LocalizedFormats, org.apache.commons.math3.util.MathArrays

Basic implementation of FieldMatrix methods regardless of the underlying storage.

All the methods implemented here use getEntry(int, int) to access matrix elements. Derived class can provide faster implementations.

Since
2.0

Field Summary

Modifier and TypeField and Description
private final Field<T>
field

Field to which the elements belong.

Constructor Summary

AccessConstructor and Description
protected
AbstractFieldMatrix()

Constructor for use with Serializable

protected
AbstractFieldMatrix(final Field<T>
field to which the elements belong
field
)

Creates a matrix with no data

protected
AbstractFieldMatrix(final Field<T>
Field to which the elements belong.
field
,
final int
Number of rows in the new matrix.
rowDimension
,
final int
Number of columns in the new matrix.
columnDimension
)

Create a new FieldMatrix<t> with the supplied row and column dimensions.

Method Summary

Modifier and TypeMethod and Description
public FieldMatrix<T>
add(FieldMatrix<T>
Matrix to be added.
m
)

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

Compute the sum of this and m.

public abstract void
addToEntry(int
Row location of entry to be set.
row
,
int
Column location of entry to be set.
column
,
T
Value to add to the current matrix entry in (row, column).
increment
)

Redeclares org.apache.commons.math3.linear.FieldMatrix.addToEntry.

Change an entry in the specified row and column.

protected static <
Type of the field elements
T extends FieldElement<T>
>
T[][]

Returns:

a new array
buildArray
(final Field<T>
field to which array elements belong
field
,
final int
number of rows
rows
,
final int
number of columns (may be negative to build partial arrays in the same way new Field[rows][] works)
columns
)
Deprecated as of 3.2, replaced by MathArrays#buildArray(Field, int, int)

Build an array of elements.

protected static <
the type of the field elements
T extends FieldElement<T>
>
T[]

Returns:

a new array
buildArray
(final Field<T>
field to which array elements belong
field
,
final int
of the array
length
)
Deprecated as of 3.2, replaced by MathArrays#buildArray(Field, int)

Build an array of elements.

protected void
checkAdditionCompatible(final FieldMatrix<T>
Matrix to check.
m
)

Check if a matrix is addition compatible with the instance.

protected void
checkColumnIndex(final int
Column index to check.
column
)

Check if a column index is valid.

protected void
checkMultiplicationCompatible(final FieldMatrix<T>
Matrix to check.
m
)

Check if a matrix is multiplication compatible with the instance.

protected void
checkRowIndex(final int
Row index to check.
row
)

Check if a row index is valid.

protected void
checkSubMatrixIndex(final int
Initial row index.
startRow
,
final int
Final row index.
endRow
,
final int
Initial column index.
startColumn
,
final int
Final column index.
endColumn
)

Check if submatrix ranges indices are valid.

protected void
checkSubMatrixIndex(final int[]
Array of row indices.
selectedRows
,
final int[]
Array of column indices.
selectedColumns
)

Check if submatrix ranges indices are valid.

protected void
checkSubtractionCompatible(final FieldMatrix<T>
Matrix to check.
m
)

Check if a matrix is subtraction compatible with the instance.

public abstract FieldMatrix<T>
copy()

Redeclares org.apache.commons.math3.linear.FieldMatrix.copy.

Make a (deep) copy of this.

public void
copySubMatrix(final int
Initial row index.
startRow
,
final int
Final row index (inclusive).
endRow
,
final int
Initial column index.
startColumn
,
final int
Final column index (inclusive).
endColumn
,
final T[][]
The array where the submatrix data should be copied (if larger than rows/columns counts, only the upper-left part will be modified).
destination
)

Implements org.apache.commons.math3.linear.FieldMatrix.copySubMatrix.

Copy a submatrix.

public void
copySubMatrix(int[]
Array of row indices.
selectedRows
,
int[]
Array of column indices.
selectedColumns
,
T[][]
Arrays where the submatrix data should be copied (if larger than rows/columns counts, only the upper-left part will be used)
destination
)

Implements org.apache.commons.math3.linear.FieldMatrix.copySubMatrix.

Copy a submatrix.

public abstract FieldMatrix<T>
createMatrix(final int
the number of rows in the new matrix
rowDimension
,
final int
the number of columns in the new matrix
columnDimension
)

Redeclares org.apache.commons.math3.linear.FieldMatrix.createMatrix.

Create a new FieldMatrix<t> of the same type as the instance with the supplied row and column dimensions.

public boolean

Returns:

true if object equals this
equals
(final Object
the object to test equality against.
object
)

Overrides java.lang.Object.equals.

Returns true iff object is a FieldMatrix instance with the same dimensions as this and all corresponding matrix entries are equal.

protected static <
Type of the field elements.
T extends FieldElement<T>
>
Field<T>

Returns:

the field to which the array elements belong.
extractField
(final T[][]
Data array.
d
)

Get the elements type from an array.

protected static <
Type of the field elements.
T extends FieldElement<T>
>
Field<T>

Returns:

the field to which the array elements belong.
extractField
(final T[]
Data array.
d
)

Get the elements type from an array.

public T[]
getColumn(final int
the column to be fetched
column
)

Implements org.apache.commons.math3.linear.FieldMatrix.getColumn.

Get the entries in column number col as an array.

public abstract int
getColumnDimension()

Redeclares org.apache.commons.math3.linear.AnyMatrix.getColumnDimension.

Returns the number of columns in the matrix.

public FieldMatrix<T>
getColumnMatrix(final int
Column to be fetched.
column
)

Implements org.apache.commons.math3.linear.FieldMatrix.getColumnMatrix.

Get the entries in column number column as a column matrix.

public FieldVector<T>
getColumnVector(final int
Column to be fetched.
column
)

Implements org.apache.commons.math3.linear.FieldMatrix.getColumnVector.

Returns the entries in column number column as a vector.

public T[][]
getData()

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

Returns matrix entries as a two-dimensional array.

public abstract T
getEntry(int
row location of entry to be fetched
row
,
int
column location of entry to be fetched
column
)

Redeclares org.apache.commons.math3.linear.FieldMatrix.getEntry.

Returns the entry in the specified row and column.

public Field<T>
getField()

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

Get the type of field elements of the matrix.

public T[]
getRow(final int
Row to be fetched.
row
)

Implements org.apache.commons.math3.linear.FieldMatrix.getRow.

Get the entries in row number row as an array.

public abstract int
getRowDimension()

Redeclares org.apache.commons.math3.linear.AnyMatrix.getRowDimension.

Returns the number of rows in the matrix.

public FieldMatrix<T>
getRowMatrix(final int
Row to be fetched.
row
)

Implements org.apache.commons.math3.linear.FieldMatrix.getRowMatrix.

Get the entries in row number row as a row matrix.

public FieldVector<T>
getRowVector(final int
Row to be fetched
row
)

Implements org.apache.commons.math3.linear.FieldMatrix.getRowVector.

Get the entries in row number row as a vector.

public FieldMatrix<T>
getSubMatrix(final int
Initial row index
startRow
,
final int
Final row index (inclusive)
endRow
,
final int
Initial column index
startColumn
,
final int
Final column index (inclusive)
endColumn
)

Implements org.apache.commons.math3.linear.FieldMatrix.getSubMatrix.

Get a submatrix.

public FieldMatrix<T>
getSubMatrix(final int[]
Array of row indices.
selectedRows
,
final int[]
Array of column indices.
selectedColumns
)

Implements org.apache.commons.math3.linear.FieldMatrix.getSubMatrix.

Get a submatrix.

public T
getTrace()

Implements org.apache.commons.math3.linear.FieldMatrix.getTrace.

Returns the trace of the matrix (the sum of the elements on the main diagonal).

public int

Returns:

hashcode for matrix
hashCode
()

Overrides java.lang.Object.hashCode.

Computes a hashcode for the matrix.

public boolean
isSquare()

Implements org.apache.commons.math3.linear.AnyMatrix.isSquare.

Is this a square matrix?

public FieldMatrix<T>
multiply(final FieldMatrix<T>
Matrix to postmultiply by.
m
)

Implements org.apache.commons.math3.linear.FieldMatrix.multiply.

Postmultiply this matrix by m.

public abstract void
multiplyEntry(int
Row location of entry to be set.
row
,
int
Column location of entry to be set.
column
,
T
Multiplication factor for the current matrix entry in (row,column)
factor
)

Redeclares org.apache.commons.math3.linear.FieldMatrix.multiplyEntry.

Change an entry in the specified row and column.

public T[]
operate(final T[]
the vector to operate on
v
)

Implements org.apache.commons.math3.linear.FieldMatrix.operate.

Returns the result of multiplying this by the vector v.

public FieldVector<T>
operate(final FieldVector<T>
the vector to operate on
v
)

Implements org.apache.commons.math3.linear.FieldMatrix.operate.

Returns the result of multiplying this by the vector v.

public FieldMatrix<T>
power(final int
raise this to power p
p
)

Implements org.apache.commons.math3.linear.FieldMatrix.power.

Returns the result multiplying this with itself p times.

public FieldMatrix<T>
preMultiply(final FieldMatrix<T>
Matrix to premultiply by.
m
)

Implements org.apache.commons.math3.linear.FieldMatrix.preMultiply.

Premultiply this matrix by m.

public T[]
preMultiply(final T[]
the row vector to premultiply by
v
)

Implements org.apache.commons.math3.linear.FieldMatrix.preMultiply.

Returns the (row) vector result of premultiplying this by the vector v.

public FieldVector<T>
preMultiply(final FieldVector<T>
the row vector to premultiply by
v
)

Implements org.apache.commons.math3.linear.FieldMatrix.preMultiply.

Returns the (row) vector result of premultiplying this by the vector v.

public FieldMatrix<T>
scalarAdd(final T
Value to be added to each entry.
d
)

Implements org.apache.commons.math3.linear.FieldMatrix.scalarAdd.

Increment each entry of this matrix.

public FieldMatrix<T>
scalarMultiply(final T
Value to multiply all entries by.
d
)

Implements org.apache.commons.math3.linear.FieldMatrix.scalarMultiply.

Multiply each entry by d.

public void
setColumn(final int
the column to be set
column
,
final T[]
column array (must have the same number of rows as the instance)
array
)

Implements org.apache.commons.math3.linear.FieldMatrix.setColumn.

Set the entries in column number column as a column matrix.

public void
setColumnMatrix(final int
Column to be set.
column
,
final FieldMatrix<T>
column matrix (must have one column and the same number of rows as the instance).
matrix
)

Implements org.apache.commons.math3.linear.FieldMatrix.setColumnMatrix.

Set the entries in column number column as a column matrix.

public void
setColumnVector(final int
Column to be set.
column
,
final FieldVector<T>
Column vector (must have the same number of rows as the instance).
vector
)

Implements org.apache.commons.math3.linear.FieldMatrix.setColumnVector.

Set the entries in column number column as a vector.

public abstract void
setEntry(int
row location of entry to be set
row
,
int
column location of entry to be set
column
,
T
matrix entry to be set in row,column
value
)

Redeclares org.apache.commons.math3.linear.FieldMatrix.setEntry.

Set the entry in the specified row and column.

public void
setRow(final int
Row to be set.
row
,
final T[]
Row matrix (must have the same number of columns as the instance).
array
)

Implements org.apache.commons.math3.linear.FieldMatrix.setRow.

Set the entries in row number row as a row matrix.

public void
setRowMatrix(final int
Row to be set.
row
,
final FieldMatrix<T>
Row matrix (must have one row and the same number of columns as the instance).
matrix
)

Implements org.apache.commons.math3.linear.FieldMatrix.setRowMatrix.

Set the entries in row number row as a row matrix.

public void
setRowVector(final int
Row to be set.
row
,
final FieldVector<T>
row vector (must have the same number of columns as the instance).
vector
)

Implements org.apache.commons.math3.linear.FieldMatrix.setRowVector.

Set the entries in row number row as a vector.

public void
setSubMatrix(final T[][]
Array containing the submatrix replacement data.
subMatrix
,
final int
Row coordinate of the top-left element to be replaced.
row
,
final int
Column coordinate of the top-left element to be replaced.
column
)

Implements org.apache.commons.math3.linear.FieldMatrix.setSubMatrix.

Replace the submatrix starting at (row, column) using data in the input subMatrix array.

public FieldMatrix<T>
subtract(final FieldMatrix<T>
Matrix to be subtracted.
m
)

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

Subtract m from this matrix.

public String

Returns:

a string representation for this matrix
toString
()

Overrides java.lang.Object.toString.

Get a string representation for this matrix.

public FieldMatrix<T>
transpose()

Implements org.apache.commons.math3.linear.FieldMatrix.transpose.

Returns the transpose of this matrix.

public T
walkInColumnOrder(final FieldMatrixChangingVisitor<T>
visitor used to process all matrix entries
visitor
)

Implements org.apache.commons.math3.linear.FieldMatrix.walkInColumnOrder.

Visit (and possibly change) all matrix entries in column order.

public T
walkInColumnOrder(final FieldMatrixPreservingVisitor<T>
visitor used to process all matrix entries
visitor
)

Implements org.apache.commons.math3.linear.FieldMatrix.walkInColumnOrder.

Visit (but don't change) all matrix entries in column order.

public T
walkInColumnOrder(final FieldMatrixChangingVisitor<T>
visitor used to process all matrix entries
visitor
,
final int
Initial row index
startRow
,
final int
Final row index (inclusive)
endRow
,
final int
Initial column index
startColumn
,
final int
Final column index
endColumn
)

Implements org.apache.commons.math3.linear.FieldMatrix.walkInColumnOrder.

Visit (and possibly change) some matrix entries in column order.

public T
walkInColumnOrder(final FieldMatrixPreservingVisitor<T>
visitor used to process all matrix entries
visitor
,
final int
Initial row index
startRow
,
final int
Final row index (inclusive)
endRow
,
final int
Initial column index
startColumn
,
final int
Final column index
endColumn
)

Implements org.apache.commons.math3.linear.FieldMatrix.walkInColumnOrder.

Visit (but don't change) some matrix entries in column order.

public T
walkInOptimizedOrder(final FieldMatrixChangingVisitor<T>
visitor used to process all matrix entries
visitor
)

Implements org.apache.commons.math3.linear.FieldMatrix.walkInOptimizedOrder.

Visit (and possibly change) all matrix entries using the fastest possible order.

public T
walkInOptimizedOrder(final FieldMatrixPreservingVisitor<T>
visitor used to process all matrix entries
visitor
)

Implements org.apache.commons.math3.linear.FieldMatrix.walkInOptimizedOrder.

Visit (but don't change) all matrix entries using the fastest possible order.

public T
walkInOptimizedOrder(final FieldMatrixChangingVisitor<T>
visitor used to process all matrix entries
visitor
,
final int
Initial row index
startRow
,
final int
Final row index (inclusive)
endRow
,
final int
Initial column index
startColumn
,
final int
Final column index (inclusive)
endColumn
)

Implements org.apache.commons.math3.linear.FieldMatrix.walkInOptimizedOrder.

Visit (and possibly change) some matrix entries using the fastest possible order.

public T
walkInOptimizedOrder(final FieldMatrixPreservingVisitor<T>
visitor used to process all matrix entries
visitor
,
final int
Initial row index
startRow
,
final int
Final row index (inclusive)
endRow
,
final int
Initial column index
startColumn
,
final int
Final column index (inclusive)
endColumn
)

Implements org.apache.commons.math3.linear.FieldMatrix.walkInOptimizedOrder.

Visit (but don't change) some matrix entries using the fastest possible order.

public T
walkInRowOrder(final FieldMatrixChangingVisitor<T>
visitor used to process all matrix entries
visitor
)

Implements org.apache.commons.math3.linear.FieldMatrix.walkInRowOrder.

Visit (and possibly change) all matrix entries in row order.

public T
walkInRowOrder(final FieldMatrixPreservingVisitor<T>
visitor used to process all matrix entries
visitor
)

Implements org.apache.commons.math3.linear.FieldMatrix.walkInRowOrder.

Visit (but don't change) all matrix entries in row order.

public T
walkInRowOrder(final FieldMatrixChangingVisitor<T>
visitor used to process all matrix entries
visitor
,
final int
Initial row index
startRow
,
final int
Final row index (inclusive)
endRow
,
final int
Initial column index
startColumn
,
final int
Final column index
endColumn
)

Implements org.apache.commons.math3.linear.FieldMatrix.walkInRowOrder.

Visit (and possibly change) some matrix entries in row order.

public T
walkInRowOrder(final FieldMatrixPreservingVisitor<T>
visitor used to process all matrix entries
visitor
,
final int
Initial row index
startRow
,
final int
Final row index (inclusive)
endRow
,
final int
Initial column index
startColumn
,
final int
Final column index
endColumn
)

Implements org.apache.commons.math3.linear.FieldMatrix.walkInRowOrder.

Visit (but don't change) some matrix entries in row order.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait