Class ElementaryOperation
- java.lang.Object
-
- dev.nm.algebra.linear.matrix.doubles.operation.ElementaryOperation
-
- All Implemented Interfaces:
MatrixAccess,MatrixTable,Table
public class ElementaryOperation extends Object implements MatrixTable
There are three elementary row operations which are equivalent to left multiplying an elementary matrix. They are row switching, row multiplication, and row addition. By applying these operations to an identity matrix, I, the resultant matrix, T, is a transformation matrix, such that left multiplying T with a matrix A, i.e., T * A, is equivalent to applying the same sequence of operations to A. Similarly, the three elementary column operations are: column switching, column multiplication, and column addition. Column operations correspond to right multiplying a transformation matrix.- See Also:
- Wikipedia: Elementary matrix
-
-
Constructor Summary
Constructors Constructor Description ElementaryOperation(int dim)Construct a transformation matrix of elementary operations.ElementaryOperation(int nRows, int nCols)Construct a transformation matrix of elementary operations.ElementaryOperation(Matrix A)Transform A by elementary operations.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ElementaryOperationaddColumn(int j1, int j2, double c)Column addition: A[, j1] = A[, j1] + c * A[, j2]ElementaryOperationaddRow(int i1, int i2, double c)Row addition: A[i1, ] = A[i1, ] + c * A[i2, ]doubleget(int i, int j)Get the matrix entry at [i,j].intnCols()Gets the number of columns.intnRows()Gets the number of rows.ElementaryOperationscaleColumn(int j, double c)Scale a column: A[, j] = c * A[, j]ElementaryOperationscaleRow(int i, double c)Scale a row: A[i, ] = c * A[i, ]voidset(int i, int j, double value)Deprecated.ElementaryOperationswapColumn(int j1, int j2)Swap columns:ElementaryOperationswapRow(int i1, int i2)Swap rows:MatrixT()Get the transformed matrix T.StringtoString()
-
-
-
Constructor Detail
-
ElementaryOperation
public ElementaryOperation(int dim)
Construct a transformation matrix of elementary operations. The initial transformation matrix T is an identity matrix.- Parameters:
dim- the dimension of T
-
ElementaryOperation
public ElementaryOperation(int nRows, int nCols)Construct a transformation matrix of elementary operations. The initial transformation matrix T is an identity matrix, if it is square. Otherwise, the rightmost columns are padded with zeros.- Parameters:
nRows- the number of rows of TnCols- the number of columns of T
-
ElementaryOperation
public ElementaryOperation(Matrix A)
Transform A by elementary operations.- Parameters:
A- a matrix
-
-
Method Detail
-
nRows
public int nRows()
Description copied from interface:TableGets the number of rows. Rows count from 1.
-
nCols
public int nCols()
Description copied from interface:TableGets the number of columns. Columns count from 1.
-
get
public double get(int i, int j)Description copied from interface:MatrixAccessGet the matrix entry at [i,j].- Specified by:
getin interfaceMatrixAccess- Parameters:
i- the row indexj- the column index- Returns:
- A[i,j]
-
T
public Matrix T()
Get the transformed matrix T.- Returns:
- T
-
swapRow
public ElementaryOperation swapRow(int i1, int i2)
Swap rows:A[i1, ] = A[i2, ] A[i2, ] = A[i1, ]
- Parameters:
i1- becoming row i2i2- becoming row i1- Returns:
- the modified self
-
scaleRow
public ElementaryOperation scaleRow(int i, double c)
Scale a row:A[i, ] = c * A[i, ]
- Parameters:
i- the row to be scaledc- the scaling factor- Returns:
- the modified self
-
addRow
public ElementaryOperation addRow(int i1, int i2, double c)
Row addition:A[i1, ] = A[i1, ] + c * A[i2, ]
- Parameters:
i1- addend; the row to add to; the row is modified afterwardi2- the row to add withc- the scaling factor for row i2- Returns:
- the modified self
-
swapColumn
public ElementaryOperation swapColumn(int j1, int j2)
Swap columns:A[, j1] = A[, j2] A[, j2] = A[, j1]
- Parameters:
j1- becoming column j2j2- becoming column j1- Returns:
- the modified self
-
scaleColumn
public ElementaryOperation scaleColumn(int j, double c)
Scale a column:A[, j] = c * A[, j]
- Parameters:
j- the column to be scaledc- the scaling factor- Returns:
- the modified self
-
addColumn
public ElementaryOperation addColumn(int j1, int j2, double c)
Column addition:A[, j1] = A[, j1] + c * A[, j2]
- Parameters:
j1- addend; the column to add to; the column is modified afterwardj2- the column to add withc- the scaling factor forcol2- Returns:
- the modified self
-
set
@Deprecated public void set(int i, int j, double value) throws MatrixAccessException
Deprecated.Description copied from interface:MatrixAccessSet the matrix entry at [i,j] to a value. This is the only method that may change a matrix.- Specified by:
setin interfaceMatrixAccess- Parameters:
i- the row indexj- the column indexvalue- the value to set A[i,j] to- Throws:
MatrixAccessException- if i or j is out of range
-
-