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