# class name silence?
-My_flex_lexer 0
-yyFlexLexer 0
+My_flex_lexer 1
+yyFlexLexer 1
PCol 1
Score_column 1
Ineq_constrained_qp 1
Idealspacing 1
# yydebug
-Parser 0
+Parser 1
# FlexLexer debug
Lexer 1
Rhythmic_req 1
Rest_req 1
delete_identifiers 1
-Command 1
-Staff_commands 1
+Command 0
+Staff_commands 0
Stem 0
Staff 0
Score 0
include Variables.make
+.SUFFIXES:
+.SUFFIXES: .cc .o .hh .y .l
+
$(exe): $(obs)
$(CXX) -o $@ $^ $(LOADLIBES)
clean:
# $(MAKE) -C objects clean
rm -f $(exe) objects/*.o $(DOCDIR)/* core
+ $(MAKE) -C $(CCDIR) clean
+ $(MAKE) -C $(HEADERDIR) clean
distclean: clean
rm -f depend version.hh $(gencc) .GENERATE *~
+pl 18:
+ - robust Staff_commands
+
pl 17:
- robust Input_commands
- merged Vertical_/Horizontal music
-*-text-*-
-last update: 96/12/12, 0.0.16
+last update: 96/17/12, 0.0.17
+
+LICENSE
+
+See file COPYING
INTRODUCTION
builtin bool
typeof
operator <?, operator >?
+ new for-scope
USING
This is what the output looks like over here:
-hw:~/musix/spacer$ lilypond maartje.ly
-LilyPond version 0.0.16 compiled on Dec 11 1996 at 13:54:27
-Parsing ... [symbol.ini][maartje.ly]
-Processing ... Calculating ... Postprocessing ...
-output to lelie.uit...
+ hw:~/musix/spacer$ lilypond maartje.ly
+ LilyPond 0.0.17/FlowerLib 1.0.14. Compile: Dec 17 1996, 11:33:54 (g++ 2.7.2)
+ Parsing ... [symbol.ini][maartje.ly]
+ Processing ... Calculating ... Postprocessing ...
+ output to lelie.uit...
-hw:~/musix/spacer$ tex test
-This is TeX, Version 3.14159 (C version 6.1)
-(test.tex
-Hyphenation patterns for english, dutch, loaded.
-(lilyponddefs.tex) (lelie.uit) [1] [2] )
-Output written on test.dvi (2 pages, 8072 bytes).
-Transcript written on test.log.
+ hw:~/musix/spacer$ tex test
+ This is TeX, Version 3.14159 (C version 6.1)
+ (test.tex
+ Hyphenation patterns for english, dutch, loaded.
+ (lilyponddefs.tex) (lelie.uit) [1] [2] )
+ Output written on test.dvi (2 pages, 8072 bytes).
+ Transcript written on test.log.
-hw:~/musix/spacer$ xdvi test&
-[1] 1468
+ hw:~/musix/spacer$ xdvi test&
+ [1] 1468
Check out kortjakje.ly, it has some comments
+
PROBLEMS
If LilyPond bombs out, then please recompile using -g, and send a gdb
-stacktrace of the crash.
+stacktrace of the crash. It also helps if you can print the values of the objects. So if you trace is
+
+(gdb) backtrace 12
+#0 Interval::operator+= (this=0x11fffec60, r=-1.7976931348623157e+308)
+ at ../flower/interval.hh:50
+#1 0x12005195c in Item::width (this=0x14008a680) at src/item.cc:39
+#2 0x12008fdbc in itemlist_width (its=0x11fffed58) at src/simpleprint.cc:40
+ :
+ :
+Than it would help if you send a dump of the Interval and the Item (use: 'print *this' or use LilyPond print() methods)
HOW DOES IT WORK
# version info
MAJVER=0
MINVER=0
-PATCHLEVEL=17
+PATCHLEVEL=18
VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL)
CXXVER=`$(CXX) --version`
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\
+
MAJVER=1
MINVER=0
-PATCHLEVEL=17
+PATCHLEVEL=18
PACKAGENAME=flower
#PROFILEFLAG=-pg
-DEBUGFLAG=-g -O2
+DEBUGFLAG=-g -O2 -DNDEBUG
OPTIFLAG=-DNDEBUG -DNPRINT -O2
#########################################
+++ /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
#include "pcursor.hh"
#include "list.hh"
#include "cursor.inl"
+#include "iterate.hh"
#endif // CURSOR_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;
-}
left += t;
right += t;
}
- T operator[](int j) {
+ T& idx(int j) {
if (j==-1)
return left;
else if (j==1)
return right;
else
assert(false);
- return 0;
+ return left;
}
+ T& operator[](int j) {
+ return idx(j);
+ }
+ T operator[](int j) const {
+ return ((Interval_t<T> *)this)->idx(j);
+ }
+ T &max() { return right;}
+ T max()const { return right;}
+ T min()const{ return left; }
+ T &min(){ return left; }
void unite(Interval_t<T> h);
/**
PRE
--- /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
+
+#define iterator(set) typeof((set).top())
+
+// should use top()
+#define iter_top(set,var) iterator(set) var(set)
+
+++ /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
List();
virtual ~List();
- Cursor<T> bottom();
-
int size() const;
- Cursor<T> top();
- void OK() const;
+
+ Cursor<T> bottom() const; // const sucks..
+ Cursor<T> top() const;
+
+ void OK() const; // check list
+
protected:
friend class Cursor<T>;
friend class Link<T>;
template<class T>
inline Cursor<T>
-List<T>::top()
+List<T>::top()const
{
return Cursor<T>( *this, top_ );
}
template<class T>
inline Cursor<T>
-List<T>::bottom()
+List<T>::bottom()const
{
return Cursor<T>( *this, bottom_ );
}
--- /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;
-}
class PointerList : public List<void *>
{
public:
- PCursor<T> top() { return PCursor<T> (List<void*>::top()); }
- PCursor<T> bottom() { return PCursor<T> (List<void*>::bottom()); }
+ PCursor<T> top() const{
+ return PCursor<T> (List<void*>::top());
+ }
+ PCursor<T> bottom() const {
+ return PCursor<T> (List<void*>::bottom());
+ }
PCursor<T> find(T) const;
void concatenate(PointerList<T> const &s) { List<void*>::concatenate(s); }
PointerList() {}
--- /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;
+}
Real *r = els[maxh -1];
if (maxw>0) {
assert(r);
- Real s = r[maxw -1];
+ Real s = r[maxw -1]; // accessing unitialised memory.
s = sin(s);
}
}
+++ /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>;
--- /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>;
TAGS: $(hdr)
etags -CT $(hdr)
+
+clean:
+ rm -f parser.hh
\ No newline at end of file
virtual Interval width()const;
- Spanner *broken_at(const PCol *, const PCol *) const;
+ Spanner *broken_at(PCol *, PCol *) const;
Beam();
void add(Stem*);
void process();
struct Command {
Commandcode code;
- Real when;
+// Real when;
/// analogous to argv[]
svec<Scalar> args;
/****************/
Command();
- Command(Real w);
+// Command(Real w);
bool isbreak()const;
void print() const;
};
#include "proto.hh"
-Command* get_meter_command( Real,int,int);
+Command* get_meter_command(int,int);
#include "interval.hh"
#include "vray.hh"
-struct Rhythmic_grouping {
- Interval t;
+
+struct Rhythmic_grouping {
+ svec<Real> divisions;
svec<Rhythmic_grouping*> children;
+
/****************/
-
- void split_half();
- Real last();
- Rhythmic_grouping* sub_grouping(Interval v);
- void split_grouping(Rhythmic_grouping &initial_grouping);
- void split_grouping(svec<Real> initial_grouping);
- svec<Real> get_bounds();
- Rhythmic_grouping(Interval);
- Rhythmic_grouping(svec<Interval> notes,
- svec<Real> initial_grouping);
+ svec<Real> interior();
+ Rhythmic_grouping partial_grouping(Interval t);
+ Real length() const;
+ Interval time() const;
+ Rhythmic_grouping(Interval);
+ Rhythmic_grouping();
+ Rhythmic_grouping(svec<Real>);
+ Rhythmic_grouping(Rhythmic_grouping const&);
+
+ void split(Rhythmic_grouping r);
+ void split(svec<Real>);
+ void intersect(Interval);
+ void split(int n);
void print() const;
+ void OK() const;
~Rhythmic_grouping();
};
-
-#endif // GROUPING_HH
+#endif
void postprocess();
/// search all pcols which are breakable.
- svec<const PCol *> find_breaks() const;
+ svec< PCol *> find_breaks() const;
/// add a line to the broken stuff. Positions given in #config#
- void add_line(svec<const PCol *> curline, svec<Real> config);
+ void add_line(svec< PCol *> curline, svec<Real> config);
/// helper: solve for the columns in #curline#.
- svec<Real> solve_line(svec<const PCol *> curline) const;
+ svec<Real> solve_line(svec<PCol *> curline) const;
void add(PStaff *);
/// add item
*/
/// return argument as a cursor.
- PCursor<PCol *> find_col(const PCol *)const;
+ PCursor<PCol *> find_col(PCol *)const;
/// delete unused columns
void clean_cols();
void print() const;
/// does curline fit on the paper?
- bool feasible(svec<const PCol *> curline) const;
+ bool feasible(svec<PCol *> curline) const;
/// which is first (left, higher)
- int compare_pcols(const PCol*, const PCol*)const;
+ int compare_pcols( PCol*, PCol*)const;
};
/** notes, signs, symbols in a score can be grouped in two ways:
horizontally (staffwise), and vertically (columns). #PScore#
/// the columns of a score that form one line.
struct
Line_of_score {
- PointerList<const PCol *> cols;
+ PointerList<PCol *> cols;
// need to store height of each staff.
IPointerList<Line_of_staff*> staffs;
/****************/
void process() ;
- Line_of_score(svec<const PCol *> sv, PScore *);
+ Line_of_score(svec<PCol *> sv, PScore *);
String TeXstring() const;
#define SIMPLEWALKER_HH
#include "proto.hh"
+#include "grouping.hh"
struct Simple_walker: Staff_walker {
Stem *stem_;
bool processed_key;
bool processed_clef;
Clef clef_;
+ Rhythmic_grouping default_grouping;
+ Rhythmic_grouping current_grouping;
+
svec<Slur_req*> pending_slur_reqs;
svec<Slur*> pending_slurs;
+
+
+
/****************/
virtual void do_TYPESET_command(Command*);
void add(Notehead*);
void set_default_dir();
Interval height() const;
- Spanner* broken_at(const PCol*, const PCol*) const;
+ Spanner* broken_at( PCol*, PCol*) const;
void process();
private:
void brew_molecule();
/// clone a piece of this spanner.
- virtual Spanner *broken_at(const PCol *c1, const PCol *c2) const=0;
+ virtual Spanner *broken_at( PCol *c1, PCol *c2) const=0;
/**
PRE
#include "vray.hh"
#include "plist.hh"
+
+struct Staff_commands_at : public IPointerList<Command*> {
+ Real when;
+
+ /****************/
+
+ bool is_breakable();
+
+ Staff_commands_at(Real);
+ void set_breakable();
+ void add_command_to_break(Command pre, Command mid,Command post);
+ void print() const;
+ void OK() const;
+ void insert_between(Command victim, PCursor<Command*> firstc,
+ PCursor<Command*> last);
+ void add(Command c);
+
+};
+
/// the list of commands in Score
-struct Staff_commands : public IPointerList<Command*> {
- void process_add(Command);
- void add_seq(svec<Command>,bool);
+struct Staff_commands : public IPointerList<Staff_commands_at*>
+{
+ Staff_commands_at*find(Real);
+ void add(Command,Real);
void clean(Real last);
- void set_breakable(Real when);
- bool is_breakable(Real w);
- PCursor<Command*> last_insertion(Real w);
- PCursor<Command*> first(Real w);
- void add_command_to_break(Command pre, Command mid,Command post);
void OK() const;
void print() const;
Real last() const;
- void insert_between(Command victim, PCursor<Command*> firstc,
- PCursor<Command*> last);
};
/** the list of commands in Score. Put in a separate class, since it
otherwise clutters the methods of Score.
- This class serves two purposes: it stores the commands (via
- parser_add()) in the yacc parser. at a later stage, some 'high
- level' commands are converted (method: parse())
*/
#endif
#!/bin/sh
+
+case $# in
+0) echo make_patch old new name
+ exit 1;;
+esac
+
old=$1
new=$2
nm=$3-
#(cd $nm$old; touch depend; make clean)
#(cd $nm$new; touch depend; make clean)
-(cd $nm$new; diff -rP -c ../$nm$old . > ../patch-$new)
+(cd $nm$new; diff -urP ../$nm$old . > ../patch-$new)
rm -rf $nm$old $nm$new
TAGS: $(mycc)
etags -CT $(mycc)
+
+clean:
+ rm -f $(gencc)
\ No newline at end of file
+#include "dimen.hh"
#include "beam.hh"
#include "misc.hh"
#include "debug.hh"
// todo.
Spanner *
-Beam::broken_at(const PCol *, const PCol *) const
+Beam::broken_at( PCol *, PCol *) const
{
return new Beam(*this);
}
return Interval( (*me->stems.top()) ->hpos(),
(*me->stems.bottom()) ->hpos() );
}
+
/*
beams to go with one stem.
*/
Real dy=paper()->internote()*2;
Real stemdx = paper()->rule_thickness();
Real sl = slope*paper()->internote();
+ paper()->lookup_->beam(sl, convert_dimen(20,"pt"));
+ slope = sl /paper()->internote();
Molecule leftbeams;
Molecule rightbeams;
{
assert(left->line == right->line);
Real inter=paper()->internote();
- Real sl = slope*inter;
-
output = new Molecule;
- slope = sl / inter;
Real x0 = stems.top()->hpos();
for (PCursor<Stem*> i(stems); i.ok(); i++) {
// construct an appropriate Spacing_problem and solve it.
svec<Real>
-PScore::solve_line(svec<const PCol *> curline) const
+PScore::solve_line(svec< PCol *> curline) const
{
Spacing_problem sp;
}
bool
-PScore::feasible(svec<const PCol *> curline) const
+PScore::feasible(svec< PCol *> curline) const
{
Real l =0;
for (int i=0; i < curline.sz(); i++)
}
struct Col_configuration {
- svec<const PCol*> line;
+ svec< PCol*> line;
svec<Real> config;
Real energy;
Col_configuration() {
energy = INFTY;
}
- void add(const PCol*c) { line.add(c);}
+ void add( PCol*c) { line.add(c);}
void setsol(svec<Real> sol) {
config = sol;
energy = config.last();
problem_OK();
PCursor<PCol *> curcol(cols);
- svec<const PCol *> breakpoints(find_breaks());
+ svec<PCol *> breakpoints(find_breaks());
assert(breakpoints.sz()>=2);
for (int i=0 ; i < breakpoints.sz() -1; ) {
Col_configuration minimum;
void
Score::calc_idealspacing()
{
-#if 1
PCursor<Score_column*> i(cols_);
for (; i.ok(); i++) {
assert(i->used());
PCursor<Score_column*> j (i+1);
if (i->musical) {
+ assert(j.ok());
for (int n=0; n < i->durations.sz(); n++) {
Real d = i->durations[n];
Real dist = paper_->duration_to_dist(d);
while (j->when < d + i->when)
j++;
- assert(j->when == d+i->when);
+ assert( distance(j->when, d+i->when) < 1e-8);
connect(i->pcol_, j->pcol_, dist);
if (!j->musical && (j+1).ok()
Real d = j->when - i->when;
Real dist = (d) ? paper_->duration_to_dist(d) :
- convert_dimen(2,"pt");
+ convert_dimen(2,"pt"); // todo
connect(i->pcol_, j->pcol_, dist, (d) ? 1.0:1.0);
}
// !j.ok() might hold if we're at the last col.
}
-#else
- PCursor<Score_column*> sc(cols_);
-
- for (; sc.ok(); sc++) {
- if (sc->musical)
- for (int i=0; i < sc->durations.sz(); i++) {
- Real d = sc->durations[i];
- Real dist = paper_->duration_to_dist(d);
- PCol * c2 = find_col(sc->when + d,true)->pcol_;
- connect(sc->pcol_, c2, dist);
- c2 = find_col(sc->when + d,false)->pcol_;
- connect(sc->pcol_, c2, dist);
- }
- else if (sc->used()) { // ignore empty columns
- PCol * c2 = find_col(sc->when,true)->pcol_;
- connect(sc->pcol_, c2, 0.0);
- }
-#endif
}
Command::Command()
{
code = NOP;
- when = -1;
- priority=0;
-}
-
-Command::Command(Real w)
-{
- code = NOP;
- when = w;
priority=0;
}
Command::print() const
{
#ifndef NPRINT
- mtor << "command at " << when << ", code " << code << " prio " << priority;
+ mtor << "Command " << "code " << code << " prio " << priority;
if ( isbreak())
mtor << "(break separator)";
if (args.sz()) {
}
Command *
-get_meter_command(Real w, int n, int m)
+get_meter_command(int n, int m)
{
Command*c = new Command;
- c->when = w;
+// c->when = w;
c->code = TYPESET;
c->args.add( "METER");
c->args.add( n );
-#include "grouping.hh"
#include "debug.hh"
+#include "grouping.hh"
+#include "interval.hh"
-Interval
-vec_union(svec<Interval> notes)
+void
+Rhythmic_grouping::OK()const
{
- Interval u;
- u.set_empty();
- for (int i =0 ; i < notes.sz() ; i++) {
- u.unite(notes[i]);
- }
- return u;
+ for (int i= 1; i < divisions.sz(); i++) {
+ Real dt = divisions[i] - divisions[i-1];
+ assert(dt>0);
+ }
+ Interval u;
+ for (int i= 1; i < children.sz(); i++) {
+ children[i]->OK();
+ u.unite(children[i]->time());
+ }
+
}
-svec<Real>
-default_bounds(Interval t)
+Real
+Rhythmic_grouping::length() const
{
- svec<Real> bounds;
- Real dt = t.length();
- bounds.add(t.min);
- bounds.add(t.min + dt/2);
- return bounds;
+ return divisions.last() - divisions[0];
}
-svec<Real>
-Rhythmic_grouping::get_bounds()
+void
+Rhythmic_grouping::split(Rhythmic_grouping r)
{
- svec<Real> bounds;
- if (children.sz()) {
- for (int i=0; i < children.sz(); i++) {
- bounds.add(children[i]->t.min);
- }
- } else {
- default_bounds(t);
+ svec<Real> ir = r.interior();
+ split(ir);
+
+ for (int i= 0; i < children.sz(); i++) {
+ Rhythmic_grouping here(r.partial_grouping(children[i]->time()));
+ if (here.divisions.sz() == 2)
+ here.split(2);
+ children[i]->split(here);
}
-// bounds.add(t.max );
- return bounds;
}
-Real
-Rhythmic_grouping::last()
+svec<Real>
+Rhythmic_grouping::interior()
{
- return t.max;
+ svec<Real> r(divisions);
+ r.del(0);
+ r.pop();
+ return r;
}
void
-Rhythmic_grouping::split_grouping(svec<Real> bounds)
+Rhythmic_grouping::split(int n)
{
- int lasti =0;
- svec<Rhythmic_grouping*> newgrp;
- for (int i=0, j = 1; i < children.sz() && j < bounds.sz(); ) {
- if ( children[i]->t.max < bounds[j]) {
- i ++;
- continue;
- } else if (children[i]->t.max > bounds[j]) {
- j ++;
- continue;
- }
-
- assert( children[lasti]->t.min == bounds[j-1] );
- assert( children[i]->t.max == bounds[j] );
-
- Rhythmic_grouping * n = new Rhythmic_grouping(Interval(
- bounds[j-1], bounds[j]));
- for (int k = lasti ; k < i; k++)
- n->children.add(children[k]);
- newgrp.add(n);
-
- i = lasti = i+1;
- }
- if (newgrp.sz() <= 1) {
- newgrp[0]->children.set_size(0);
- delete newgrp[0];
- return;
- }
- children = newgrp;
+ assert(divisions.sz() == 2 && children.sz() == 0);
+ Real dt =(divisions.last()-divisions[0] )/n;
+ svec<Real> r;
+ for (int i= 0; i <= n; i++)
+ r.add(divisions[0] +dt *i);
+ divisions = r;
}
void
-Rhythmic_grouping::split_half()
+Rhythmic_grouping::intersect(Interval t)
{
- svec<Real> bounds = default_bounds(t);
- bounds.add(t.max);
- split_grouping(bounds);
+ svec<Real> r;
+ for (int i=0; i < divisions.sz(); i++)
+ if (t.elt_q(divisions[i]))
+ r.add(divisions[i]);
+ if (r[0] > t.min ) // todo
+ r.insert( t.min,0);
+ if (r.last() < t.max)
+ r.add(t.max);
+ divisions = r;
+ svec<Rhythmic_grouping*> nc;
for (int i=0; i < children.sz(); i++) {
- if (children[i]->children.sz())
- children[i]->split_half();
+ Interval inter = intersection(t, children[i]->time());
+ if (!inter.empty()) {
+ Rhythmic_grouping*p =new Rhythmic_grouping(*children[i]);
+ nc.add(p);
+ p->intersect(inter);
+ }
+ delete children[i];
}
+ children = nc;
}
-Rhythmic_grouping*
-Rhythmic_grouping::sub_grouping(Interval v)
+Rhythmic_grouping
+Rhythmic_grouping::partial_grouping(Interval t)
{
- return 0; // todo!
+ Rhythmic_grouping r(*this);
+ r.intersect(t);
+ return r;
}
+
void
-Rhythmic_grouping::split_grouping(Rhythmic_grouping &initial_grouping)
+Rhythmic_grouping::split(svec<Real> splitpoints)
{
- svec<Rhythmic_grouping*> newgrp;
- svec<Real> bounds = initial_grouping.get_bounds();
- bounds.add(initial_grouping.last());
- split_grouping(bounds);
- for (int i=0; i < children.sz(); i++) {
- Interval h = children[i]->t;
- Rhythmic_grouping*r = initial_grouping.sub_grouping(h);
- if (children[i]->children.sz()) {
- if (r)
- children[i]->split_grouping(*r);
- else
- children[i]->split_half();
+ assert(!children.sz());
+ svec<Real> child;
+ int j = 0, i=0;
+ while (1) {
+ if ( i >= divisions.sz() || j >= splitpoints.sz())
+ break;
+
+ child.add(divisions[i]);
+ if (divisions[i] < splitpoints[j]) {
+ i++;
+ } else if (divisions[i] > splitpoints[j]) {
+ j ++;
+ } else {
+ children.add(new Rhythmic_grouping(child));
+ child.set_size(1);
+ child[0] = divisions[i];
}
}
}
-Rhythmic_grouping::Rhythmic_grouping(Interval i)
+Rhythmic_grouping::Rhythmic_grouping(svec<Real> d)
+ :divisions(d)
{
- t=i;
}
-
-Rhythmic_grouping::Rhythmic_grouping(svec<Interval> notes,
- svec<Real> initial_grouping)
+Rhythmic_grouping::Rhythmic_grouping()
{
- t = vec_union(notes);
- for (int i=0; i < notes.sz(); i++) {
- children.add(new Rhythmic_grouping(notes[i]));
- }
- split_grouping(initial_grouping);
+}
+Interval
+Rhythmic_grouping::time()const
+{
+ return Interval(divisions[0], divisions.last());
+}
+Rhythmic_grouping::Rhythmic_grouping(Interval h)
+{
+ divisions.add(h.min);
+ divisions.add(h.max);
}
Rhythmic_grouping::~Rhythmic_grouping()
{
- for (int i=0; i < children.sz(); i++) {
+ for (int i=0; i < children.sz(); i++)
delete children[i];
- }
}
+
+Rhythmic_grouping::Rhythmic_grouping(Rhythmic_grouping const&s)
+{
+ divisions = s.divisions;
+ for (int i=0; i < s.children.sz(); i++)
+ children.add(new Rhythmic_grouping(*s.children[i]));
+}
+
void
Rhythmic_grouping::print()const
{
- mtor << "{ " << t << "\n";
+#ifndef NPRINT
+ mtor << "{ ";
+ for (int i=0; i < divisions.sz(); i++) {
+ mtor << divisions[i] << ',';
+ }
for (int i=0; i < children.sz(); i++) {
children[i]->print();
}
mtor << "}";
+#endif
}
Commands_at::print() const
{
#ifndef NPRINT
- mtor << "{ at "<<when<<'\n';
+ mtor << "Commands_at { at "<<when<<'\n';
mtor << "meter " << whole_per_measure
<< " pos "<< bars << ":" << whole_in_measure <<'\n';
for (PCursor<Input_command *> cc(*this); cc.ok(); cc++)
}
void
-Commands_at::add(Input_command *i )
+Commands_at::add(Input_command *i)
{
bottom().add(i);
if (i->args[0] == "METER") { // should check for other meterchanges here.
}
Real
Commands_at::barleft()
-
{
return whole_per_measure-whole_in_measure;
}
Staff_commands*nc = new Staff_commands;
{ /* all pieces should start with a breakable. */
- Command c(0.0);
+ Command c;//(0.0);
c.code = INTERPRET;
c.args.add("BAR");
c.args.add("empty");
- nc->process_add(c);
+ nc->add(c,0.0);
}
for (PCursor<Commands_at*> i(*this); i.ok(); i++)
for (PCursor<Input_command *> cc(**i); cc.ok(); cc++) {
if (cc->args.sz() && cc->args[0] !="") {
Command c = **cc;
- c.when = i->when;
- nc->process_add(c);
+// c.when = i->when;
+ nc->add(c, i->when);
}
}
Item::width() const
{
Interval i =output->extent().x ;
- return i+=offset_.x;
+ if (!i.empty()) // float exception on DEC Alpha
+ i+=offset_.x;
+ return i;
}
Interval
c_position = c;
}
-
void
Keyitem::read(svec<int> s)
{
}
void
-Keyitem::preprocess() {
+Keyitem::preprocess()
+{
brew_molecole();
}
{
quad.fill(0);
lin.fill(0);
+ c = 0;
for (int j=0; j < ideals.sz(); j++){
Idealspacing const*i=ideals[j];
int l = col_id(i->left);
OK();
assert(check_feasible());
-
/* optimalisatiefunctie */
Mixed_qp lp(cols.sz());
make_matrices(lp.quad,lp.lin, lp.const_term);
/* */ {
$$ = new svec<int>;
}
- | int {
- $$->add($1);
+ | int_list int {
+ $$->add($2);
}
;
{
if(!pscore_)
return -1;
- PCursor<PCol*> me=pscore_->find_col(this);
+ PCursor<PCol*> me=pscore_->find_col( (PCol*)this);
if (!me.ok())
return -1;
PCursor<PCol*> bot(pscore_->cols.top());
int
PCol::compare(const PCol &c1, const PCol &c2)
{
- return c1.pscore_->compare_pcols(&c1,&c2);
+ return c1.pscore_->compare_pcols((PCol*)&c1,(PCol*)&c2);
}
void
void
-PScore::add_line(svec<const PCol *> curline, svec<Real> config)
+PScore::add_line(svec< PCol *> curline, svec<Real> config)
{
Line_of_score *p = new Line_of_score(curline,this);
lines.bottom().add(p);
int
-PScore::compare_pcols(const PCol*a, const PCol*b)const
+PScore::compare_pcols(PCol*a, PCol*b)const
{
PCursor<PCol*> ac(find_col(a));
PCursor<PCol*> bc(find_col(b));
/*
return all breakable columns
*/
-svec<const PCol *>
+svec< PCol *>
PScore::find_breaks() const
{
- svec<const PCol *> retval;
+ svec< PCol *> retval;
for (PCursor<PCol *> c(cols); c.ok(); c++)
if (c->breakable())
retval.add(c);
}
PCursor<PCol *>
-PScore::find_col(const PCol *c)const
+PScore::find_col(PCol *c)const
{
PCol*what = (PCol*)c;
if (what->daddy )
Ineq_constrained_qp::Ineq_constrained_qp(int novars):
quad(novars),
- lin(novars)
+ lin(novars),
+ const_term (0.0)
{
}
{
return v * quad * v + lin * v + const_term;
}
-/*
- eliminate appropriate variables, until we have a Ineq_constrained_qp
- then solve that.
-
- PRE
- cons should be ascending
- */
Vector
Mixed_qp::solve(Vector start) const
{
-
-Mixed_qp::Mixed_qp(int n)
- : Ineq_constrained_qp(n)
-{
-}
-
void
-Mixed_qp::OK() const
+Ineq_constrained_qp::assert_solution(Vector sol) const
{
-#ifndef NDEBUG
- Ineq_constrained_qp::OK();
- assert(eq_consrhs.sz() == eq_cons.sz());
-#endif
+ svec<int> binding;
+ for (int i=0; i < cons.sz(); i++) {
+ Real R=cons[i] * sol- consrhs[i];
+ assert(R> -EPS);
+ if (R < EPS)
+ binding.add(i);
+ }
+ // KKT check...
+ // todo
}
+
void
Ineq_constrained_qp::print() const
{
#ifndef NPRINT
mtor << "Quad " << quad;
- mtor << "lin " << lin <<"\n";
+ mtor << "lin " << lin <<"\n"
+ << "const " << const_term<<"\n";
for (int i=0; i < cons.sz(); i++) {
mtor << "constraint["<<i<<"]: " << cons[i] << " >= " << consrhs[i];
mtor << "\n";
}
#endif
}
+
+/****************/
+
+/*
+ eliminate appropriate variables, until we have a Ineq_constrained_qp
+ then solve that.
+
+ PRE
+ cons should be ascending
+ */
+
+
+Mixed_qp::Mixed_qp(int n)
+ : Ineq_constrained_qp(n)
+{
+}
+
+void
+Mixed_qp::OK() const
+{
+#ifndef NDEBUG
+ Ineq_constrained_qp::OK();
+ assert(eq_consrhs.sz() == eq_cons.sz());
+#endif
+}
+
void
Mixed_qp::print() const
{
#endif
}
-
-void
-Ineq_constrained_qp::assert_solution(Vector sol) const
-{
- svec<int> binding;
- for (int i=0; i < cons.sz(); i++) {
- Real R=cons[i] * sol- consrhs[i];
- assert(R> -EPS);
- if (R < EPS)
- binding.add(i);
- }
- // KKT check...
- // todo
-}
// do this after processing, staffs first have to generate PCols.
do_pcols();
- // ugh. Would want to clean the columns before anything else.
- clean_cols();
+
+ clean_cols(); // can't move this farther up.
+
calc_idealspacing();
// debugging
}
-Line_of_score::Line_of_score(svec<const PCol *> sv,
+Line_of_score::Line_of_score(svec<PCol *> sv,
PScore *ps)
{
pscore_ = ps;
#include "slur.hh"
#include "localkeyitem.hh"
+Rhythmic_grouping
+parse_grouping(svec<Scalar> a)
+{
+ Rhythmic_grouping ret;
+ Real one_beat =a[0];
+ a.del(0);
+ svec<int> r;
+ for (int i= 0 ; i < a.sz(); i++)
+ r.add(a[i]);
+ Real here =0.0;
+ for (int i=0; i < r.sz(); i++) {
+ ret.divisions.add(here);
+ Real last = here;
+ here += one_beat * r[i];
+ Rhythmic_grouping *child =new Rhythmic_grouping(Interval(last, here));
+ child->split(r[i]);
+ ret.children.add(child);
+ }
+ ret.divisions.add(here);
+}
+
void
Simple_walker::do_INTERPRET_command(Command*com)
{
- if (com->args[0] == "BAR") {
+ svec<Scalar> args(com->args);
+ args.del(0);
+ if (com->args[0] == "GROUPING") {
+ default_grouping = parse_grouping(args);
+ }else if (com->args[0] == "BAR") {
local_key_.reset(key_);
+ current_grouping = default_grouping;
} else if (com->args[0] == "KEY") {
- svec<Scalar>s(com->args);
- s.del(0);
- if (com->when) {
+
+ if (col()->when()) {
assert(!oldkey_undo);
- oldkey_undo = new svec<int>( key_.oldkey_undo(s));
+ oldkey_undo = new svec<int>( key_.oldkey_undo(args));
}
- typesetkey = key_.read(s);
+ typesetkey = key_.read(args);
local_key_.reset(key_);
} else if (com->args[0] == "CLEF") {
- svec<Scalar>s(com->args);
- s.del(0);
- clef_.read(s);
+ clef_.read(args);
} else {
WARN << " ignoring INTERPRET command: " << com->args[0]<< '\n';
}
}
Spanner*
-Slur::broken_at(const PCol*l, const PCol*r) const
+Slur::broken_at(PCol*l, PCol*r) const
{
assert(l->line == r->line);
Slur*ret = new Slur(*this);
}
}
- for (PCursor<Command*> cc(*staff_commands_); cc.ok(); cc++) {
+ for (PCursor<Staff_commands_at*> cc(*staff_commands_); cc.ok(); cc++) {
Staff_column *sc=get_col(cc->when,false);
- sc->s_commands.add(cc);
+ for (PCursor<Command*> i(**cc); i.ok(); i++)
+ sc->s_commands.add(i);
}
}
#include "debug.hh"
#include "parseconstruct.hh"
-/*
- ARG!
- */
-
-/*
- maybe it's time for a "narrowing" cursor?
- */
-PCursor<Command*>
-Staff_commands::first(Real w)
+void
+Staff_commands_at::print() const
{
- PCursor<Command*> pc(*this);
- while (pc.ok() && pc->when < w)
- pc++;
- if (!pc.ok() || pc->when != w) {
- Command *c = new Command(w);
- c->priority = 10000;
- if (!pc.ok())
- pc.add(c);
- else
- pc.insert(c);
- }
-
- return pc;
+#ifndef NPRINT
+ PCursor<Command*> i (*this);
+ mtor << "Commands at: " << when<<"\n";
+
+ for (; i.ok(); i++)
+ i->print();
+#endif
}
-/*
- RETURN: pc->when == w && pc.ok
- */
-
-PCursor<Command*>
-Staff_commands::last_insertion(Real w)
-{
- PCursor<Command*> pc(first(w)), next(pc);
- while (next.ok() && next->when == w) {
- pc=next;
- next++;
- }
- if (pc->priority != -10000) {
- Command*c = new Command(w);
- c->priority = -10000;
- pc.add(c);
- pc++;
- }
-
- return pc;
+void
+Staff_commands_at::OK()const
+{
+ PCursor<Command*> i (*this);
+ for (; i.ok() && (i+1).ok(); i++)
+ if (!i->isbreak() && !(i+1)->isbreak())
+ assert(i->priority >= (i+1)->priority);
}
-/*
- */
-void
-Staff_commands::add_seq(svec<Command> com, bool checkbreak)
+Staff_commands_at::Staff_commands_at(Real r)
{
- if (!com.sz())
- return;
-
- Real when = com[0].when;
+ when = r;
+}
- PCursor<Command*> begin(first(when));
- PCursor<Command*> end(last_insertion(when));
- if (checkbreak && is_breakable(when)) {
- if (com[0].priority < 0)
- while (begin->code != BREAK_END)
- begin++;
- else
- while (end->code != BREAK_PRE)
- end--;
- }
- for (int i = 0; i < com.sz(); i++) {
- insert_between(com[i], begin, end);
+bool
+Staff_commands_at::is_breakable()
+{
+ PCursor<Command*> i(*this);
+ for (; i.ok(); i++) {
+ if (i->isbreak())
+ return true;
}
+ return false;
}
void
-Staff_commands::set_breakable(Real when)
+Staff_commands_at::set_breakable()
{
- bool found_typeset(false);
- PCursor<Command*> cc = first(when);
- for (; cc.ok() && cc->when == when; cc++) {
- if (cc->isbreak())
- return;
- if (cc->code == TYPESET)
- found_typeset=true;
- }
-
- assert(!found_typeset);
+ assert(!is_breakable());
- svec<Command> seq;
- Command k(when);
- k.priority = 5;
+ Command k;
k.code = BREAK_PRE;
- seq.add(k);
- k.priority = 4;
+ bottom().add(new Command(k));
k.code = BREAK_MIDDLE;
- seq.add(k);
- k.priority = 3;
+ bottom().add(new Command(k));
k.code = BREAK_POST;
- seq.add(k);
- k.priority = 2;
+ bottom().add(new Command(k));
k.code = BREAK_END;
- seq.add(k);
-
- add_seq(seq,false);
-}
-
-bool
-Staff_commands::is_breakable(Real w)
-{
- PCursor<Command*> cc = first(w);
- for (; cc.ok() && cc->when == w; cc++) {
- if (cc->isbreak())
- return true;
- }
- return false;
+ bottom().add(new Command(k));
}
void
-Staff_commands::insert_between(Command victim, PCursor<Command*> firstc,
- PCursor<Command*> last)
+Staff_commands_at::insert_between(Command victim, PCursor<Command*> firstc,
+ PCursor<Command*> last)
{
PCursor<Command*> c(firstc+1);
- assert(last->when==firstc->when&&firstc < last&&last.ok());
+ assert(firstc < last&&last.ok());
while (c < last) {
if (c->priority <= victim.priority) {
}
void
-Staff_commands::add_command_to_break(Command pre, Command mid, Command post)
+Staff_commands_at::add_command_to_break(Command pre, Command mid,Command post)
{
- Real w = pre.when;
- assert(w >= 0);
- PCursor<Command*> c ( first(w)), f(c), l(c);
+ assert(is_breakable());
+ PCursor<Command*> c ( *this), f(c), l(c);
while (!c->isbreak())
c++;
while (!c->isbreak())
c++;
l = c++;
- assert(l.ok() && l->when ==w && l->code == BREAK_END);
+ assert(l.ok() && l->code == BREAK_END);
insert_between(post, f, l);
}
-
+
void
-Staff_commands::process_add(Command c)
+Staff_commands_at::add(Command c)
{
bool encapsulate =false;
- Real w = c.when;
- assert(w >= 0);
-
- Command pre(w);
- Command mid(w);
- Command post(w);
+ Command pre;
+ Command mid;
+ Command post;
if (c.code == INTERPRET)
{ // UGH
if (c.args[0] == "BAR") {
- Command typeset(w); // kut met peren
+ Command typeset; // kut met peren
typeset.code = TYPESET;
typeset.args = c.args;
typeset.priority = 100;
- process_add(typeset);
+ add(typeset);
} else if (c.args[0] == "KEY") {
- Command typeset(w);
+ Command typeset;
typeset.code = TYPESET;
typeset.args.add("KEY");
typeset.priority = 70;
- process_add(typeset);
+ add(typeset);
} else if (c.args[0] == "CLEF") {
- Command typeset(w);
+ Command typeset;
typeset.code = TYPESET;
typeset.args=c.args;
typeset.priority = 90;
- process_add(typeset);
+ add(typeset);
} else if (c.args[0] == "METER") {
- Command typeset(w);
+ Command typeset;
typeset.code = TYPESET;
typeset.args=c.args;
typeset.priority = 40;
- process_add(typeset);
+ add(typeset);
return;
}
}
// kut en peer
if (c.code == TYPESET) {
+ encapsulate = is_breakable();
if (c.args[0] == "BAR") {
- set_breakable(w);
- encapsulate = true;
+ set_breakable();
+ encapsulate = true;
mid = c;
pre = c;
{ /* every line a currentkey. */
- Command kc(w);
+ Command kc;
kc.code =TYPESET;
kc.args.add( "CURRENTKEY");
kc.priority = 60;
- process_add(kc);
+ add(kc);
}
{ /* every line a currentclef. */
- Command kc(w);
+ Command kc;
kc.code =TYPESET;
kc.args.add( "CURRENTCLEF");
kc.priority = 80;
- process_add(kc);
+ add(kc);
}
- }else
- if (c.args[0] == "METER" && is_breakable(w)) {
- encapsulate = true;
+ }else if (c.args[0] == "METER" && is_breakable()) {
mid = c;
pre = c;
post =c;
}else
- if( c.args[0] == "KEY" && is_breakable(c.when)) {
- encapsulate = true;
+ if( c.args[0] == "KEY" && is_breakable()) {
+
mid = c;
pre = c;
post = c;
- }else
- if (c.args[0] == "CURRENTKEY" && is_breakable(w)) {
+ }else if (c.args[0] == "CURRENTKEY" && is_breakable() ){
post = c;
- encapsulate = true;
+
}else
- if (c.args[0] == "CURRENTCLEF" && is_breakable(w)) {
+ if (c.args[0] == "CURRENTCLEF" && is_breakable() ){
post = c;
- encapsulate = true;
+
}else
- if (c.args[0] == "CLEF" && is_breakable(w)) {
- encapsulate = true;
+ if (c.args[0] == "CLEF" && is_breakable()) {
+
post = c;
pre = c;
mid = c;
}
if (encapsulate)
- add_command_to_break(pre, mid, post);
+ add_command_to_break(pre, mid, post);
else {
- svec<Command> seq;
- seq.add(c);
- add_seq(seq,true);
+ bottom().add(new Command(c));
}
}
-/*
- first and last column should be breakable.
- Remove any command past the last musical column.
- */
+
+/****************************************************************/
+
void
-Staff_commands::clean(Real l)
+Staff_commands::OK() const
{
- assert(l>0);
- if (!is_breakable(0.0)) {
- Command c(0.0);
- c.code = TYPESET;
- c.args.add("BAR");
- c.args.add("empty");
- process_add(c);
+#ifndef NDEBUG
+ for (PCursor<Staff_commands_at*> i(*this); i.ok() && (i+1).ok(); i++) {
+ assert(i->when <= (i+1)->when);
+ i->OK();
+
}
-
- PCursor<Command*> bot(bottom());
+#endif
+}
- while (bot.ok() && bot->when > l) {
- mtor <<"removing ";
- bot->print();
- bot.del();
- bot = bottom();
+void
+Staff_commands::print() const
+{
+#ifndef NPRINT
+ for (PCursor<Staff_commands_at*> i(*this); i.ok() ; i++) {
+ i->print();
}
+#endif
+}
- if (!is_breakable(l)) {
- Command c(l);
- c.code = TYPESET;
- c.args.add("BAR");
- c.args.add("||");
- process_add(c);
+Staff_commands_at*
+Staff_commands::find(Real w)
+{
+ PCursor<Staff_commands_at*> i(bottom());
+ for (; i.ok() ; i--) {
+ if (i->when == w)
+ return i;
+ if (i->when < w)
+ break;
+ }
+ Staff_commands_at*p =new Staff_commands_at(w);
+ if (!i.ok())
+ i.insert(p);
+ else {
+ i.add(p);
+ i++;
}
- OK();
+ return i;
}
void
-Staff_commands::OK() const
+Staff_commands::add(Command c, Real when)
{
- for (PCursor<Command*> cc(*this); cc.ok() && (cc+1).ok(); cc++) {
- assert(cc->when <= (cc+1)->when);
- if (cc->when == (cc+1)->when && !cc->isbreak() && !(cc+1)->isbreak())
- assert(cc->priority >= (cc+1)->priority);
- }
+ Staff_commands_at* p = find(when);
+ p->add(c);
}
void
-Staff_commands::print() const
+Staff_commands::clean(Real l)
{
-#ifndef NPRINT
- for (PCursor<Command*> cc(*this); cc.ok() ; cc++) {
- cc->print();
+ PCursor<Staff_commands_at*> i(bottom());
+ for (; i->when > l ; i=bottom()) {
+ remove(i);
+ }
+ Staff_commands_at*p = find(l);
+
+ if (!p->is_breakable()) {
+ p->set_breakable();
+/* Command b;
+ b.code = INTERPRET;
+ b.args.add("BAR");*/
}
-#endif
}
pstaff_=st;
- const PCol *linestart = sc->cols.top();
- const PCol *linestop = sc->cols.bottom();
+ PCol *linestart = sc->cols.top();
+ PCol *linestop = sc->cols.bottom();
for (PCursor<const Spanner*> sp(pstaff_->spans); sp.ok(); sp++) {
- const PCol *brokenstart = &MAX(*linestart, *sp->left);
- const PCol *brokenstop = &MIN(*linestop, *sp->right);
+ PCol *brokenstart = &MAX(*linestart, *sp->left);
+ PCol *brokenstop = &MIN(*linestop, *sp->right);
if ( *brokenstart < *brokenstop) {
line_of_score_->pscore_-> // higghl
add_broken(sp->broken_at(brokenstart,brokenstop));
IPL_instantiate(Input_command);
IPL_instantiate(Commands_at);
IPL_instantiate(Input_staff);
+IPL_instantiate(Input_music);
}
default_table = symboltables { table_sixteen }
-notenames { dutch_names }
\ No newline at end of file
+notenames { dutch_names }