+++ /dev/null
-#include "choleski.hh"
-
-Vector
-Choleski_decomposition::solve(Vector rhs)const
-{
- int n= rhs.dim();
- assert(n == L.dim());
- Vector y(n);
-
- // forward substitution
- for (int i=0; i < n; i++) {
- Real sum(0.0);
- for (int j=0; j < i; j++)
- sum += y(j) * L(i,j);
- y(i) = (rhs(i) - sum)/L(i,i);
- }
- for (int i=0; i < n; i++) {
- assert(D(i));
- y(i) /= D(i);
- }
-
- // backward subst
- Vector x(n);
- for (int i=n-1; i >= 0; i--) {
- Real sum(0.0);
- for (int j=i+1; j < n; j++)
- sum += L(j,i)*x(j);
- x(i) = (y(i) - sum)/L(i,i);
- }
- return x;
-}
-
-/*
- Standard matrix algorithm.
- */
-
-Choleski_decomposition::Choleski_decomposition(Matrix P)
- : L(P.dim()), D(P.dim())
-{
- int n = P.dim();
- assert((P-P.transposed()).norm() < EPS);
- L.unit();
- for (int k= 0; k < n; k++) {
- for (int j = 0; j < k; j++){
- Real sum(0.0);
- for (int l=0; l < j; l++)
- sum += L(k,l)*L(j,l)*D(l);
- L(k,j) = (P(k,j) - sum)/D(j);
- }
- Real sum=0.0;
-
- for (int l=0; l < k; l++)
- sum += sqr(L(k,l))*D(l);
- Real d = P(k,k) - sum;
- D(k) = d;
- }
-
-#ifdef NDEBUG
- assert((original()-P).norm() < EPS);
-#endif
-}
-
-Matrix
-Choleski_decomposition::original() const
-{
- Matrix T(L.dim());
- T.set_diag(D);
- return L*T*L.transposed();
-}
-
-Matrix
-Choleski_decomposition::inverse() const
-{
- int n=L.dim();
- Matrix invm(n);
- Vector e_i(n);
- for (int i = 0; i < n; i++) {
- e_i.set_unit(i);
- Vector inv(solve(e_i));
- for (int j = 0 ; j<n; j++)
- invm(i,j) = inv(j);
- }
-
-#ifdef NDEBUG
- Matrix I1(n), I2(original());
- I1.unit();
- assert((I1-original()*invm).norm() < EPS);
-#endif
-
- return invm;
-}
-
-
-
-
+++ /dev/null
-#ifndef CHOLESKI_HH
-#define CHOLESKI_HH
-
-#include "matrix.hh"
-
-struct Choleski_decomposition {
-
- /// lower triangle of Choleski decomposition
- Matrix L;
-
- /// diagonal
- Vector D;
- ///Create decomposition of P
- Choleski_decomposition(Matrix P);
- /**
- PRE
- P needs to be symmetric positive definite
- */
-
- Vector solve(Vector rhs) const;
- Vector operator * (Vector rhs) const { return solve (rhs); }
- /**
- solve Px = rhs
- */
-
- Matrix inverse() const;
- /**
- return the inverse of the matrix P.
- */
-
- Matrix original() const;
- /**
- return P, calc'ed from L and D
- */
-
-};
-/**
- structure for using the LU decomposition of a positive definite .
-
- #P# is split into
-
- LD transpose(L)
- */
-
-
-#endif
+++ /dev/null
-#include <fstream.h>
-
-#include "dstream.hh"
-#include "string.hh"
-#include "textdb.hh"
-
-
-/*
- should use Regexp library.
- */
-static String
-strip_pretty(String pret)
-{
- String cl(pret.left(pret.pos('(')-1));
- int l = cl.lastPos(' ');
- cl = cl.right(cl.len() -l);
- return cl;
-}
-
-static String
-strip_member(String pret)
-{
- String cl(pret.left(pret.lastPos(':')-2));
- return cl;
-}
-
-Dstream&
-Dstream::identify_as(String name)
-{
- String mem(strip_pretty(name));
- String cl(strip_member(mem));
-
- if(!silent.elt_query(cl))
- silent[cl] = false;
- local_silence = silent[cl];
- if (classname != cl && !local_silence) {
- classname=cl;
- *os << "[" << classname << ":]";
- }
- return *this;
-}
-
-void
-Dstream::switch_output(String name,bool b)
-{
- silent[name] = b;
-}
-
-///
-Dstream &
-Dstream::operator<<(String s)
-{
- if (local_silence)
- return *this;
-
- for (const char *cp = s ; *cp; cp++)
- switch(*cp)
- {
- case '{':
- case '[':
- case '(': indentlvl += INDTAB;
- *os << *cp;
- break;
-
- case ')':
- case ']':
- case '}':
- indentlvl -= INDTAB;
- *os << *cp ;
-
- if (indentlvl<0) indentlvl = 0;
- break;
-
- case '\n':
- *os << '\n' << String (' ', indentlvl) << flush;
- break;
- default:
- *os << *cp;
- break;
- }
- return *this;
-}
-
-/** only output possibility. Delegates all conversion to String class.
- */
-
-Dstream::Dstream(ostream &r, const char * cfg_nm )
-{
- os = &r;
- indentlvl = 0;
-
- const char * fn =cfg_nm ? cfg_nm : ".dstreamrc";
- {
- ifstream ifs(fn); // can't open
- if (!ifs)
- return;
- }
- cerr << "(" << fn;
- Text_db cfg(fn);
- while (! cfg.eof()){
- Text_record r( cfg++);
- assert(r.sz() == 2);
- silent[r[0]] = r[1].to_bool();
- }
- cerr <<")";
-}
-
-
+++ /dev/null
-// debug_stream
-
-#ifndef DSTREAM_HH
-#define DSTREAM_HH
-
-#include "string.hh"
-#include "assoc.hh"
-
-const char eol= '\n';
-
-/// debug stream
-class Dstream
-{
- ostream *os;
- int indentlvl;
- Assoc<String, bool> silent;
- bool local_silence;
- String classname;
- /// indent of each level
- const INDTAB = 3;
-
-public:
- Dstream(ostream &r, const char * = 0);
- Dstream &identify_as(String s);
- void switch_output(String s,bool);
- Dstream &operator << (String s);
-};
- /**
- a class for providing debug output of nested structures,
- with indents according to \{\}()[].
-
- Using identify_as() one can turn on and off specific messages. Init
- for these can be given in a rc file
-
- */
-#endif
-
#include <iostream.h>
+#include <assert.h>
#include "lgetopt.hh"
#include "misc.hh"
-#include "debug.hh"
-#include "score.hh"
-#include "globvars.hh"
+#include "string.hh"
+#include "main.hh"
extern void parse_file(String s);
-Score *the_score =0;
long_option_init theopts[] = {
- 1, "debug", 'd',
1, "output", 'o',
+ 0, "warranty", 'w',
0,0,0
};
-String outfn="lelie.uit";
-
-void
-set_output(String s)
+void notice()
{
- outfn = s;
+ cout <<
+ "LilyPond, a music typesetter.
+Copyright (C) 1996 by
+ Han-Wen Nienhuys <hanwen@stack.urc.tue.nl>
+
+
+ This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License version 2
+as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+ You should have received a copy (refer to the file COPYING) of the
+GNU General Public License along with this program; if not, write to
+the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
+USA.
+"
}
int
{
Getopt_long oparser(argc, argv,theopts);
- cout << get_version()
- << "copyright 1996 Han-Wen Nienhuys\n";
+ cout << get_version();
while (long_option_init * opt = oparser()) {
switch ( opt->shortname){
- case 'd':
- set_debug(oparser.optarg);
- break;
case 'o':
- set_output(oparser.optarg);
+ set_default_output(oparser.optarg);
+ break;
+ case 'w':
+ notice();
+ exit(0);
break;
default:
assert(false);
if (!arg) arg = "";
parse_file(arg);
- the_score->process();
- the_score->output(outfn);
+ do_scores();
+ exit (0);
}
+++ /dev/null
-#include "matrix.hh"
-#include "string.hh"
-
-
-Real
-Matrix::norm() const
-{
- Real r =0.0;
- for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j))
- r += sqr(dat->elem(i,j));
- return sqrt(r);
-}
-
-//inline
-Real
-Matrix::operator()(int i,int j) const
-{
- assert(i >= 0 && j >= 0);
- assert(i < rows() && j < cols());
- return dat->elem(i,j);
-}
-
-//inline
-Real &
-Matrix::operator()(int i, int j)
-{
- assert(i >= 0 && j >= 0);
- assert(i < rows() && j < cols());
- return dat->elem(i,j);
-}
-
-void
-Matrix::fill(Real r)
-{
- for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j))
- dat->elem(i,j)=r;
-}
-
-void
-Matrix::set_diag(Real r)
-{
- for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j))
- dat->elem(i,j)=(i==j) ? r: 0.0;
-}
-
-void
-Matrix::set_diag(Vector d)
-{
- for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j))
- dat->elem(i,j)=(i==j) ? d(i): 0.0;
-}
-
-void
-Matrix::operator+=(const Matrix&m)
-{
- assert(m.cols() == cols());
- assert(m.rows() == rows());
- for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j))
- dat->elem(i,j) += m(i,j);
-}
-
-void
-Matrix::operator-=(const Matrix&m)
-{
- assert(m.cols() == cols());
- assert(m.rows() == rows());
- for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j))
- dat->elem(i,j) -= m(i,j);
-}
-
-
-void
-Matrix::operator*=(Real a)
-{
- for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j))
- dat->elem(i,j) *= a;
-}
-
-void
-Matrix::operator=(const Matrix&m)
-{
- if (&m == this)
- return ;
- delete dat;
- dat = m.dat->clone();
-}
-
-Matrix::Matrix(const Matrix &m)
-{
- m.OK();
-
- dat = m.dat->clone();
-}
-
-
-Matrix::Matrix(int n, int m)
-{
- dat = virtual_smat::get_full(n,m);
- fill(0);
-}
-
-Matrix::Matrix(int n)
-{
- dat = virtual_smat::get_full(n,n);
- fill(0);
-}
-
-Matrix::Matrix(Vector v, Vector w)
-{
- dat = virtual_smat::get_full(v.dim(), w.dim());
- for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j))
- dat->elem(i,j)=v(i)*w(j);
-}
-
-
-Vector
-Matrix::row(int k) const
-{
- int n=cols();
-
-
- Vector v(n);
- for(int i=0; i < n; i++)
- v(i)=dat->elem(k,i);
-
- return v;
-}
-
-Vector
-Matrix::col(int k) const
-{
- int n=rows();
- Vector v(n);
- for(int i=0; i < n; i++)
- v(i)=dat->elem(i,k);
- return v;
-}
-
-Vector
-Matrix::left_multiply(const Vector& v) const
-{
- Vector dest(v.dim());
- assert(dat->cols()==v.dim());
- for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j))
- dest(i)+= dat->elem(j,i)*v(j);
- return dest;
-}
-
-Vector
-Matrix::operator *(const Vector& v) const
-{
- Vector dest(rows());
- assert(dat->cols()==v.dim());
- for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j))
- dest(i)+= dat->elem(i,j)*v(j);
- return dest;
-}
-
-Matrix
-operator /(Matrix const& m1,Real a)
-{
- Matrix m(m1);
- m /= a;
- return m;
-}
-
-void
-Matrix::transpose() // delegate to storage?
-{
- for (int i=0, j=0; dat->mult_ok(i,j); dat->mult_next(i,j)) {
- if (i >= j)
- continue;
- Real r=dat->elem(i,j);
- dat->elem(i,j) = dat->elem(j,i);
- dat->elem(j,i)=r;
- }
-}
-
-Matrix
-Matrix::operator-() const
-{
- OK();
- Matrix m(*this);
- m*=-1.0;
- return m;
-}
-
-Matrix
-Matrix::transposed() const
-{
- Matrix m(*this);
- m.transpose();
- return m;
-}
-
-
-/* should do something smarter: bandmatrix * bandmatrix is also banded matrix. */
-Matrix
-operator *(const Matrix &m1, const Matrix &m2)
-{
- Matrix result(m1.rows(), m2.cols());
- result.set_product(m1,m2);
- return result;
-}
-
-void
-Matrix::set_product(const Matrix &m1, const Matrix &m2)
-{
- assert(m1.cols()==m2.rows());
- assert(cols()==m2.cols() && rows()==m1.rows());
-
- for (int i=0, j=0; dat->mult_ok(i,j);
- dat->mult_next(i,j)) {
- Real r=0.0;
- for (int k = 0; k < m1.cols(); k++)
- r += m1(i,k)*m2(k,j);
- dat->elem(i,j)=r;
- }
-}
-
-void
-Matrix::insert_row(Vector v, int k)
-{
- assert(v.dim()==cols());
- dat->insert_row(k);
- for (int j=0; j < cols(); j++)
- dat->elem(k,j)=v(j);
-}
-
-
-void
-Matrix::swap_columns(int c1, int c2)
-{
- assert(c1>=0&& c1 < cols()&&c2 < cols() && c2 >=0);
- for (int i=0; i< rows(); i++) {
- Real r=dat->elem(i,c1);
- dat->elem(i,c1) = dat->elem(i,c2);
- dat->elem(i,c2)=r;
- }
-}
-
-void
-Matrix::swap_rows(int c1, int c2)
-{
- assert(c1>=0&& c1 < rows()&&c2 < rows() && c2 >=0);
- for (int i=0; i< cols(); i++) {
- Real r=dat->elem(c1,i);
- dat->elem(c1,i) = dat->elem(c2,i);
- dat->elem(c2,i)=r;
- }
-}
-
-
-int
-Matrix::dim() const
-{
- assert(cols() == rows());
- return rows();
-}
-
-Matrix::operator String() const
-{
- String s("matrix {\n");
- for (int i=0; i< rows(); i++){
- for (int j = 0; j < cols(); j++) {
- s+= String(dat->elem(i,j), "%6f ");
- }
- s+="\n";
- }
- s+="}\n";
- return s;
-}
-
-
-
-#include "debug.hh"
-void
-Matrix::print() const
-{
- mtor << *this;
-}
+++ /dev/null
-#ifndef MATRIX_HH
-#define MATRIX_HH
-
-
-#include "vsmat.hh"
-#include "vector.hh"
-
-/// a Real matrix
-class Matrix {
- virtual_smat *dat;
-
-public:
- void OK() const { dat->OK(); }
- int cols() const { return dat->cols(); }
- int rows() const { return dat->rows(); }
-
- /// return the size of a matrix
- int dim() const;
- /**
- PRE
- the matrix needs to be square.
- */
-
- // Matrix() { dat = 0; }
- ~Matrix() { delete dat; }
-
- /// set entries to r
- void fill(Real r);
-
- /// set diagonal to d
- void set_diag(Real d);
-
- void set_diag(Vector d);
- /// set unit matrix
- void unit() { set_diag(1.0); }
-
- void operator+=(const Matrix&m);
- void operator-=(const Matrix&m);
- void operator*=(Real a);
- void operator/=(Real a) { (*this) *= 1/a; }
-
- /// add a row
- void insert_row(Vector v,int k);
- /**
- add a row to the matrix before row k
-
- PRE
- v.dim() == cols()
- 0 <= k <= rows()
- */
- ///
- void delete_row(int k) { dat->delete_row(k); }
- /**
- delete a row from this matrix.
-
- PRE
- 0 <= k < rows();
- */
- void delete_column(int k) { dat->delete_column(k); }
- ///
- Matrix(int n);
- /**
- square n matrix, initialised to null
- */
- ///
- Matrix(int n, int m);
- /**
- n x m matrix, init to 0
- */
- Matrix(const Matrix &m);
-
- /// dyadic product: v * w.transpose
- Matrix(Vector v, Vector w);
- void operator=(const Matrix&m);
-
- /// access an element
- Real operator()(int i,int j) const;
-
- /// access an element
- Real &operator()(int i, int j);
-
- /// Matrix multiply with vec (from right)
- Vector operator *(const Vector &v) const;
-
- /// set this to m1*m2.
- void set_product(const Matrix &m1, const Matrix &m2);
-
-
- Vector left_multiply(Vector const &) const;
-
- Matrix operator-() const;
-
- /// transpose this.
- void transpose();
-
- /// return a transposed copy.
- Matrix transposed() const ;
-
- Real norm() const;
- /// swap
- void swap_columns(int c1, int c2);
- /**
- PRE
- 0 <= c1,c2 < cols()
- */
-
- /// swap
- void swap_rows(int c1, int c2);
- /**
- PRE
- 0 <= c1,c2 < rows()
- */
-
-
- Vector row(int ) const;
- Vector col(int) const;
-
- operator String() const;
- void print() const;
-};
-
-/** 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.)
-
-
- TODO
- implement ref counting? */
-
-
-inline Vector
-operator *(Vector &v, const Matrix& m) { return m.left_multiply(v); }
-Matrix operator *(const Matrix& m1,const Matrix &m2);
-Matrix operator /(const Matrix &m1,Real a);
-inline Matrix operator -(Matrix m1,const Matrix m2)
-{
- m1 -= m2;
- return m1;
-}
-#endif
+++ /dev/null
-#ifndef REAL_HH
-#define REAL_HH
-typedef double Real;
-inline Real sqr(Real x){
- return x*x;
-}
-inline Real MIN(Real x, Real y) {
- return (x < y)? x : y;
-}
-
-inline Real MAX(Real x, Real y) {
- return (x > y) ? x : y;
-}
-
-inline Real ABS(Real x)
-{
- return (x>0)? x:-x;
-}
-inline
-int sgn(Real x) {
- if (!x)return 0;
- return (x > 0) ?1: -1;
-}
-
-#endif
+++ /dev/null
-#include "smat.hh"
-
-void
-Full_storage::operator=(Full_storage const &fs)
-{
- resize(fs.h, fs.w);
- OK();
- fs.OK();
- for (int i=0; i<h; i++)
- for (int j=0; j<w; j++)
- els[i][j]= fs.els[i][j];
-}
-
-void
-Full_storage::OK() const
-{
- // static Real dummy;
- assert(maxh >= h && maxw >= w);
- assert(h >= 0 && w >= 0);
- assert(els||!maxh);
- if (maxh>0) { // access outer elts.
- Real *r = els[maxh -1];
- if (maxw>0) {
- assert(r);
- Real s = r[maxw -1];
- s = sin(s);
- }
- }
-}
-void
-Full_storage::resize_cols(int newh)
-{
- if (newh <= maxh) {
- h=newh;
- return;
- }
-
- Real ** newa=new Real*[newh];
- int j=0;
- for (; j < h; j++)
- newa[j] = els[j];
- for (; j < newh; j++)
- newa[j] = new Real[maxw];
- delete[] els;
- els=newa;
-
- h = maxh = newh;
-}
-
-void
-Full_storage::resize_rows(int neww)
-{
- if (neww <= maxw) {
- w=neww;
- return;
- }
- for (int i=0; i < maxh ; i++) {
- Real* newa=new Real[neww];
- for (int k=0; k < w; k++)
- newa[k] = els[i][k];
-
- delete[] els[i];
- els[i] = newa;
- }
- w = maxw = neww;
-}
-
-Full_storage::~Full_storage() {
- for (int i=0; i < maxh; i++)
- delete [] els[i];
- delete[] els;
-}
-
-void
-Full_storage::resize(int rows, int cols)
-{
- OK();
- resize_cols(rows);
- resize_rows(cols);
-
-}
-
-
-bool
-Full_storage::mult_ok(int i, int j) const
-{
- return valid(i,j);
-}
-
-bool
-Full_storage::trans_ok(int i, int j) const
-{
- return valid(i,j);
-}
-
-
-void
-Full_storage::trans_next(int &i, int &j) const
-{
- assert(trans_ok(i,j));
- i++;
- if (i >= h) {
- i=0;
- j ++;
- }
-}
-
-void
-Full_storage::mult_next(int &i, int &j) const
-{
- assert(mult_ok(i,j));
- j++;
- if (j >= w) {
- j=0;
- i++;
- }
-}
-
-void
-Full_storage::delete_column(int k)
-{
- assert(0 <= k &&k<w);
- for (int i=0; i< h ; i++)
- for (int j=k+1; j <w; j++)
- els[i][j-1]=els[i][j];
- w--;
-}
-void
-Full_storage::delete_row(int k)
-{
- assert(0 <= k &&k<h);
- for (int i=k+1; i < h ; i++)
- for (int j=0; j < w; j++)
- els[i-1][j]=els[i][j];
- h--;
-}
-
-
-void
-Full_storage::insert_row(int k)
-{
- assert(0 <= k&& 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];
-
-}
-
-
-svec<Real>
-Full_storage::row(int n) const
-{
- svec<Real> r;
- for (int j = 0; j < w; j++)
- r.add(els[n][j]);
- return r;
-}
-
-svec<Real>
-Full_storage::column(int n) const
-{
-
- svec<Real> r;
- for (int i = 0; i<h; i++)
- r.add(els[i][n]);
- return r;
-}
-
-
-Full_storage::Full_storage(Full_storage&s)
-{
- init();
- (*this) = s;
-}
-virtual_smat*
-Full_storage::clone()
-{
- return new Full_storage(*this);
-}
-/****************************************************************/
-
-virtual_smat *
-virtual_smat::get_full(int n, int m)
-{
- return new Full_storage(n,m);
-}
+++ /dev/null
-#ifndef SMAT_HH
-#define SMAT_HH
-#include "vray.hh"
-#include "vsmat.hh"
-#include "real.hh"
-/// simplest matrix storage. refer to its baseclass for the doco.
-class Full_storage : public virtual_smat
-{
- /// height, width
- int h,w;
- /// maxima.
- int maxh, maxw;
-
- /// the storage
- Real** els;
- void
- init() {
- els=0;
- h=w=maxh=maxw=0;
-
- }
-
- bool valid(int i, int j) const {
- return (i>=0 && i < h)
- && (j < w && j >=0);
- }
-
-
- void resize_rows(int);
- void resize_cols(int);
-
-public:
- virtual int rows() const {
- return h;
- }
- virtual int cols() const {
- return w;
- }
-
-
- virtual void set_size(int i, int j)
- {
- resize(i,j); //this could be more efficient.
- }
-
- virtual void set_size(int i) {
- set_size(i,i);
- }
- virtual void resize(int i, int j);
- virtual void resize(int i) {
- resize(i,i);
- }
-
- virtual Real& elem(int i,int j) {
- assert(valid(i,j));
- return els[i][j];
- }
- virtual const Real& elem(int i, int j) const {
- assert(valid(i,j));
- return els[i][j];
- }
- virtual svec<Real> row(int i) const;
- virtual svec<Real> column(int j) const;
-
- Full_storage() {
- init();
- }
- Full_storage(int i, int j) {
- init();
- set_size(i,j);
- }
- Full_storage(Full_storage&);
- Full_storage(int i) {
- init();
- set_size(i);
- }
- void OK() const;
- void operator=(Full_storage const &);
-
- virtual void insert_row(int k);
- virtual void delete_row(int k);
- virtual void delete_column(int k);
-
-
- ~Full_storage();
- virtual bool mult_ok(int i, int j)const;
- virtual void mult_next(int &i, int &j) const ;
- virtual bool trans_ok(int i, int j) const;
- virtual void trans_next(int &i, int &j) const;
- virtual virtual_smat * clone();
-};
-
-#endif
+++ /dev/null
-#include "line.hh"
-
-#include "list.hh"
-#include "cols.hh"
-#include "item.hh"
-#include "request.hh"
-#include "score.hh"
-#include "command.hh"
-#include "staff.hh"
-
-#include "list.cc"
-#include "cursor.cc"
-
-
-PL_instantiate(Line_of_score);
-PL_instantiate(Line_of_staff);
-PL_instantiate(Item);
-PL_instantiate(Spanner);
-PL_instantiate(PStaff);
-PL_instantiate(Idealspacing);
-PL_instantiate(PCol);
-PL_instantiate(Command);
-PL_instantiate(Request);
-PL_instantiate(Score_column);
-
-
+++ /dev/null
-#include "debug.hh"
-#include "vector.hh"
-#include "string.hh"
-
-Vector::Vector(const Vector&n)
- :dat(n.dat)
- // this makes GCC 272 barf
-{
- //dat = n.dat;
-}
-
-Vector::operator String() const
-{
- int i=0;
- String s("vector [");
- for (; i < dim(); i++) {
- s += String(dat[i], "%6f") + ' ';
- }
- s+="]";
- return s;
-}
-
-
-void
-Vector::print() const
-{
- mtor << *this<<'\n';
-}
-
-Vector
-Vector::operator-() const
-{
- Vector v(*this); v*=-1; return v;
-}
-
-void
-Vector::set_unit(int j)
-{
- fill(0.0);
- dat[j] = 1.0;
-}
+++ /dev/null
-#ifndef VECTOR_HH
-#define VECTOR_HH
-
-#include "glob.hh"
-#include "vray.hh"
-
-/// a row of numbers
-class Vector {
- svec<Real> dat;
-public:
- void OK() const { dat.OK();}
- int dim() const { return dat.sz(); }
- Vector() { }
- Vector(const Vector&n);
- Vector(int n) {
- dat.set_size(n);
- fill(0);
- }
- void insert(Real v, int i) {
- dat.insert(v,i);
- }
- void del(int i) { dat.del(i); }
- operator String() const;
- void fill(Real r) {
- for (int i=0; i < dim(); i++)
- dat[i] =r;
- }
-
- void operator +=(Vector v) {
- assert(v.dim() == dim());
- for (int i=0; i < dim(); i++)
- dat[i] += v.dat[i];
- }
-
- void operator /=(Real a) {
- (*this) *= 1/a;
- }
-
- void operator *=(Real a) {
- for (int i=0; i < dim(); i++)
- dat[i] *= a;
- }
-
- void operator -=(Vector v) {
- assert(v.dim() == dim());
- for (int i=0; i < dim(); i++)
- dat[i] -= v(i);
- }
-
- Real &operator()(int i) { return dat[i]; }
- Real operator()(int i) const { return dat[i]; }
- Real elem(int i) { return dat[i]; }
- Real operator *(Vector v) const {
- Real ip=0;
- assert(v.dim() == dim());
- for (int i=0; i < dim(); i++)
- ip += dat[i] *v(i);
- return ip;
- }
- Vector operator-() const;
- Real norm() {
- return sqrt(norm_sq() );
- }
- Real norm_sq() {
- return ((*this) * (*this));
- }
- operator svec<Real> () { return dat; }
- void print() const;
- /// set to j-th element of unit-base
- void set_unit(int j) ;
-};
-/**
- a vector. Storage is handled in svec, Vector only does the mathematics.
- */
-
-inline Vector
-operator+(Vector a, Vector const &b) {
- a += b;
- return a;
-}
-
-inline Vector
-operator-(Vector a, Vector const &b) {
- a -= b;
- return a;
-}
-
-inline Vector
-operator*(Vector v, Real a) {
- v *= a;
- return v;
-}
-
-inline Vector
-operator*( Real a,Vector v) {
- v *= a;
- return v;
-}
-
-inline Vector
-operator/(Vector v,Real a) {
- v *= 1/a;
- return v;
-}
-
-#endif
+++ /dev/null
-#ifndef VSMAT_HH
-#define VSMAT_HH
-#include "vray.hh"
-#include "real.hh"
-/// a matrix storage baseclass.
-class virtual_smat {
-
-
-public:
- /// check invariants
- virtual void OK() const=0;
-
- /// height of matrix
- virtual int rows() const = 0;
-
- /// width of matrix
- virtual int cols() const = 0;
-
- /// set the size. contents lost
- virtual void set_size(int i, int j) = 0;
- /**
- PRE
- i >=0, j>=0
- */
-
- /// set the size to square dimen. contents lost
- virtual void set_size(int i) = 0;
- /**
- PRE
- i>=0
- */
- /// set the size to i
- virtual void resize(int i, int j) = 0;
- /**
-
- keep contents. If enlarged contents unspecified
-
- PRE
- i>=0, j>=0
-
- */
-
- /// set the size to square dimen. contents kept
- virtual void resize(int i) = 0;
- /**
- Keep contents. If enlarged contents are unspecified
-
- PRE
- 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.
- */
-
- /// access a element, no modify
- virtual const Real& elem(int i, int j) const = 0;
-
-#if 1
- virtual svec<Real> row(int i) const = 0;
- virtual svec<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()
- */
-
- /// delete a row
- virtual void delete_row(int k)=0;
- /**
- delete a row from this matrix.
-
- PRE
- 0 <= k < rows();
- */
- 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
-
- for(i=0; i<h; i++)
- for(j=0; j<w; j++)
- ...
-
- */
- /// iterate
- virtual void mult_next(int &i, int &j) const = 0;
- /**
- 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;
- /**
- valid matrix entry. return false if at end of row
- */
- virtual void trans_next(int &i, int &j) const = 0;
- /**
- walk through matrix (transposed multiply).
- Get next i (for column j)
-
- PRE
- ver_ok(i,j)
- */
-
- /// 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