smat.cc matrix.cc choleski.cc vector.cc dstream.cc\
matdebug.cc scalar.cc
-templatecc=cursor.cc list.cc tsmat.cc plist.cc interval.cc
+templatecc=cursor.tcc list.tcc tsmat.tcc plist.tcc interval.tcc
+
inl=findcurs.inl link.inl list.inl cursor.inl plist.inl
hh=cursor.hh pcursor.hh lgetopt.hh link.hh list.hh dstream.hh \
string.hh stringutil.hh vray.hh textdb.hh textstr.hh assoc.hh\
findcurs.hh unionfind.hh compare.hh handle.hh matrix.hh\
smat.hh vsmat.hh vector.hh real.hh choleski.hh\
tsmat.hh tvsmat.hh plist.hh associter.hh fproto.hh\
- interval.hh scalar.hh sstack.hh rational.hh
+ interval.hh scalar.hh sstack.hh rational.hh iterate.hh\
+
+++ /dev/null
-#ifndef CURSOR_CC
-#define CURSOR_CC
-
-#include "cursor.hh"
-#include <assert.h>
-
-template<class T>
- void
-Cursor<T>::backspace()
-{
- Cursor<T> c(*this);
- c--;
- list_.remove( *this );
-}
-
-template<class T>
- void
-Cursor<T>::del()
-{
- Cursor<T> c(*this);
- c++;
- list_.remove( *this );
- *this = c;
-}
-
-
-template<class T>
-Cursor<T>
-Cursor<T>::operator -=( int j )
-{
- while (j--)
- (*this)--;
- return *this;
-}
-template<class T>
-Cursor<T>
-Cursor<T>::operator +=( int j )
-{
- while (j++)
- (*this)++;
- return *this;
-}
-
-template<class T>
-Cursor<T>
-Cursor<T>::operator +( int i ) const
-{
- Cursor<T> r = *this;
-
- if (i<0)
- return r -(-i);
-
- while (i--)
- r++;
-
- return r;
-}
-
-template<class T>
-Cursor<T>
-Cursor<T>::operator -( int i ) const
-{
- Cursor<T> r = *this;
- if (i<0)
- return r +(-i);
-
- while (i--)
- r--;
-
- return r;
-}
-/*
- warning: can't use Cursor::operator == (Cursor),
- since it uses Cursor::operator-(Cursor)
- */
-template<class T>
-int
-Cursor<T>::operator-(Cursor<T> rhs) const
-{
- assert(rhs.list == list);
- int dif = 0;
-
- // search from *this on further up (positive difference)
- Cursor<T> c(*this);
- while (c.ok() && c.pointer_ != rhs.pointer_) {
- c--;
- dif++;
- }
-
- if (c.ok())
- goto gotcha; // so, sue me.
-
- // search in direction of bottom. (negative diff)
- dif =0;
- c=*this;
- while (c.ok() && c.pointer_ !=rhs.pointer_) {
- dif --;
- c++;
- }
- assert(c.ok());
-
-gotcha:
- assert((*this - dif).pointer_ == c.pointer_);
- return dif;
-}
-
-#endif
+++ /dev/null
-#include <assert.h>
-#include <math.h>
-#include "interval.hh"
-#include "string.hh"
-
-
-
-template<class T>
-int
-Interval__compare(const Interval_t<T>&a,Interval_t<T> const&b)
-{
- if (a.left == b.left && a.right == b.right)
- return 0;
-
- if (a.left <= b.left && a.right >= b.right)
- return 1;
-
- if (a.left >= b.left && a.right <= b.right)
- return -1;
-
- assert(false); // not comparable
-
- return 0;
-}
-
-const Real INFTY = HUGE;
-
-template<class T>
-void
-Interval_t<T>::set_empty() {
- left = INFTY;
- right = -INFTY;
-}
-
-template<class T>
-T
-Interval_t<T>::length() const {
- assert(right >= left);
- return right-left;
-}
-
-template<class T>
-void
-Interval_t<T>::unite(Interval_t<T> h)
-{
- if (h.left<left)
- left = h.left;
- if (h.right>right)
- right = h.right;
-}
-
-/**
- smallest Interval which includes *this and #h#
- */
-
-template<class T>
-void
-Interval_t<T>::intersect(Interval_t<T> h)
-{
-#if defined (__GNUG__) && ! defined (__STRICT_ANSI__)
- left = h.left >? left;
- right = h.right <?right;
-#else
- left = max(h.left, left);
- right = min(h.right, right);
-#endif
-}
-
-template<class T>
-Interval_t<T>
-intersect(Interval_t<T> x, Interval_t<T> const &y)
-{
- x.intersect(y);
- return x;
-}
-
-template<class T>
-String
-Interval_t<T>::str() const
-{
- if (empty())
- return "[empty]";
- String s("[");
-
- return s + left + "," + right +"]";
-}
-
-template<class T>
-bool
-Interval_t<T>::elt_q(T r)
-{
- return r >= left && r <= right;
-}
+++ /dev/null
-#ifndef LIST_CC
-#define LIST_CC
-
-#include "list.hh"
-
-template<class T>
-List<T>::List(List const&src)
-{
- set_empty();
- // probably el stupido
- for (Cursor<T> c(src); c.ok(); c++)
- bottom().add(c);
-}
-
-template<class T>
-void
-List<T>::OK() const
-{
- int i = size_;
- Link<T> *lp = top_;
- while (i--) {
- assert(lp);
- lp->OK();
- lp = lp->next();
- }
- assert(!lp);
- i = size_;
- lp = bottom_;
- while (i--) {
- assert(lp);
- lp->OK();
- lp = lp->previous();
- }
- assert(!lp);
-}
-
-
-template<class T>
-List<T>::~List()
-{
- Cursor<T> next(*this);
- for ( Cursor<T> c( *this ); c.ok(); c = next ) {
- next = c;
- next++;
- remove( c );
- }
-}
-
-template<class T>
-void
-List<T>::add( const T& thing, Cursor<T> &after_me )
-{
- if (!size_) { // not much choice if list is empty
- bottom_ = top_ = new Link<T>( thing );
- if (!after_me.ok())
- after_me = bottom();
- } else { // add at aprioprate place
- if (!after_me.ok())
- after_me = bottom();
- Link<T> *p =after_me.pointer();
- p->add(thing);
- if (p == bottom_) // adjust bottom_ if necessary.
- bottom_ = p->next();
- }
-
- size_++;
-}
-/**
-
- Procedure:
- \begin{itemize}
- \item if #after_me# is #ok()#, add after #after_me#, else
- \item if list !empty simply add to bottom, else
- \item list is empty: create first \Ref{Link} and initialize
- #bottom_# and #top_#.
- \end{itemize}
-*/
-
-template<class T>
-void
-List<T>::insert( const T& thing, Cursor<T> &before_me )
-{
- if (!size_) {
- bottom_ = top_ = new Link<T>( thing );
- if (!before_me.ok())
- before_me = top();
-
- } else {
- if (!before_me.ok())
- before_me = top();
-
- Link<T> *p = before_me.pointer() ;
-
- p->insert(thing);
- if (p == top_)
- top_ = p->previous();
- }
-
- size_++;
-}
-
-
-template<class T>
-void
-List<T>::concatenate(List<T> const&s)
-{
- Cursor<T> b(bottom());
- for (Cursor<T> c(s); c.ok(); c++) {
- b.add(c);
- b++;
- }
-}
-#endif
+++ /dev/null
-#include "plist.hh"
-
-// not inlined since it assumes knowledge of destructor.
-template<class T>
-void
-IPointerList<T>::remove(PCursor<T> me )
-{
- if ( me.ok() ) {
- delete me.ptr();
- List<void*>::remove(me);
- }
-}
-template<class T>
-PCursor<T>
-PointerList<T>::find(T what ) const
-{
- PCursor<T> i(*this);
- for (; i.ok(); i++)
- if (i.ptr() == what)
- break;
- return i;
-}
+++ /dev/null
-#include "smat.hh"
-
-template<class T>
-void
-Full_storage<T>::operator=(Full_storage const &fs)
-{
- resize(fs.h, fs.w);
- for (int i=0; i<h; i++)
- for (int j=0; i<w; j++)
- els[i][j]= fs.els[i][j];
-}
-
-template<class T>
-void
-Full_storage<T>::OK() const
-{
- assert(maxh >= h && maxw >= w);
- assert(h >= 0 && w >= 0);
-}
-template<class T>
-void
-Full_storage<T>::resize_cols(int newh)
-{
- if (newh <= maxh) {
- h=newh;
- return;
- }
-
- T** newa=new T*[newh];
- int j=0;
- for (; j < h; j++)
- newa[j] = els[j];
- for (; j < newh; j++)
- newa[j] = new T[w];
- delete[] els;
- els=newa;
- maxh = newh;
-}
-
-template<class T>
-void
-Full_storage<T>::resize_rows(int neww)
-{
- if (neww <= maxw) {
- w=neww;
- return;
- }
- for (int i=0; i < h ; i++) {
- T* newa=new T[neww];
- for (int k=0; k < w; k++)
- newa[k] = els[i][k];
-
- delete[] els[i];
- els[i] = newa;
- maxw = neww;
- }
-}
-
-template<class T>
-Full_storage<T>::~Full_storage() {
- for (int i=0; i < maxh; i++)
- delete [] els[i];
- delete[] els;
-}
-
-template<class T>
-void
-Full_storage<T>::resize(int i, int j)
-{
- resize_cols(i);
- resize_rows(j);
-}
-
-template<class T>
-void
-Full_storage<T>::set_size(int i, int j)
-{
- resize(i,j)
-}
-
-template<class T>
-bool
-Full_storage<T>::mult_ok(int i, int j) const
-{
- return valid(i,j);
-}
-
-template<class T>
-bool
-Full_storage<T>::trans_ok(int i, int j) const
-{
- return valid(i,j);
-}
-
-
-template<class T>
-void
-Full_storage<T>::trans_next(int &i, int &j) const
-{
- assert(trans_ok(i,j));
- i++;
- if (i >= h) {
- i=0;
- j ++;
- }
-}
-
-template<class T>
-void
-Full_storage<T>::mult_next(int &i, int &j) const
-{
- assert(mult_ok(i,j));
- j++;
- if (j >= w) {
- j=0;
- i++;
- }
-}
-
-template<class T>
-void
-Full_storage<T>::delete_row(int k)
-{
- assert(0 <= k <h);
- for (int i=h-1; i > k ; i++)
- for (int j=0; j < w; j++)
- els[i-1][j]=els[i][j];
-}
-
-template<class T>
-void
-Full_storage<T>::insert_row(int k)
-{
- assert(0 <= k <=h);
- resize_cols(h+1);
- for (int i=h-1; i > k ; i++)
- for (int j=0; j <w; j++)
- els[i][j]=els[i-1][j];
-}
-
-/****************************************************************/
-
-template<class T>
-virtual_smat<T> *
-virtual_smat<T>::get_full(int n, int m)
-{
- return new Full_storage<T>(n,m);
-}
-#include "real.hh"
-
-template Full_storage<Real>;