nr
Class Mat_array

java.lang.Object
  extended by nr.Mat_array
All Implemented Interfaces:
Mat

public class Mat_array
extends java.lang.Object
implements Mat

Implements a simple Mat based on a fixed array

Author:
Daniel Wachsstock

Constructor Summary
Mat_array(double[][] d)
          Creates a new instance of Mat_array from a double[][].
Mat_array(int n)
          Creates a new instance of Mat_array
Mat_array(Mat m)
          Creates a new instance of Mat_array.
 
Method Summary
 double[][] asArray()
          get the data
 Mat copy()
          return a copy of this, or some version that the user can manipulate at will.
 double get(int i, int j)
          get an individual element
 Vec getColumn(int j)
          get a column
 Vec getRow(int i)
          get a row
static Mat identity(int n)
          returns an identity matrix
 void set(int i, int j, double d)
          set an individual element
 int size()
          the size of the matrix
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Mat_array

public Mat_array(int n)
Creates a new instance of Mat_array

Parameters:
n - the size of the matrix

Mat_array

public Mat_array(double[][] d)
Creates a new instance of Mat_array from a double[][].

Parameters:
d - the source array
Throws:
java.lang.IndexOutOfBoundsException - if d is not a square array

Mat_array

public Mat_array(Mat m)
Creates a new instance of Mat_array. Copy constructor.

Parameters:
m - the Mat to copy
Method Detail

asArray

public double[][] asArray()
Description copied from interface: Mat
get the data

Specified by:
asArray in interface Mat
Returns:
the data as a double[][]

copy

public Mat copy()
Description copied from interface: Mat
return a copy of this, or some version that the user can manipulate at will. If the implementation of this is immutable, can return the original, or the implementation can do some kind of copy-on-write.

Specified by:
copy in interface Mat
Returns:
a copy of the data

get

public double get(int i,
                  int j)
Description copied from interface: Mat
get an individual element

Specified by:
get in interface Mat
Parameters:
i - the row
j - the column
Returns:
the value at i,j

getColumn

public Vec getColumn(int j)
Description copied from interface: Mat
get a column

Specified by:
getColumn in interface Mat
Parameters:
j - the column
Returns:
the actual column, or a Vec whose changes are reflected in the original matrix

getRow

public Vec getRow(int i)
Description copied from interface: Mat
get a row

Specified by:
getRow in interface Mat
Parameters:
i - the row
Returns:
the actual row, or a Vec whose changes are reflected in the original matrix

set

public void set(int i,
                int j,
                double d)
Description copied from interface: Mat
set an individual element

Specified by:
set in interface Mat
Parameters:
i - the row
j - the column
d - the value to set it to

size

public int size()
Description copied from interface: Mat
the size of the matrix

Specified by:
size in interface Mat
Returns:
the size of the square matrix

identity

public static Mat identity(int n)
returns an identity matrix

Parameters:
n - the size
Returns:
an identity matrix (A[i][j] = i==j ? 1 : 0)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object