Doxygen updates

This commit is contained in:
Harry Moffat 2009-01-15 20:08:50 +00:00
parent ae24104220
commit 6ac81c73ff
5 changed files with 242 additions and 198 deletions

View file

@ -1,6 +1,5 @@
/**
* @file Array.h
*
* Header file for class Array2D
*/
@ -23,211 +22,225 @@
namespace Cantera {
/**
* A class for 2D arrays stored in column-major
* (Fortran-compatible) form.
* In this form, the data entry for an n row, m col
* matrix is
* index = i + (n-1) * j
* where
* J(i,j) = data_start + index
* i = row
* j = column
*/
class Array2D {
public:
typedef vector_fp::iterator iterator;
typedef vector_fp::const_iterator const_iterator;
/**
* A class for 2D arrays stored in column-major
* (Fortran-compatible) form.
* In this form, the data entry for an n row, m col
* matrix is
* index = i + (n-1) * j
* where
* J(i,j) = data_start + index
* i = row
* j = column
* Default constructor. Create an empty array.
*/
class Array2D {
public:
typedef vector_fp::iterator iterator;
typedef vector_fp::const_iterator const_iterator;
/**
* Default constructor. Create an empty array.
*/
Array2D() : m_nrows(0), m_ncols(0) { m_data.clear(); }
Array2D() : m_nrows(0), m_ncols(0) { m_data.clear(); }
/**
* Constructor. Create an \c m by \c n array, and initialize
* all elements to \c v.
*/
Array2D(int m, int n, doublereal v = 0.0)
: m_nrows(m), m_ncols(n) {
m_data.resize(n*m);
std::fill(m_data.begin(), m_data.end(), v);
}
/**
* Constructor. Create an \c m by \c n array, and initialize
* all elements to \c v.
*/
Array2D(int m, int n, doublereal v = 0.0)
: m_nrows(m), m_ncols(n) {
m_data.resize(n*m);
std::fill(m_data.begin(), m_data.end(), v);
}
/// copy constructor
Array2D(const Array2D& y) {
m_nrows = y.m_nrows;
m_ncols = y.m_ncols;
m_data.resize(m_nrows*m_ncols);
m_data = y.m_data;
}
/// copy constructor
Array2D(const Array2D& y) {
m_nrows = y.m_nrows;
m_ncols = y.m_ncols;
m_data.resize(m_nrows*m_ncols);
m_data = y.m_data;
}
/// assignment operator
Array2D& operator=(const Array2D& y) {
if (&y == this) return *this;
m_nrows = y.m_nrows;
m_ncols = y.m_ncols;
m_data.resize(m_nrows*m_ncols);
m_data = y.m_data;
return *this;
}
/// assignment operator
Array2D& operator=(const Array2D& y) {
if (&y == this) return *this;
m_nrows = y.m_nrows;
m_ncols = y.m_ncols;
m_data.resize(m_nrows*m_ncols);
m_data = y.m_data;
return *this;
}
//! resize the array, and fill the new entries with 'v'
/*!
* @param n This is the number of rows
* @param m This is the number of columns in the new matrix
* @param v Default fill value -> defaults to zero.
*/
void resize(int n, int m, doublereal v = 0.0) {
m_nrows = n;
m_ncols = m;
m_data.resize(n*m, v);
}
//! resize the array, and fill the new entries with 'v'
/*!
* @param n This is the number of rows
* @param m This is the number of columns in the new matrix
* @param v Default fill value -> defaults to zero.
*/
void resize(int n, int m, doublereal v = 0.0) {
m_nrows = n;
m_ncols = m;
m_data.resize(n*m, v);
}
/// append a column
void appendColumn(const vector_fp& c) {
m_ncols++;
m_data.resize(m_nrows*m_ncols);
int m;
for (m = 0; m < m_nrows; m++) value(m_ncols, m) = c[m];
}
/// append a column
void appendColumn(const vector_fp& c) {
m_ncols++;
m_data.resize(m_nrows*m_ncols);
int m;
for (m = 0; m < m_nrows; m++) value(m_ncols, m) = c[m];
}
/// append a column
void appendColumn(doublereal* c) {
m_ncols++;
m_data.resize(m_nrows*m_ncols);
int m;
for (m = 0; m < m_nrows; m++) value(m_ncols, m) = c[m];
}
/// append a column
void appendColumn(doublereal* c) {
m_ncols++;
m_data.resize(m_nrows*m_ncols);
int m;
for (m = 0; m < m_nrows; m++) value(m_ncols, m) = c[m];
}
/// set the nth row to array rw
void setRow(int n, doublereal* rw) {
for (int j = 0; j < m_ncols; j++) {
m_data[m_nrows*j + n] = rw[j];
}
}
/// set the nth row to array rw
void setRow(int n, doublereal* rw) {
for (int j = 0; j < m_ncols; j++) {
m_data[m_nrows*j + n] = rw[j];
}
}
/// get the nth row
void getRow(int n, doublereal* rw) {
for (int j = 0; j < m_ncols; j++) {
rw[j] = m_data[m_nrows*j + n];
}
}
/// get the nth row
void getRow(int n, doublereal* rw) {
for (int j = 0; j < m_ncols; j++) {
rw[j] = m_data[m_nrows*j + n];
}
}
/// set the values in column m to those in array col
void setColumn(int m, doublereal* col) {
for (int i = 0; i < m_nrows; i++) {
m_data[m_nrows*m + i] = col[i];
}
}
/// set the values in column m to those in array col
void setColumn(int m, doublereal* col) {
for (int i = 0; i < m_nrows; i++) {
m_data[m_nrows*m + i] = col[i];
}
}
/// get the values in column m
void getColumn(int m, doublereal* col) {
for (int i = 0; i < m_nrows; i++) {
col[i] = m_data[m_nrows*m + i];
}
}
/// get the values in column m
void getColumn(int m, doublereal* col) {
for (int i = 0; i < m_nrows; i++) {
col[i] = m_data[m_nrows*m + i];
}
}
/**
* Destructor. Does nothing, since no memory allocated on the
* heap.
*/
virtual ~Array2D(){}
/**
* Destructor. Does nothing, since no memory allocated on the
* heap.
*/
virtual ~Array2D(){}
/**
* Evaluate a*x + y.
*/
void axpy(doublereal a, const Array2D& x, const Array2D& y) {
iterator b = begin();
const_iterator xb = x.begin();
const_iterator yb = y.begin();
for (; b != end(); ++b, ++xb, ++yb) *b = a*(*xb) + *yb;
}
/**
* Allows setting elements using the syntax A(i,j) = x.
*/
doublereal& operator()( int i, int j) { return value(i,j); }
/**
* Allows retrieving elements using the syntax x = A(i,j).
*/
doublereal operator() ( int i, int j) const {return value(i,j);}
//! Returns a changeable reference to position in the matrix
/*!
* This is a key entry. Returns a reference to the matrixes (i,j)
* element. This may be used as an L value.
* @param i The row index
* @param j The column index
*/
doublereal& value( int i, int j) {return m_data[m_nrows*j + i];}
doublereal value( int i, int j) const {return m_data[m_nrows*j + i];}
/// Number of rows
size_t nRows() const { return m_nrows; }
/// Number of columns
size_t nColumns() const { return m_ncols; }
/// Return an iterator pointing to the first element
iterator begin() { return m_data.begin(); }
/// Return an iterator pointing past the last element
iterator end() { return m_data.end(); }
/// Return a const iterator pointing to the first element
const_iterator begin() const { return m_data.begin(); }
/// Return a const iterator pointing to past the last element
const_iterator end() const { return m_data.end(); }
/// Return a reference to the data vector
vector_fp& data() { return m_data; }
/// Return a const reference to the data vector
const vector_fp& data() const { return m_data; }
/// Return a pointer to the top of column j, columns are contiguous
/// in memory
doublereal * ptrColumn(int j) { return &(m_data[m_nrows*j]); }
const doublereal * ptrColumn(int j) const { return &(m_data[m_nrows*j]); }
protected:
vector_fp m_data;
int m_nrows, m_ncols;
};
/// output the array
inline std::ostream& operator<<(std::ostream& s, const Array2D& m) {
int nr = static_cast<int>(m.nRows());
int nc = static_cast<int>(m.nColumns());
int i,j;
for (i = 0; i < nr; i++) {
for (j = 0; j < nc; j++) {
s << m(i,j) << ", ";
}
s << std::endl;
}
return s;
/**
* Evaluate a*x + y.
*/
void axpy(doublereal a, const Array2D& x, const Array2D& y) {
iterator b = begin();
const_iterator xb = x.begin();
const_iterator yb = y.begin();
for (; b != end(); ++b, ++xb, ++yb) *b = a*(*xb) + *yb;
}
inline void operator*=(Array2D& m, doublereal a) {
scale(m.begin(), m.end(), m.begin(), a);
}
/**
* Allows setting elements using the syntax A(i,j) = x.
*/
doublereal& operator()( int i, int j) { return value(i,j); }
inline void operator+=(Array2D& x, const Array2D& y) {
sum_each(x.begin(), x.end(), y.begin());
}
/**
* Allows retrieving elements using the syntax x = A(i,j).
*/
doublereal operator() ( int i, int j) const {return value(i,j);}
//! Returns a changeable reference to position in the matrix
/*!
* This is a key entry. Returns a reference to the matrixes (i,j)
* element. This may be used as an L value.
* @param i The row index
* @param j The column index
*/
doublereal& value( int i, int j) {return m_data[m_nrows*j + i];}
doublereal value( int i, int j) const {return m_data[m_nrows*j + i];}
/// Number of rows
size_t nRows() const { return m_nrows; }
/// Number of columns
size_t nColumns() const { return m_ncols; }
/// Return an iterator pointing to the first element
iterator begin() { return m_data.begin(); }
/// Return an iterator pointing past the last element
iterator end() { return m_data.end(); }
/// Return a const iterator pointing to the first element
const_iterator begin() const { return m_data.begin(); }
/// Return a const iterator pointing to past the last element
const_iterator end() const { return m_data.end(); }
/// Return a reference to the data vector
vector_fp& data() { return m_data; }
/// Return a const reference to the data vector
const vector_fp& data() const { return m_data; }
/// Return a pointer to the top of column j, columns are contiguous
/// in memory
doublereal * ptrColumn(int j) { return &(m_data[m_nrows*j]); }
const doublereal * ptrColumn(int j) const { return &(m_data[m_nrows*j]); }
protected:
vector_fp m_data;
int m_nrows, m_ncols;
};
/// output the array
inline std::ostream& operator<<(std::ostream& s, const Array2D& m) {
int nr = static_cast<int>(m.nRows());
int nc = static_cast<int>(m.nColumns());
int i,j;
for (i = 0; i < nr; i++) {
for (j = 0; j < nc; j++) {
s << m(i,j) << ", ";
}
s << std::endl;
}
return s;
}
//! Overload the times equals operator for multiplication
//! of a matrix and a scalar.
/*!
* Scaled every element of the matrix by the scalar input
*
* @param m Matrix
* @param a scalar
*/
inline void operator*=(Array2D& m, doublereal a) {
scale(m.begin(), m.end(), m.begin(), a);
}
//! Overload the plus equals operator for addition
//! of one matrix with another
/*!
* Adds each element of the second matrix into the first
* matrix
*
* @param x First matrix
* @param y Second matrix, which is a const
*/
inline void operator+=(Array2D& x, const Array2D& y) {
sum_each(x.begin(), x.end(), y.begin());
}
}
#endif

View file

@ -4,7 +4,6 @@
* (see \ref Cantera::LogPrintCtrl).
*/
/*
* $Author$
* $Revision$
* $Date$
*/
@ -45,8 +44,6 @@ namespace Cantera {
/*!
* This also serves to initialize the ticks within the object
*
* @param coutProxy This is a reference to the ostream
* to use for all IO from ths object.
* @param Ndec value of Ndec. Defaults to -1000, i.e.,
* no decade cropping
*/
@ -165,8 +162,15 @@ namespace Cantera {
private:
//! local stringstream class for temp output
std::ostringstream m_os;
//! Pointer to the ostream where this class actually
//! prints its information
std::ostream *m_ffss;
//! Pointer to the PrintCtrl class
PrintCtrl *m_pc;

View file

@ -10,6 +10,7 @@
// Copyright 2001 California Institute of Technology
//@{
#ifdef WIN32
#pragma warning(disable:4786)
#pragma warning(disable:4503)
@ -18,7 +19,7 @@
#else
#define SNPRINTF snprintf
#endif
//@}
#include "ct_defs.h"
#include "stringUtils.h"
#include "ctexceptions.h"

View file

@ -1,5 +1,5 @@
/**
* @file std::stringUtils.h
* @file stringUtils.h
* Contains declarations for string manipulation functions
* within Cantera.
*/
@ -184,9 +184,9 @@ namespace Cantera {
//! Line wrap a string via a copy operation
/*!
* @param s Input string to be line wrapped
* @paramlen Length at which to wrap. The
* default is 70.
* @param s Input string to be line wrapped
* @param len Length at which to wrap. The
* default is 70.
*/
std::string wrapString(const std::string &s,
const int len=70);
@ -198,7 +198,7 @@ namespace Cantera {
* characters still included in the string (excluding the null character).
*
* Comments are excluded -> All instances of the comment character, '!',
* are replaced by '\0' thereby terminating
* are replaced by NULL character thereby terminating
* the string
*
* Parameter list:

View file

@ -23,9 +23,16 @@
namespace Cantera {
/**
* Copy the first n entries from x to y. Both x and y must have
* size greater than or equal to n.
//! Templated function that copies the first n entries from x to y.
/*!
*
*
* The templated type is the type of x and y
*
* @param n Number of elements to copy from x to y
* @param x The object x, of templated type const T&
* @param y The object y, of templated type T&
*/
template<class T>
inline void copyn(size_t n, const T& x, T& y) {
@ -85,6 +92,25 @@ namespace Cantera {
x.begin(), std::plus<TYPENAME_KEYWORD T::value_type>());
}
//! Templated dot ratio class
/*!
* Calculates the quantity:
*
* S += x[n]/y[n]
*
* The first templated type is the iterator type for x[] and y[].
* The second templated type is the type of S.
*
* @param x_begin InputIter type, indicating the address of the
* first element of x
* @param x_end InputIter type, indicating the address of the
* last element of x
* @param y_begin InputIter type, indicating the address of the
* first element of y
* @param start_value S type, indicating the type of the
* accumulation result.
*/
template<class InputIter, class S>
inline doublereal _dot_ratio(InputIter x_begin, InputIter x_end,
InputIter y_begin, S start_value) {