#include "matrix.hh"
/**
- structure for using the LU decomposition of a positive definite .
+ Choleski decomposition of a matrix
+ structure for using the LU decomposition of a positive definite matrix.
#P# is split into
/// diagonal
Vector D;
- ///Create decomposition of P
- /**
+
+ /** Create decomposition of P.
PRE
P needs to be symmetric positive definite
*/
Choleski_decomposition(Matrix P);
- Vector solve(Vector rhs) const;
- /**
+
+ /**
solve Px = rhs
*/
-Vector operator * (Vector rhs) const { return solve (rhs); }
+ Vector solve(Vector rhs) const;
+
+ Vector operator * (Vector rhs) const { return solve (rhs); }
/**
return the inverse of the matrix P.
*/
-
Matrix inverse() const;
/**
return P, calc'ed from L and D
#include "real.hh"
-/// a T interval
-/**
+/** a T interval.
this represents the closed interval [left,right].
No invariants. T must be a totally ordered ring
*/
bool elt_q(T r);
};
-/// partial ordering
-template<class T>
-int Interval__compare(const Interval_t<T>&,Interval_t<T> const&);
+
/**
inclusion ordering. Crash if not comparable.
*/
+template<class T>
+int Interval__compare(const Interval_t<T>&,Interval_t<T> const&);
-/****************************************************************
+/*
INLINE
- ****************************************************************/
+ */
#include "compare.hh"
};
-/// C++ for version of long_getopt.
-/** For processing GNU style command line arguments. No pointer
- (return values, arguments) contents are copied. */
+/** C++ for version of long_getopt. For processing GNU style command
+ line arguments. No pointer (return values, arguments) contents are
+ copied. */
class Getopt_long {
public:
/** errorcodes: no error, argument expected, no argument expected,
/// report an error and abort
void report(Errorcod c);
public:
- /// what to do with errors
- /**
+ /** what to do with errors.
report messages on #*os#, and abort.
if #os# is null, then do not report nor abort, just set #error#
*/
/// construct: pass arguments and option info.
Getopt_long(int c, char **v, long_option_init *lo);
- /// get the next option
- /**
+ /** get the next option.
@return pointer to next option found.
0 if error occurred, or next argument is no option.
*/
#include "vsmat.hh"
#include "vector.hh"
-/// a Real matrix
-/** This is a class for a nonsquare block of #Real#s. The
+/** a Real matrix. This is a class for a nonsquare block of #Real#s. The
implementation of sparse matrices is done in the appropriate #smat#
class. Matrix only does the mathematical actions (adding,
multiplying, etc.)
int cols() const { return dat->cols(); }
int rows() const { return dat->rows(); }
- /// return the size of a matrix
- /**
- @pre
+ /** return the size of a matrix.
+ PRE
the matrix needs to be square.
*/
int dim() const;
void operator*=(Real a);
void operator/=(Real a) { (*this) *= 1/a; }
- /// add a row
- /**
+ /** add a row.
add a row to the matrix before row k
PRE
0 <= k <= rows()
*/
void insert_row(Vector v,int k);
- ///
- /**
+ /** .
delete a row from this matrix.
PRE
Matrix transposed() const ;
Real norm() const;
- /// swap
- /**
+ /** swap.
PRE
0 <= c1,c2 < cols()
*/
void swap_columns(int c1, int c2);
- /// swap
- /**
+ /** swap.
PRE
0 <= c1,c2 < rows()
*/
#endif
/**
- INPUT: path the original full filename
- OUTPUT: 4 components of the path. They can be empty
+ @param path the original full filename
+ @return 4 components of the path. They can be empty
*/
void
split_path(String path,
}
-///find a file
-/**
+/** find a file.
It will search in the current dir, in the construction-arg, and
in any other added path, in this order.
*/
bool isnum();
operator Real();
operator int();
- ///
- /** perl -like string to bool conversion
+
+ /** perl -like string to bool conversion.
*/
operator bool() const;
const INITIALMAX=8;
class String_handle;
-/// Internal String struct
-/**
+/** Internal String struct.
the data itself. Handles simple tasks (resizing, resetting)
*/
length = j;
}
- /** not really safe. Can alter length without StringData knowing it.
- */
+ /** access a char. not really safe. Can alter length without
+ *StringData knowing it. */
char &operator [](int j) {
assert(j >= 0 && j <= length);
return string[j] ;
-/// ref. counting for strings
-/**
+/** ref. counting for strings.
handles ref. counting, and provides a very thin
interface using char *
*/
#include "textstr.hh"
-/** do "#" comments, read quote enclosed fields */
-/// a "const" Array. Contents can't be changed.
+/**a "const" Array. Contents can't be changed. do "#" comments, read quote enclosed fields */
+
class Text_record : Array<String>
{
int line_no;
Array<String>::size;
};
-/**
+/** abstraction for a datafile.
add a subrec/fieldsep/record separator
*/
-/// abstraction for a datafile
+
class Text_db : private Data_file
{
void gobble_leading_white();
#define VSMAT_HH
#include "varray.hh"
#include "real.hh"
-/// a matrix storage baseclass.
+/** base class for interface with matrix storageclasses. There are no
+ iterators for matrixclasses, since matrices are (like arrays)
+ explicitly int-indexed.
+
+ Iteration is provided by *_next, *_ok, which update and check both
+ index variables simultaneously.
+
+ TODO
+ determine type of product matrix.
+
+*/
class virtual_smat {
/// width of matrix
virtual int cols() const = 0;
-
- /// set the size. contents lost
- /**
+
+
+ /** set the size. contents lost.
PRE
i >=0, j>=0
*/
-
virtual void set_size(int i, int j) = 0;
- /// set the size to square dimen. contents lost
- virtual void set_size(int i) = 0;
- /**
+
+ /**set the size to square dimen. contents lost
PRE
i>=0
*/
- /// set the size to i
- virtual void resize(int i, int j) = 0;
- /**
+ virtual void set_size(int i) = 0;
+ /**set the size to i.
keep contents. If enlarged contents unspecified
i>=0, j>=0
*/
-
- /// set the size to square dimen. contents kept
- virtual void resize(int i) = 0;
- /**
+ virtual void resize(int i, int j) = 0;
+
+ /**
+ set the size to square dimen. contents kept
Keep contents. If enlarged contents are unspecified
PRE
i>=0
*/
+ virtual void resize(int i) = 0;
+
- /// access an element
- virtual Real& elem(int i,int j) = 0;
- /**
+ /**
access an element.
Generate an errormessage, if this happens
in the 0-part of a sparse matrix.
*/
+ virtual Real& elem(int i,int j) = 0;
+
/// access a element, no modify
virtual const Real& elem(int i, int j) const = 0;
virtual Array<Real> column(int j) const = 0;
#endif
- /// add a row
- virtual void insert_row(int k)=0;
+
/**
add a row to the matrix before row k. Contents
of added row are unspecified
0 <= k <= rows()
*/
+ virtual void insert_row(int k)=0;
- /// delete a row
- virtual void delete_row(int k)=0;
+
/**
delete a row from this matrix.
PRE
0 <= k < rows();
*/
+ virtual void delete_row(int k)=0;
virtual void delete_column(int k)=0;
virtual ~virtual_smat() { }
virtual virtual_smat *clone()=0;
- /// is there a next?
- virtual bool mult_ok(int i, int j) const=0;
+
/**
- at end of matrix? when doing loop
+ at end of matrix?. when doing loop
for(i=0; i<h; i++)
for(j=0; j<w; j++)
- ...
+ ..
*/
- /// iterate
- virtual void mult_next(int &i, int &j) const = 0;
+ virtual bool mult_ok(int i, int j) const=0;
+
/**
- walk through matrix (regular multiply)
+ walk through matrix (regular multiply).
get next j for row i, or get next row i and reset j.
this will make sparse matrix implementation easy.
PRE
mult_ok(i,j)
*/
- virtual bool trans_ok(int i, int j) const=0;
- /**
+ virtual void mult_next(int &i, int &j) const = 0;
+
+/**
valid matrix entry. return false if at end of row
*/
- virtual void trans_next(int &i, int &j) const = 0;
+ virtual bool trans_ok(int i, int j) const=0;
+
/**
walk through matrix (transposed multiply).
Get next i (for column j)
ver_ok(i,j)
*/
+ virtual void trans_next(int &i, int &j) const = 0;
/// generate a "Full_storage" matrix
static virtual_smat *get_full(int n, int m);
};
-/** base class for interface with matrix storageclasses. There are no
- iterators for matrixclasses, since matrices are (like arrays)
- explicitly int-indexed.
-
- Iteration is provided by *_next, *_ok, which update and check both
- index variables simultaneously.
-
- TODO
- determine type of product matrix.
-
-*/
#endif