org.jutil.math.matrix
Class Column

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

public class Column
extends Matrix

A class of matrices containing only 1 column.


Class Specifications
public invariant getNbColumns() == 1;

Specifications inherited from class Matrix
public invariant getNbDimensions() == 2;

Specifications inherited from class NMatrix
public invariant getDimensions().length == getNbDimensions();
public invariant ( \forall int i; i >= 0&&i < getNbDimensions(); getDimensions()[i] > 0);

Field Summary
static java.lang.String CVS_REVISION
           
 
Constructor Summary
Column(double[] elements)
          Create a new Column with the given elements.
Column(int size)
          Create a new Column with the given size.
 
Method Summary
 java.lang.Object clone()
          See superclass
 double elementAt(int index)
          Return the element at the given index
 double norm(int p)
          Return the p-norm of this vector.
 void normalize()
          Normalize this vector
 void setElementAt(int index, double value)
          Set the element at the given index
 void setSubColumn(int lower, Column column)
          Replace a subcolumn of this Column, starting at the given position with the given column.
 int size()
          Return the size of this Column.
 Column subColumn(int lower, int upper)
          Return a sub-column of this column starting from and ending at
 boolean validIndex(int index)
          Check whether or not the given index is a valid index for this Column.
 
Methods inherited from class org.jutil.math.matrix.Matrix
add, 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

Column

public Column(int size)
Create a new Column with the given size.

Parameters:
size - The size of the new column.

Specifications:
public behavior
requires size > 0;
ensures size() == size;
ensures ( \forall int i; i > 0&&i <= size(); elementAt(i) == 0);

Column

public Column(double[] elements)
Create a new Column with the given elements.

Parameters:
elements - An array containing the elements for this Column

Specifications:
public behavior
requires elements != null;
requires elements.length > 0;
ensures size() == elements.length;
ensures ( \forall int i; i > 0&&i <= size(); elementAt(i) == elements[i-1]);
Method Detail

elementAt

public double elementAt(int index)
Return the element at the given index

Parameters:
index - The index of the element to be retrieved.

Specifications:
public behavior
requires validIndex(index);
ensures \result == elementAt(index,1);

setElementAt

public void setElementAt(int index,
                         double 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

Specifications:
public behavior
requires validIndex(index);
ensures elementAt(index) == value;

size

public int size()
Return the size of this Column.

Specifications:
public behavior
ensures \result == getNbRows();

subColumn

public Column subColumn(int lower,
                        int upper)
Return a sub-column of this column starting from and ending at

Parameters:
lower - The lower index
upper - The upper index

Specifications:
public behavior
requires validIndex(lower);
requires validIndex(upper);
requires lower <= upper;
ensures \result != null;
ensures \result .size() == upper-lower+1;
ensures ( \forall int i; i >= lower&&i <= upper; \result .elementAt(i-lower+1) == elementAt(i));

setSubColumn

public void setSubColumn(int lower,
                         Column column)
Replace a subcolumn of this Column, starting at the given position with the given column.

Parameters:
lower - The index at which the column must be pasted.
column - The column to paste into this column.

Specifications:
public behavior
requires validIndex(lower);
requires validIndex(lower+column.size()-1);
requires column != null;
ensures subColumn(lower,lower+column.size()-1).equals(column);

norm

public double norm(int p)
Return the p-norm of this vector.

Parameters:
p - The p in p-norm.

Specifications:
public behavior
requires p > 0;
ensures \result == Math.pow(( \sum int i; i >= 1&&i <= size(); Math.pow(elementAt(i),p)),1/p);

clone

public java.lang.Object clone()
See superclass

Specifications:
     also
public behavior
ensures \result instanceof Column;

Specifications inherited from overridden method in class Matrix:
     also
public behavior
ensures equals(\result );
ensures \result instanceof Matrix;

normalize

public void normalize()
Normalize this vector

Specifications:
public behavior
requires norm(2) > 0;
ensures ( \forall int i; i >= 1&&i <= size(); elementAt(i) == \old(elementAt(i)/norm(2)));

validIndex

public boolean validIndex(int index)
Check whether or not the given index is a valid index for this Column.

Parameters:
index - The index to be verified

Specifications:
public behavior
ensures \result == (index > 0)&&(index <= size());