org.strbio.math
Class DHalfMatrix

java.lang.Object
  extended by org.strbio.math.DVector
      extended by org.strbio.math.DHalfMatrix

public class DHalfMatrix
extends DVector

like an upper triangular DMatrix. This pretends that you have a NxN matrix, but only allows access to elements in the upper triangular part (not including the diagonal). Allowed elements are of the form (i, i+1...n-1). You can access the data[] directly or call inherited methods from DVector, but you SHOULDN'T DO THIS.

Version:
1.0, 3/30/98
Author:
JMC
See Also:
DMatrix

Field Summary
 
Fields inherited from class org.strbio.math.DVector
data
 
Constructor Summary
DHalfMatrix()
          Makes a new DHalfMatrix with no data.
DHalfMatrix(DHalfMatrix x)
          This makes a DHalfMatrix from another one, making a separate copy of the data.
DHalfMatrix(int x)
          This makes a new DHalfMatrix which is the upper triangular part of a square matrix.
 
Method Summary
 int cols()
          Returns the number of columns (of the theoretical whole matrix, not just the upper triangular part.
 void load(java.io.BufferedReader fp)
          Loads from an open BufferedReader.
 void print(PrintfStream outfile)
          Print nicely formatted data to a PrintfStream.
 int rows()
          Returns the number of rows (of the theoretical whole matrix, not just the upper triangular part.
 void setValueAt(int x, int y, double d)
          This allows you to set a value at column x, row y in the theoretical whole matrix.
 double valueAt(int x, int y)
          This allows you to get a value at column x, row y in the theoretical whole matrix.
 
Methods inherited from class org.strbio.math.DVector
add, add, append, append, average, averageRW, covar, cross, cross, dimension, distance, distance, divide, divide, dot, dot, equals, findNClosest, length, linearFit, load, makeZScores, max, median, min, multiply, multiply, multiply, multiply, multiply, multiply, norm, normalize, pearson, print, reverse, reverse, save, save, setValue, setValueAt, sort, stdev, stdevp, subtract, subtract, transform, valueAt, zScore
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DHalfMatrix

public DHalfMatrix(int x)
This makes a new DHalfMatrix which is the upper triangular part of a square matrix. All elements are zero.

Parameters:
x - the number of rows and columns (x by x matrix)

DHalfMatrix

public DHalfMatrix()
Makes a new DHalfMatrix with no data. You can then load the data out of a file.


DHalfMatrix

public DHalfMatrix(DHalfMatrix x)
This makes a DHalfMatrix from another one, making a separate copy of the data.

Method Detail

rows

public final int rows()
Returns the number of rows (of the theoretical whole matrix, not just the upper triangular part.


cols

public final int cols()
Returns the number of columns (of the theoretical whole matrix, not just the upper triangular part.


valueAt

public final double valueAt(int x,
                            int y)
This allows you to get a value at column x, row y in the theoretical whole matrix. y must be greater than x, or you will probably get an ArrayOutOfBounds exception.

Parameters:
x - column number
y - row number

setValueAt

public final void setValueAt(int x,
                             int y,
                             double d)
This allows you to set a value at column x, row y in the theoretical whole matrix. y must be greater than x, or you will probably get an ArrayOutOfBounds exception.

Parameters:
x - column number
y - row number
d - double to store

print

public final void print(PrintfStream outfile)
                 throws java.io.IOException
Print nicely formatted data to a PrintfStream.

Throws:
java.io.IOException

load

public final void load(java.io.BufferedReader fp)
                throws java.io.IOException
Loads from an open BufferedReader. Other load and save functions are inherited from DVector, and work.

Overrides:
load in class DVector
Throws:
java.io.IOException
See Also:
DVector