| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
  |
  +--org.jutil.math.matrix.NMatrix
        |
        +--org.jutil.math.matrix.Matrix
A class of 2D matrices. This version doesn't try that hard to perform stable calculations. If you need that, use the non-existing nummath package. If you don't know what it means, use this version :) Matrix also doesn't report any overflow (standard Java behavior).
| Class Specifications | 
| public invariant getNbDimensions() == 2; | 
| Specifications inherited from class NMatrix | 
| public invariant getDimensions().length == getNbDimensions(); public invariant ( \forall int i; i >= 0&&i < getNbDimensions(); getDimensions()[i] > 0); | 
| Field Summary | |
| static java.lang.String | CVS_REVISIONMvDMvDMvD : some operations don't have 2 sensible names for use as a mutator and inspector. | 
| Constructor Summary | |
| Matrix(double[] elements)Initialize a new diagonal Matrix with the given array of diagonal element. | |
| Matrix(double[][] elements)Initialize a new Matrix from the given 2D array of doubles. | |
| Matrix(int rows,
       int columns)Initialize a new Matrix with the given number of rows and columns | |
| Method Summary | |
|  void | add(Matrix other)Add the given matrix to this matrix. | 
|  java.lang.Object | clone()Return a clone | 
|  void | divide(double factor)Divide this matrix by a given factor. | 
|  double | elementAt(int row,
          int column)Return the element at the given row and column. | 
|  double | elementAt(int[] index) | 
|  boolean | equals(java.lang.Object other)Check whether the given object is equal to this matrix. | 
|  Column | getColumn(int index)Return the column with the given index. | 
|  int[] | getDimensions() | 
|  int | getNbColumns()Return the number of columns of this matrix. | 
|  int | getNbDimensions() | 
|  int | getNbRows()Return the number of rows of this matrix. | 
|  Row | getRow(int index)Return the row with the given index. | 
|  boolean | isDiagonal()Check whether or not this matrix is a diagonal matrix. | 
|  boolean | isLowerTriangular()Check whether or not this matrix is lower triangular | 
|  boolean | isPermutationMatrix()Check whether or not this matrix is a permutation matrix. | 
|  boolean | isSquare()Check whether or not this matrix is square. | 
|  boolean | isSymmetric()Check whether or not this matrix is symmetric. | 
|  boolean | isUpperTriangular()Check whether or not this matrix is upper triangular | 
|  void | leftGivens(double c,
           double s,
           int i,
           int k)Perform a givens rotation on this matrix from the left side with the givens matrix defined by c, s, i and k as follows (m = getNbRows()). 1 i k m 1 1 . | 
|  Matrix | minus(Matrix other)Return a new matrix that equals this matrix minus the given matrix. | 
|  void | multiply(double factor)Multiply this matrix by a given factor. | 
|  Matrix | plus(Matrix other)Return a new matrix that is the sum of this matrix and the given matrix | 
|  Matrix | returnTranspose()Return the transpose of this matrix. | 
|  void | rightGivens(double c,
            double s,
            int i,
            int k)Perform a givens rotation on this matrix from the right side with the givens matrix defined by c, s, i and k as follows (n = getNbColumns()). 1 i k n 1 1 . | 
|  boolean | sameDimensions(Matrix other)Check wether the given matrix has the same dimensions as this one. | 
|  void | setColumn(int i,
          Column column)Set the i-th column of this matrix | 
|  void | setElementAt(int row,
             int column,
             double value)Set the element at the given row and column to the given value. | 
|  void | setElementAt(int[] index,
             double value) | 
|  void | setRow(int i,
       Row row)Set the i-th row of this matrix | 
|  void | setSubMatrix(int row,
             int column,
             Matrix matrix)Replace a submatrix of this matrix with the given matrix at the given coordinates. | 
|  Matrix | subMatrix(int x1,
          int y1,
          int x2,
          int y2)Return the submatrix starting from (x1,y1) to (x2,y2). | 
|  void | subtract(Matrix other)Subtract the given matrix from this matrix. | 
|  Matrix | times(double factor)Return a matrix that equals this matrix times a given factor. | 
|  Matrix | times(Matrix other)Right-multiply this matrix by another. | 
|  java.lang.String | toString()see superclass | 
|  void | transpose()Transpose this matrix. | 
| static Matrix | unity(int size)Return a new unity matrix of the given size | 
|  boolean | validIndex(int row,
           int column)Check whether or not the given row and column point to a valid position for this Matrix. | 
