3 * Implementation of GiNaC's clifford objects.
4 * No real implementation yet, to be done.
6 * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany
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.
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.
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
31 // default constructor, destructor, copy constructor assignment operator and helpers
38 debugmsg("clifford default constructor",LOGLEVEL_CONSTRUCT);
40 name=autoname_prefix()+ToString(serial);
41 tinfo_key=TINFO_clifford;
46 debugmsg("clifford destructor",LOGLEVEL_DESTRUCT);
50 clifford::clifford(clifford const & other)
52 debugmsg("clifford copy constructor",LOGLEVEL_CONSTRUCT);
56 clifford const & clifford::operator=(clifford const & other)
58 debugmsg("clifford operator=",LOGLEVEL_ASSIGNMENT);
68 void clifford::copy(clifford const & other)
75 void clifford::destroy(bool call_parent)
78 indexed::destroy(call_parent);
88 clifford::clifford(string const & initname)
90 debugmsg("clifford constructor from string",LOGLEVEL_CONSTRUCT);
93 tinfo_key=TINFO_clifford;
97 // functions overriding virtual functions from bases classes
102 basic * clifford::duplicate() const
104 debugmsg("clifford duplicate",LOGLEVEL_DUPLICATE);
105 return new clifford(*this);
108 void clifford::printraw(ostream & os) const
110 debugmsg("clifford printraw",LOGLEVEL_PRINT);
111 os << "clifford(" << "name=" << name << ",serial=" << serial
114 os << ",hash=" << hashvalue << ",flags=" << flags << ")";
117 void clifford::printtree(ostream & os, unsigned indent) const
119 debugmsg("clifford printtree",LOGLEVEL_PRINT);
120 os << string(indent,' ') << name << " (clifford): "
121 << "serial=" << serial << ","
122 << seq.size() << "indices=";
123 printtreeindices(os,indent);
124 os << ", hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")"
125 << ", flags=" << flags << endl;
128 void clifford::print(ostream & os, unsigned upper_precedence) const
130 debugmsg("clifford print",LOGLEVEL_PRINT);
135 void clifford::printcsrc(ostream & os, unsigned type, unsigned upper_precedence) const
137 debugmsg("clifford print csrc",LOGLEVEL_PRINT);
138 print(os,upper_precedence);
141 bool clifford::info(unsigned inf) const
143 return indexed::info(inf);
148 int clifford::compare_same_type(basic const & other) const
150 ASSERT(other.tinfo() == TINFO_clifford);
151 const clifford *o = static_cast<const clifford *>(&other);
152 if (serial==o->serial) {
153 return indexed::compare_same_type(other);
155 return serial < o->serial ? -1 : 1;
158 ex clifford::simplify_ncmul(exvector const & v) const
160 return simplified_ncmul(v);
163 unsigned clifford::calchash(void) const
165 hashvalue=golden_ratio_hash(golden_ratio_hash(0x55555556U ^
166 golden_ratio_hash(tinfo_key) ^
168 setflag(status_flags::hash_calculated);
173 // virtual functions which can be overridden by derived classes
179 // non-virtual functions in this class
182 void clifford::setname(string const & n)
189 string & clifford::autoname_prefix(void)
191 static string * s=new string("clifford");
196 // static member variables
201 unsigned clifford::next_serial=0;
207 const clifford some_clifford;
208 type_info const & typeid_clifford=typeid(some_clifford);