csli.util.math.matrix
Class ArrayMatrix

java.lang.Object
  extended by java.util.AbstractCollection<Double>
      extended by csli.util.math.matrix.AbstractMatrix
          extended by csli.util.math.matrix.ArrayMatrix
All Implemented Interfaces:
Matrix, Iterable<Double>, Collection<Double>

public class ArrayMatrix
extends AbstractMatrix

Matrix implementation as a 2D array.

Author:
jefe

Nested Class Summary
 
Nested classes/interfaces inherited from interface csli.util.math.matrix.Matrix
Matrix.SingularMatrixException
 
Constructor Summary
ArrayMatrix(double[][] data)
          Create a Matrix from a 2D array.
ArrayMatrix(int dim)
          Create a square matrix of dimension dim, filled with zeros.
ArrayMatrix(int m, int n)
          Create an m x n matrix filled with zeros.
ArrayMatrix(int m, int n, double... args)
          Create an m x n matrix from data given as arguments.
ArrayMatrix(Matrix M)
          Create a new ArrayMatrix by copying the contents of another matrix.
 
Method Summary
 double get(int i, int j)
           
static void main(String[] args)
          Matrix test.
 int numCols()
           
 int numRows()
           
 void set(int i, int j, double val)
           
 
Methods inherited from class csli.util.math.matrix.AbstractMatrix
add, addIP, appendRight, cols, equals, fill, getCol, getRow, inverse, isIdentity, isZero, iterator, leftDivide, multiply, multiply, multiplyIP, ref, rows, rref, setCol, setDiag, setRow, size, submatrix, submatrix, subtract, subtractIP, toString, transpose
 
Methods inherited from class java.util.AbstractCollection
add, addAll, clear, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
add, addAll, clear, contains, containsAll, hashCode, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Constructor Detail

ArrayMatrix

public ArrayMatrix(double[][] data)
Create a Matrix from a 2D array. Assumes every row of data has the same length.

Parameters:
data -

ArrayMatrix

public ArrayMatrix(int dim)
Create a square matrix of dimension dim, filled with zeros.

Parameters:
dim -

ArrayMatrix

public ArrayMatrix(int m,
                   int n)
Create an m x n matrix filled with zeros.

Parameters:
m -
n -

ArrayMatrix

public ArrayMatrix(int m,
                   int n,
                   double... args)
Create an m x n matrix from data given as arguments.

Parameters:
m -
n -
args -

ArrayMatrix

public ArrayMatrix(Matrix M)
Create a new ArrayMatrix by copying the contents of another matrix.

Parameters:
M -
Method Detail

get

public double get(int i,
                  int j)

set

public void set(int i,
                int j,
                double val)
Specified by:
set in interface Matrix
Overrides:
set in class AbstractMatrix

numRows

public int numRows()

numCols

public int numCols()

main

public static void main(String[] args)
                 throws Matrix.SingularMatrixException
Matrix test.

Parameters:
args -
Throws:
Matrix.SingularMatrixException