]> www.ginac.de Git - ginac.git/blob - ginac/printraw.cpp
Hunted down some output bugs. Hope it can be safely piped into Maple now.
[ginac.git] / ginac / printraw.cpp
1 /** @file printraw.cpp
2  *
3  * print in ugly raw format, so brave developers can have a look at the
4  * underlying structure. */
5
6 /* We are cheating here, because we don't want to include the underlying
7  * bignum package's headers again, so in this file we omit the definition of
8  * void numeric::printraw(ostream & os) const; */
9
10 #include <iostream>
11
12 #include "ginac.h"
13
14 void ex::printraw(ostream & os) const
15 {
16     debugmsg("ex printraw",LOGLEVEL_PRINT);
17     ASSERT(bp!=0);
18     os << "ex(";
19     bp->printraw(os);
20     os << ")";
21 }
22
23 void basic::printraw(ostream & os) const
24 {
25     debugmsg("basic printraw",LOGLEVEL_PRINT);
26     os << "[basic object]";
27 }
28
29 void symbol::printraw(ostream & os) const
30 {
31     debugmsg("symbol printraw",LOGLEVEL_PRINT);
32     os << "symbol(" << "name=" << name << ",serial=" << serial
33        << ",hash=" << hashvalue << ",flags=" << flags << ")";
34 }
35
36 void constant::printraw(ostream & os) const
37 {
38     debugmsg("constant printraw",LOGLEVEL_PRINT);
39     os << "constant(" << name << ")";
40 }
41
42 void power::printraw(ostream & os) const
43 {
44     debugmsg("power printraw",LOGLEVEL_PRINT);
45
46     os << "power(";
47     basis.printraw(os);
48     os << ",";
49     exponent.printraw(os);
50     os << ",hash=" << hashvalue << ",flags=" << flags << ")";
51 }
52
53 void fail::printraw(ostream & os) const
54 {
55     debugmsg("fail printraw",LOGLEVEL_PRINT);
56     os << "FAIL";
57 }
58
59 void expairseq::printraw(ostream & os) const
60 {
61     debugmsg("expairseq printraw",LOGLEVEL_PRINT);
62
63     os << "expairseq(";
64     for (epvector::const_iterator cit=seq.begin(); cit!=seq.end(); ++cit) {
65         os << "(";
66         (*cit).rest.printraw(os);
67         os << ",";
68         (*cit).coeff.printraw(os);
69         os << "),";
70     }
71     os << ")";
72 }
73
74 void add::printraw(ostream & os) const
75 {
76     debugmsg("add printraw",LOGLEVEL_PRINT);
77
78     os << "+(";
79     for (epvector::const_iterator it=seq.begin(); it!=seq.end(); ++it) {
80         os << "(";
81         (*it).rest.bp->printraw(os);
82         os << ",";
83         (*it).coeff.bp->printraw(os);        
84         os << "),";
85     }
86     os << ",hash=" << hashvalue << ",flags=" << flags;
87     os << ")";
88 }
89
90 void mul::printraw(ostream & os) const
91 {
92     debugmsg("mul printraw",LOGLEVEL_PRINT);
93
94     os << "*(";
95     for (epvector::const_iterator it=seq.begin(); it!=seq.end(); ++it) {
96         os << "(";
97         (*it).rest.bp->printraw(os);
98         os << ",";
99         (*it).coeff.bp->printraw(os);
100         os << "),";
101     }
102     os << ",hash=" << hashvalue << ",flags=" << flags;
103     os << ")";
104 }
105
106 void ncmul::printraw(ostream & os) const
107 {
108     debugmsg("ncmul printraw",LOGLEVEL_PRINT);
109
110     os << "%(";
111     for (exvector::const_iterator it=seq.begin(); it!=seq.end(); ++it) {
112         (*it).bp->printraw(os);
113         os << ",";
114     }
115     os << ",hash=" << hashvalue << ",flags=" << flags;
116     os << ")";
117 }
118
119 /*void function::printraw(ostream & os) const
120  *{
121  *    debugmsg("function printraw",LOGLEVEL_PRINT);
122  *
123  *    os << "function." << name << "(";
124  *    for (exvector::const_iterator it=seq.begin(); it!=seq.end(); ++it) {
125  *        (*it).bp->print(os);
126  *        os << ",";
127  *    }
128  *    os << ")";
129  *}*/
130
131 void series::printraw(ostream &os) const
132 {
133         debugmsg("symbol printraw", LOGLEVEL_PRINT);
134         os << "series(" << var << ";" << point << ";";
135         for (epvector::const_iterator i=seq.begin(); i!=seq.end(); i++) {
136                 os << "(" << (*i).rest << "," << (*i).coeff << "),";
137         }
138         os << ")";
139 }
140
141 void relational::printraw(ostream & os) const
142 {
143     debugmsg("relational printraw",LOGLEVEL_PRINT);
144     os << "RELATIONAL(";
145     lh.printraw(os);
146     os << ",";
147     rh.printraw(os);
148     os << ",";
149     switch (o) {
150     case equal:
151         os << "==";
152         break;
153     case not_equal:
154         os << "!=";
155         break;
156     case less:
157         os << "<";
158         break;
159     case less_or_equal:
160         os << "<=";
161         break;
162     case greater:
163         os << ">";
164         break;
165     case greater_or_equal:
166         os << ">=";
167         break;
168     default:
169         os << "(INVALID RELATIONAL OPERATOR)";
170     }
171     os << ")";
172 }
173
174 void matrix::printraw(ostream & os) const
175 {
176     debugmsg("matrix printraw",LOGLEVEL_PRINT);
177     os << "matrix(" << row << "," << col <<",";
178     for (int r=0; r<row-1; ++r) {
179         os << "(";
180         for (int c=0; c<col-1; ++c) {
181             os << m[r*col+c] << ",";
182         }
183         os << m[col*(r-1)-1] << "),";
184     }
185     os << "(";
186     for (int c=0; c<col-1; ++c) {
187         os << m[(row-1)*col+c] << ",";
188     }
189     os << m[row*col-1] << "))";
190 }