DataTable< Type > Class Template Reference

Provides access to homogeneous tabular data. More...

#include <DataTable.h>

List of all members.

Public Member Functions

 DataTable (const bool columnLabels=true, const bool rowLabels=false)
enum DataTableResult Read (const std::string fileName)
void SetWidth (const std::string s)
Type Value (const unsigned row, const unsigned col) const
void SetValue (const unsigned row, const unsigned col, const Type value)
std::string ColumnLabel (const unsigned index) const
std::string RowLabel (const unsigned index) const
std::vector< Type > RowVector (const unsigned row) const
std::vector< Type > ColumnVector (const unsigned col) const
void PrintTable (std::ostream &out=std::cout)
void Flush (void)
unsigned Rows (void) const
unsigned Columns (void) const
unsigned ColumnLabels (void) const
void SetZero (void)


Detailed Description

template<typename Type>
class DataTable< Type >

Provides access to homogeneous tabular data.

The DataTable class reads homogeneous tabular data, i.e., numerical data that is either all of type Type or that can be converted to Type using standard conversions. Rows or columns or both can be labeled, but labels are not required. A simple method for stream output of errors is also provided.

Definition at line 99 of file DataTable.h.


Constructor & Destructor Documentation

template<typename Type>
DataTable< Type >::DataTable ( const bool  columnLabels = true,
const bool  rowLabels = false 
) [inline]

Constructor -- no default constructor is provided.

Parameters:
columnLabels Are columns labeled?
rowLabels Are rows labeled?
Initializes data structures. Use Read() to collect the data.

Definition at line 113 of file DataTable.h.


Member Function Documentation

template<typename Type>
enum DataTableResult DataTable< Type >::Read ( const std::string  fileName  )  [inline]

Read data from a file.

Parameters:
fileName The name of the file from which data is to be read
Returns:
notEmptyError If the DataTable is not empty

labelError If there is an error reading column labels

valueError If there is an error reading values

openError If filename could not be opened for reading

readSuccess If everything works

The DataTable must be empty for data to be read. If it has been used before, Flush() must be used to re-initialize the internal state.

Definition at line 129 of file DataTable.h.

template<typename Type>
void DataTable< Type >::SetWidth ( const std::string  s  )  [inline]

Sets width of output based on length of string

Parameters:
s The string used to set the width

Definition at line 152 of file DataTable.h.

template<typename Type>
Type DataTable< Type >::Value ( const unsigned  row,
const unsigned  col 
) const [inline]

Value of the data at specified row and column

Parameters:
row Index of the data row
col Index of the data column

Definition at line 165 of file DataTable.h.

References argCheck_.

Referenced by DataTable< Type >::ColumnVector().

template<typename Type>
void DataTable< Type >::SetValue ( const unsigned  row,
const unsigned  col,
const Type  value 
) [inline]

Set value of the data at specified row and column

Parameters:
row Index of the data row
col Index of the data column
value Value to be inserted

Definition at line 177 of file DataTable.h.

References argCheck_.

template<typename Type>
std::string DataTable< Type >::ColumnLabel ( const unsigned  index  )  const [inline]

Label associated with a particular column index

Parameters:
index column index

Definition at line 189 of file DataTable.h.

References argCheck_.

template<typename Type>
std::string DataTable< Type >::RowLabel ( const unsigned  index  )  const [inline]

Label associated with a particular row index

Parameters:
index row index

Definition at line 199 of file DataTable.h.

References argCheck_.

Referenced by DataTable< Type >::PrintTable().

template<typename Type>
std::vector<Type> DataTable< Type >::RowVector ( const unsigned  row  )  const [inline]

An entire row of the data matrix

Parameters:
row Index of the data row

Definition at line 208 of file DataTable.h.

References argCheck_.

template<typename Type>
std::vector<Type> DataTable< Type >::ColumnVector ( const unsigned  col  )  const [inline]

An entire column of the data matrix

Parameters:
col Index of the data column

Definition at line 217 of file DataTable.h.

References argCheck_, and DataTable< Type >::Value().

template<typename Type>
void DataTable< Type >::PrintTable ( std::ostream &  out = std::cout  )  [inline]

Print the table to the specified stream

Parameters:
out The stream for output (defaults to std::cout)

Definition at line 230 of file DataTable.h.

References DataTable< Type >::RowLabel().

template<typename Type>
void DataTable< Type >::Flush ( void   )  [inline]

Re-initialize internal data structures.

Definition at line 244 of file DataTable.h.

template<typename Type>
unsigned DataTable< Type >::Rows ( void   )  const [inline]

Number of rows in the data

Definition at line 253 of file DataTable.h.

template<typename Type>
unsigned DataTable< Type >::Columns ( void   )  const [inline]

Number of columns in the data

Definition at line 259 of file DataTable.h.

template<typename Type>
unsigned DataTable< Type >::ColumnLabels ( void   )  const [inline]

Number of column labels

Definition at line 265 of file DataTable.h.

template<typename Type>
void DataTable< Type >::SetZero ( void   )  [inline]

Set all data elements to zero

Definition at line 271 of file DataTable.h.


The documentation for this class was generated from the following file:
Generated on Tue Mar 27 16:03:48 2007 for mcmc by  doxygen 1.5.1