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