org.jmatrices.dbl
Interface Matrix

All Superinterfaces:
java.io.Serializable

public interface Matrix
extends java.io.Serializable

Matrix represents a structurally immutable matrix of numbers(double) with index begining at 1.

The only way to change the elements in a matrix is through set(int, int, double)

A good convention to follow is to use row=1;row<=rows();row++(col=1;col<=cols();coll++) as indices while looping over matrix elements.

And use the normal i,j,k etc. to iterate over arrays!

Author: purangp

Date: 07.03.2004 Time: 15:52:02


Method Summary
 int cols()
          Gets the number of columns in the matrix

counts from 1

 double[][] get()
          Gets a copy of the elements as a 2D array.
 double get(int row, int col)
          Gets the value of the element at the given row and column
 Matrix getColumn(int col)
          Gets the entire column as a matrix
 Matrix getRow(int row)
          Gets the entire row as a matrix
 Matrix getSubMatrix(int[] r, int[] c)
          Get a submatrix.
 Matrix getSubMatrix(int[] r, int colI, int colF)
          Get a submatrix.
 Matrix getSubMatrix(int rowI, int rowF, int[] c)
          Get a submatrix.
 Matrix getSubMatrix(int rowI, int colI, int rowF, int colF)
          Get a submatrix.
 int rows()
          Gets the number of rows in the matrix

Counts from 1

 void set(int row, int col, double value)
          Sets an element at the given position to a new value
 

Method Detail

rows

public int rows()
Gets the number of rows in the matrix

Counts from 1

Returns:
number of rows in the matrix

cols

public int cols()
Gets the number of columns in the matrix

counts from 1

Returns:
number of columns in the matrix

set

public void set(int row,
                int col,
                double value)
Sets an element at the given position to a new value

Parameters:
row - row in which the element occurs
col - column in which the element occurs
value - the new value to be set

get

public double get(int row,
                  int col)
Gets the value of the element at the given row and column

Parameters:
row - row in which the element occurs
col - column in which the element occurs
Returns:
value of the element

getRow

public Matrix getRow(int row)
Gets the entire row as a matrix

Parameters:
row - row asked for
Returns:
Matrix containing the row

getColumn

public Matrix getColumn(int col)
Gets the entire column as a matrix

Parameters:
col - column asked for
Returns:
Matrix containing the column

get

public double[][] get()
Gets a copy of the elements as a 2D array.

Copy signifies the fact that any modifications made on the copy will not affect the Source matrix!

Returns:
copy of all elements as a 2D array

getSubMatrix

public Matrix getSubMatrix(int rowI,
                           int colI,
                           int rowF,
                           int colF)
Get a submatrix.

Parameters:
rowI - Initial row index
colI - Initial column index
rowF - Final row index
colF - Final column index
Returns:
A(rowI:rowF,colI:colF)
Throws:
java.lang.ArrayIndexOutOfBoundsException - Submatrix indices

getSubMatrix

public Matrix getSubMatrix(int[] r,
                           int[] c)
Get a submatrix.

Parameters:
r - Array of row indices.
c - Array of column indices.
Returns:
A(r(:),c(:))
Throws:
java.lang.ArrayIndexOutOfBoundsException - Submatrix indices

getSubMatrix

public Matrix getSubMatrix(int rowI,
                           int rowF,
                           int[] c)
Get a submatrix.

Parameters:
rowI - Initial row index
rowF - Final row index
c - Array of column indices.
Returns:
A(i0:i1,c(:))
Throws:
java.lang.ArrayIndexOutOfBoundsException - Submatrix indices

getSubMatrix

public Matrix getSubMatrix(int[] r,
                           int colI,
                           int colF)
Get a submatrix.

Parameters:
r - Array of row indices.
colI - Initial column index
colF - Final column index
Returns:
A(r(:),j0:j1)
Throws:
java.lang.ArrayIndexOutOfBoundsException - Submatrix indices