]> www.ginac.de Git - ginac.git/blob - ginac/printraw.cpp
- put everything in "GiNaC" namespace
[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 #include "debugmsg.h"
47
48 namespace GiNaC {
49
50 void ex::printraw(ostream & os) const
51 {
52     debugmsg("ex printraw",LOGLEVEL_PRINT);
53     ASSERT(bp!=0);
54     os << "ex(";
55     bp->printraw(os);
56     os << ")";
57 }
58
59 void basic::printraw(ostream & os) const
60 {
61     debugmsg("basic printraw",LOGLEVEL_PRINT);
62     os << "[basic object]";
63 }
64
65 void symbol::printraw(ostream & os) const
66 {
67     debugmsg("symbol printraw",LOGLEVEL_PRINT);
68     os << "symbol(" << "name=" << name << ",serial=" << serial
69        << ",hash=" << hashvalue << ",flags=" << flags << ")";
70 }
71
72 void constant::printraw(ostream & os) const
73 {
74     debugmsg("constant printraw",LOGLEVEL_PRINT);
75     os << "constant(" << name << ")";
76 }
77
78 void power::printraw(ostream & os) const
79 {
80     debugmsg("power printraw",LOGLEVEL_PRINT);
81
82     os << "power(";
83     basis.printraw(os);
84     os << ",";
85     exponent.printraw(os);
86     os << ",hash=" << hashvalue << ",flags=" << flags << ")";
87 }
88
89 void fail::printraw(ostream & os) const
90 {
91     debugmsg("fail printraw",LOGLEVEL_PRINT);
92     os << "FAIL";
93 }
94
95 void expairseq::printraw(ostream & os) const
96 {
97     debugmsg("expairseq printraw",LOGLEVEL_PRINT);
98
99     os << "expairseq(";
100     for (epvector::const_iterator cit=seq.begin(); cit!=seq.end(); ++cit) {
101         os << "(";
102         (*cit).rest.printraw(os);
103         os << ",";
104         (*cit).coeff.printraw(os);
105         os << "),";
106     }
107     os << ")";
108 }
109
110 void add::printraw(ostream & os) const
111 {
112     debugmsg("add printraw",LOGLEVEL_PRINT);
113
114     os << "+(";
115     for (epvector::const_iterator it=seq.begin(); it!=seq.end(); ++it) {
116         os << "(";
117         (*it).rest.bp->printraw(os);
118         os << ",";
119         (*it).coeff.bp->printraw(os);        
120         os << "),";
121     }
122     os << ",hash=" << hashvalue << ",flags=" << flags;
123     os << ")";
124 }
125
126 void mul::printraw(ostream & os) const
127 {
128     debugmsg("mul printraw",LOGLEVEL_PRINT);
129
130     os << "*(";
131     for (epvector::const_iterator it=seq.begin(); it!=seq.end(); ++it) {
132         os << "(";
133         (*it).rest.bp->printraw(os);
134         os << ",";
135         (*it).coeff.bp->printraw(os);
136         os << "),";
137     }
138     os << ",hash=" << hashvalue << ",flags=" << flags;
139     os << ")";
140 }
141
142 void ncmul::printraw(ostream & os) const
143 {
144     debugmsg("ncmul printraw",LOGLEVEL_PRINT);
145
146     os << "%(";
147     for (exvector::const_iterator it=seq.begin(); it!=seq.end(); ++it) {
148         (*it).bp->printraw(os);
149         os << ",";
150     }
151     os << ",hash=" << hashvalue << ",flags=" << flags;
152     os << ")";
153 }
154
155 /*void function::printraw(ostream & os) const
156  *{
157  *    debugmsg("function printraw",LOGLEVEL_PRINT);
158  *
159  *    os << "function." << name << "(";
160  *    for (exvector::const_iterator it=seq.begin(); it!=seq.end(); ++it) {
161  *        (*it).bp->print(os);
162  *        os << ",";
163  *    }
164  *    os << ")";
165  *}*/
166
167 void series::printraw(ostream &os) const
168 {
169         debugmsg("symbol printraw", LOGLEVEL_PRINT);
170         os << "series(" << var << ";" << point << ";";
171         for (epvector::const_iterator i=seq.begin(); i!=seq.end(); i++) {
172                 os << "(" << (*i).rest << "," << (*i).coeff << "),";
173         }
174         os << ")";
175 }
176
177 void relational::printraw(ostream & os) const
178 {
179     debugmsg("relational printraw",LOGLEVEL_PRINT);
180     os << "RELATIONAL(";
181     lh.printraw(os);
182     os << ",";
183     rh.printraw(os);
184     os << ",";
185     switch (o) {
186     case equal:
187         os << "==";
188         break;
189     case not_equal:
190         os << "!=";
191         break;
192     case less:
193         os << "<";
194         break;
195     case less_or_equal:
196         os << "<=";
197         break;
198     case greater:
199         os << ">";
200         break;
201     case greater_or_equal:
202         os << ">=";
203         break;
204     default:
205         os << "(INVALID RELATIONAL OPERATOR)";
206     }
207     os << ")";
208 }
209
210 void matrix::printraw(ostream & os) const
211 {
212     debugmsg("matrix printraw",LOGLEVEL_PRINT);
213     os << "matrix(" << row << "," << col <<",";
214     for (int r=0; r<row-1; ++r) {
215         os << "(";
216         for (int c=0; c<col-1; ++c) {
217             os << m[r*col+c] << ",";
218         }
219         os << m[col*(r-1)-1] << "),";
220     }
221     os << "(";
222     for (int c=0; c<col-1; ++c) {
223         os << m[(row-1)*col+c] << ",";
224     }
225     os << m[row*col-1] << "))";
226 }
227
228 } // namespace GiNaC