|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--HFE.Matrix2
The class Matrix2 provides matrix operations for matrices over the
finite field F_2 which is specified in Field2
.
The class provides only operations which are needed in the
HFE package. The class is based upon the Jama package, which
was produced by The MathWorks, Inc. and the National Institute of Standards and Technology.
Jama can be downloaded from the NIST page
http://math.nist.gov/javanumerics/jama/.
Field Summary | |
private int[][] |
A
Array for internal storage of elements. |
private int |
m
Row (m) and column (n) dimensions. |
private int |
n
Row (m) and column (n) dimensions. |
Constructor Summary | |
Matrix2(int[][] A)
Construct a matrix using the given array with checking. |
|
Matrix2(int[][] A,
int m,
int n)
Construct a matrix using the given array without checking. |
|
Matrix2(int m,
int n)
Construct an m-by-n matrix of zeros. |
|
Matrix2(int m,
int n,
java.util.Random rnd)
Generats an m-by-n random matrix. |
Method Summary | |
Matrix2 |
add(Matrix2 B)
C = A + B |
(package private) void |
addEquals(Matrix2 B)
A += B |
void |
addRowsEquals(int i,
int j)
A[i] += A[j]. |
void |
addRowsEquals(int f,
int i,
int j)
A[i] += f*A[j]. |
private void |
checkMatrixDimensions(Matrix2 B)
Check if size(A) == size(B) |
java.lang.Object |
clone()
Clone the Matrix object. |
Matrix2 |
copy()
Make a deep copy of a matrix Allocates new memory |
int |
get(int i,
int j)
Get a single element. |
int[][] |
getArray()
Returns a pointer to the internal two-dimensional array. |
int[][] |
getArrayCopy()
Copy the internal two-dimensional array. |
int |
getColumnDimension()
Get column dimension. |
int[] |
getColumnPackedCopy()
Make a one-dimensional column packed copy of the internal array. |
Matrix2 |
getMatrix(int[] r,
int[] c)
Get a submatrix. |
Matrix2 |
getMatrix(int[] r,
int j0,
int j1)
Get a submatrix. |
Matrix2 |
getMatrix(int i0,
int i1,
int[] c)
Get a submatrix. |
Matrix2 |
getMatrix(int i0,
int i1,
int j0,
int j1)
Get a submatrix. |
int |
getRowDimension()
Get row dimension. |
int[] |
getRowPackedCopy()
Make a one-dimensional row packed copy of the internal array. |
static Matrix2 |
identity(int m,
int n)
Generate identity matrix |
boolean |
isEqual(Matrix2 B)
Compares two matrices. |
LUDecomposition2 |
lu()
LU Decomposition |
static void |
main(java.lang.String[] args)
Tests everything in this class |
void |
mul(int[] b,
int[] res)
Linear algebraic matrix/vector multiplication, res = A * b. |
Matrix2 |
mul(Matrix2 B)
Linear algebraic matrix multiplication, A * B. |
void |
set(int i,
int j,
int s)
Set a single element. |
void |
set(java.util.Random rnd)
Generats an m-by-n random matrix. |
void |
setMatrix(int[] r,
int[] c,
Matrix2 X)
Set a submatrix. |
void |
setMatrix(int[] r,
int j0,
int j1,
Matrix2 X)
Set a submatrix. |
void |
setMatrix(int i0,
int i1,
int[] c,
Matrix2 X)
Set a submatrix. |
void |
setMatrix(int i0,
int i1,
int j0,
int j1,
Matrix2 X)
Set a submatrix. |
void |
setRowZero(int i)
Set a row elementwise zero. |
Matrix2 |
sub(Matrix2 B)
C = A - B |
(package private) void |
subEquals(Matrix2 B)
A -= B |
static void |
testIt()
Tests the functionality of the whole class. |
Matrix2 |
transpose()
Matrix transpose. |
Methods inherited from class java.lang.Object |
|
Field Detail |
private int[][] A
private int m
private int n
Constructor Detail |
public Matrix2(int m, int n)
m
- Number of rows.n
- Number of colums.public Matrix2(int[][] A)
A
- Elements of the matrix as a 2D array.public Matrix2(int[][] A, int m, int n)
A
- Elements of the matrix as a 2D array.m
- Number of rows.n
- Number of colums.public Matrix2(int m, int n, java.util.Random rnd)
m
- Number of rows.n
- Number of colums.rnd
- number generatorMethod Detail |
public Matrix2 copy()
public java.lang.Object clone()
clone
in class java.lang.Object
public int[][] getArray()
public int[][] getArrayCopy()
public int[] getColumnPackedCopy()
public int[] getRowPackedCopy()
public int getRowDimension()
public int getColumnDimension()
public int get(int i, int j)
i
- Row index.j
- Column index.ArrayIndexOutOfBoundsException
- public Matrix2 getMatrix(int i0, int i1, int j0, int j1)
i0
- Initial row indexi1
- Final row indexj0
- Initial column indexj1
- Final column indexArrayIndexOutOfBoundsException
- Submatrix indicespublic Matrix2 getMatrix(int[] r, int[] c)
r
- Array of row indices.c
- Array of column indices.ArrayIndexOutOfBoundsException
- Submatrix indicespublic Matrix2 getMatrix(int i0, int i1, int[] c)
i0
- Initial row indexi1
- Final row indexc
- Array of column indices.ArrayIndexOutOfBoundsException
- Submatrix indicespublic Matrix2 getMatrix(int[] r, int j0, int j1)
r
- Array of row indices.i0
- Initial column indexi1
- Final column indexArrayIndexOutOfBoundsException
- Submatrix indicespublic void set(int i, int j, int s)
i
- Row index.j
- Column index.s
- A(i,j).ArrayIndexOutOfBoundsException
- public void set(java.util.Random rnd)
rnd
- number generatorpublic void setMatrix(int i0, int i1, int j0, int j1, Matrix2 X)
i0
- Initial row indexi1
- Final row indexj0
- Initial column indexj1
- Final column indexX
- A(i0:i1,j0:j1)ArrayIndexOutOfBoundsException
- Submatrix indicespublic void setMatrix(int[] r, int[] c, Matrix2 X)
r
- Array of row indices.c
- Array of column indices.X
- A(r(:),c(:))ArrayIndexOutOfBoundsException
- Submatrix indicespublic void setMatrix(int[] r, int j0, int j1, Matrix2 X)
r
- Array of row indices.j0
- Initial column indexj1
- Final column indexX
- A(r(:),j0:j1)ArrayIndexOutOfBoundsException
- Submatrix indicespublic void setMatrix(int i0, int i1, int[] c, Matrix2 X)
i0
- Initial row indexi1
- Final row indexc
- Array of column indices.X
- A(i0:i1,c(:))ArrayIndexOutOfBoundsException
- Submatrix indicespublic void setRowZero(int i)
public Matrix2 transpose()
public Matrix2 add(Matrix2 B)
B
- another matrixpublic void addRowsEquals(int i, int j)
public void addRowsEquals(int f, int i, int j)
f
- scalari
- number of the destination rowj
- number of the source rowvoid addEquals(Matrix2 B)
B
- another matrixpublic Matrix2 sub(Matrix2 B)
B
- another matrixvoid subEquals(Matrix2 B)
B
- another matrixpublic Matrix2 mul(Matrix2 B)
B
- another matrix with B.m == A.n (rows equals columns)java.lang.IllegalArgumentException
- Matrix inner dimensions must agree.public void mul(int[] b, int[] res)
b
- a vector with b.length == A.n (rows equals columns)public LUDecomposition2 lu()
LUDecomposition2
public static Matrix2 identity(int m, int n)
m
- Number of rows.n
- Number of colums.public boolean isEqual(Matrix2 B)
B
- another matrixtrue
: Matrices are equal. false
: Matrices are not equal (e.g. different size, different elements)public static void testIt()
public static void main(java.lang.String[] args)
testIt()
private void checkMatrixDimensions(Matrix2 B)
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |