3 * Implementation of GiNaC's clifford objects.
4 * No real implementation yet, to be done. */
7 * GiNaC Copyright (C) 1999-2000 Johannes Gutenberg University Mainz, Germany
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.
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.
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
32 #ifndef NO_NAMESPACE_GINAC
34 #endif // ndef NO_NAMESPACE_GINAC
37 // default constructor, destructor, copy constructor assignment operator and helpers
44 debugmsg("clifford default constructor",LOGLEVEL_CONSTRUCT);
46 name=autoname_prefix()+ToString(serial);
47 tinfo_key=TINFO_clifford;
52 debugmsg("clifford destructor",LOGLEVEL_DESTRUCT);
56 clifford::clifford(const clifford & other)
58 debugmsg("clifford copy constructor",LOGLEVEL_CONSTRUCT);
62 const clifford & clifford::operator=(const clifford & other)
64 debugmsg("clifford operator=",LOGLEVEL_ASSIGNMENT);
74 void clifford::copy(const clifford & other)
81 void clifford::destroy(bool call_parent)
84 indexed::destroy(call_parent);
94 clifford::clifford(const std::string & initname)
96 debugmsg("clifford constructor from string",LOGLEVEL_CONSTRUCT);
99 tinfo_key=TINFO_clifford;
103 // functions overriding virtual functions from bases classes
108 basic * clifford::duplicate() const
110 debugmsg("clifford duplicate",LOGLEVEL_DUPLICATE);
111 return new clifford(*this);
114 void clifford::printraw(std::ostream & os) const
116 debugmsg("clifford printraw",LOGLEVEL_PRINT);
117 os << "clifford(" << "name=" << name << ",serial=" << serial
120 os << ",hash=" << hashvalue << ",flags=" << flags << ")";
123 void clifford::printtree(std::ostream & os, unsigned indent) const
125 debugmsg("clifford printtree",LOGLEVEL_PRINT);
126 os << std::string(indent,' ') << name << " (clifford): "
127 << "serial=" << serial << ","
128 << seq.size() << "indices=";
129 printtreeindices(os, indent);
130 os << ", hash=" << hashvalue
131 << " (0x" << std::hex << hashvalue << std::dec << ")"
132 << ", flags=" << flags << std::endl;
135 void clifford::print(std::ostream & os, unsigned upper_precedence) const
137 debugmsg("clifford print",LOGLEVEL_PRINT);
142 void clifford::printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence) const
144 debugmsg("clifford print csrc",LOGLEVEL_PRINT);
145 print(os,upper_precedence);
148 bool clifford::info(unsigned inf) const
150 return indexed::info(inf);
155 int clifford::compare_same_type(const basic & other) const
157 GINAC_ASSERT(other.tinfo() == TINFO_clifford);
158 const clifford *o = static_cast<const clifford *>(&other);
159 if (serial==o->serial) {
160 return indexed::compare_same_type(other);
162 return serial < o->serial ? -1 : 1;
165 ex clifford::simplify_ncmul(const exvector & v) const
167 return simplified_ncmul(v);
170 unsigned clifford::calchash(void) const
172 hashvalue=golden_ratio_hash(golden_ratio_hash(0x55555556U ^
173 golden_ratio_hash(tinfo_key) ^
175 setflag(status_flags::hash_calculated);
180 // virtual functions which can be overridden by derived classes
186 // non-virtual functions in this class
189 void clifford::setname(const std::string & n)
196 std::string & clifford::autoname_prefix(void)
198 static std::string * s = new std::string("clifford");
203 // static member variables
208 unsigned clifford::next_serial=0;
214 const clifford some_clifford;
215 const std::type_info & typeid_clifford = typeid(some_clifford);
217 #ifndef NO_NAMESPACE_GINAC
219 #endif // ndef NO_NAMESPACE_GINAC