3 * Implementation of GiNaC's isospin objects.
4 * No real implementation yet, to be done. */
7 * GiNaC Copyright (C) 1999 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 // default constructor, destructor, copy constructor assignment operator and helpers
39 debugmsg("isospin default constructor",LOGLEVEL_CONSTRUCT);
41 name=autoname_prefix()+ToString(serial);
42 tinfo_key=TINFO_isospin;
47 debugmsg("isospin destructor",LOGLEVEL_DESTRUCT);
51 isospin::isospin(isospin const & other)
53 debugmsg("isospin copy constructor",LOGLEVEL_CONSTRUCT);
57 isospin const & isospin::operator=(isospin const & other)
59 debugmsg("isospin operator=",LOGLEVEL_ASSIGNMENT);
69 void isospin::copy(isospin const & other)
76 void isospin::destroy(bool call_parent)
79 indexed::destroy(call_parent);
89 isospin::isospin(string const & initname)
91 debugmsg("isospin constructor from string",LOGLEVEL_CONSTRUCT);
94 tinfo_key=TINFO_isospin;
98 // functions overriding virtual functions from bases classes
103 basic * isospin::duplicate() const
105 debugmsg("isospin duplicate",LOGLEVEL_DUPLICATE);
106 return new isospin(*this);
109 void isospin::printraw(ostream & os) const
111 debugmsg("isospin printraw",LOGLEVEL_PRINT);
112 os << "isospin(" << "name=" << name << ",serial=" << serial
115 os << ",hash=" << hashvalue << ",flags=" << flags << ")";
118 void isospin::printtree(ostream & os, unsigned indent) const
120 debugmsg("isospin printtree",LOGLEVEL_PRINT);
121 os << string(indent,' ') << name << " (isospin): "
122 << "serial=" << serial << ","
123 << seq.size() << "indices=";
124 printtreeindices(os,indent);
125 os << ", hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")"
126 << ", flags=" << flags << endl;
129 void isospin::print(ostream & os, unsigned upper_precedence) const
131 debugmsg("isospin print",LOGLEVEL_PRINT);
136 void isospin::printcsrc(ostream & os, unsigned type, unsigned upper_precedence) const
138 debugmsg("isospin print csrc",LOGLEVEL_PRINT);
139 print(os,upper_precedence);
142 bool isospin::info(unsigned inf) const
144 return indexed::info(inf);
149 int isospin::compare_same_type(basic const & other) const
151 ASSERT(other.tinfo() == TINFO_isospin);
152 const isospin *o = static_cast<const isospin *>(&other);
153 if (serial==o->serial) {
154 return indexed::compare_same_type(other);
156 return serial < o->serial ? -1 : 1;
159 ex isospin::simplify_ncmul(exvector const & v) const
161 return simplified_ncmul(v);
164 unsigned isospin::calchash(void) const
166 hashvalue=golden_ratio_hash(golden_ratio_hash(0x55555556U ^
167 golden_ratio_hash(tinfo_key) ^
169 setflag(status_flags::hash_calculated);
174 // virtual functions which can be overridden by derived classes
180 // non-virtual functions in this class
183 void isospin::setname(string const & n)
190 string & isospin::autoname_prefix(void)
192 static string * s=new string("isospin");
197 // static member variables
202 unsigned isospin::next_serial=0;
208 const isospin some_isospin;
209 type_info const & typeid_isospin=typeid(some_isospin);