public class PermutationMatrix extends Object implements Matrix
| Constructor and Description |
|---|
PermutationMatrix(int dim)
Construct an identity permutation matrix.
|
PermutationMatrix(int[] data)
Construct a permutation matrix from an 1D
double[]. |
PermutationMatrix(PermutationMatrix P)
Copy constructor.
|
| Modifier and Type | Method and Description |
|---|---|
Matrix |
add(Matrix that)
this + that
|
PermutationMatrix |
deepCopy()
The implementation returns an instance created from
this by the copy
constructor of the class, or just this if the instance itself is
immutable. |
boolean |
equals(Object obj) |
double |
get(int i,
int j)
Get the matrix entry at [i,j].
|
Vector |
getColumn(int j)
Get the specified column in the matrix as a vector.
|
Vector |
getRow(int i)
Get the specified row in the matrix as a vector.
|
int |
hashCode() |
Matrix |
minus(Matrix that)
this - that
|
void |
moveColumn2End(int j)
Swaps a column of a permutation matrix with the last column.
|
void |
moveRow2End(int i)
Swaps a row of the permutation matrix with the last row.
|
Matrix |
multiply(Matrix A)
Left multiplication by P.
|
Vector |
multiply(Vector v)
Left multiplication by P.
|
int |
nCols()
Gets the number of columns.
|
int |
nRows()
Gets the number of rows.
|
PermutationMatrix |
ONE()
Get an identity matrix that has the same dimension as this matrix.
|
Matrix |
opposite()
Get the opposite of this matrix.
|
Matrix |
rightMultiply(Matrix A)
Right multiplication by P.
|
Matrix |
scaled(double scalar)
Scale this matrix, A, by a constant.
|
void |
set(int i,
int j,
double value)
Deprecated.
use the swap functions instead
|
double |
sign()
Gets the sign of the permutation matrix which is also the determinant.
|
void |
swapColumn(int j1,
int j2)
Swaps two columns of a permutation matrix.
|
void |
swapRow(int i1,
int i2)
Swaps two rows of a permutation matrix.
|
PermutationMatrix |
t()
The transpose of a permutation matric is the same as its inverse.
|
String |
toString() |
Matrix |
ZERO()
Get a zero matrix that has the same dimension as this matrix.
|
public PermutationMatrix(int dim)
dim - the matrix dimensionpublic PermutationMatrix(int[] data)
double[].data - the 1D double[] indicating the column position of the 1 in each rowIllegalArgumentException - if data is not a permutation matrixpublic PermutationMatrix(PermutationMatrix P)
P - a permutation matrixpublic PermutationMatrix deepCopy()
DeepCopyablethis by the copy
constructor of the class, or just this if the instance itself is
immutable.deepCopy in interface MatrixdeepCopy in interface DeepCopyablepublic int nRows()
Tablepublic int nCols()
Tablepublic double sign()
public void swapRow(int i1,
int i2)
i1 - row 1i2 - row 2public void swapColumn(int j1,
int j2)
j1 - column 1j2 - column 2public void moveRow2End(int i)
i - the row to be swapped with the last rowpublic void moveColumn2End(int j)
j - the column to be swapped with the last columnpublic double get(int i,
int j)
throws MatrixAccessException
MatrixAccessget in interface MatrixAccessi - the row indexj - the column indexMatrixAccessException - if i or j is out of rangepublic Vector getRow(int i) throws MatrixAccessException
MatrixgetRow in interface Matrixi - the row indexMatrixAccessException - when i < 1, or when i > the number of rowspublic Vector getColumn(int j) throws MatrixAccessException
MatrixgetColumn in interface Matrixj - the column indexMatrixAccessException - when j < 1, or when j > the number of columnspublic Matrix rightMultiply(Matrix A)
A - a matrixpublic Vector multiply(Vector v)
public Matrix multiply(Matrix A)
multiply in interface MatrixRingmultiply in interface Monoid<Matrix>A - a matrixpublic Matrix add(Matrix that)
MatrixRingadd in interface MatrixRingadd in interface AbelianGroup<Matrix>that - a matrixthis and thatpublic Matrix minus(Matrix that)
MatrixRingminus in interface MatrixRingminus in interface AbelianGroup<Matrix>that - a matrixthis and thatpublic Matrix scaled(double scalar)
Matrixpublic Matrix opposite()
MatrixRingopposite in interface MatrixRingopposite in interface AbelianGroup<Matrix>public PermutationMatrix t()
P.multiply(P.t()) == P.t().multiply(P) == P.toDense().ONE()t in interface MatrixRingpublic PermutationMatrix ONE()
MatrixRingONE in interface MatrixRingONE in interface Monoid<Matrix>public Matrix ZERO()
MatrixRingZERO in interface MatrixRingZERO in interface AbelianGroup<Matrix>@Deprecated public void set(int i, int j, double value) throws MatrixAccessException
swapRow(int, int),
swapColumn(int, int),
moveRow2End(int),
moveColumn2End(int),set in interface MatrixAccessi - the row indexj - the column indexvalue - the value to set A[i,j] toUnsupportedOperationException - when calledMatrixAccessException - if i or j is out of rangeCopyright © 2010-2020 NM FinTech Ltd.. All Rights Reserved.