jeffheaton's picture

    There are several ways to construct a Matrix object. To construct an empty matrix, use the following code:

Matrix matrix = new Matrix(3,2);

    This will construct an empty matrix of three rows and two columns, which contains only zeros. This matrix is described in Equation 2.3.

Equation 2.3: An Empty Matrix

A Threshold and Weight Matrix

    You can also construct a matrix using a two dimensional array, which allows you to initialize the cells of the matrix in the declaration. The following code creates an initialized 3x2 matrix.

double matrixData[][] = {
  {1.0,2.0,3.0},
  {4.0,5.0,6.0}
};
		
Matrix matrix = new Matrix(matrixData);

    This matrix is described in Equation 2.4.

Equation 2.4: An Initialized Matrix

A Threshold and Weight Matrix

    Matrixes can also be created using a single dimensional array. A single dimensional array can be used to create a row or a column matrix. Row and column matrixes contain either a single row or a single column, respectively. These matrixes are also called vectors. The following code can be used to create a row matrix.

double matrixData[] = {1.0,2.0,3.0,4.0};
Matrix matrix = Matrix.createRowMatrix(matrixData);

    This will create a matrix that contains a single row. This matrix is described in Equation 2.5.

Equation 2.5: A Row Matrix/Vector

A Threshold and Weight Matrix

    It is also possible to create a column matrix. This matrix takes a single dimensional array, just as before; however, this time a matrix with a single column is created. The code to do this is shown here.

double matrixData[] = {1.0,2.0,3.0,4.0};
Matrix matrix = Matrix.createColumnMatrix(matrixData);

    This matrix is described in Equation 2.6.

Equation 2.6: A Column Matrix/Vector

A Threshold and Weight Matrix

    In the next section you will see how mathematical operations can be performed on one or more matrixes.

Comments

Mathematica provides a range

Huan's picture

Mathematica provides a range of methods for representing and constructing matrices. Especially powerful are symbolic representations, in terms of symbolic systems of equations, symbolic sparse or banded matrices, and symbolic geometric transformations.

Possible typo?

peter's picture

Should Equation 2.3 (an empty matrix defined as new Matrix(3,2)) be:

[0, 0]
[0, 0]
[0, 0]

and the initialization code below:

double matrixData[][] = {
{1.0,2.0,3.0},
{4.0,5.0,6.0}
};

should create a matrix of

[1, 2, 3]
[4, 5, 6]

and not

[1, 2, 3, 4]
[5, 6, 7, 8]

as indicated in equation 2.4

there is "jama" package whihc

prasanna.hande's picture

there is "jama" package whihc contains set Matrix calss to perform matrix operations


Copyright 2005 - 2012 by Heaton Research, Inc.. Heaton Research™ and Encog™ are trademarks of Heaton Research. Click here for copyright, license and trademark information.