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