databionics.io
Class Array2DFile

java.lang.Object
  extended by databionics.io.BaseFile
      extended by databionics.io.Array2DFile
Direct Known Subclasses:
Array3DFile, LrnFile, UmxFile

public abstract class Array2DFile
extends BaseFile

Base class for all filetypes with 2D data arrays.


Field Summary
protected  cern.colt.matrix.DoubleMatrix2D data
          2D matrix.
protected static org.apache.log4j.Logger log
          Log4j logging.
 
Fields inherited from class databionics.io.BaseFile
allowEmptyLines, comment, commentPrefix, delimiter, delimiters, file, header, headerPrefix, loc, nf
 
Constructor Summary
Array2DFile()
          Standard constructor
Array2DFile(int rows, int cols)
          Constructor with size for an empty array.
Array2DFile(java.lang.String filename)
          Constructor with a filename
 
Method Summary
protected  void buildHeader()
          Generate header.
protected  java.lang.String buildLine(int row)
          Construct a line for saving.
 double get(int r, int c)
          Get element of matrix.
 int getColumns()
          Get number of columns in matrix.
 cern.colt.matrix.DoubleMatrix2D getData()
          Get 2D matrix.
 int getRows()
          Get number of rows in matrix.
 int getSize()
          Get the number of lines in file.
protected  void init(int rows, int cols)
          Initialize 2D array.
protected  void parseLine(int row, java.lang.String line)
          Parse a line.
 void set(int r, int c, double v)
          Change element of matrix.
 void setData(double[][] data)
          Set 2D matrix as array
 void setData(cern.colt.matrix.DoubleMatrix2D data)
          Set 2D matrix.
 
Methods inherited from class databionics.io.BaseFile
checkHeader, checkHeaderAgainstSize, getComment, getFile, getFilename, getHeader, getLocale, getNumberFormat, isHeader, isNaN, isNumber, load, load, parseError, parseHeader, save, save, setComment, setFilename, setLocale, writeStringList, writeStringList
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.apache.log4j.Logger log
Log4j logging.


data

protected cern.colt.matrix.DoubleMatrix2D data
2D matrix.

Constructor Detail

Array2DFile

public Array2DFile()
Standard constructor


Array2DFile

public Array2DFile(java.lang.String filename)
Constructor with a filename

Parameters:
filename - Name of the file

Array2DFile

public Array2DFile(int rows,
                   int cols)
Constructor with size for an empty array.

Parameters:
rows - Rows of data array.
cols - Columns of data array.
Method Detail

init

protected void init(int rows,
                    int cols)
Initialize 2D array.

Overrides:
init in class BaseFile
Parameters:
rows - Rows of data array.
cols - Columns of data array.

parseLine

protected void parseLine(int row,
                         java.lang.String line)
Parse a line.

Overrides:
parseLine in class BaseFile
Parameters:
row - Number of current line.
line - Current line.

buildHeader

protected void buildHeader()
Generate header.

Overrides:
buildHeader in class BaseFile

buildLine

protected java.lang.String buildLine(int row)
Construct a line for saving.

Overrides:
buildLine in class BaseFile
Parameters:
row - Number of current line.
Returns:
Line with that number.

getSize

public int getSize()
Get the number of lines in file.

Overrides:
getSize in class BaseFile
Returns:
Number of lines in file.

getColumns

public int getColumns()
Get number of columns in matrix.


getRows

public int getRows()
Get number of rows in matrix.


getData

public cern.colt.matrix.DoubleMatrix2D getData()
Get 2D matrix.


setData

public void setData(cern.colt.matrix.DoubleMatrix2D data)
Set 2D matrix.

Parameters:
data - 2D Data array.

setData

public void setData(double[][] data)
Set 2D matrix as array

Parameters:
data - 2D Data array.

set

public void set(int r,
                int c,
                double v)
Change element of matrix.

Parameters:
r - Row of value.
c - Column of value.
v - Value.

get

public double get(int r,
                  int c)
Get element of matrix.

Returns:
Value at this position


Copyright © 2005-2006 Databionics Research Group. All Rights Reserved.