lilypond-0.1.12
[lilypond.git] / flower / matdebug.cc
blobbcc2843bcaa43e0fe85bdd2cb4d93c9ef9eca8da
1 #include "dstream.hh"
2 #include "matrix.hh"
4 static Dstream *dout = 0;
6 /**
7 Set the debugging output. Will not delete/swallow argument.
8 */
9 void set_matrix_debug(Dstream&ds)
11 dout = &ds;
14 Matrix::operator String() const
16 String s;
17 #ifndef NPRINT
18 s="matrix {\n";
19 for (int i=0; i< rows(); i++){
20 for (int j = 0; j < cols(); j++) {
21 s+= String(dat->elem(i,j), "%6f ");
23 s+="\n";
25 s+="}\n";
26 #endif
27 return s;
31 void
32 Matrix::print() const
34 #ifndef NPRINT
35 if (!dout)
36 return;
37 *dout << *this;
38 #endif
41 Vector::operator String() const
43 String s;
44 #ifndef NPRINT
45 s="vector [";
46 for (int i=0; i < dim(); i++) {
47 s += String(dat[i], "%6f") + String(' ');
49 s+="]";
50 #endif
51 return s;
55 void
56 Vector::print() const
58 #ifndef NDEBUG
59 if (!dout)
60 return;
61 *dout << *this<<'\n';
62 #endif