|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.encog.mathutil.matrices.Matrix
public class Matrix
This class implements a mathematical matrix. Matrix math is very important to neural network processing. Many of the neural network classes make use of the matrix classes in this package.
| Constructor Summary | |
|---|---|
Matrix(boolean[][] sourceMatrix)
Construct a bipolar matrix from an array of booleans. |
|
Matrix(double[][] sourceMatrix)
Create a matrix from an array of doubles. |
|
Matrix(int rows,
int cols)
Create a blank array with the specified number of rows and columns. |
|
| Method Summary | |
|---|---|
void |
add(int row,
int col,
double value)
Add a value to one cell in the matrix. |
void |
add(Matrix theMatrix)
Add the specified matrix to this matrix. |
void |
clear()
Set all rows and columns to zero. |
Matrix |
clone()
Create a copy of the matrix. |
static Matrix |
createColumnMatrix(double[] input)
Turn an array of doubles into a column matrix. |
static Matrix |
createRowMatrix(double[] input)
Turn an array of doubles into a row matrix. |
boolean |
equals(Matrix theMatrix,
int precision)
Compare to matrixes with the specified level of precision. |
boolean |
equals(Object other)
Check to see if this matrix equals another, using default precision. |
int |
fromPackedArray(Double[] array,
int index)
Create a matrix from a packed array. |
double |
get(int row,
int col)
Read the specified cell in the matrix. |
double[][] |
getArrayCopy()
|
Matrix |
getCol(int col)
Read one entire column from the matrix as a sub-matrix. |
int |
getCols()
Get the columns in the matrix. |
double[][] |
getData()
|
Matrix |
getMatrix(int[] r,
int[] c)
Get a submatrix. |
Matrix |
getMatrix(int[] r,
int j0,
int j1)
Get a submatrix. |
Matrix |
getMatrix(int i0,
int i1,
int[] c)
Get a submatrix. |
Matrix |
getMatrix(int i0,
int i1,
int j0,
int j1)
Get a submatrix. |
Matrix |
getRow(int row)
Get the specified row as a sub-matrix. |
int |
getRows()
Get the number of rows in the matrix. |
int |
hashCode()
Compute a hash code for this matrix. |
Matrix |
inverse()
|
boolean |
isVector()
Determine if the matrix is a vector. |
boolean |
isZero()
Return true if every value in the matrix is zero. |
void |
multiply(double value)
Multiply every value in the matrix by the specified value. |
void |
multiply(double[] vector,
double[] result)
Multiply every row by the specified vector. |
void |
randomize(double min,
double max)
Randomize the matrix. |
void |
set(double value)
Set every value in the matrix to the specified value. |
void |
set(int row,
int col,
double value)
Set an individual cell in the matrix to the specified value. |
void |
set(Matrix theMatrix)
Set this matrix's values to that of another matrix. |
void |
setMatrix(int[] r,
int[] c,
Matrix x)
Set a submatrix. |
void |
setMatrix(int[] r,
int j0,
int j1,
Matrix x)
Set a submatrix. |
void |
setMatrix(int i0,
int i1,
int[] c,
Matrix x)
Set a submatrix. |
void |
setMatrix(int i0,
int i1,
int j0,
int j1,
Matrix x)
Set a submatrix. |
int |
size()
Get the size of the array. |
Matrix |
solve(Matrix b)
Solve A*X = B. |
double |
sum()
Sum all of the values in the matrix. |
Double[] |
toPackedArray()
Convert the matrix into a packed array. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Matrix(boolean[][] sourceMatrix)
sourceMatrix - The booleans to create the matrix from.public Matrix(double[][] sourceMatrix)
sourceMatrix - An array of doubles.
public Matrix(int rows,
int cols)
rows - How many rows in the matrix.cols - How many columns in the matrix.| Method Detail |
|---|
public static Matrix createColumnMatrix(double[] input)
input - A double array.
public static Matrix createRowMatrix(double[] input)
input - A double array.
public final void add(int row,
int col,
double value)
row - The row to add to.col - The column to add to.value - The value to add to the matrix.public final void add(Matrix theMatrix)
theMatrix - The matrix to add.public final void clear()
public final Matrix clone()
clone in class Object
public final boolean equals(Matrix theMatrix,
int precision)
theMatrix - The other matrix to compare to.precision - How much precision to use.
public final boolean equals(Object other)
equals in class Objectother - The other matrix to compare.
public final int fromPackedArray(Double[] array,
int index)
array - The packed array.index - Where to start in the packed array.
public final double get(int row,
int col)
row - The row to read.col - The column to read.
public final double[][] getArrayCopy()
public final Matrix getCol(int col)
col - The column to read.
public final int getCols()
public final double[][] getData()
public final Matrix getMatrix(int i0,
int i1,
int j0,
int j1)
i0 - Initial row index.i1 - Final row index.j0 - Initial column index.j1 - Final column index.
public final Matrix getMatrix(int i0,
int i1,
int[] c)
i0 - Initial row index.i1 - Final row index.c - Array of column indices.
public final Matrix getMatrix(int[] r,
int j0,
int j1)
r - Array of row indices.j0 - Initial column indexj1 - Final column index
public final Matrix getMatrix(int[] r,
int[] c)
r - Array of row indices.c - Array of column indices.
public final Matrix getRow(int row)
row - The row to get.
public final int getRows()
public final int hashCode()
hashCode in class Objectpublic final Matrix inverse()
public final boolean isVector()
public final boolean isZero()
public final void multiply(double value)
value - The value to multiply the matrix by.
public final void multiply(double[] vector,
double[] result)
vector - The vector to multiply by.result - The result to hold the values.
public final void randomize(double min,
double max)
min - Minimum random value.max - Maximum random value.public final void set(double value)
value - The value to set the matrix to.
public final void set(int row,
int col,
double value)
row - The row to set.col - The column to set.value - The value to be set.public final void set(Matrix theMatrix)
theMatrix - The other matrix.
public final void setMatrix(int i0,
int i1,
int j0,
int j1,
Matrix x)
i0 - Initial row indexi1 - Final row indexj0 - Initial column indexj1 - Final column indexx - A(i0:i1,j0:j1)
public final void setMatrix(int i0,
int i1,
int[] c,
Matrix x)
i0 - Initial row indexi1 - Final row indexc - Array of column indices.x - The submatrix.
public final void setMatrix(int[] r,
int j0,
int j1,
Matrix x)
r - Array of row indices.j0 - Initial column indexj1 - Final column indexx - A(r(:),j0:j1)
public final void setMatrix(int[] r,
int[] c,
Matrix x)
r - Array of row indices.c - Array of column indices.x - The matrix to set.public final int size()
public final Matrix solve(Matrix b)
b - right hand side.
public final double sum()
public final Double[] toPackedArray()
public final String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||