org.jutil.math.matrix
Class NMatrix

java.lang.Object
  |
  +--org.jutil.math.matrix.NMatrix
Direct Known Subclasses:
Matrix

public abstract class NMatrix
extends java.lang.Object

This is a class of N-dimensional matrices The name Matrix has been reserved for 2D matrices since they are use more frequently than a general N-dimensional matrix. Since java has no generic classes, a matrix contains double values.

Version:
$Revision: 1.2 $
Author:
Marko van Dooren

Field Summary
static java.lang.String CVS_REVISION
           
 
Constructor Summary
NMatrix()
           
 
Method Summary
abstract  double elementAt(int[] index)
          pre validIndex(index);
Return the element at the given index.
abstract  int[] getDimensions()
          post \result.length == getNbDimensions();
Return the dimensions of this matrix
abstract  int getNbDimensions()
          public invariant getDimensions().length == getNbDimensions();
public invariant (\forall int i; i>=0 && i getDimensions()[i] > 0);
Return the number of dimensions of this matrix.
abstract  void setElementAt(int[] index, double value)
          pre validIndex(index);

post elementAt(index) == value;
Set the element at the given index to the given value.
 boolean validIndex(int[] index)
          post \result == (index != null) &&
(index.length == getNbDimensions()) &&
(\forall int i; i>=0 && i (index[i] > 0) && (index[i] <= getDimensions()[i]));
Check whether or not the given index is a valid index for this matrix.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CVS_REVISION

public static final java.lang.String CVS_REVISION
Constructor Detail

NMatrix

public NMatrix()
Method Detail

getNbDimensions

public abstract int getNbDimensions()
public invariant getDimensions().length == getNbDimensions();
public invariant (\forall int i; i>=0 && i getDimensions()[i] > 0);
Return the number of dimensions of this matrix.

getDimensions

public abstract int[] getDimensions()
post \result.length == getNbDimensions();
Return the dimensions of this matrix

elementAt

public abstract double elementAt(int[] index)
pre validIndex(index);
Return the element at the given index.
Parameters:
index - The index of the requested element.

setElementAt

public abstract void setElementAt(int[] index,
                                  double value)
pre validIndex(index);

post elementAt(index) == value;
Set the element at the given index to the given value.
Parameters:
index - The index of the element to be changed.
value - The new value for the element at index .

validIndex

public boolean validIndex(int[] index)
post \result == (index != null) &&
(index.length == getNbDimensions()) &&
(\forall int i; i>=0 && i (index[i] > 0) && (index[i] <= getDimensions()[i]));
Check whether or not the given index is a valid index for this matrix.
Parameters:
index - The index to be verified.