]> git.donarmstrong.com Git - lilypond.git/blob - flower/matdebug.cc
release: 0.0.2
[lilypond.git] / flower / matdebug.cc
1 #include "dstream.hh"
2 #include "matrix.hh"
3
4 static Dstream *dout = new Dstream(0,0);
5
6 void set_matrix_debug(Dstream&ds)
7 {
8     dout = &ds;
9 }
10
11 Matrix::operator String() const
12 {
13     String s("matrix {\n");
14 #ifndef NPRINT
15     for (int i=0; i< rows(); i++){
16         for (int j = 0; j < cols(); j++) {
17             s+= String(dat->elem(i,j), "%6f ");
18         }
19         s+="\n";
20     }
21     s+="}\n";
22 #endif
23     return s;
24 }
25
26
27 void
28 Matrix::print() const
29 {
30 #ifndef NPRINT
31     *dout << *this;
32 #endif
33 }
34
35 Vector::operator String() const
36 {
37     int i=0;
38     String s("vector [");
39 #ifndef NDEBUG
40     for (; i < dim(); i++) {
41         s += String(dat[i], "%6f") + ' ';
42     }
43 #endif
44     s+="]";
45     return s;
46 }
47
48
49 void
50 Vector::print() const
51 {
52 #ifndef NDEBUG
53     *dout << *this<<'\n';
54 #endif
55 }