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
29 // default constructor, destructor, copy constructor assignment operator and helpers
36 debugmsg("clifford default constructor",LOGLEVEL_CONSTRUCT);
38 name=autoname_prefix()+ToString(serial);
39 tinfo_key=TINFO_CLIFFORD;
44 debugmsg("clifford destructor",LOGLEVEL_DESTRUCT);
48 clifford::clifford(clifford const & other)
50 debugmsg("clifford copy constructor",LOGLEVEL_CONSTRUCT);
54 clifford const & clifford::operator=(clifford const & other)
56 debugmsg("clifford operator=",LOGLEVEL_ASSIGNMENT);
66 void clifford::copy(clifford const & other)
73 void clifford::destroy(bool call_parent)
76 indexed::destroy(call_parent);
86 clifford::clifford(string const & initname)
88 debugmsg("clifford constructor from string",LOGLEVEL_CONSTRUCT);
91 tinfo_key=TINFO_CLIFFORD;
95 // functions overriding virtual functions from bases classes
100 basic * clifford::duplicate() const
102 debugmsg("clifford duplicate",LOGLEVEL_DUPLICATE);
103 return new clifford(*this);
106 void clifford::printraw(ostream & os) const
108 debugmsg("clifford printraw",LOGLEVEL_PRINT);
109 os << "clifford(" << "name=" << name << ",serial=" << serial
112 os << ",hash=" << hashvalue << ",flags=" << flags << ")";
115 void clifford::printtree(ostream & os, unsigned indent) const
117 debugmsg("clifford printtree",LOGLEVEL_PRINT);
118 os << string(indent,' ') << name << " (clifford): "
119 << "serial=" << serial << ","
120 << seq.size() << "indices=";
121 printtreeindices(os,indent);
122 os << ", hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")"
123 << ", flags=" << flags << endl;
126 void clifford::print(ostream & os, unsigned upper_precedence) const
128 debugmsg("clifford print",LOGLEVEL_PRINT);
133 void clifford::printcsrc(ostream & os, unsigned type, unsigned upper_precedence) const
135 debugmsg("clifford print csrc",LOGLEVEL_PRINT);
136 print(os,upper_precedence);
139 bool clifford::info(unsigned inf) const
141 return indexed::info(inf);
146 int clifford::compare_same_type(basic const & other) const
148 ASSERT(other.tinfo() == TINFO_CLIFFORD);
149 const clifford *o = static_cast<const clifford *>(&other);
150 if (serial==o->serial) {
151 return indexed::compare_same_type(other);
153 return serial < o->serial ? -1 : 1;
156 ex clifford::simplify_ncmul(exvector const & v) const
158 return simplified_ncmul(v);
161 unsigned clifford::calchash(void) const
163 hashvalue=golden_ratio_hash(golden_ratio_hash(0x55555556U ^
164 golden_ratio_hash(tinfo_key) ^
166 setflag(status_flags::hash_calculated);
171 // virtual functions which can be overridden by derived classes
177 // non-virtual functions in this class
180 void clifford::setname(string const & n)
187 string & clifford::autoname_prefix(void)
189 static string * s=new string("clifford");
194 // static member variables
199 unsigned clifford::next_serial=0;
205 const clifford some_clifford;
206 type_info const & typeid_clifford=typeid(some_clifford);