]> git.donarmstrong.com Git - lilypond.git/blob - flower/matdebug.cc
release: 0.0.43
[lilypond.git] / flower / matdebug.cc
1 #include "dstream.hh"
2 #include "matrix.hh"
3
4 static Dstream *dout = 0;
5
6 /**
7   Set the debugging output. Will not delete/swallow argument.
8  */
9 void set_matrix_debug(Dstream&ds)
10 {
11     dout = &ds;
12 }
13
14 Matrix::operator String() const
15 {
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 ");
22         }
23         s+="\n";
24     }
25     s+="}\n";
26 #endif
27     return s;
28 }
29
30
31 void
32 Matrix::print() const
33 {
34 #ifndef NPRINT
35     if (!dout)
36         return;
37     *dout << *this;
38 #endif
39 }
40
41 Vector::operator String() const
42 {
43     String s;
44 #ifndef NPRINT
45     s="vector [";
46     for (int i=0; i < dim(); i++) {
47         s += String(dat[i], "%6f") + String(' ');
48     }
49     s+="]";
50 #endif
51     return s;
52 }
53
54
55 void
56 Vector::print() const
57 {
58 #ifndef NDEBUG
59     if (!dout)
60         return;
61     *dout << *this<<'\n';
62 #endif
63 }