From 4fac7cb7f554ad08c06225c985c7ddbcee1006dc Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Tue, 29 Oct 1996 00:49:49 +0100 Subject: [PATCH] release: 0.0.3 --- .dstreamrc | 15 ++ COPYING | 339 ++++++++++++++++++++++++++++++++++++ Makefile | 43 +++-- Sources.make | 22 +-- boxes.cc | 3 +- break.cc | 2 +- choleski.cc | 95 ---------- choleski.hh | 46 ----- cols.cc | 9 +- const.hh | 6 +- debug.cc | 19 +- debug.hh | 2 +- depend | 245 +++++++++++++------------- dimen.tex | 49 ++++++ dstream.cc | 108 ------------ dstream.hh | 37 ---- flower/Makefile | 7 +- flower/Sources.make | 2 +- flower/TODO | 4 - flower/compare.hh | 21 ++- flower/cursor.cc | 26 ++- flower/cursor.hh | 45 +++-- flower/pcursor.hh | 26 +++ globvars.hh | 2 +- identifier.cc | 22 +++ keyword.hh | 8 +- lexer.l | 34 ++-- lilyponddefs.tex | 19 +- line.cc | 7 +- linespace.cc | 14 +- maartje.ly | 19 ++ main.cc | 51 ++++-- main.hh | 8 + make_patch | 14 +- matrix.cc | 281 ------------------------------ matrix.hh | 141 --------------- misc.hh | 2 +- molecule.cc | 8 +- molecule.hh | 4 +- note.cc | 18 +- parser.y | 21 ++- pscore.cc | 13 +- qlp.cc | 21 ++- qlpsolve.cc | 1 + real.hh | 25 --- score.cc | 144 +++++++++------ score.hh | 4 + scores.cc | 29 +++ smat.cc | 187 -------------------- smat.hh | 93 ---------- staff.cc | 13 +- symbol.ini | 21 ++- symtable.cc | 27 ++- symtable.hh | 2 +- table.cc | 10 +- template.cc => template1.cc | 6 - template2.cc | 8 +- template3.cc | 11 ++ tstream.cc | 13 +- tstream.hh | 2 +- vector.cc | 41 ----- vector.hh | 106 ----------- version.cc | 2 +- vsmat.hh | 141 --------------- 64 files changed, 1092 insertions(+), 1672 deletions(-) create mode 100644 .dstreamrc create mode 100644 COPYING delete mode 100644 choleski.cc delete mode 100644 choleski.hh create mode 100644 dimen.tex delete mode 100644 dstream.cc delete mode 100644 dstream.hh create mode 100644 flower/pcursor.hh create mode 100644 identifier.cc create mode 100644 maartje.ly create mode 100644 main.hh delete mode 100644 matrix.cc delete mode 100644 matrix.hh delete mode 100644 real.hh create mode 100644 scores.cc delete mode 100644 smat.cc delete mode 100644 smat.hh rename template.cc => template1.cc (74%) create mode 100644 template3.cc delete mode 100644 vector.cc delete mode 100644 vector.hh delete mode 100644 vsmat.hh diff --git a/.dstreamrc b/.dstreamrc new file mode 100644 index 0000000000..ec6e96fabc --- /dev/null +++ b/.dstreamrc @@ -0,0 +1,15 @@ +#class name silence? + +yyFlexLexer 1 +PCol 1 +Score 1 +Score_column 1 +Ineq_constrained_qp 1 +Spacing_problem 1 +Colinfo 1 +Mixed_qp 1 +PScore 1 +Parser 1 +Lexer 1 +parse_duration 1 +parse_pitch 1 \ No newline at end of file diff --git a/COPYING b/COPYING new file mode 100644 index 0000000000..a43ea2126f --- /dev/null +++ b/COPYING @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 675 Mass Ave, Cambridge, MA 02139, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + 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 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. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/Makefile b/Makefile index 71217f39b1..38b71b9bbb 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ MAJVER=0 MINVER=0 -PATCHLEVEL=2 +PATCHLEVEL=3 # # @@ -9,7 +9,7 @@ include Sources.make progdocs=$(hdr) $(mycc) gencc=parser.cc lexer.cc cc=$(mycc) $(gencc) -obs=$(cc:.cc=.o) +obs=$(cc:.cc=.o) #dist @@ -20,27 +20,28 @@ PACKAGENAME=lilypond DNAME=$(PACKAGENAME)-$(VERSION) othersrc=lexer.l parser.y SCRIPTS=make_version make_patch -IFILES= symbol.ini suzan.ly lilyponddefs.tex test.tex .dstreamrc +IFILES=dimen.tex symbol.ini suzan.ly maartje.ly lilyponddefs.tex test.tex .dstreamrc OFILES=Makefile Sources.make depend -DFILES=$(hdr) $(mycc) $(othersrc) $(OFILES) $(IFILES) $(SCRIPTS) +DFILES=$(hdr) $(mycc) $(othersrc) $(OFILES) $(IFILES) $(SCRIPTS) COPYING #compiling LOADLIBES=-L$(FLOWERDIR) -lflower FLOWERDIR=../flower -CXXFLAGS=-I$(FLOWERDIR) -pipe -Wall -g +#DEFINES=-DNDEBUG +CXXFLAGS=$(DEFINES) -I$(FLOWERDIR) -pipe -Wall -g exe=$(PACKAGENAME) - +################################################################## $(exe): $(obs) - $(CXX) -o $(exe) $(obs) $(LOADLIBES) + $(CXX) -o $@ $(obs) $(LOADLIBES) clean: - rm -f $(exe) *.o $(DOCDIR)/* core + rm -f $(exe) *.o $(DOCDIR)/* core + +distclean: clean + rm -f TAGS depend version.hh $(gencc) .GENERATE *~ -realclean: clean - rm -f TAGS depend - all: kompijl doc # doc++ documentation of classes @@ -48,11 +49,15 @@ doc: -mkdir $(DOCDIR) doc++ -p -I -d $(DOCDIR) $(progdocs) -back: - zip -u ~/backs/spacer *cc *hh +depend: Sources.make .GENERATE + $(CXX) $(CXXFLAGS) -MM $(cc) > $@ -depend: Sources.make - $(CXX) $(CXXFLAGS) -MM $(cc) > depend +# hack to create these sources once, before the dependencies +.GENERATE: + touch .GENERATE depend + $(MAKE) version.hh + $(MAKE) $(gencc) + rm -f depend include depend @@ -66,18 +71,20 @@ parser.hh: parser.cc version.o: $(obs) version.hh version.hh: Makefile make_version - make_version $(MAJVER) $(MINVER) $(PATCHLEVEL) > version.hh + make_version $(MAJVER) $(MINVER) $(PATCHLEVEL) > $@ lexer.cc: lexer.l - flex -+ -t lexer.l > lexer.cc + flex -+ -t $< > $@ DDIR=$(DNAME) dist: -mkdir $(DDIR) ln $(DFILES) $(DDIR)/ - tar cfz $(DNAME).tar.gz $(DDIR)/* + tar cfz $(DNAME).tar.gz $(DDIR)/ rm -rf $(DDIR)/ TAGS: $(mycc) $(hdr) Sources.make etags -CT $(mycc) $(hdr) + + diff --git a/Sources.make b/Sources.make index 4e7949f081..54ff23ac29 100644 --- a/Sources.make +++ b/Sources.make @@ -1,20 +1,22 @@ -hdr=matrix.hh qlp.hh smat.hh vsmat.hh\ - linespace.hh qlpsolve.hh vector.hh\ +hdr= qlp.hh \ + linespace.hh qlpsolve.hh\ cols.hh proto.hh pstaff.hh line.hh\ const.hh glob.hh molecule.hh boxes.hh pscore.hh item.hh tex.hh\ request.hh voice.hh command.hh staff.hh linestaff.hh \ - tstream.hh dstream.hh mtime.hh rhythmstaf.hh\ - parseconstruct.hh real.hh debug.hh globvars.hh keyword.hh\ + tstream.hh mtime.hh rhythmstaf.hh\ + parseconstruct.hh debug.hh globvars.hh keyword.hh\ misc.hh score.hh notename.hh lexer.hh symtable.hh\ - choleski.hh symbol.hh + symbol.hh main.hh -mycc=smat.cc matrix.cc choleski.cc qlp.cc qlpsolve.cc \ +mycc= qlp.cc qlpsolve.cc \ break.cc linespace.cc molecule.cc line.cc\ pscore.cc tex.cc item.cc cols.cc staff.cc rhythmstaf.cc\ - score.cc note.cc dstream.cc main.cc misc.cc \ + score.cc note.cc main.cc misc.cc \ symbol.cc request.cc notename.cc voice.cc\ keyword.cc linestaff.cc table.cc command.cc\ warn.cc debug.cc symtable.cc boxes.cc\ - pstaff.cc vector.cc tstream.cc version.cc\ - calcideal.cc\ - template.cc template2.cc + pstaff.cc tstream.cc version.cc\ + calcideal.cc scores.cc identifier.cc \ + template1.cc template2.cc template3.cc + + diff --git a/boxes.cc b/boxes.cc index 3965a0659e..e55af6c6f5 100644 --- a/boxes.cc +++ b/boxes.cc @@ -17,8 +17,7 @@ Box::Box(svec s) } Box::Box() -{ - +{ } Box::Box(Interval ix, Interval iy) { diff --git a/break.cc b/break.cc index 0647d5f3e2..9eb55cc9f7 100644 --- a/break.cc +++ b/break.cc @@ -13,7 +13,7 @@ svec PScore::solve_line(svec curline) const { Spacing_problem sp; - // mtor << "line of " << curline.sz() << " cols\n"; + mtor << "line of " << curline.sz() << " cols\n"; sp.add_column(curline[0], true, 0.0); for (int i=1; i< curline.sz()-1; i++) sp.add_column(curline[i]); diff --git a/choleski.cc b/choleski.cc deleted file mode 100644 index 2d8c68aa66..0000000000 --- a/choleski.cc +++ /dev/null @@ -1,95 +0,0 @@ -#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= 0 && left && right); +#endif } Interval @@ -31,6 +33,7 @@ int PCol::compare(const PCol &c1, const PCol &c2) { assert(false); + return 0 ; } void @@ -64,8 +67,10 @@ PCol::PCol(PCol *parent) { PCol::~PCol() { - delete prebreak; - delete postbreak; + if (prebreak) + delete prebreak; // no recursion! + if (postbreak) + delete postbreak; } void diff --git a/const.hh b/const.hh index bc9d17147f..38e464c382 100644 --- a/const.hh +++ b/const.hh @@ -1,8 +1,11 @@ /* global constants */ - +#ifndef CONST_HH +#define CONST_HH #include +#include "real.hh" + const Real CM_TO_PT=72/2.54; const Real VERT_TO_PT=CM_TO_PT; // tex output const Real HOR_TO_PT=CM_TO_PT; // tex output @@ -10,3 +13,4 @@ const Real HOR_TO_PT=CM_TO_PT; // tex output const Real EPS=1e-7; // qlpsolve.hh const int MAXITER=100; // qlpsolve.hh const Real INFTY=HUGE; +#endif diff --git a/debug.cc b/debug.cc index 69c5a04a5b..874937573e 100644 --- a/debug.cc +++ b/debug.cc @@ -1,18 +1,11 @@ #include "debug.hh" #include "dstream.hh" -int debug_flags; +#include "vector.hh" + +Dstream monitor(&cout,".dstreamrc"); void -set_debug(String s) +debug_init() { - if (s.pos ('t')) { - debug_flags |= DEBUGTOKEN; - mtor << " Turning on token debug\n"; - } - if (s.pos ('p')){ - debug_flags |= DEBUGPARSER; - mtor << "Turning on parser debugger\n"; - } -} - -Dstream monitor(cout,".dstreamrc"); + set_matrix_debug(monitor); +} diff --git a/debug.hh b/debug.hh index cf2c4ada52..ae75b77fa1 100644 --- a/debug.hh +++ b/debug.hh @@ -6,7 +6,7 @@ -#define WARN warnout << "warning: "<<__FUNCTION__ << ": " +#define WARN warnout << "warning: "<<__FUNCTION__ << "(): " extern ostream &warnout ; extern ostream *mlog; extern Dstream monitor; // monitor diff --git a/depend b/depend index 1bc847e241..3c3bccbdb5 100644 --- a/depend +++ b/depend @@ -1,183 +1,192 @@ -smat.o: smat.cc smat.hh ../flower/vray.hh vsmat.hh real.hh -matrix.o: matrix.cc matrix.hh vsmat.hh ../flower/vray.hh real.hh \ - vector.hh glob.hh proto.hh const.hh ../flower/string.hh \ - ../flower/stringutil.hh debug.hh dstream.hh ../flower/assoc.hh -choleski.o: choleski.cc choleski.hh matrix.hh vsmat.hh \ - ../flower/vray.hh real.hh vector.hh glob.hh proto.hh const.hh -qlp.o: qlp.cc debug.hh dstream.hh ../flower/string.hh \ - ../flower/stringutil.hh ../flower/assoc.hh ../flower/vray.hh qlp.hh \ - matrix.hh vsmat.hh real.hh vector.hh glob.hh proto.hh const.hh \ - choleski.hh -qlpsolve.o: qlpsolve.cc qlpsolve.hh qlp.hh matrix.hh vsmat.hh \ - ../flower/vray.hh real.hh vector.hh glob.hh proto.hh const.hh \ - debug.hh dstream.hh ../flower/string.hh ../flower/stringutil.hh \ - ../flower/assoc.hh choleski.hh -break.o: break.cc linespace.hh glob.hh real.hh proto.hh const.hh \ - ../flower/list.hh ../flower/list.inl ../flower/cursor.hh \ - ../flower/link.hh ../flower/link.inl ../flower/cursor.inl \ - ../flower/vray.hh cols.hh boxes.hh ../flower/textdb.hh \ - ../flower/textstr.hh ../flower/string.hh ../flower/stringutil.hh \ - item.hh tex.hh ../flower/compare.hh matrix.hh vsmat.hh vector.hh \ - debug.hh dstream.hh ../flower/assoc.hh line.hh pstaff.hh pscore.hh -linespace.o: linespace.cc linespace.hh glob.hh real.hh proto.hh \ +qlp.o: qlp.cc debug.hh ../flower/dstream.hh ../flower/string.hh \ + ../flower/stringutil.hh ../flower/assoc.hh ../flower/vray.hh const.hh \ + ../flower/real.hh qlp.hh ../flower/matrix.hh ../flower/vsmat.hh \ + ../flower/vector.hh ../flower/choleski.hh +qlpsolve.o: qlpsolve.cc qlpsolve.hh qlp.hh ../flower/matrix.hh \ + ../flower/vsmat.hh ../flower/vray.hh ../flower/real.hh \ + ../flower/vector.hh const.hh debug.hh ../flower/dstream.hh \ + ../flower/string.hh ../flower/stringutil.hh ../flower/assoc.hh \ + ../flower/choleski.hh +break.o: break.cc linespace.hh glob.hh ../flower/real.hh proto.hh \ const.hh ../flower/list.hh ../flower/list.inl ../flower/cursor.hh \ ../flower/link.hh ../flower/link.inl ../flower/cursor.inl \ ../flower/vray.hh cols.hh boxes.hh ../flower/textdb.hh \ ../flower/textstr.hh ../flower/string.hh ../flower/stringutil.hh \ - item.hh tex.hh ../flower/compare.hh matrix.hh vsmat.hh vector.hh \ - debug.hh dstream.hh ../flower/assoc.hh qlp.hh ../flower/unionfind.hh -molecule.o: molecule.cc glob.hh real.hh proto.hh const.hh \ + item.hh tex.hh ../flower/compare.hh ../flower/matrix.hh \ + ../flower/vsmat.hh ../flower/vector.hh debug.hh ../flower/dstream.hh \ + ../flower/assoc.hh line.hh pstaff.hh pscore.hh +linespace.o: linespace.cc linespace.hh glob.hh ../flower/real.hh \ + proto.hh const.hh ../flower/list.hh ../flower/list.inl \ + ../flower/cursor.hh ../flower/link.hh ../flower/link.inl \ + ../flower/cursor.inl ../flower/vray.hh cols.hh boxes.hh \ + ../flower/textdb.hh ../flower/textstr.hh ../flower/string.hh \ + ../flower/stringutil.hh item.hh tex.hh ../flower/compare.hh \ + ../flower/matrix.hh ../flower/vsmat.hh ../flower/vector.hh debug.hh \ + ../flower/dstream.hh ../flower/assoc.hh qlp.hh ../flower/unionfind.hh +molecule.o: molecule.cc glob.hh ../flower/real.hh proto.hh const.hh \ ../flower/string.hh ../flower/stringutil.hh molecule.hh \ ../flower/list.hh ../flower/list.inl ../flower/cursor.hh \ ../flower/link.hh ../flower/link.inl ../flower/cursor.inl boxes.hh \ ../flower/textdb.hh ../flower/textstr.hh ../flower/vray.hh item.hh \ tex.hh symbol.hh -line.o: line.cc line.hh real.hh ../flower/list.hh ../flower/list.inl \ - ../flower/cursor.hh ../flower/link.hh ../flower/link.inl \ - ../flower/cursor.inl ../flower/vray.hh glob.hh proto.hh const.hh \ - pstaff.hh item.hh boxes.hh ../flower/textdb.hh ../flower/textstr.hh \ - ../flower/string.hh ../flower/stringutil.hh tex.hh symbol.hh cols.hh \ - ../flower/compare.hh pscore.hh -pscore.o: pscore.cc debug.hh dstream.hh ../flower/string.hh \ - ../flower/stringutil.hh ../flower/assoc.hh ../flower/vray.hh line.hh \ - real.hh ../flower/list.hh ../flower/list.inl ../flower/cursor.hh \ - ../flower/link.hh ../flower/link.inl ../flower/cursor.inl glob.hh \ +line.o: line.cc line.hh ../flower/real.hh ../flower/list.hh \ + ../flower/list.inl ../flower/cursor.hh ../flower/link.hh \ + ../flower/link.inl ../flower/cursor.inl ../flower/vray.hh glob.hh \ proto.hh const.hh pstaff.hh item.hh boxes.hh ../flower/textdb.hh \ - ../flower/textstr.hh tex.hh pscore.hh cols.hh ../flower/compare.hh \ - tstream.hh + ../flower/textstr.hh ../flower/string.hh ../flower/stringutil.hh \ + tex.hh symbol.hh cols.hh ../flower/compare.hh pscore.hh +pscore.o: pscore.cc debug.hh ../flower/dstream.hh ../flower/string.hh \ + ../flower/stringutil.hh ../flower/assoc.hh ../flower/vray.hh line.hh \ + ../flower/real.hh ../flower/list.hh ../flower/list.inl \ + ../flower/cursor.hh ../flower/link.hh ../flower/link.inl \ + ../flower/cursor.inl glob.hh proto.hh const.hh pstaff.hh item.hh \ + boxes.hh ../flower/textdb.hh ../flower/textstr.hh tex.hh pscore.hh \ + cols.hh ../flower/compare.hh tstream.hh tex.o: tex.cc tex.hh ../flower/string.hh ../flower/stringutil.hh \ boxes.hh ../flower/textdb.hh ../flower/textstr.hh ../flower/vray.hh \ - real.hh symbol.hh const.hh -item.o: item.cc line.hh real.hh ../flower/list.hh ../flower/list.inl \ - ../flower/cursor.hh ../flower/link.hh ../flower/link.inl \ - ../flower/cursor.inl ../flower/vray.hh glob.hh proto.hh const.hh \ - pstaff.hh item.hh boxes.hh ../flower/textdb.hh ../flower/textstr.hh \ - ../flower/string.hh ../flower/stringutil.hh tex.hh symbol.hh cols.hh \ - ../flower/compare.hh -cols.o: cols.cc cols.hh glob.hh real.hh proto.hh const.hh boxes.hh \ - ../flower/textdb.hh ../flower/textstr.hh ../flower/string.hh \ + ../flower/real.hh symbol.hh const.hh +item.o: item.cc line.hh ../flower/real.hh ../flower/list.hh \ + ../flower/list.inl ../flower/cursor.hh ../flower/link.hh \ + ../flower/link.inl ../flower/cursor.inl ../flower/vray.hh glob.hh \ + proto.hh const.hh pstaff.hh item.hh boxes.hh ../flower/textdb.hh \ + ../flower/textstr.hh ../flower/string.hh ../flower/stringutil.hh \ + tex.hh symbol.hh cols.hh ../flower/compare.hh +cols.o: cols.cc cols.hh glob.hh ../flower/real.hh proto.hh const.hh \ + boxes.hh ../flower/textdb.hh ../flower/textstr.hh ../flower/string.hh \ ../flower/stringutil.hh ../flower/vray.hh ../flower/list.hh \ ../flower/list.inl ../flower/cursor.hh ../flower/link.hh \ ../flower/link.inl ../flower/cursor.inl item.hh tex.hh \ ../flower/compare.hh pstaff.hh staff.o: staff.cc staff.hh score.hh ../flower/vray.hh cols.hh glob.hh \ - real.hh proto.hh const.hh boxes.hh ../flower/textdb.hh \ + ../flower/real.hh proto.hh const.hh boxes.hh ../flower/textdb.hh \ ../flower/textstr.hh ../flower/string.hh ../flower/stringutil.hh \ ../flower/list.hh ../flower/list.inl ../flower/cursor.hh \ ../flower/link.hh ../flower/link.inl ../flower/cursor.inl item.hh \ tex.hh ../flower/compare.hh mtime.hh command.hh voice.hh request.hh \ - debug.hh dstream.hh ../flower/assoc.hh pscore.hh pstaff.hh -rhythmstaf.o: rhythmstaf.cc request.hh glob.hh real.hh proto.hh \ - const.hh ../flower/string.hh ../flower/stringutil.hh mtime.hh \ - debug.hh dstream.hh ../flower/assoc.hh ../flower/vray.hh linestaff.hh \ - pstaff.hh ../flower/list.hh ../flower/list.inl ../flower/cursor.hh \ - ../flower/link.hh ../flower/link.inl ../flower/cursor.inl item.hh \ - boxes.hh ../flower/textdb.hh ../flower/textstr.hh tex.hh staff.hh \ - score.hh cols.hh ../flower/compare.hh command.hh voice.hh pscore.hh \ + debug.hh ../flower/dstream.hh ../flower/assoc.hh pscore.hh pstaff.hh +rhythmstaf.o: rhythmstaf.cc request.hh glob.hh ../flower/real.hh \ + proto.hh const.hh ../flower/string.hh ../flower/stringutil.hh \ + mtime.hh debug.hh ../flower/dstream.hh ../flower/assoc.hh \ + ../flower/vray.hh linestaff.hh pstaff.hh ../flower/list.hh \ + ../flower/list.inl ../flower/cursor.hh ../flower/link.hh \ + ../flower/link.inl ../flower/cursor.inl item.hh boxes.hh \ + ../flower/textdb.hh ../flower/textstr.hh tex.hh staff.hh score.hh \ + cols.hh ../flower/compare.hh command.hh voice.hh pscore.hh \ molecule.hh rhythmstaf.hh symbol.hh score.o: score.cc tstream.hh ../flower/string.hh \ ../flower/stringutil.hh score.hh ../flower/vray.hh cols.hh glob.hh \ - real.hh proto.hh const.hh boxes.hh ../flower/textdb.hh \ + ../flower/real.hh proto.hh const.hh boxes.hh ../flower/textdb.hh \ ../flower/textstr.hh ../flower/list.hh ../flower/list.inl \ ../flower/cursor.hh ../flower/link.hh ../flower/link.inl \ ../flower/cursor.inl item.hh tex.hh ../flower/compare.hh mtime.hh \ command.hh pscore.hh pstaff.hh staff.hh voice.hh request.hh misc.hh \ - debug.hh dstream.hh ../flower/assoc.hh -note.o: note.cc ../flower/string.hh ../flower/stringutil.hh real.hh \ - debug.hh dstream.hh ../flower/assoc.hh ../flower/vray.hh request.hh \ - glob.hh proto.hh const.hh mtime.hh voice.hh ../flower/list.hh \ - ../flower/list.inl ../flower/cursor.hh ../flower/link.hh \ - ../flower/link.inl ../flower/cursor.inl notename.hh -dstream.o: dstream.cc dstream.hh ../flower/string.hh \ - ../flower/stringutil.hh ../flower/assoc.hh ../flower/vray.hh \ - ../flower/textdb.hh ../flower/textstr.hh -main.o: main.cc ../flower/lgetopt.hh misc.hh mtime.hh real.hh debug.hh \ - dstream.hh ../flower/string.hh ../flower/stringutil.hh \ - ../flower/assoc.hh ../flower/vray.hh score.hh cols.hh glob.hh \ - proto.hh const.hh boxes.hh ../flower/textdb.hh ../flower/textstr.hh \ - ../flower/list.hh ../flower/list.inl ../flower/cursor.hh \ - ../flower/link.hh ../flower/link.inl ../flower/cursor.inl item.hh \ - tex.hh ../flower/compare.hh command.hh globvars.hh -misc.o: misc.cc misc.hh mtime.hh real.hh glob.hh proto.hh const.hh + debug.hh ../flower/dstream.hh ../flower/assoc.hh +note.o: note.cc ../flower/string.hh ../flower/stringutil.hh \ + ../flower/real.hh debug.hh ../flower/dstream.hh ../flower/assoc.hh \ + ../flower/vray.hh request.hh glob.hh proto.hh const.hh mtime.hh \ + voice.hh ../flower/list.hh ../flower/list.inl ../flower/cursor.hh \ + ../flower/link.hh ../flower/link.inl ../flower/cursor.inl notename.hh +main.o: main.cc ../flower/lgetopt.hh misc.hh mtime.hh \ + ../flower/real.hh ../flower/string.hh ../flower/stringutil.hh main.hh \ + proto.hh +misc.o: misc.cc misc.hh mtime.hh ../flower/real.hh glob.hh proto.hh \ + const.hh symbol.o: symbol.cc symbol.hh ../flower/string.hh \ ../flower/stringutil.hh boxes.hh ../flower/textdb.hh \ - ../flower/textstr.hh ../flower/vray.hh real.hh -request.o: request.cc request.hh glob.hh real.hh proto.hh const.hh \ - ../flower/string.hh ../flower/stringutil.hh mtime.hh -notename.o: notename.cc glob.hh real.hh proto.hh const.hh \ + ../flower/textstr.hh ../flower/vray.hh ../flower/real.hh +request.o: request.cc request.hh glob.hh ../flower/real.hh proto.hh \ + const.hh ../flower/string.hh ../flower/stringutil.hh mtime.hh +notename.o: notename.cc glob.hh ../flower/real.hh proto.hh const.hh \ ../flower/string.hh ../flower/stringutil.hh -voice.o: voice.cc debug.hh dstream.hh ../flower/string.hh \ +voice.o: voice.cc debug.hh ../flower/dstream.hh ../flower/string.hh \ ../flower/stringutil.hh ../flower/assoc.hh ../flower/vray.hh voice.hh \ - mtime.hh real.hh ../flower/list.hh ../flower/list.inl \ + mtime.hh ../flower/real.hh ../flower/list.hh ../flower/list.inl \ ../flower/cursor.hh ../flower/link.hh ../flower/link.inl \ ../flower/cursor.inl request.hh glob.hh proto.hh const.hh -keyword.o: keyword.cc glob.hh real.hh proto.hh const.hh lexer.hh +keyword.o: keyword.cc glob.hh ../flower/real.hh proto.hh const.hh \ + lexer.hh linestaff.o: linestaff.cc linestaff.hh pstaff.hh ../flower/list.hh \ ../flower/list.inl ../flower/cursor.hh ../flower/link.hh \ - ../flower/link.inl ../flower/cursor.inl item.hh glob.hh real.hh \ - proto.hh const.hh boxes.hh ../flower/textdb.hh ../flower/textstr.hh \ - ../flower/string.hh ../flower/stringutil.hh ../flower/vray.hh tex.hh \ - symbol.hh -table.o: table.cc glob.hh real.hh proto.hh const.hh \ - ../flower/string.hh ../flower/stringutil.hh keyword.hh parser.hh + ../flower/link.inl ../flower/cursor.inl item.hh glob.hh \ + ../flower/real.hh proto.hh const.hh boxes.hh ../flower/textdb.hh \ + ../flower/textstr.hh ../flower/string.hh ../flower/stringutil.hh \ + ../flower/vray.hh tex.hh symbol.hh +table.o: table.cc glob.hh ../flower/real.hh proto.hh const.hh debug.hh \ + ../flower/dstream.hh ../flower/string.hh ../flower/stringutil.hh \ + ../flower/assoc.hh ../flower/vray.hh keyword.hh parser.hh command.o: command.cc ../flower/string.hh ../flower/stringutil.hh \ - command.hh glob.hh real.hh proto.hh const.hh mtime.hh \ + command.hh glob.hh ../flower/real.hh proto.hh const.hh mtime.hh \ ../flower/vray.hh -warn.o: warn.cc debug.hh dstream.hh ../flower/string.hh \ - ../flower/stringutil.hh ../flower/assoc.hh ../flower/vray.hh -debug.o: debug.cc debug.hh dstream.hh ../flower/string.hh \ +warn.o: warn.cc debug.hh ../flower/dstream.hh ../flower/string.hh \ ../flower/stringutil.hh ../flower/assoc.hh ../flower/vray.hh -symtable.o: symtable.cc misc.hh mtime.hh real.hh debug.hh dstream.hh \ - ../flower/string.hh ../flower/stringutil.hh ../flower/assoc.hh \ - ../flower/vray.hh symbol.hh boxes.hh ../flower/textdb.hh \ - ../flower/textstr.hh symtable.hh const.hh +debug.o: debug.cc debug.hh ../flower/dstream.hh ../flower/string.hh \ + ../flower/stringutil.hh ../flower/assoc.hh ../flower/vray.hh \ + ../flower/vector.hh ../flower/real.hh +symtable.o: symtable.cc misc.hh mtime.hh ../flower/real.hh debug.hh \ + ../flower/dstream.hh ../flower/string.hh ../flower/stringutil.hh \ + ../flower/assoc.hh ../flower/vray.hh symbol.hh boxes.hh \ + ../flower/textdb.hh ../flower/textstr.hh symtable.hh const.hh boxes.o: boxes.cc boxes.hh ../flower/textdb.hh ../flower/textstr.hh \ - ../flower/string.hh ../flower/stringutil.hh ../flower/vray.hh real.hh \ - const.hh + ../flower/string.hh ../flower/stringutil.hh ../flower/vray.hh \ + ../flower/real.hh const.hh pstaff.o: pstaff.cc pstaff.hh ../flower/list.hh ../flower/list.inl \ ../flower/cursor.hh ../flower/link.hh ../flower/link.inl \ - ../flower/cursor.inl item.hh glob.hh real.hh proto.hh const.hh \ - boxes.hh ../flower/textdb.hh ../flower/textstr.hh ../flower/string.hh \ - ../flower/stringutil.hh ../flower/vray.hh tex.hh -vector.o: vector.cc debug.hh dstream.hh ../flower/string.hh \ - ../flower/stringutil.hh ../flower/assoc.hh ../flower/vray.hh \ - vector.hh glob.hh real.hh proto.hh const.hh + ../flower/cursor.inl item.hh glob.hh ../flower/real.hh proto.hh \ + const.hh boxes.hh ../flower/textdb.hh ../flower/textstr.hh \ + ../flower/string.hh ../flower/stringutil.hh ../flower/vray.hh tex.hh tstream.o: tstream.cc tex.hh ../flower/string.hh \ ../flower/stringutil.hh boxes.hh ../flower/textdb.hh \ - ../flower/textstr.hh ../flower/vray.hh real.hh tstream.hh debug.hh \ - dstream.hh ../flower/assoc.hh + ../flower/textstr.hh ../flower/vray.hh ../flower/real.hh misc.hh \ + mtime.hh tstream.hh debug.hh ../flower/dstream.hh ../flower/assoc.hh version.o: version.cc version.hh calcideal.o: calcideal.cc tstream.hh ../flower/string.hh \ ../flower/stringutil.hh score.hh ../flower/vray.hh cols.hh glob.hh \ - real.hh proto.hh const.hh boxes.hh ../flower/textdb.hh \ + ../flower/real.hh proto.hh const.hh boxes.hh ../flower/textdb.hh \ ../flower/textstr.hh ../flower/list.hh ../flower/list.inl \ ../flower/cursor.hh ../flower/link.hh ../flower/link.inl \ ../flower/cursor.inl item.hh tex.hh ../flower/compare.hh mtime.hh \ command.hh pscore.hh pstaff.hh staff.hh voice.hh request.hh misc.hh \ - debug.hh dstream.hh ../flower/assoc.hh -template.o: template.cc line.hh real.hh ../flower/list.hh \ + debug.hh ../flower/dstream.hh ../flower/assoc.hh +scores.o: scores.cc main.hh proto.hh ../flower/real.hh score.hh \ + ../flower/vray.hh cols.hh glob.hh const.hh boxes.hh \ + ../flower/textdb.hh ../flower/textstr.hh ../flower/string.hh \ + ../flower/stringutil.hh ../flower/list.hh ../flower/list.inl \ + ../flower/cursor.hh ../flower/link.hh ../flower/link.inl \ + ../flower/cursor.inl item.hh tex.hh ../flower/compare.hh mtime.hh \ + command.hh +identifier.o: identifier.cc keyword.hh lexer.hh proto.hh \ + ../flower/real.hh parser.hh +template1.o: template1.cc line.hh ../flower/real.hh ../flower/list.hh \ ../flower/list.inl ../flower/cursor.hh ../flower/link.hh \ ../flower/link.inl ../flower/cursor.inl ../flower/vray.hh glob.hh \ proto.hh const.hh pstaff.hh item.hh boxes.hh ../flower/textdb.hh \ ../flower/textstr.hh ../flower/string.hh ../flower/stringutil.hh \ - tex.hh cols.hh ../flower/compare.hh request.hh mtime.hh score.hh \ - command.hh staff.hh voice.hh ../flower/list.cc ../flower/cursor.cc -template2.o: template2.cc line.hh real.hh ../flower/list.hh \ + tex.hh cols.hh ../flower/compare.hh request.hh mtime.hh command.hh \ + ../flower/list.cc ../flower/cursor.cc +template2.o: template2.cc line.hh ../flower/real.hh ../flower/list.hh \ ../flower/list.inl ../flower/cursor.hh ../flower/link.hh \ ../flower/link.inl ../flower/cursor.inl ../flower/vray.hh glob.hh \ proto.hh const.hh pstaff.hh item.hh boxes.hh ../flower/textdb.hh \ ../flower/textstr.hh ../flower/string.hh ../flower/stringutil.hh \ - tex.hh symbol.hh voice.hh mtime.hh request.hh molecule.hh staff.hh \ - score.hh cols.hh ../flower/compare.hh command.hh ../flower/list.cc \ + tex.hh symbol.hh voice.hh mtime.hh request.hh staff.hh score.hh \ + cols.hh ../flower/compare.hh command.hh ../flower/list.cc \ ../flower/cursor.cc -parser.o: parser.cc lexer.hh proto.hh real.hh staff.hh score.hh \ - ../flower/vray.hh cols.hh glob.hh const.hh boxes.hh \ +template3.o: template3.cc request.hh glob.hh ../flower/real.hh \ + proto.hh const.hh ../flower/string.hh ../flower/stringutil.hh \ + mtime.hh command.hh ../flower/vray.hh molecule.hh ../flower/list.hh \ + ../flower/list.inl ../flower/cursor.hh ../flower/link.hh \ + ../flower/link.inl ../flower/cursor.inl boxes.hh ../flower/textdb.hh \ + ../flower/textstr.hh item.hh tex.hh ../flower/list.cc \ + ../flower/cursor.cc +parser.o: parser.cc lexer.hh proto.hh ../flower/real.hh staff.hh \ + score.hh ../flower/vray.hh cols.hh glob.hh const.hh boxes.hh \ ../flower/textdb.hh ../flower/textstr.hh ../flower/string.hh \ ../flower/stringutil.hh ../flower/list.hh ../flower/list.inl \ ../flower/cursor.hh ../flower/link.hh ../flower/link.inl \ ../flower/cursor.inl item.hh tex.hh ../flower/compare.hh mtime.hh \ - command.hh voice.hh request.hh keyword.hh globvars.hh debug.hh \ - dstream.hh ../flower/assoc.hh parseconstruct.hh -lexer.o: lexer.cc glob.hh real.hh proto.hh const.hh \ + command.hh voice.hh request.hh main.hh keyword.hh debug.hh \ + ../flower/dstream.hh ../flower/assoc.hh parseconstruct.hh +lexer.o: lexer.cc glob.hh ../flower/real.hh proto.hh const.hh \ ../flower/string.hh ../flower/stringutil.hh lexer.hh keyword.hh \ - ../flower/vray.hh parser.hh debug.hh dstream.hh ../flower/assoc.hh + ../flower/vray.hh parser.hh debug.hh ../flower/dstream.hh \ + ../flower/assoc.hh diff --git a/dimen.tex b/dimen.tex new file mode 100644 index 0000000000..0be3eca9a8 --- /dev/null +++ b/dimen.tex @@ -0,0 +1,49 @@ +\font\musicfnt=musix20 +\def\mb#1{{\musicfnt\musicfnt\char#1}} +\newdimen\wid +\newdimen\inc +\newdimen\here +\def\hruler#1{% + \wid=#1pt + \inc=\wid + \divide\inc by #1 + \divide\wid by 2 + \here=-\wid + \loop\ifdim\here<\wid\advance\here by\inc + \hbox to0pt{\kern\here\vrule width0.05pt height 2pt\hss}% + \repeat% +} +\def\vruler#1{% + \wid=#1pt + \inc=\wid + \divide\inc by #1 + \divide\wid by 2 + \here=-\wid + \loop\ifdim\here<\wid\advance\here by\inc + \vbox to0pt{\vskip\here\vrule width2pt height 0.05pt\vss}% + \repeat% +} +\def\twhrul{\hbox to 0pt{\hbox{\hruler{20}\vrule + width0.1pt height 3ptdepth 1pt}}} +\def\twvrul{\hbox{\vbox to 20pt{\vruler{20}\vrule + width3pt height 0.1pt}}} + +\def\doitem#1{ + #1 % + %\twvrul%doesn't work + \hbox to 50pt{\qquad\twhrul\mb{#1}\hss}\setbox0=\hbox{\mb{#1}} width \the\wd0\ depth \the\dp0 \ height \the\ht0} + +\newcount\n +\def\charn{\n=0 + \loop\ifnum\n<255\advance\n by1 + \doitem{\number\n}\endgraf\repeat} + + + \charn + + + + + + +\bye \ No newline at end of file diff --git a/dstream.cc b/dstream.cc deleted file mode 100644 index 1326b8b667..0000000000 --- a/dstream.cc +++ /dev/null @@ -1,108 +0,0 @@ -#include - -#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 <<")"; -} - - diff --git a/dstream.hh b/dstream.hh deleted file mode 100644 index 24673695f2..0000000000 --- a/dstream.hh +++ /dev/null @@ -1,37 +0,0 @@ -// 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 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 - diff --git a/flower/Makefile b/flower/Makefile index 9db4fbf5e8..aff8ac8f14 100644 --- a/flower/Makefile +++ b/flower/Makefile @@ -1,12 +1,13 @@ MAJVER=1 MINVER=0 -PATCHLEVEL=2 +PATCHLEVEL=3 PACKAGENAME=flower VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL) DNAME=$(PACKAGENAME)-$(VERSION) -#DEFINES=-DNDEBUG -CXXFLAGS+=$(DEFINES) -g -Wall -W -pedantic +DEFINES=-DNDEBUG -DNPRINT -O2 +#DEFINES=-g +CXXFLAGS+=$(DEFINES) -Wall -W -pedantic include Sources.make diff --git a/flower/Sources.make b/flower/Sources.make index 18fb18cb24..6521100b3b 100644 --- a/flower/Sources.make +++ b/flower/Sources.make @@ -5,7 +5,7 @@ cc=lgetopt.cc string.cc dataf.cc textdb.cc unionfind.cc \ templatecc=cursor.cc list.cc tsmat.cc inl=findcurs.inl link.inl list.inl -hh=cursor.hh cursor.inl lgetopt.hh link.hh list.hh dstream.hh \ +hh=cursor.hh pcursor.hh cursor.inl 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\ diff --git a/flower/TODO b/flower/TODO index c8f3e5ad52..8d6e50591d 100644 --- a/flower/TODO +++ b/flower/TODO @@ -9,10 +9,6 @@ * Restricted cursor/list: make sublist from a list, and use rcursor as if list is as big as the sublist. - * Cursor signedcompare - - * int Cursor::op-(Cursor) - * move towards gnu? parsestream.h diff --git a/flower/compare.hh b/flower/compare.hh index 05b6e89e41..47c7101c87 100644 --- a/flower/compare.hh +++ b/flower/compare.hh @@ -2,21 +2,24 @@ #define COMPARE_HH /// handy notations for a signed comparison -#define instantiate_compare(type, function) \ -inline bool operator>(type t1, type t2) { return function(t1, t2) > 0; } \ - inline bool operator>=(type t1, type t2) { return function(t1, t2) >= 0; } \ - inline bool operator==(type t1, type t2) { return function(t1, t2) == 0; } \ - inline bool operator<=(type t1, type t2) { return function(t1, t2) <= 0; } \ - inline bool operator<(type t1, type t2) { return function(t1, t2) < 0; } \ - inline type MAX(type t1, type t2) { return (t1 > t2 )? t1 : t2; }\ - inline type MIN(type t1, type t2) { return (t1 < t2 )? t1 : t2; }\ +#define template_instantiate_compare(type, function, prefix) \ +prefix inline bool operator>(type t1, type t2) { return function(t1, t2) > 0; } \ +prefix inline bool operator>=(type t1, type t2) { return function(t1, t2) >= 0; } \ +prefix inline bool operator==(type t1, type t2) { return function(t1, t2) == 0; } \ +prefix inline bool operator<=(type t1, type t2) { return function(t1, t2) <= 0; } \ +prefix inline bool operator<(type t1, type t2) { return function(t1, t2) < 0; } \ +prefix inline type MAX(type t1, type t2) { return (t1 > t2 )? t1 : t2; }\ +prefix inline type MIN(type t1, type t2) { return (t1 < t2 )? t1 : t2; }\ \ - bool operator<(type t1, type t2) /* stupid fix to allow ; */ +prefix bool operator<(type t1, type t2) /* stupid fix to allow ; */ /** make the operators{<,<=,==,>=,>} and the MAX and MIN of two. Please fill a & in the type argument if necessary. */ + + +#define instantiate_compare(type, func) template_instantiate_compare(type,func, ) diff --git a/flower/cursor.cc b/flower/cursor.cc index 10e90de919..2a9f885689 100644 --- a/flower/cursor.cc +++ b/flower/cursor.cc @@ -1,10 +1,7 @@ -// cursor.cc #ifndef CURSOR_CC #define CURSOR_CC #include "cursor.hh" -//#define inline -//#include "cursor.inl" #include template @@ -72,4 +69,27 @@ Cursor::operator -( int i ) const return r; } +template +int +Cursor::operator-(Cursor c) const +{ + assert(c.list == list); + int dif = 0; + Cursor upward(c); + while (upward.ok() && upward.pointer_ != pointer_) { + upward++; + dif++; + } + + if (upward.ok()) + return dif; + dif =0; + while (c.ok()&& c.pointer_ != pointer_) { + dif --; + c--; + } + assert(c.ok()); + return dif; +} + #endif diff --git a/flower/cursor.hh b/flower/cursor.hh index 45c02aea15..cff93c68ce 100644 --- a/flower/cursor.hh +++ b/flower/cursor.hh @@ -24,7 +24,7 @@ class Cursor /// make cursor with #no# items further Cursor operator +( int no) const; - + int operator -(Cursor op) const; Cursor operator -=(int); Cursor operator +=(int); @@ -80,13 +80,11 @@ class Cursor /// access the list this came from const List& list() const ; Link* pointer(); - + private: List& list_; Link* pointer_; }; - - /** add and insert extend the list items are always stored as copies in List, but: @@ -98,31 +96,32 @@ private: -/// cursor which feels like a pointer -template -struct PCursor : public Cursor { - /// make cursor with #no# items back - PCursor operator -( int no) const { - return PCursor (Cursor::operator-(no)); - } - /// make cursor with #no# items further - PCursor operator +( int no) const { - return PCursor (Cursor::operator+(no)); - } - PCursor(List & l) : Cursor (l) {} - PCursor( const Cursor& cursor ) : Cursor(cursor) { } - T operator ->() { return *(*this); } +/* + comparations. + */ -}; -/** - HWN: I'd like an operator->(), so here it is. - Cursor to go with pointer list. - */ + + + + + + +#include "compare.hh" + +template +inline int cursor_compare(Cursor a,Cursorb) +{ + return b-a; +} + +template_instantiate_compare(Cursor, cursor_compare, template); + +#include "pcursor.hh" #include "list.hh" #include "cursor.inl" diff --git a/flower/pcursor.hh b/flower/pcursor.hh new file mode 100644 index 0000000000..8b0b179b4f --- /dev/null +++ b/flower/pcursor.hh @@ -0,0 +1,26 @@ + + +/// cursor which feels like a pointer +template +struct PCursor : public Cursor { + + /// make cursor with #no# items back + PCursor operator -( int no) const { + return PCursor (Cursor::operator-(no)); + } + + /// make cursor with #no# items further + PCursor operator +( int no) const { + return PCursor (Cursor::operator+(no)); + } + PCursor(List & l) : Cursor (l) {} + + PCursor( const Cursor& cursor ) : Cursor(cursor) { } + T operator ->() { return *(*this); } + +}; +/** + HWN: I'd like an operator->(), so here it is. + + Cursor to go with pointer list. + */ diff --git a/globvars.hh b/globvars.hh index c79e017f71..8b13789179 100644 --- a/globvars.hh +++ b/globvars.hh @@ -1 +1 @@ -extern Score *the_score; + diff --git a/identifier.cc b/identifier.cc new file mode 100644 index 0000000000..9eab42e114 --- /dev/null +++ b/identifier.cc @@ -0,0 +1,22 @@ +#include +#include "keyword.hh" +#include "lexer.hh" +#include "parser.hh" + +Identifier::Identifier() +{ + data = 0; + type = IDENTIFIER; +} + + +Identifier::~Identifier() +{ + if (!data) + return; + switch (type) { + case IDENTIFIER: + default: + assert(false); + } +} diff --git a/keyword.hh b/keyword.hh index aa87a8dc1a..42267ef57a 100644 --- a/keyword.hh +++ b/keyword.hh @@ -13,5 +13,11 @@ struct Keyword_table int lookup(const char *s) const; }; -struct Identifier{ +struct Identifier +{ + void *data; + int type; + + Identifier(); + ~Identifier(); }; diff --git a/lexer.l b/lexer.l index 0063227f4e..a0da226a99 100644 --- a/lexer.l +++ b/lexer.l @@ -23,6 +23,7 @@ const int DOTPRINT=50; // every 50 lines dots %option debug %x notes %x incl +%x quote OPTSIGN !? NOTENAMEI A|B|C|D|E|F|G|As|Bes|Ces|Des|Es|Fes|Ges|Ais|Bis|Cis|Dis|Eis|Fis|Gis @@ -46,16 +47,14 @@ REAL [0-9]+(\.[0-9]*)? {RESTNAME} { const char *s = YYText(); - yylval.string = new String (s); - if (debug_flags & DEBUGTOKEN) - mtor << "rest:"<< yylval.string; + yylval.string = new String (s); + mtor << "rest:"<< yylval.string; return RESTNAME; } {PITCH} { const char *s = YYText(); yylval.string = new String (s); - if (debug_flags & DEBUGTOKEN) - mtor << "pitch:"<< yylval.string; + mtor << "pitch:"<< *yylval.string; return PITCH; } {DURATION} { @@ -73,9 +72,20 @@ REAL [0-9]+(\.[0-9]*)? BEGIN(INITIAL); return '$'; } . { - cout << "SCANNER HOLE `" << YYText()<<'\''<[^\"]* { + yylval.string = new String (YYText()); +} +\" { + BEGIN(INITIAL); + return STRING; } + <> { if(!close_input()) yyterminate(); @@ -91,14 +101,16 @@ REAL [0-9]+(\.[0-9]*)? {REAL} { Real r; - sscanf (YYText(), "%lf", &r); + int cnv=sscanf (YYText(), "%lf", &r); + assert(cnv == 1); + mtor << "token (REAL)" << r; yylval.real = r; return REAL; } [\{\}\[\]\(\)] { - if (debug_flags & DEBUGTOKEN) - cout << "parens\n"; + + mtor << "parens\n"; return YYText()[0]; } [ \t\n]+ { @@ -136,7 +148,7 @@ new_input(String s) if (!lexer) { lexer = new yyFlexLexer; - lexer->set_debug( bool(debug_flags & DEBUGPARSER)); + lexer->set_debug( !monitor.silence("Lexer")); } lexer->switch_streams(newin); diff --git a/lilyponddefs.tex b/lilyponddefs.tex index 48d1e32059..46da68d7fb 100644 --- a/lilyponddefs.tex +++ b/lilyponddefs.tex @@ -2,17 +2,26 @@ \def\musixtwentydefs{ \font\musicfnt=musix20 + % \hulplijnbreedte5pt %\hlijnhoogte1pt %\balkskip4pt } +\def\interstaffline{ +% \vskip 20pt% +} +\def\interscoreline{ + \par\vskip 10pt\par + \hrule height 2pt width2cm + \vskip 10pt +} \musixtwentydefs \def\mdef#1#2{\def#1{{\musicfnt\char#2}}} \mdef\quartball{'007} \mdef\halfball{'010} \mdef\wholeball{'011} -\mdef\wholerest{'074} -\mdef\halfrest{'072} +\mdef\wholerest{'075} +\mdef\halfrest{'074} \mdef\quartrest{'076} \mdef\eighthrest{'077} \mdef\sixteenthrest{'078} @@ -23,7 +32,11 @@ \mdef\singledot{'00} \mdef\doubledot{'01} \mdef\tripledot{'02} -\def\maatstreep{\vrule height10pt width 1pt} +\def\maatstreep{\vrule height10pt } +\def\finishbar{\vrule height10pt width 1pt} \parindent0pt +\def\vcenter#1{\vbox to 0pt{\vss #1\vss}} + +\def\cquartrest{\vcenter\quartrest} diff --git a/line.cc b/line.cc index 88e2f3eb28..d0a5d794bb 100644 --- a/line.cc +++ b/line.cc @@ -39,7 +39,7 @@ Line_of_staff::TeXstring() const s += sc->TeXstring(); } } - s+="\\hss}}"; + s+="\\hss}\\vss}"; return s; } @@ -47,8 +47,11 @@ String Line_of_score::TeXstring() const { String s("\\vbox{"); - for (PCursor sc(staffs); sc.ok(); sc++) + for (PCursor sc(staffs); sc.ok(); sc++){ s += sc->TeXstring(); + if ((sc+1).ok()) + s+= "\\interstaffline\n"; + } s += "}"; return s; } diff --git a/linespace.cc b/linespace.cc index 91b0e3009c..402bd4074e 100644 --- a/linespace.cc +++ b/linespace.cc @@ -27,6 +27,7 @@ Spacing_problem::col_id(const PCol *w)const void Spacing_problem::OK() const { +#ifndef NDEBUG Union_find connected(cols.sz()); for (int i=0; i < ideals.sz(); i++) { @@ -39,6 +40,7 @@ Spacing_problem::OK() const for (int i = 0; i < cols.sz(); i++) { assert( connected.equiv(0,i)); } +#endif } bool @@ -164,9 +166,10 @@ Spacing_problem::make_constraints(Optimisation_problem& lp) const svec Spacing_problem::solve() const { + print(); OK(); assert(check_feasible()); - print(); + /* optimalisatiefunctie */ Optimisation_problem lp(cols.sz()); @@ -212,16 +215,19 @@ Spacing_problem::add_ideal(const Idealspacing *i) void Spacing_problem::print_ideal(const Idealspacing*id)const { +#ifndef NPRINT int l = col_id(id->left); int r = col_id(id->right); mtor << "idealspacing { between " << l <<","<space<< " strength " << id->hooke << "}\n"; +#endif } void Spacing_problem::print() const { + #ifndef NPRINT for (int i=0; i < cols.sz(); i++) { mtor << "col " << i<<' '; cols[i].print(); @@ -229,14 +235,20 @@ Spacing_problem::print() const for (int i=0; i < ideals.sz(); i++) { print_ideal(ideals[i]); } + #endif + } void Colinfo::print() const { +#ifndef NPRINT mtor << "column { "; if (fixed) mtor << "fixed at " << fixpos<<", "; mtor << "[" << minleft() << ", " << minright() << "]"; mtor <<"}\n"; +#endif } + + diff --git a/maartje.ly b/maartje.ly new file mode 100644 index 0000000000..a0711079af --- /dev/null +++ b/maartje.ly @@ -0,0 +1,19 @@ +% erg lang + + +score { +% output "maartje.uit" + rhythmstaff { + voice { $ c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 $ } + } + rhythmstaff { + voice { $ c4 r4 c4 r4 c4 r4 c4 r4 c4 r4 c4 r4 c4 r4 c4 r4 + r2 r4 r1 + $ } + } +bar 0.5 + bar 2 bar 3 + bar 4.5 bar 5 bar 5.5 + bar 6 bar 7 bar 8 +} + diff --git a/main.cc b/main.cc index 3758840ac6..2145331565 100644 --- a/main.cc +++ b/main.cc @@ -1,26 +1,41 @@ #include +#include #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 + + + 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 @@ -28,16 +43,16 @@ main (int argc, char **argv) { 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); @@ -49,6 +64,6 @@ main (int argc, char **argv) if (!arg) arg = ""; parse_file(arg); - the_score->process(); - the_score->output(outfn); + do_scores(); + exit (0); } diff --git a/main.hh b/main.hh new file mode 100644 index 0000000000..264ac3aa78 --- /dev/null +++ b/main.hh @@ -0,0 +1,8 @@ +#ifndef MAIN_HH +#define MAIN_HH +#include "proto.hh" +void debug_init(); +void do_scores(); +void add_score(Score * s); +void set_default_output(String s); +#endif diff --git a/make_patch b/make_patch index 08420639d6..80548815df 100755 --- a/make_patch +++ b/make_patch @@ -1,7 +1,19 @@ #!/bin/sh old=$1 new=$2 -nm=$3 +nm=$3- +newarc=$nm$new.tar.gz +oldarc=$nm$old.tar.gz +if [ ! -f $newarc ] +then + echo cant find $newarc + exit +fi +if [ ! -f $oldarc ] +then + echo cant find oldarc + exit +fi if [ ! -x $nm$new ] then echo untarring .. diff --git a/matrix.cc b/matrix.cc deleted file mode 100644 index ab59a87308..0000000000 --- a/matrix.cc +++ /dev/null @@ -1,281 +0,0 @@ -#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; -} diff --git a/matrix.hh b/matrix.hh deleted file mode 100644 index e092a5fbe6..0000000000 --- a/matrix.hh +++ /dev/null @@ -1,141 +0,0 @@ -#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 diff --git a/misc.hh b/misc.hh index a0ce0161ad..fb8889f551 100644 --- a/misc.hh +++ b/misc.hh @@ -4,5 +4,5 @@ int intlog2(int d); Real duration_to_idealspace(Mtime d); class String; -char *get_version(); +const char *get_version(); #endif diff --git a/molecule.cc b/molecule.cc index 3e107ae7fb..e1c4ac5f8d 100644 --- a/molecule.cc +++ b/molecule.cc @@ -11,13 +11,19 @@ Atom::extent() const return b; } +Atom::Atom(const Symbol * s) +{ + sym=s; +} + String Atom::TeXstring() const { // whugh.. Hard coded... String s("\\raise"); s+= String(off.y * VERT_TO_PT)+"pt\\hbox to 0pt{\\kern "; - s+=String(off.x * HOR_TO_PT) + "pt" + sym->tex + "\\hss}"; + s+= String(off.x * HOR_TO_PT) + "pt"; + s+= sym->tex + "\\hss}"; return s; } diff --git a/molecule.hh b/molecule.hh index 6f63be3ba9..6709b73750 100644 --- a/molecule.hh +++ b/molecule.hh @@ -16,9 +16,7 @@ struct Atom { /// how big is #this#? Box extent() const; - Atom(const Symbol*s) { - sym=s; - } + Atom(const Symbol*s); String TeXstring() const; }; diff --git a/note.cc b/note.cc index 538f26a28e..c51e3c33af 100644 --- a/note.cc +++ b/note.cc @@ -27,8 +27,8 @@ parse_duration(const char *a, int &j, int &intdur, int &dots) intdur = (durstr.len()) ? durstr.value():default_duration; - if (debug_flags & DEBUGTOKEN) - mtor << "dur " << intdur << "dots " << dots< -//#include "mudobs.hh" + #include "lexer.hh" #include "staff.hh" #include "score.hh" +#include "main.hh" #include "keyword.hh" -#include "globvars.hh" #include "debug.hh" #include "parseconstruct.hh" #define YYDEBUG 1 @@ -27,12 +27,13 @@ Score *score; } -%token VOICE STAFF SCORE TITLE RHYTHMSTAFF BAR NOTENAME +%token VOICE STAFF SCORE TITLE RHYTHMSTAFF BAR NOTENAME OUTPUT + %token IDENTIFIER %token PITCH DURATION RESTNAME %token REAL - +%token STRING %type voice_block voice_body voice_elts voice_elts_dollar %type voice_elt @@ -42,10 +43,9 @@ %% -mudela: - score_block { - delete the_score; - the_score = $1; +mudela: /* empty */ + | score_block { + add_score($1); } ; @@ -56,6 +56,9 @@ score_block: SCORE '{' score_body '}' { $$ = $3; } score_body: { $$ = new Score; } | score_body staff_block { $$->add($2); } | score_body score_command { $$->add($2); } + | score_body OUTPUT STRING { $$->outfile = *$3; + delete $3; + } ; staff_block: @@ -115,7 +118,7 @@ void parse_file(String s) { *mlog << "Parsing ... "; - yydebug = debug_flags & DEBUGPARSER; + yydebug = !monitor.silence("Parser"); new_input(s); yyparse(); } diff --git a/pscore.cc b/pscore.cc index dd8ae697bc..16156d1321 100644 --- a/pscore.cc +++ b/pscore.cc @@ -7,13 +7,14 @@ void PScore::clean_cols() { - for (PCursor c(cols); c.ok(); c++) + for (PCursor c(cols); c.ok(); ) if (!c->used) { - c.remove(); - //mtor << "removing pcol\n"; - } + c.del(); + mtor << "removing pcol\n"; + } else + c++; } - + void PScore::add(PStaff *s) @@ -95,5 +96,7 @@ PScore::output(Tex_stream &ts) for (PCursor lic(lines); lic.ok(); lic++) { ts << "% line of score no. " << l++ <<"\n"; ts << lic->TeXstring(); + if ((lic+1).ok()) + ts << "\\interscoreline\n"; } } diff --git a/qlp.cc b/qlp.cc index 9ad72de4a0..c76946e866 100644 --- a/qlp.cc +++ b/qlp.cc @@ -1,18 +1,22 @@ #include "debug.hh" +#include "const.hh" #include "qlp.hh" #include "choleski.hh" + void Mixed_qp::add_equality_cons(Vector v, double r) { assert(false); } + void Mixed_qp::add_fixed_var(int i, Real r) { eq_cons.add(i); eq_consrhs.add(r); } - void + +void Ineq_constrained_qp::add_inequality_cons(Vector c, double r) { cons.add(c); @@ -26,11 +30,13 @@ Ineq_constrained_qp::Ineq_constrained_qp(int novars): } void -Ineq_constrained_qp::OK()const +Ineq_constrained_qp::OK() const { +#ifndef NDEBUG assert(cons.sz() == consrhs.sz()); Matrix Qdif= quad - quad.transposed(); - assert(Qdif.norm() < EPS); + assert(Qdif.norm()/quad.norm() < EPS); +#endif } @@ -95,29 +101,34 @@ Mixed_qp::Mixed_qp(int n) } void -Mixed_qp::OK()const +Mixed_qp::OK() const { +#ifndef NDEBUG Ineq_constrained_qp::OK(); assert(eq_consrhs.sz() == eq_cons.sz()); +#endif } void Ineq_constrained_qp::print() const { - +#ifndef NPRINT mtor << "Quad " << quad; mtor << "lin " << lin <<"\n"; for (int i=0; i < cons.sz(); i++) { mtor << "constraint["<= " << consrhs[i]; mtor << "\n"; } +#endif } void Mixed_qp::print() const { +#ifndef NPRINT Ineq_constrained_qp::print(); for (int i=0; i < eq_cons.sz(); i++) { mtor << "eq cons "< 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 diff --git a/score.cc b/score.cc index b2b520c443..f5e357ecdb 100644 --- a/score.cc +++ b/score.cc @@ -1,4 +1,4 @@ -#include + #include "tstream.hh" #include "score.hh" #include "pscore.hh" @@ -6,33 +6,57 @@ #include "misc.hh" #include "debug.hh" +void +Score::add_command_seq(svec com) +{ + if (!com.sz()) + return; + Real when = com[0]->when; + + PCursor pc(commands_); + while (pc.ok()&&pc->when <= when) + pc++; + + for (int i = 0; i < com.sz(); i++) { + assert(com[i]->when == when); + if (!pc.ok()) + pc.add(com[i]); + else + pc.insert(com[i]); + } + +} + void Score::add(Command *c) { + svec seq; if (c->code == TYPESET && c->args[0] == "BAR") { /* should be encapsulated in BREAKs THIS SUX. */ + Command k; k.when = c->when; k.code = BREAK_PRE; - commands_.bottom().add(new Command(k)); - commands_.bottom().add(new Command(*c)); + + seq.add(new Command(k)); + seq.add(new Command(*c)); k.code = BREAK_MIDDLE; - commands_.bottom().add(new Command(k)); - commands_.bottom().add(new Command(*c)); + seq.add(new Command(k)); + seq.add(new Command(*c)); k.code = BREAK_POST; - commands_.bottom().add(new Command(k)); + seq.add(new Command(k)); k.code = BREAK_END; - commands_.bottom().add(new Command(k)); + seq.add(new Command(k)); } else - commands_.bottom().add(new Command(*c)); - + seq.add(new Command(*c)); + add_command_seq(seq); } void @@ -53,43 +77,41 @@ Score::do_pcols() } /* this sux. Really makeshift. + + first and last column should be breakable. + Remove any command past the last musical column. */ void Score::do_miscs() { Command c; - c.when = 0.0; + { + Command c; + c.when = 0.0; + c.code = TYPESET; + c.args.add("BAR"); + c.args.add("empty"); + add(&c); + } - c.code = BREAK_END; - commands_.top().insert(new Command(c)); - c.code = BREAK_POST; - commands_.top().insert(new Command(c)); - c.code = BREAK_MIDDLE; - commands_.top().insert(new Command(c)); - c.code = BREAK_PRE; - commands_.top().insert(new Command(c)); - PCursor bot(commands_.bottom()); - c.when = last(); - while (bot.ok() && bot->when > c.when) { -// mtor <<"removing "<< bot->code <<" at " << bot->when<<'\n'; - bot.remove(); - bot = commands_.bottom(); + Real l = last(); + while (bot.ok() && bot->when > l) { + + mtor <<"removing "<< bot->code <<" at " << bot->when<<'\n'; + bot.del(); + bot = commands_.bottom(); + } + + if (bot->when != l || bot->code != BREAK_END) { + Command c; + c.code = TYPESET; + c.when = l; + c.args.add("BAR"); + c.args.add("||"); + add(&c); } - - c.code = BREAK_PRE; - bot.add(new Command(c)); - bot++; - c.code = BREAK_MIDDLE; - bot.add(new Command(c)); - bot++; - c.code = BREAK_POST; - bot.add(new Command(c)); - bot++; - c.code = BREAK_END; - bot.add(new Command(c)); - commands_.OK(); } @@ -106,11 +128,12 @@ void Score::clean_commands() { Mtime l= last(); - for (PCursor cc(commands_); cc.ok(); cc++) { + for (PCursor cc(commands_); cc.ok(); ) { if (cc->when > l){ - mtor << "remming \n"; - cc.remove(); - } + mtor << "remming \n"; + cc.del(); + } else + cc++; } } void @@ -143,14 +166,17 @@ Score::process() */ void Score::clean_cols() -{ +{ for (PCursor sc(staffs_); sc.ok(); sc++) sc->clean_cols(); - for (PCursor c(cols_); c.ok(); c++) { + + for (PCursor c(cols_); c.ok(); ) { if (!c->pcol->used) { -// mtor << "removing : "; c->print(); - c.remove(); - } + mtor << "removing : "; + c->print(); + c.del(); + } else + c++; } pscore_->clean_cols(); @@ -218,19 +244,18 @@ void Score::output(String s) { OK(); - mtor << "output to " << s << "...\n"; - - Tex_stream the_output(s); - the_output << "% Automatically generated by LilyPond 0.0 at"; - time_t t(time(0)); - the_output << ctime(&t)<<"\n"; - the_output << "% from input file ..\n"; + if (outfile=="") + outfile = s; + + *mlog << "output to " << outfile << "...\n"; + Tex_stream the_output(outfile); pscore_->output(the_output); } void Score::OK() const { +#ifndef NDEBUG for (PCursor sc(staffs_); sc.ok(); sc++) { sc->OK(); assert(sc->score_ == this); @@ -243,12 +268,13 @@ Score::OK() const for (PCursor cc(commands_); cc.ok() && (cc+1).ok(); cc++) { assert(cc->when <= (cc+1)->when); } - +#endif } void Score::print() const { +#ifndef NPRINT mtor << "score {\n"; for (PCursor sc(staffs_); sc.ok(); sc++) { sc->print(); @@ -257,8 +283,12 @@ Score::print() const sc->print(); } mtor << "}\n"; +#endif +} +Score::Score() +{ + pscore_=0; } - /****************************************************************/ Score_column::Score_column(Mtime w) @@ -276,10 +306,14 @@ Score_column::used() { void Score_column::print() const { + #ifndef NPRINT mtor << "Score_column { mus "<< musical <<" at " << when<<'\n'; mtor << " # symbols: " << pcol->its.size() << "\n"; mtor << "durations: [" ; for (int i=0; i < durations.sz(); i++) mtor << durations[i] << " "; mtor << "]\n}\n"; + #endif } + + diff --git a/score.hh b/score.hh index 3e65d50d99..5ec7f33b5a 100644 --- a/score.hh +++ b/score.hh @@ -41,6 +41,7 @@ instantiate_compare(Score_column&, Score_column::compare); /// the total music def of one movement struct Score { + String outfile; /// staffs_ and commands_ form the problem definition. PointerList staffs_; PointerList commands_; @@ -50,6 +51,8 @@ struct Score { PScore *pscore_; /****************************************************************/ + + Score(); /// add #Idealspacings# to #pscore_# void calc_idealspacing(); @@ -66,6 +69,7 @@ struct Score { void do_pcols(); void add(Command *); void add(Staff*); + void add_command_seq(svec ); void output(String fn); PCursor create_cols(Mtime); void print() const; diff --git a/scores.cc b/scores.cc new file mode 100644 index 0000000000..cb06b0074f --- /dev/null +++ b/scores.cc @@ -0,0 +1,29 @@ +#include "main.hh" +#include "score.hh" + +static svec sv; + +static String outfn="lelie.uit"; + +void +do_scores() +{ + for (int i=0; i < sv.sz(); i++) { + sv[i]->process(); + sv[i]->output(outfn); + } +} + +void +add_score(Score * s) +{ + sv.add(s); +} + + +void +set_default_output(String s) +{ + outfn = s; +} + diff --git a/smat.cc b/smat.cc deleted file mode 100644 index 3830fd6825..0000000000 --- a/smat.cc +++ /dev/null @@ -1,187 +0,0 @@ -#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 && 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 k ; i--) - for (int j=0; j -Full_storage::row(int n) const -{ - svec r; - for (int j = 0; j < w; j++) - r.add(els[n][j]); - return r; -} - -svec -Full_storage::column(int n) const -{ - - svec r; - for (int i = 0; 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 row(int i) const; - virtual svec 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 diff --git a/staff.cc b/staff.cc index 61699dccb2..12bf074d04 100644 --- a/staff.cc +++ b/staff.cc @@ -6,9 +6,11 @@ void Staff::clean_cols() { PCursor stc(cols); - for(; stc.ok(); stc++){ + for(; stc.ok(); ){ if (!stc->score_column->used()) - stc.remove(); + stc.del(); + else + stc++; } } @@ -122,11 +124,12 @@ Staff::process() void Staff::OK() const { +#ifndef NDEBUG cols.OK(); commands.OK(); voices.OK(); - assert(score_); - + assert(score_); +#endif } @@ -164,6 +167,7 @@ Staff_column::when() const { return score_column->when; } + void Staff_column::add(Voice_element*ve) { @@ -174,6 +178,7 @@ Staff_column::add(Voice_element*ve) v_elts.add(ve); } + Staff_column::Staff_column(Score_column*s) { score_column = s; } diff --git a/symbol.ini b/symbol.ini index 5375e227f4..d00e751dc5 100644 --- a/symbol.ini +++ b/symbol.ini @@ -1,4 +1,4 @@ -# TeXstring, xmin xmax ymin ymax +# index TeXstring, xmin xmax ymin ymax table balls 1 \wholeball -5 5 -1 1 @@ -7,14 +7,21 @@ table balls end table bars + empty \emptybar 0 0 0 0 | \maatstreep 0 1 0 10 + || \finishbar 0 2 0 10 end table rests - 1 \wholerest -1 1 -1 1 - 2 \halfrest -1 1 -1 1 - 4 \quartrest -1 1 -1 1 - 8 \eighthrest -1 1 -1 1 - 16 \sixteenthrest -1 1 -1 1 + 1 \wholerest -5 1 -1 1 + 2 \halfrest -5 1 -1 1 + 4 \cquartrest -5 2 -5 5 + 8 \eighthrest -5 1 -1 1 + 16 \sixteenthrest -5 1 -1 1 32 \thirtysecondrest -1 1 -1 1 -end \ No newline at end of file +end + + + + + diff --git a/symtable.cc b/symtable.cc index 8b87e2fc99..5d295d0be5 100644 --- a/symtable.cc +++ b/symtable.cc @@ -6,6 +6,20 @@ #include "symtable.hh" #include "const.hh" +static Symbol unknown; + + +// scary! What if Symtable resizes on the fly...? +const Symbol * +Symtable::lookup(String s) const +{ + if (elt_query(s)) + return &(*this)[s]; + else { + WARN<<"Unknown symbol " << s <<'\n'; + return &unknown; + } +} Symtable* Symtables::operator()(String s) @@ -53,25 +67,22 @@ Symtables the_sym_tables("symbol.ini"); const Symbol* -Symbol::find_ball(int i) +Symbol::find_ball(int j) { - int j = intlog2(i)+1; if (j > 4) j = 4; Symtable * st = the_sym_tables("balls"); - return &(*st)[String(j)]; - + return st->lookup(String(j)); } const Symbol* -Symbol::find_rest(int i) +Symbol::find_rest(int j) { - int j = intlog2(i)+1; - return &(*the_sym_tables("rests"))[String(j)]; + return the_sym_tables("rests")->lookup(String(j)); } const Symbol* Symbol::find_bar(String s) { - return &(*the_sym_tables("bars"))[s]; + return the_sym_tables("bars")->lookup(s); } /****************************************************************/ // bare bones. diff --git a/symtable.hh b/symtable.hh index 9d5213a7c3..f390e285e0 100644 --- a/symtable.hh +++ b/symtable.hh @@ -1,5 +1,5 @@ struct Symtable : public Assoc { - + const Symbol * lookup(String)const; }; diff --git a/table.cc b/table.cc index 45e6f4a0e4..b06e2ee92f 100644 --- a/table.cc +++ b/table.cc @@ -1,4 +1,5 @@ #include "glob.hh" +#include "debug.hh" #include "string.hh" #include "keyword.hh" #include "parser.hh" @@ -8,6 +9,7 @@ static Keyword_ent the_key_tab[]={ "rhythmstaff", RHYTHMSTAFF, "score", SCORE, "bar", BAR, + "output", OUTPUT, 0,0 } ; @@ -19,9 +21,13 @@ lookup_keyword(String s) return table.lookup(s); } +Assoc the_id_tab; + Identifier* lookup_identifier(String s) { - assert(false); - return 0; + if (!the_id_tab.elt_query(s)) + the_id_tab[s]= new Identifier; + + return the_id_tab[s]; } diff --git a/template.cc b/template1.cc similarity index 74% rename from template.cc rename to template1.cc index f0260b5edc..908de8d4e1 100644 --- a/template.cc +++ b/template1.cc @@ -4,9 +4,7 @@ #include "cols.hh" #include "item.hh" #include "request.hh" -#include "score.hh" #include "command.hh" -#include "staff.hh" #include "list.cc" #include "cursor.cc" @@ -19,8 +17,4 @@ PL_instantiate(Spanner); PL_instantiate(PStaff); PL_instantiate(Idealspacing); PL_instantiate(PCol); -PL_instantiate(Command); -PL_instantiate(Request); -PL_instantiate(Score_column); - diff --git a/template2.cc b/template2.cc index bd9a0dcade..40cd5b9fbe 100644 --- a/template2.cc +++ b/template2.cc @@ -1,17 +1,15 @@ #include "line.hh" #include "symbol.hh" #include "voice.hh" -#include "molecule.hh" -#include "staff.hh" - - +#include "staff.hh" #include "list.cc" #include "cursor.cc" +PL_instantiate(Score_column); PL_instantiate(Staff_column); PL_instantiate(Staff); PL_instantiate(Voice_element); PL_instantiate(Voice); -L_instantiate(Atom); + diff --git a/template3.cc b/template3.cc new file mode 100644 index 0000000000..b647f18598 --- /dev/null +++ b/template3.cc @@ -0,0 +1,11 @@ +#include "request.hh" +#include "command.hh" +#include "molecule.hh" +#include "list.cc" +#include "cursor.cc" +L_instantiate(Atom); +PL_instantiate(Command); +PL_instantiate(Request); + + + diff --git a/tstream.cc b/tstream.cc index 78c9a72852..c47fca6da6 100644 --- a/tstream.cc +++ b/tstream.cc @@ -1,5 +1,7 @@ #include +#include #include "tex.hh" +#include "misc.hh" #include "tstream.hh" #include "debug.hh" @@ -11,8 +13,17 @@ Tex_stream::Tex_stream(String filename) error("can't open " + filename); nest_level = 0; outputting_comment=false; + header(); +} +void +Tex_stream::header() +{ + *os << "% Creator: " << get_version() << "\n"; + *os << "% Automatically generated, at "; + time_t t(time(0)); + *os << ctime(&t)<<"\n"; +//*os << "% from input file ..\n"; } - Tex_stream::~Tex_stream() { assert(nest_level == 0); diff --git a/tstream.hh b/tstream.hh index 07be0c1706..9474dd69a8 100644 --- a/tstream.hh +++ b/tstream.hh @@ -12,7 +12,7 @@ struct Tex_stream { /// open a file for writing Tex_stream(String filename); - + void header(); /// delegate conversion to string class. Tex_stream &operator<<(String); diff --git a/vector.cc b/vector.cc deleted file mode 100644 index be2423250d..0000000000 --- a/vector.cc +++ /dev/null @@ -1,41 +0,0 @@ -#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; -} diff --git a/vector.hh b/vector.hh deleted file mode 100644 index 5be792c54b..0000000000 --- a/vector.hh +++ /dev/null @@ -1,106 +0,0 @@ -#ifndef VECTOR_HH -#define VECTOR_HH - -#include "glob.hh" -#include "vray.hh" - -/// a row of numbers -class Vector { - svec 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 () { 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 diff --git a/version.cc b/version.cc index d305e403c6..401273b6b1 100644 --- a/version.cc +++ b/version.cc @@ -2,7 +2,7 @@ static char *s = "LilyPond version " VERSIONSTR " compiled on " __DATE__ " at " __TIME__ "\n"; -char * +const char * get_version() { return s; diff --git a/vsmat.hh b/vsmat.hh deleted file mode 100644 index 4e1ea797b6..0000000000 --- a/vsmat.hh +++ /dev/null @@ -1,141 +0,0 @@ -#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 row(int i) const = 0; - virtual svec 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