nr
Class Mat_wrapper

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

public class Mat_wrapper
extends java.lang.Object
implements Mat

Implements a simple Mat based on a based on an external array. The underlying data is publicly available.

Author:
Daniel Wachsstock

Field Summary
 double[][] data
          the array underlying this Mat
 
Constructor Summary
Mat_wrapper(double[][] d)
          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
 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
 

Field Detail

data

public final double[][] data
the array underlying this Mat

Constructor Detail

Mat_wrapper

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

Parameters:
d - the array to use
Throws:
java.lang.IndexOutOfBoundsException - if d is not a square array
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

toString

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