]> git.donarmstrong.com Git - lilypond.git/blob - flower/matdebug.cc
release: 0.0.4
[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     String s("vector [");
38 #ifndef NDEBUG
39     for (int i=0; i < dim(); i++) {
40         s += String(dat[i], "%6f") + ' ';
41     }
42 #endif
43     s+="]";
44     return s;
45 }
46
47
48 void
49 Vector::print() const
50 {
51 #ifndef NDEBUG
52     *dout << *this<<'\n';
53 #endif
54 }