| Methods inherited from class org.jutil.math.matrix.NMatrix | 
| validIndex | 
| Methods inherited from class java.lang.Object | 
| finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
| Field Detail | 
public static final java.lang.String CVS_REVISION
| Constructor Detail | 
public Matrix(int rows,
              int columns)
columns - The number of columns for the new Matrix.rows - The number of rows for the new Matrix.public Matrix(double[][] elements)
elements - A 2D array containing the elements of the new Matrix.
        The first dimension is for the rows, the second for the columns.public Matrix(double[] elements)
elements - An array containing the diagonal elements of the new Matrix.| Method Detail | 
public static Matrix unity(int size)
size - The number of rows/columns of the matrixpublic int getNbDimensions()
superclasspublic int[] getDimensions()
superclasspublic int getNbRows()
public int getNbColumns()
public double elementAt(int[] index)
superclass
public double elementAt(int row,
                        int column)
row - The row of the element to be retrieved.column - The column of the element to be retrieved.
public void setElementAt(int row,
                         int column,
                         double value)
row - The row of the element to be retrieved.column - The column of the element to be retrieved.value - The new value for the element at the given row and column.
public void setElementAt(int[] index,
                         double value)
superclass
public boolean validIndex(int row,
                          int column)
row - The row of the position.column - The row of the position.public Column getColumn(int index)
index - The index of the requested column.
public void setColumn(int i,
                      Column column)
i - The index of the column to be set.column - The column which will be the new i-th column of this matrixpublic Row getRow(int index)
index - The index of the requested row.
public void setRow(int i,
                   Row row)
i - The index of the row to be set.column - The row which will be the new i-th row of this matrixpublic void add(Matrix other)
other - The matrix to be added.public Matrix plus(Matrix other)
other - The matrix to be added.public void subtract(Matrix other)
other - The matrix to be added.public Matrix minus(Matrix other)
other - The matrix to be added.public Matrix times(Matrix other)
other - The matrix to multiply this matrix by.public Matrix times(double factor)
factor - The factor to multiply this matrix with.public void multiply(double factor)
factor - The factor to multiply this matrix with.public void divide(double factor)
factor - The factor to divide this matrix by.public void transpose()
public void leftGivens(double c,
                       double s,
                       int i,
                       int k)
Perform a givens rotation on this matrix from the left side with the givens matrix defined by c, s, i and k as follows (m = getNbRows()).
     1       i       k       m
 
 1   1 . . . 0 . . . 0 . . . 0
     . .     . .     . .     .
     .   .   .   .   .   .   .
     .     . .     . .     . .
 i   0 . . . c . . . s . . . 0
     . .     . .     . .     .
     .   .   .   .   .   .   .
     .     . .     . .     . .
 k   0 . . .-s . . . c . . . 0
     . .     . .     . .     .
     .   .   .   .   .   .   .
     .     . .     . .     . .
 m   0 . . . 0 . . . 0 . . . 1
 
  This matrix (A) will be transformed into G*A.
c - The value of cc - The value of si - The value of ik - The value of k
public void rightGivens(double c,
                        double s,
                        int i,
                        int k)
Perform a givens rotation on this matrix from the right side with the givens matrix defined by c, s, i and k as follows (n = getNbColumns()).
     1       i       k       n
 
 1   1 . . . 0 . . . 0 . . . 0
     . .     . .     . .     .
     .   .   .   .   .   .   .
     .     . .     . .     . .
 i   0 . . . c . . . s . . . 0
     . .     . .     . .     .
     .   .   .   .   .   .   .
     .     . .     . .     . .
 k   0 . . .-s . . . c . . . 0
     . .     . .     . .     .
     .   .   .   .   .   .   .
     .     . .     . .     . .
 n   0 . . . 0 . . . 0 . . . 1
 
  This matrix (A) will be transformed into A*G.
c - The value of cc - The value of si - The value of ik - The value of kpublic Matrix returnTranspose()
public boolean sameDimensions(Matrix other)
other - The other matrix
public Matrix subMatrix(int x1,
                        int y1,
                        int x2,
                        int y2)
x1 - The row from which to start.y1 - The column from which to start.x2 - The end row.y2 - The end column.
public void setSubMatrix(int row,
                         int column,
                         Matrix matrix)
row - The row of the top-left element of the submatrix that will be replaced.column - The column of the top-left element of the submatrix that will be replaced.matrix - The matrix to put into this matrixpublic boolean isUpperTriangular()
public boolean isLowerTriangular()
public boolean isDiagonal()
public java.lang.String toString()
public java.lang.Object clone()
public boolean equals(java.lang.Object other)
public boolean isSquare()
public boolean isSymmetric()
public boolean isPermutationMatrix()
| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||