Class FieldDenseMatrix<T>
- java.lang.Object
-
- org.apache.commons.math4.legacy.field.linalg.FieldDenseMatrix<T>
-
- Type Parameters:
T- Type of the field elements.
- All Implemented Interfaces:
AnyMatrix
public final class FieldDenseMatrix<T> extends Object implements AnyMatrix
Square matrix whose elements define aField.- Since:
- 4.0
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description FieldDenseMatrix<T>add(FieldDenseMatrix<T> other)Addition.FieldDenseMatrix<T>copy()Copies this matrix.static <T> FieldDenseMatrix<T>create(org.apache.commons.numbers.field.Field<T> f, int r, int c)Factory method.booleanequals(Object other)FieldDenseMatrix<T>fill(T value)Sets all elements to the given value.Tget(int i, int j)Gets an element.intgetColumnDimension()Gets the number of columns.org.apache.commons.numbers.field.Field<T>getField()intgetRowDimension()Gets the number of rows.inthashCode()static <T> FieldDenseMatrix<T>identity(org.apache.commons.numbers.field.Field<T> f, int n)Factory method.FieldDenseMatrix<T>multiply(FieldDenseMatrix<T> other)Multiplication.FieldDenseMatrix<T>negate()Negate.FieldDenseMatrix<T>pow(int p)Multiplies the matrix with itselfptimes.voidset(int i, int j, T value)Sets an element.FieldDenseMatrix<T>subtract(FieldDenseMatrix<T> other)Subtraction.FieldDenseMatrix<T>transpose()Transposes this matrix.static <T> FieldDenseMatrix<T>zero(org.apache.commons.numbers.field.Field<T> f, int r, int c)Factory method.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.commons.math4.legacy.linear.AnyMatrix
canAdd, canMultiply, checkAdd, checkMultiply, isSquare
-
-
-
-
Method Detail
-
create
public static <T> FieldDenseMatrix<T> create(org.apache.commons.numbers.field.Field<T> f, int r, int c)
Factory method.- Type Parameters:
T- Type of the field elements.- Parameters:
f- Field.r- Number of rows.c- Number of columns.- Returns:
- a new instance.
- Throws:
IllegalArgumentException- ifr <= 0orc <= 0.
-
zero
public static <T> FieldDenseMatrix<T> zero(org.apache.commons.numbers.field.Field<T> f, int r, int c)
Factory method.- Type Parameters:
T- Type of the field elements.- Parameters:
f- Field.r- Number of rows.c- Number of columns.- Returns:
- a matrix with elements zet to
zero. - Throws:
IllegalArgumentException- ifr <= 0orc <= 0.
-
identity
public static <T> FieldDenseMatrix<T> identity(org.apache.commons.numbers.field.Field<T> f, int n)
Factory method.- Type Parameters:
T- Type of the field elements.- Parameters:
f- Field.n- Dimension of the matrix.- Returns:
- the identity matrix.
- Throws:
IllegalArgumentException- ifn <= 0.
-
copy
public FieldDenseMatrix<T> copy()
Copies this matrix.- Returns:
- a new instance.
-
transpose
public FieldDenseMatrix<T> transpose()
Transposes this matrix.- Returns:
- a new instance.
-
getRowDimension
public int getRowDimension()
Gets the number of rows.- Specified by:
getRowDimensionin interfaceAnyMatrix- Returns:
- the number of rows.
-
getColumnDimension
public int getColumnDimension()
Gets the number of columns.- Specified by:
getColumnDimensionin interfaceAnyMatrix- Returns:
- the number of columns.
-
getField
public org.apache.commons.numbers.field.Field<T> getField()
- Returns:
- the field associated with the matrix entries.
-
fill
public FieldDenseMatrix<T> fill(T value)
Sets all elements to the given value.- Parameters:
value- Value of the elements of the matrix.- Returns:
this.
-
get
public T get(int i, int j)
Gets an element.- Parameters:
i- Row.j- Column.- Returns:
- the element at (i, j).
-
set
public void set(int i, int j, T value)
Sets an element.- Parameters:
i- Row.j- Column.value- Value.
-
add
public FieldDenseMatrix<T> add(FieldDenseMatrix<T> other)
Addition.- Parameters:
other- Matrix to add.- Returns:
- a new instance with the result of the addition.
- Throws:
IllegalArgumentException- if the dimensions do not match.
-
subtract
public FieldDenseMatrix<T> subtract(FieldDenseMatrix<T> other)
Subtraction.- Parameters:
other- Matrix to subtract.- Returns:
- a new instance with the result of the subtraction.
- Throws:
IllegalArgumentException- if the dimensions do not match.
-
negate
public FieldDenseMatrix<T> negate()
Negate.- Returns:
- a new instance with the opposite matrix.
-
multiply
public FieldDenseMatrix<T> multiply(FieldDenseMatrix<T> other)
Multiplication.- Parameters:
other- Matrix to multiply with.- Returns:
- a new instance with the result of the multiplication.
- Throws:
IllegalArgumentException- if the dimensions do not match.
-
pow
public FieldDenseMatrix<T> pow(int p)
Multiplies the matrix with itselfptimes.- Parameters:
p- Exponent.- Returns:
- a new instance.
- Throws:
IllegalArgumentException- ifp < 0.
-
-