l4P5 (beta-003) | 2009-05-05 20:38 |
Loc (beta-005) | 2009-05-05 20:33 |
wrj4p5 (alpha-011) | 2009-05-05 20:41 |
- /*[class] Mat 5/20/2008 by Classiclll
- * the model of Linear Algebra with the linear operations.
- * The index of Matrices is 0-based -- e.g.,
- * elem(0, 0) : the element in the first row, first column
- * elem(n, m) : the element in the (n-1)th. row, (m-1)th column.
- *
- * can solve the linear equations, with LU decomposition
- * [[cij]] * [xj] = [bj]
- *
- * [Caution!]
- * The LU matrix is cached and reused on subsequent calls,
- * solve(), isSingular(), det(), inverse()
- * If data are modified via references getDataRef(), then the
- * stored LU decomposition will not be discarded. In this case,
- * you need to explicitly invoke LUDecompose() to recompute
- * The LU decomposition is performed before using any of the
- * methods above.
- */
- [members]
- static final Mat NaN //constant Mat of one Double.NaN(not a number)
- [constructer]
- Mat() //construct empty
- Mat(int rows, int cols) //construct sized by rows*cols
- Mat(double d, int rows, int cols)//construct sized by rows*cols, all having d
- Mat(double[][] d) //construct having d[row][col]
- Mat(Mat m) //construct having d[row][col]
- Mat(double[] v) //construct single raw having v[col]
- Mat(Vec v) //construct having d[row][col]
- Mat(Loc v) //construct 3D single row, (x,y,z)
- [methods]
- <group #0 - Matrix Operation - generator>
- Mat copy() //return the copy of me.
- Mat getIdentity() //return the identity mtx, sized by min(rows,cols)
- Mat add(Mat m) //return me[i][j] + m[i][j]
- Mat add(double d) //return me[i][j] + d (scalar)
- Mat sub(Mat m) //return me[i][j] - m[i][j]
- Mat mul(double d) //return me[i][j] - d (scalar)
- Mat mul(Mat m) //return me[i][k] * m[k][j]
- Mat preMul(Mat m) //return m[i][k] * me[k][j]
- Mat setSubMat(Mat subMat, int row, int col)//ret[row+i][col+j] <= subMat[i][j]
- Mat setSubMat(double[][] subMat, int row, int col)// <same above>
- Mat setRowMat(Vec v, int row) //return Mat({me[row][0],.....,me[row][col-1]})
- Mat setColMat(Vec v, int col) //return {MAT(me[0][col],.....,me[row-1][col]})
- Mat SubMat(int startRow, int endRow,//return me[sRow->eRow][sCol->eCol]
- int startCol, int endCol)
- Mat SubMat(int[] selectedRows,//retturn {{.},..{me[selRow][selCol]},..{.}}
- int[] selectedCols)
- Mat rowMat(int row) //return Mat({me[row][0],.....,me[row][col-1]})
- Mat colMat(int col) //return {MAT(me[0][col],.....,me[row-1][col]})
- Mat transpose() //return the transpose of me.
- Mat inverse() //"me" must be square, otherwize null returned
- <group #1 - Vector Operation - generator>
- Vec rowVec(int row) //return array({me[row][0],.....,me[row][col-1]})
- Vec colVec(int col) //return array({me[0][col],.....,me[row-1][col]})
- Vec preMul(Vec v) //reurn v[]*me[][]
- Vec operate(Vec v) //return me[][]*transpose(v[])
- <group #2 - Scalar - information>
- int rowDim() //return the number of rows
- int colDim() //return the numbrt of columns
- double elem(int row, int column) //return the specified element
- double norm() //return the infinit(=maximum) norm of me.
- double det() //return the deturminant of me.
- double trace() //return the trace of me.
- boolean isSquare() //return is "me" square? (rows==columns)
- boolean isSingular() //return is "me" singular?
- boolean equals(Object object) //return shallow equolity between me and object
- boolean hasNaN() //return has me some Double.NaN
- boolean hasInf() //return has me some Double.Infinity
- boolean isNaN() //return is me containing NaN or Infinity
- <group #3 - Utilities - generator>
- double[][] toArray() //return 2d array of me
- double[][] arrayRef() //retuen the reference to 2d array of "me"
- // *modification may cause some trouble.
- String toString() //get the string expression of me.
- <group #4 - High level operator>
- Vec leqValueAt(Vec x) //same as operate(Vec x)
- Vec solve(Vec b)
- // Returns a matrix of (column) solution vectors for linear systems with
- [me] * [x] = b[].
- // when no solution, null refference will be returned.
- Mat solve(Mat b)
- // Returns a matrix of (column) solution vectors for linear systems with
- [me] * [x] = [b].
- // when no solution, null refference will be returned.
- Mat luDecompose()
- // Returns the LU decomposition of me as a Mat,
- /* a fresh copy of the cached LU matrix if this has been computed;
- When none chashed
- the composition is computed and cached for use by other methods.
- solve(), isSingular(), det(), inverse()
- The matrix returned is a compact representation of the LU decomposition.
- *Example :
- Returned matrix L U
- 2 3 1 1 0 0 2 3 1
- 5 4 6 5 1 0 0 4 6
- 1 7 8 1 7 1 0 0 8
- The L and U matrices satisfy the matrix equation LU = permuteRows of me.
- when "me" is singular, null refference will be returned. */
[PageInfo]
LastUpdate: 2008-08-08 12:02:28, ModifiedBy: classiclll
[License]
Creative Commons 2.1 Attribution-ShareAlike
[Permissions]
view:all, edit:login users, delete/config:members