]> www.ginac.de Git - ginac.git/blob - ginac/printraw.cpp
d1aac63e1e5c86ea1be6f95248ae10612b774260
[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 /*
7  *  GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany
8  *
9  *  This program is free software; you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License as published by
11  *  the Free Software Foundation; either version 2 of the License, or
12  *  (at your option) any later version.
13  *
14  *  This program is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *  GNU General Public License for more details.
18  *
19  *  You should have received a copy of the GNU General Public License
20  *  along with this program; if not, write to the Free Software
21  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22  */
23
24 /* We are cheating here, because we don't want to include the underlying
25  * bignum package's headers again, so in this file we omit the definition of
26  * void numeric::printraw(ostream & os) const; */
27
28 #include <iostream>
29
30 #include "basic.h"
31 #include "ex.h"
32 #include "add.h"
33 #include "constant.h"
34 #include "expairseq.h"
35 #include "fail.h"
36 #include "indexed.h"
37 #include "inifcns.h"
38 #include "matrix.h"
39 #include "mul.h"
40 #include "ncmul.h"
41 #include "numeric.h"
42 #include "power.h"
43 #include "relational.h"
44 #include "series.h"
45 #include "symbol.h"
46
47 void ex::printraw(ostream & os) const
48 {
49     debugmsg("ex printraw",LOGLEVEL_PRINT);
50     ASSERT(bp!=0);
51     os << "ex(";
52     bp->printraw(os);
53     os << ")";
54 }
55
56 void basic::printraw(ostream & os) const
57 {
58     debugmsg("basic printraw",LOGLEVEL_PRINT);
59     os << "[basic object]";
60 }
61
62 void symbol::printraw(ostream & os) const
63 {
64     debugmsg("symbol printraw",LOGLEVEL_PRINT);
65     os << "symbol(" << "name=" << name << ",serial=" << serial
66        << ",hash=" << hashvalue << ",flags=" << flags << ")";
67 }
68
69 void constant::printraw(ostream & os) const
70 {
71     debugmsg("constant printraw",LOGLEVEL_PRINT);
72     os << "constant(" << name << ")";
73 }
74
75 void power::printraw(ostream & os) const
76 {
77     debugmsg("power printraw",LOGLEVEL_PRINT);
78
79     os << "power(";
80     basis.printraw(os);
81     os << ",";
82     exponent.printraw(os);
83     os << ",hash=" << hashvalue << ",flags=" << flags << ")";
84 }
85
86 void fail::printraw(ostream & os) const
87 {
88     debugmsg("fail printraw",LOGLEVEL_PRINT);
89     os << "FAIL";
90 }
91
92 void expairseq::printraw(ostream & os) const
93 {
94     debugmsg("expairseq printraw",LOGLEVEL_PRINT);
95
96     os << "expairseq(";
97     for (epvector::const_iterator cit=seq.begin(); cit!=seq.end(); ++cit) {
98         os << "(";
99         (*cit).rest.printraw(os);
100         os << ",";
101         (*cit).coeff.printraw(os);
102         os << "),";
103     }
104     os << ")";
105 }
106
107 void add::printraw(ostream & os) const
108 {
109     debugmsg("add printraw",LOGLEVEL_PRINT);
110
111     os << "+(";
112     for (epvector::const_iterator it=seq.begin(); it!=seq.end(); ++it) {
113         os << "(";
114         (*it).rest.bp->printraw(os);
115         os << ",";
116         (*it).coeff.bp->printraw(os);        
117         os << "),";
118     }
119     os << ",hash=" << hashvalue << ",flags=" << flags;
120     os << ")";
121 }
122
123 void mul::printraw(ostream & os) const
124 {
125     debugmsg("mul printraw",LOGLEVEL_PRINT);
126
127     os << "*(";
128     for (epvector::const_iterator it=seq.begin(); it!=seq.end(); ++it) {
129         os << "(";
130         (*it).rest.bp->printraw(os);
131         os << ",";
132         (*it).coeff.bp->printraw(os);
133         os << "),";
134     }
135     os << ",hash=" << hashvalue << ",flags=" << flags;
136     os << ")";
137 }
138
139 void ncmul::printraw(ostream & os) const
140 {
141     debugmsg("ncmul printraw",LOGLEVEL_PRINT);
142
143     os << "%(";
144     for (exvector::const_iterator it=seq.begin(); it!=seq.end(); ++it) {
145         (*it).bp->printraw(os);
146         os << ",";
147     }
148     os << ",hash=" << hashvalue << ",flags=" << flags;
149     os << ")";
150 }
151
152 /*void function::printraw(ostream & os) const
153  *{
154  *    debugmsg("function printraw",LOGLEVEL_PRINT);
155  *
156  *    os << "function." << name << "(";
157  *    for (exvector::const_iterator it=seq.begin(); it!=seq.end(); ++it) {
158  *        (*it).bp->print(os);
159  *        os << ",";
160  *    }
161  *    os << ")";
162  *}*/
163
164 void series::printraw(ostream &os) const
165 {
166         debugmsg("symbol printraw", LOGLEVEL_PRINT);
167         os << "series(" << var << ";" << point << ";";
168         for (epvector::const_iterator i=seq.begin(); i!=seq.end(); i++) {
169                 os << "(" << (*i).rest << "," << (*i).coeff << "),";
170         }
171         os << ")";
172 }
173
174 void relational::printraw(ostream & os) const
175 {
176     debugmsg("relational printraw",LOGLEVEL_PRINT);
177     os << "RELATIONAL(";
178     lh.printraw(os);
179     os << ",";
180     rh.printraw(os);
181     os << ",";
182     switch (o) {
183     case equal:
184         os << "==";
185         break;
186     case not_equal:
187         os << "!=";
188         break;
189     case less:
190         os << "<";
191         break;
192     case less_or_equal:
193         os << "<=";
194         break;
195     case greater:
196         os << ">";
197         break;
198     case greater_or_equal:
199         os << ">=";
200         break;
201     default:
202         os << "(INVALID RELATIONAL OPERATOR)";
203     }
204     os << ")";
205 }
206
207 void matrix::printraw(ostream & os) const
208 {
209     debugmsg("matrix printraw",LOGLEVEL_PRINT);
210     os << "matrix(" << row << "," << col <<",";
211     for (int r=0; r<row-1; ++r) {
212         os << "(";
213         for (int c=0; c<col-1; ++c) {
214             os << m[r*col+c] << ",";
215         }
216         os << m[col*(r-1)-1] << "),";
217     }
218     os << "(";
219     for (int c=0; c<col-1; ++c) {
220         os << m[(row-1)*col+c] << ",";
221     }
222     os << m[row*col-1] << "))";
223 }