SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.matrix.doubles
Interface MatrixAccessor

All Known Subinterfaces:
Matrix, SparseMatrix
All Known Implementing Classes:
BidiagonalMatrix, BorderedHessian, CovarianceMatrix, CsrSparseMatrix, DenseMatrix, DiagonalMatrix, DokSparseMatrix, GivensMatrix, GoldfeldQuandtTrotter, Gradient, Hessian, HilbertMatrix, ImmutableKroneckerProduct, ImmutableMatrix, Inverse, Jacobian, JordanExchange, KroneckerProduct, LilSparseMatrix, LowerTriangularMatrix, MatrixMathImpl, MatrixStorageImpl, MatthewsDavies, PermutationMatrix, Pow, PseudoInverse, SubMatrixRef, SymmetricMatrix, TriangularMatrix, TridiagonalMatrix, UpperTriangularMatrix

public interface MatrixAccessor

This interface defines methods for accessing elements in a matrix.

Indices count from 1, e.g., get(1,1), which is what mathematicians (not programmers) are accustomed to.

Invalid access such as using out-of-range indices or altering immutable matrix will lead to MatrixAccessException.

The only way to change a matrix is by set(int, int, double). Other operations that "change" the matrix actually creates a new and independent copy.


Method Summary
 double get(int row, int col)
          Get the matrix entry at [row, col].
 Vector getColumn(int col)
          Get a specified column as a vector.
 Vector getRow(int row)
          Get a specified row as a vector.
 void set(int row, int col, double value)
          Set the matrix entry at [row, col] to value.
 

Method Detail

set

void set(int row,
         int col,
         double value)
         throws MatrixAccessException
Set the matrix entry at [row, col] to value.

This is the only method that may change the entries of a matrix.

Parameters:
row - the row index
col - the column index
value - the value to set A[row, col] to
Throws:
MatrixAccessException - if row or col is out of range

get

double get(int row,
           int col)
           throws MatrixAccessException
Get the matrix entry at [row, col].

Parameters:
row - the row index
col - the column index
Returns:
A[row, col]
Throws:
MatrixAccessException - if row or col is out of range

getRow

Vector getRow(int row)
              throws MatrixAccessException
Get a specified row as a vector.

Parameters:
row - the row index
Returns:
a vector A[row, ]
Throws:
MatrixAccessException - when row < 1, or when row > number of rows

getColumn

Vector getColumn(int col)
                 throws MatrixAccessException
Get a specified column as a vector.

Parameters:
col - the column index
Returns:
a vector A[, col]
Throws:
MatrixAccessException - when col < 1, or when col > number of columns

SuanShu, a Java numerical and statistical library

Copyright © 2011 Numerical Method Inc. Ltd. All Rights Reserved.