3 * Implementation of GiNaC's isospin 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
34 #ifndef NO_NAMESPACE_GINAC
36 #endif // ndef NO_NAMESPACE_GINAC
38 GINAC_IMPLEMENT_REGISTERED_CLASS(isospin, indexed)
41 // default constructor, destructor, copy constructor assignment operator and helpers
48 debugmsg("isospin default constructor",LOGLEVEL_CONSTRUCT);
50 name=autoname_prefix()+ToString(serial);
51 tinfo_key=TINFO_isospin;
56 debugmsg("isospin destructor",LOGLEVEL_DESTRUCT);
60 isospin::isospin(const isospin & other)
62 debugmsg("isospin copy constructor",LOGLEVEL_CONSTRUCT);
66 const isospin & isospin::operator=(const isospin & other)
68 debugmsg("isospin operator=",LOGLEVEL_ASSIGNMENT);
78 void isospin::copy(const isospin & other)
80 inherited::copy(other);
85 void isospin::destroy(bool call_parent)
88 inherited::destroy(call_parent);
98 isospin::isospin(const string & initname)
100 debugmsg("isospin constructor from string",LOGLEVEL_CONSTRUCT);
102 serial=next_serial++;
103 tinfo_key=TINFO_isospin;
110 /** Construct object from archive_node. */
111 isospin::isospin(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
113 debugmsg("isospin constructor from archive_node", LOGLEVEL_CONSTRUCT);
114 serial = next_serial++;
115 if (!(n.find_string("name", name)))
116 name = autoname_prefix() + ToString(serial);
117 tinfo_key = TINFO_isospin;
120 /** Unarchive the object. */
121 ex isospin::unarchive(const archive_node &n, const lst &sym_lst)
123 ex s = (new isospin(n, sym_lst))->setflag(status_flags::dynallocated);
125 // If isospin is in sym_lst, return the existing isospin
126 for (unsigned i=0; i<sym_lst.nops(); i++) {
127 if (is_ex_of_type(sym_lst.op(i), isospin) && (ex_to_isospin(sym_lst.op(i)).name == ex_to_isospin(s).name))
128 return sym_lst.op(i);
133 /** Archive the object. */
134 void isospin::archive(archive_node &n) const
136 inherited::archive(n);
137 n.add_string("name", name);
141 // functions overriding virtual functions from bases classes
146 basic * isospin::duplicate() const
148 debugmsg("isospin duplicate",LOGLEVEL_DUPLICATE);
149 return new isospin(*this);
152 void isospin::printraw(ostream & os) const
154 debugmsg("isospin printraw",LOGLEVEL_PRINT);
155 os << "isospin(" << "name=" << name << ",serial=" << serial
158 os << ",hash=" << hashvalue << ",flags=" << flags << ")";
161 void isospin::printtree(ostream & os, unsigned indent) const
163 debugmsg("isospin printtree",LOGLEVEL_PRINT);
164 os << string(indent,' ') << name << " (isospin): "
165 << "serial=" << serial << ","
166 << seq.size() << "indices=";
167 printtreeindices(os,indent);
168 os << ", hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")"
169 << ", flags=" << flags << endl;
172 void isospin::print(ostream & os, unsigned upper_precedence) const
174 debugmsg("isospin print",LOGLEVEL_PRINT);
179 void isospin::printcsrc(ostream & os, unsigned type, unsigned upper_precedence) const
181 debugmsg("isospin print csrc",LOGLEVEL_PRINT);
182 print(os,upper_precedence);
185 bool isospin::info(unsigned inf) const
187 return inherited::info(inf);
192 int isospin::compare_same_type(const basic & other) const
194 GINAC_ASSERT(other.tinfo() == TINFO_isospin);
195 const isospin *o = static_cast<const isospin *>(&other);
196 if (serial==o->serial) {
197 return inherited::compare_same_type(other);
199 return serial < o->serial ? -1 : 1;
202 ex isospin::simplify_ncmul(const exvector & v) const
204 return simplified_ncmul(v);
207 unsigned isospin::calchash(void) const
209 hashvalue=golden_ratio_hash(golden_ratio_hash(0x55555556U ^
210 golden_ratio_hash(tinfo_key) ^
212 setflag(status_flags::hash_calculated);
217 // virtual functions which can be overridden by derived classes
223 // non-virtual functions in this class
226 void isospin::setname(const string & n)
233 string & isospin::autoname_prefix(void)
235 static string * s=new string("isospin");
240 // static member variables
245 unsigned isospin::next_serial=0;
251 const isospin some_isospin;
252 const type_info & typeid_isospin=typeid(some_isospin);
254 #ifndef NO_NAMESPACE_GINAC
256 #endif // ndef NO_NAMESPACE_GINAC