org.jutil.math.matrix
Class Row

java.lang.Object
  |
  +--org.jutil.math.matrix.NMatrix
        |
        +--org.jutil.math.matrix.Matrix
              |
              +--org.jutil.math.matrix.Row

public class Row
extends Matrix

A class of matrices containing only 1 row.

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

Field Summary
static java.lang.String CVS_REVISION
           
 
Constructor Summary
Row(double[] elements)
          pre elements != 0
pre elements.length > 0

post size() == elements.length
post (\forall int i; i>0 && i <= size();
elementAt(i) == elements[i-1]);
Create a new Row with the given elements.
Row(int size)
          public invariant getNbRows() == 1;

pre size > 0;

post size() == size;
post (\forall int i; i > 0 && i <= size();
elementAt(i) == 0);
Create a new Row with the given size.
 
Method Summary
 double elementAt(int index)
          pre validIndex(index);

post elementAt(1, index);
Return the element at the given index.
 void setElementAt(int index, double value)
          pre validIndex(index);

post elementAt(index) == value;
Set the element at the given index
 void setSubRow(int lower, Row row)
          public behavior

pre validIndex(lower);
pre validIndex(lower + column.size() - 1);
pre row != null;

post subRow(lower, lower + row.size() - 1).equals(row);
Replace a sub-row of this Row, starting at the given position with the given row.
 int size()
          post \result == getNbColumns();
Return the size of this Row.
 Row subRow(int lower, int upper)
          public behavior

pre validIndex(lower);
pre validIndex(upper);
pre lower <= upper;

post \result != null;
post \result.size() == upper - lower + 1;
post (\forall int i; i >= lower && i <= upper;
\result.elementAt(i - lower + 1) == elementAt(i));
Return a sub-row of this row starting from and ending at
 boolean validIndex(int index)
          post \result == (index > 0) && (index <= size());
Check whether or not the given index is a valid index for this Column.
 
Methods inherited from class org.jutil.math.matrix.Matrix
add, clone, divide, elementAt, elementAt, equals, getColumn, getDimensions, getNbColumns, getNbDimensions, getNbRows, getRow, isDiagonal, isLowerTriangular, isPermutationMatrix, isSquare, isSymmetric, isUpperTriangular, leftGivens, minus, multiply, plus, returnTranspose, rightGivens, sameDimensions, setColumn, setElementAt, setElementAt, setRow, setSubMatrix, subMatrix, subtract, times, times, toString, transpose, unity, validIndex
 
Methods inherited from class org.jutil.math.matrix.NMatrix
validIndex
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CVS_REVISION

public static final java.lang.String CVS_REVISION
Constructor Detail

Row

public Row(int size)
public invariant getNbRows() == 1;

pre size > 0;

post size() == size;
post (\forall int i; i > 0 && i <= size();
elementAt(i) == 0);
Create a new Row with the given size.
Parameters:
size - The size of the new row.

Row

public Row(double[] elements)
pre elements != 0
pre elements.length > 0

post size() == elements.length
post (\forall int i; i>0 && i <= size();
elementAt(i) == elements[i-1]);
Create a new Row with the given elements.
Parameters:
elements - An array containing the elements for this row.
Method Detail

elementAt

public double elementAt(int index)
pre validIndex(index);

post elementAt(1, index);
Return the element at the given index.
Parameters:
index - The index of the element to be retrieved.

setElementAt

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

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

size

public int size()
post \result == getNbColumns();
Return the size of this Row.

subRow

public Row subRow(int lower,
                  int upper)
public behavior

pre validIndex(lower);
pre validIndex(upper);
pre lower <= upper;

post \result != null;
post \result.size() == upper - lower + 1;
post (\forall int i; i >= lower && i <= upper;
\result.elementAt(i - lower + 1) == elementAt(i));
Return a sub-row of this row starting from and ending at
Parameters:
lower - The lower index
upper - The upper index

setSubRow

public void setSubRow(int lower,
                      Row row)
public behavior

pre validIndex(lower);
pre validIndex(lower + column.size() - 1);
pre row != null;

post subRow(lower, lower + row.size() - 1).equals(row);
Replace a sub-row of this Row, starting at the given position with the given row.
Parameters:
lower - The index at which the row must be pasted.
row - The row to paste into this row.

validIndex

public boolean validIndex(int index)
post \result == (index > 0) && (index <= size());
Check whether or not the given index is a valid index for this Column.
Parameters:
index - The index to be verified