add::~add()
{
debugmsg("add destructor",LOGLEVEL_DESTRUCT);
- destroy(0);
+ destroy(false);
}
add::add(const add & other)
{
debugmsg("add operator=",LOGLEVEL_ASSIGNMENT);
if (this != &other) {
- destroy(1);
+ destroy(true);
copy(other);
}
return *this;
if (vp==0)
return *this;
- return (new add(vp,overall_coeff))->
- setflag(status_flags::expanded |
- status_flags::dynallocated);
+ return (new add(vp,overall_coeff))->setflag(status_flags::expanded | status_flags::dynallocated);
}
//////////
/** Copy constructor of archive_node. */
archive_node::archive_node(const archive_node &other)
- : a(other.a), props(other.props), has_expression(other.has_expression), e(other.e)
+ : a(other.a), props(other.props), has_expression(other.has_expression), e(other.e)
{
}
/** Recursively construct archive node from expression. */
archive_node::archive_node(archive &ar, const ex &expr)
- : a(ar), has_expression(true), e(expr)
+ : a(ar), has_expression(true), e(expr)
{
expr.bp->archive(*this);
}
basic::~basic()
{
debugmsg("basic destructor", LOGLEVEL_DESTRUCT);
- destroy(0);
+ destroy(false);
GINAC_ASSERT((!(flags & status_flags::dynallocated))||(refcount==0));
}
{
debugmsg("basic operator=", LOGLEVEL_ASSIGNMENT);
if (this != &other) {
- destroy(1);
+ destroy(true);
copy(other);
}
return *this;
ex ndiff = this->derivative(s);
while (!ndiff.is_zero() && // stop differentiating zeros
- nth>1) {
+ nth>1) {
ndiff = ndiff.diff(s);
--nth;
}
clifford::~clifford()
{
debugmsg("clifford destructor",LOGLEVEL_DESTRUCT);
- destroy(0);
+ destroy(false);
}
clifford::clifford(const clifford & other)
{
debugmsg("clifford operator=",LOGLEVEL_ASSIGNMENT);
if (this != &other) {
- destroy(1);
+ destroy(true);
copy(other);
}
return *this;
color::~color()
{
debugmsg("color destructor",LOGLEVEL_DESTRUCT);
- destroy(0);
+ destroy(false);
}
color::color(const color & other)
{
debugmsg("color operator=",LOGLEVEL_ASSIGNMENT);
if (this != &other) {
- destroy(1);
- copy(other);
+ destroy(true);
+ copy(other);
}
return *this;
}
}
color::color(color_types const t, const ex & i1, unsigned rl)
- : inherited(i1), type(t), representation_label(rl)
+ : inherited(i1), type(t), representation_label(rl)
{
debugmsg("color constructor from color_types,ex,unsigned",LOGLEVEL_CONSTRUCT);
GINAC_ASSERT(representation_label<MAX_REPRESENTATION_LABELS);
}
color::color(color_types const t, const ex & i1, const ex & i2, unsigned rl)
- : inherited(i1,i2), type(t), representation_label(rl)
+ : inherited(i1,i2), type(t), representation_label(rl)
{
debugmsg("color constructor from color_types,ex,ex,unsigned",LOGLEVEL_CONSTRUCT);
GINAC_ASSERT(representation_label<MAX_REPRESENTATION_LABELS);
}
color::color(color_types const t, const ex & i1, const ex & i2, const ex & i3,
- unsigned rl) : inherited(i1,i2,i3), type(t), representation_label(rl)
+ unsigned rl) : inherited(i1,i2,i3), type(t), representation_label(rl)
{
debugmsg("color constructor from color_types,ex,ex,ex,unsigned",LOGLEVEL_CONSTRUCT);
GINAC_ASSERT(representation_label<MAX_REPRESENTATION_LABELS);
}
color::color(color_types const t, const exvector & iv, unsigned rl)
- : inherited(iv), type(t), representation_label(rl)
+ : inherited(iv), type(t), representation_label(rl)
{
debugmsg("color constructor from color_types,exvector,unsigned",LOGLEVEL_CONSTRUCT);
GINAC_ASSERT(representation_label<MAX_REPRESENTATION_LABELS);
}
color::color(color_types const t, exvector * ivp, unsigned rl)
- : inherited(ivp), type(t), representation_label(rl)
+ : inherited(ivp), type(t), representation_label(rl)
{
debugmsg("color constructor from color_types,exvector *,unsigned",LOGLEVEL_CONSTRUCT);
GINAC_ASSERT(representation_label<MAX_REPRESENTATION_LABELS);
if (CMPINDICES(1,2,3)) {
return _ex1();
} else if (CMPINDICES(1,4,7)||CMPINDICES(2,4,6)||
- CMPINDICES(2,5,7)||CMPINDICES(3,4,5)) {
+ CMPINDICES(2,5,7)||CMPINDICES(3,4,5)) {
return _ex1_2();
} else if (CMPINDICES(1,5,6)||CMPINDICES(3,6,7)) {
return -_ex1_2();
}
void split_color_string_in_parts(const exvector & v, exvector & delta8vec,
- exvector & fvec, exvector & dvec,
- exvectorvector & Tvecs,
- exvectorvector & ONEvecs,
- exvector & unknownvec)
+ exvector & fvec, exvector & dvec,
+ exvectorvector & Tvecs,
+ exvectorvector & ONEvecs,
+ exvector & unknownvec)
{
// if not all elements are of type color, put all Ts in unknownvec to
// retain the ordering
}
exvector recombine_color_string(exvector & delta8vec, exvector & fvec,
- exvector & dvec, exvectorvector & Tvecs,
- exvectorvector & ONEvecs, exvector & unknownvec)
+ exvector & dvec, exvectorvector & Tvecs,
+ exvectorvector & ONEvecs, exvector & unknownvec)
{
unsigned sz=delta8vec.size()+fvec.size()+dvec.size()+unknownvec.size();
for (unsigned rl=0; rl<MAX_REPRESENTATION_LABELS; ++rl) {
// FIXME: check this formula for SU(N) with N!=3
return numeric(1)/numeric(2*COLOR_THREE)*color_delta8(next_to_last_index,last_index)
- % color_trace_of_one_representation_label(v1)
- +numeric(1)/numeric(2)*color_h(next_to_last_index,last_index,summation_index)
- % color_trace_of_one_representation_label(v2);
+ % color_trace_of_one_representation_label(v1)
+ +numeric(1)/numeric(2)*color_h(next_to_last_index,last_index,summation_index)
+ % color_trace_of_one_representation_label(v2);
/*
ex term1=numeric(1)/numeric(2*COLOR_THREE)*color_delta8(next_to_last_index,last_index)
% color_trace_of_one_representation_label(v1);
}
t1=_ex1();
t2=_ex1();
- ex term1=numeric(-1)/numeric(6)*nonsimplified_ncmul(recombine_color_string(
- delta8vec,fvec,dvec,Tvecs,ONEvecs,unknownvec));
+ ex term1=numeric(-1)/numeric(6)*nonsimplified_ncmul(recombine_color_string(delta8vec,fvec,dvec,Tvecs,ONEvecs,unknownvec));
for (unsigned k=i+1; k<j; ++k) {
S.push_back(_ex1());
}
t1=color_trace_of_one_representation_label(S);
- ex term2=numeric(1)/numeric(2)*nonsimplified_ncmul(recombine_color_string(
- delta8vec,fvec,dvec,Tvecs,ONEvecs,unknownvec));
+ ex term2=numeric(1)/numeric(2)*nonsimplified_ncmul(recombine_color_string(delta8vec,fvec,dvec,Tvecs,ONEvecs,unknownvec));
return simplify_color(term1+term2);
}
}
coloridx::~coloridx()
{
debugmsg("coloridx destructor",LOGLEVEL_DESTRUCT);
- destroy(0);
+ destroy(false);
}
coloridx::coloridx(const coloridx & other)
{
debugmsg("coloridx operator=",LOGLEVEL_ASSIGNMENT);
if (this != &other) {
- destroy(1);
+ destroy(true);
copy(other);
}
return *this;
// public
-constant::constant() :
- basic(TINFO_constant), name(""), ef(0),
- number(0), serial(next_serial++)
+constant::constant() : basic(TINFO_constant), name(""), ef(0), number(0), serial(next_serial++)
{
debugmsg("constant default constructor",LOGLEVEL_CONSTRUCT);
}
// public
-constant::constant(const std::string & initname, evalffunctype efun) :
- basic(TINFO_constant), name(initname), ef(efun),
- // number(0), fct_assigned(true), serial(next_serial++)
- number(0), serial(next_serial++)
+constant::constant(const std::string & initname, evalffunctype efun)
+ : basic(TINFO_constant), name(initname), ef(efun), number(0), serial(next_serial++)
{
debugmsg("constant constructor from string, function",LOGLEVEL_CONSTRUCT);
}
-constant::constant(const std::string & initname, const numeric & initnumber) :
- basic(TINFO_constant), name(initname), ef(0),
- number(new numeric(initnumber)), /* fct_assigned(false),*/ serial(next_serial++)
+constant::constant(const std::string & initname, const numeric & initnumber)
+ : basic(TINFO_constant), name(initname), ef(0), number(new numeric(initnumber)), serial(next_serial++)
{
debugmsg("constant constructor from string, numeric",LOGLEVEL_CONSTRUCT);
}
}
$constructors_interface=generate(
-' explicit ${CONTAINER}(${SEQ1});'."\n",
+' explicit ${CONTAINER}(${SEQ1});'."\n",
'const ex & param${N}',', ','','');
$constructors_implementation=generate(
- <<'END_OF_CONSTRUCTORS_IMPLEMENTATION','const ex & param${N}',', ',' seq.push_back(param${N});',"\n");
+ <<'END_OF_CONSTRUCTORS_IMPLEMENTATION','const ex & param${N}',', ',' seq.push_back(param${N});',"\n");
${CONTAINER}::${CONTAINER}(${SEQ1}) : basic(TINFO_${CONTAINER})
{
debugmsg(\"${CONTAINER} constructor from ${N}*ex\",LOGLEVEL_CONSTRUCT);
${CONTAINER}::~${CONTAINER}()
{
debugmsg("${CONTAINER} destructor",LOGLEVEL_DESTRUCT);
- destroy(0);
+ destroy(false);
}
${CONTAINER}::${CONTAINER}(${CONTAINER} const & other)
{
debugmsg("${CONTAINER} operator=",LOGLEVEL_ASSIGNMENT);
if (this != &other) {
- destroy(1);
+ destroy(true);
copy(other);
}
return *this;
{
debugmsg("expairseq operator=",LOGLEVEL_ASSIGNMENT);
if (this != &other) {
- destroy(1);
+ destroy(true);
copy(other);
}
return *this;
for (unsigned i=0; i<hashtabsize; ++i) {
hashtab[i].clear();
for (epplist::const_iterator cit=other.hashtab[i].begin();
- cit!=other.hashtab[i].end(); ++cit) {
+ cit!=other.hashtab[i].end(); ++cit) {
hashtab[i].push_back(seq.begin()+((*cit)-osb));
}
}
}
/*
-expairseq::expairseq(const epvector & v, bool do_not_canonicalize) :
- inherited(TINFO_expairseq)
+expairseq::expairseq(const epvector & v, bool do_not_canonicalize)
+ : inherited(TINFO_expairseq)
{
debugmsg("expairseq constructor from epvector",LOGLEVEL_CONSTRUCT);
if (do_not_canonicalize) {
}
*/
-expairseq::expairseq(const epvector & v, const ex & oc) :
- inherited(TINFO_expairseq), overall_coeff(oc)
+expairseq::expairseq(const epvector & v, const ex & oc)
+ : inherited(TINFO_expairseq), overall_coeff(oc)
{
debugmsg("expairseq constructor from epvector,ex",LOGLEVEL_CONSTRUCT);
construct_from_epvector(v);
GINAC_ASSERT(is_canonical());
}
-expairseq::expairseq(epvector * vp, const ex & oc) :
- inherited(TINFO_expairseq), overall_coeff(oc)
+expairseq::expairseq(epvector * vp, const ex & oc)
+ : inherited(TINFO_expairseq), overall_coeff(oc)
{
debugmsg("expairseq constructor from epvector *,ex",LOGLEVEL_CONSTRUCT);
GINAC_ASSERT(vp!=0);
return this->hold();
}
- return (new expairseq(vp,overall_coeff))
- ->setflag(status_flags::dynallocated |
- status_flags::evaluated );
+ return (new expairseq(vp,overall_coeff))->setflag(status_flags::dynallocated | status_flags::evaluated);
}
ex expairseq::evalf(int level) const
}
void expairseq::printseq(std::ostream & os, char delim,
- unsigned this_precedence,
- unsigned upper_precedence) const
+ unsigned this_precedence,
+ unsigned upper_precedence) const
{
if (this_precedence<=upper_precedence) os << "(";
epvector::const_iterator it,it_last;
}
expair expairseq::combine_ex_with_coeff_to_pair(const ex & e,
- const ex & c) const
+ const ex & c) const
{
GINAC_ASSERT(is_ex_exactly_of_type(c,numeric));
}
expair expairseq::combine_pair_with_coeff_to_pair(const expair & p,
- const ex & c) const
+ const ex & c) const
{
GINAC_ASSERT(is_ex_exactly_of_type(p.coeff,numeric));
GINAC_ASSERT(is_ex_exactly_of_type(c,numeric));
GINAC_ASSERT(is_ex_exactly_of_type(c1,numeric));
GINAC_ASSERT(is_ex_exactly_of_type(c2,numeric));
overall_coeff = ex_to_numeric(overall_coeff).
- add_dyn(ex_to_numeric(c1).mul(ex_to_numeric(c2)));
+ add_dyn(ex_to_numeric(c1).mul(ex_to_numeric(c2)));
}
bool expairseq::can_make_flat(const expair & p) const
void expairseq::construct_from_2_ex(const ex & lh, const ex & rh)
{
if (lh.bp->tinfo()==tinfo()) {
- if (rh.bp->tinfo()==tinfo()) {
+ if (rh.bp->tinfo()==tinfo()) {
#ifdef EXPAIRSEQ_USE_HASHTAB
- unsigned totalsize=ex_to_expairseq(lh).seq.size()+
- ex_to_expairseq(rh).seq.size();
- if (calc_hashtabsize(totalsize)!=0) {
- construct_from_2_ex_via_exvector(lh,rh);
- } else {
+ unsigned totalsize = ex_to_expairseq(lh).seq.size() +
+ ex_to_expairseq(rh).seq.size();
+ if (calc_hashtabsize(totalsize)!=0) {
+ construct_from_2_ex_via_exvector(lh,rh);
+ } else {
#endif // def EXPAIRSEQ_USE_HASHTAB
- construct_from_2_expairseq(ex_to_expairseq(lh),
- ex_to_expairseq(rh));
+ construct_from_2_expairseq(ex_to_expairseq(lh),
+ ex_to_expairseq(rh));
#ifdef EXPAIRSEQ_USE_HASHTAB
- }
+ }
#endif // def EXPAIRSEQ_USE_HASHTAB
- return;
- } else {
+ return;
+ } else {
#ifdef EXPAIRSEQ_USE_HASHTAB
- unsigned totalsize=ex_to_expairseq(lh).seq.size()+1;
- if (calc_hashtabsize(totalsize)!=0) {
- construct_from_2_ex_via_exvector(lh,rh);
- } else {
+ unsigned totalsize=ex_to_expairseq(lh).seq.size()+1;
+ if (calc_hashtabsize(totalsize) != 0) {
+ construct_from_2_ex_via_exvector(lh, rh);
+ } else {
#endif // def EXPAIRSEQ_USE_HASHTAB
- construct_from_expairseq_ex(ex_to_expairseq(lh),rh);
+ construct_from_expairseq_ex(ex_to_expairseq(lh), rh);
#ifdef EXPAIRSEQ_USE_HASHTAB
- }
+ }
#endif // def EXPAIRSEQ_USE_HASHTAB
- return;
- }
+ return;
+ }
} else if (rh.bp->tinfo()==tinfo()) {
#ifdef EXPAIRSEQ_USE_HASHTAB
unsigned totalsize=ex_to_expairseq(rh).seq.size()+1;
int cmpval=(*first1).rest.compare((*first2).rest);
if (cmpval==0) {
// combine terms
- const numeric & newcoeff=ex_to_numeric((*first1).coeff).
- add(ex_to_numeric((*first2).coeff));
+ const numeric & newcoeff = ex_to_numeric((*first1).coeff).
+ add(ex_to_numeric((*first2).coeff));
if (!newcoeff.is_zero()) {
seq.push_back(expair((*first1).rest,newcoeff));
if (expair_needs_further_processing(seq.end()-1)) {
int cmpval=(*first).rest.compare(p.rest);
if (cmpval==0) {
// combine terms
- const numeric & newcoeff=ex_to_numeric((*first).coeff).
- add(ex_to_numeric(p.coeff));
+ const numeric & newcoeff = ex_to_numeric((*first).coeff).
+ add(ex_to_numeric(p.coeff));
if (!newcoeff.is_zero()) {
seq.push_back(expair((*first).rest,newcoeff));
if (expair_needs_further_processing(seq.end()-1)) {
if ((cit->rest.bp->tinfo()==tinfo())&&can_make_flat(*cit)) {
const expairseq & subseqref=ex_to_expairseq((*cit).rest);
combine_overall_coeff(ex_to_numeric(subseqref.overall_coeff),
- ex_to_numeric((*cit).coeff));
+ ex_to_numeric((*cit).coeff));
epvector::const_iterator cit_s=subseqref.seq.begin();
while (cit_s!=subseqref.seq.end()) {
seq.push_back(expair((*cit_s).rest,
- ex_to_numeric((*cit_s).coeff).mul_dyn(ex_to_numeric((*cit).coeff))));
+ ex_to_numeric((*cit_s).coeff).mul_dyn(ex_to_numeric((*cit).coeff))));
//seq.push_back(combine_pair_with_coeff_to_pair(*cit_s,
// (*cit).coeff));
++cit_s;
bool must_copy=false;
while (itin2!=last) {
if ((*itin1).rest.compare((*itin2).rest)==0) {
- (*itin1).coeff=ex_to_numeric((*itin1).coeff).
- add_dyn(ex_to_numeric((*itin2).coeff));
+ (*itin1).coeff = ex_to_numeric((*itin1).coeff).
+ add_dyn(ex_to_numeric((*itin2).coeff));
if (expair_needs_further_processing(itin1)) {
needs_further_processing = true;
}
}
void expairseq::build_hashtab_and_combine(epvector::iterator & first_numeric,
- epvector::iterator & last_non_zero,
- vector<bool> & touched,
- unsigned & number_of_zeroes)
+ epvector::iterator & last_non_zero,
+ vector<bool> & touched,
+ unsigned & number_of_zeroes)
{
epp current=seq.begin();
++current;
} else {
// epplit points to a matching expair, combine it with current
- (*(*epplit)).coeff=ex_to_numeric((*(*epplit)).coeff).
- add_dyn(ex_to_numeric((*current).coeff));
+ (*(*epplit)).coeff = ex_to_numeric((*(*epplit)).coeff).
+ add_dyn(ex_to_numeric((*current).coeff));
// move obsolete current expair to end by swapping with last_non_zero element
// if this was a numeric, it is swapped with the expair before first_numeric
}
void expairseq::drop_coeff_0_terms(epvector::iterator & first_numeric,
- epvector::iterator & last_non_zero,
- vector<bool> & touched,
- unsigned & number_of_zeroes)
+ epvector::iterator & last_non_zero,
+ vector<bool> & touched,
+ unsigned & number_of_zeroes)
{
// move terms with coeff 0 to end and remove them from hashtab
// check only those elements which have been touched
++number_of_zeroes;
if (first_numeric!=current) {
-
+
// change entry in hashtab which referred to first_numeric or last_non_zero to current
move_hashtab_entry(changed_entry,current);
touched[current-seq.begin()]=touched[changed_entry-seq.begin()];
}
// copy first changed element
s->push_back(combine_ex_with_coeff_to_pair(expanded_ex,
- (*cit2).coeff));
+ (*cit2).coeff));
++cit2;
// copy rest
while (cit2!=last) {
s->push_back(combine_ex_with_coeff_to_pair((*cit2).rest.expand(options),
- (*cit2).coeff));
+ (*cit2).coeff));
++cit2;
}
return s;
}
// copy first changed element
s->push_back(combine_ex_with_coeff_to_pair(evaled_ex,
- (*cit2).coeff));
+ (*cit2).coeff));
++cit2;
// copy rest
while (cit2!=last) {
s->push_back(combine_ex_with_coeff_to_pair((*cit2).rest.eval(level),
- (*cit2).coeff));
+ (*cit2).coeff));
++cit2;
}
return s;
--level;
for (epvector::const_iterator it=seq.begin(); it!=seq.end(); ++it) {
s.push_back(combine_ex_with_coeff_to_pair((*it).rest.evalf(level),
- (*it).coeff.evalf(level)));
+ (*it).coeff.evalf(level)));
}
return s;
}
--level;
for (epvector::const_iterator it=seq.begin(); it!=seq.end(); ++it) {
s.push_back(combine_ex_with_coeff_to_pair((*it).rest.normal(level),
- (*it).coeff));
+ (*it).coeff));
}
return s;
}
for (epvector::const_iterator it=seq.begin(); it!=seq.end(); ++it) {
s.push_back(combine_ex_with_coeff_to_pair((*it).rest.diff(y),
- (*it).coeff));
+ (*it).coeff));
}
return s;
}
}
// copy first changed element
s->push_back(combine_ex_with_coeff_to_pair(subsed_ex,
- (*cit2).coeff));
+ (*cit2).coeff));
++cit2;
// copy rest
while (cit2!=last) {
s->push_back(combine_ex_with_coeff_to_pair((*cit2).rest.subs(ls,lr),
- (*cit2).coeff));
+ (*cit2).coeff));
++cit2;
}
return s;
bool exprseq::info(unsigned inf) const
{
- if (inf==info_flags::exprseq) return 1;
+ if (inf==info_flags::exprseq)
+ return 1;
return basic::info(inf);
}
fail::~fail()
{
debugmsg("fail destructor",LOGLEVEL_DESTRUCT);
- destroy(0);
+ destroy(false);
}
fail::fail(const fail & other)
{
debugmsg("fail operator=",LOGLEVEL_ASSIGNMENT);
if (this != &other) {
- destroy(1);
+ destroy(true);
copy(other);
}
return *this;
function::~function()
{
debugmsg("function destructor",LOGLEVEL_DESTRUCT);
- destroy(0);
+ destroy(false);
}
function::function(const function & other)
{
debugmsg("function operator=",LOGLEVEL_ASSIGNMENT);
if (this != &other) {
- destroy(1);
+ destroy(true);
copy(other);
}
return *this;
idx::~idx()
{
debugmsg("idx destructor",LOGLEVEL_DESTRUCT);
- destroy(0);
+ destroy(false);
}
idx::idx(const idx & other)
{
debugmsg("idx operator=",LOGLEVEL_ASSIGNMENT);
if (this != &other) {
- destroy(1);
+ destroy(true);
copy(other);
}
return *this;
serial = next_serial++;
}
-idx::idx(const char * n, bool cov) : inherited(TINFO_idx),
- symbolic(true), name(n), covariant(cov)
+idx::idx(const char * n, bool cov) : inherited(TINFO_idx), symbolic(true), name(n), covariant(cov)
{
debugmsg("idx constructor from char*,bool",LOGLEVEL_CONSTRUCT);
serial = next_serial++;
}
-idx::idx(unsigned v, bool cov) : inherited(TINFO_idx),
- symbolic(false), value(v), covariant(cov)
+idx::idx(unsigned v, bool cov) : inherited(TINFO_idx), symbolic(false), value(v), covariant(cov)
{
debugmsg("idx constructor from unsigned,bool",LOGLEVEL_CONSTRUCT);
serial = 0;
int idx::compare_same_type(const basic & other) const
{
GINAC_ASSERT(is_of_type(other,idx));
- const idx & o=static_cast<const idx &>
- (const_cast<basic &>(other));
+ const idx & o=static_cast<const idx &>(const_cast<basic &>(other));
if (covariant!=o.covariant) {
// different co/contravariant
bool idx::is_equal_same_type(const basic & other) const
{
GINAC_ASSERT(is_of_type(other,idx));
- const idx & o=static_cast<const idx &>
- (const_cast<basic &>(other));
+ const idx & o=static_cast<const idx &>(const_cast<basic &>(other));
if (covariant!=o.covariant) return false;
if (symbolic!=o.symbolic) return false;
{
// like is_equal_same_type(), but tests for different covariant status
GINAC_ASSERT(is_of_type(other,idx));
- const idx & o=static_cast<const idx &>
- (const_cast<basic &>(other));
+ const idx & o=static_cast<const idx &>(const_cast<basic &>(other));
if (covariant==o.covariant) return false;
if (symbolic!=o.symbolic) return false;
}
ex permute_free_index_to_front(const exvector & iv3, const exvector & iv2,
- bool antisymmetric, int * sig)
+ bool antisymmetric, int * sig)
{
// match (return value,iv2) to iv3 by permuting indices
// iv3 is always cyclic
}
ex subs_indices(const ex & e, const exvector & idxv_subs,
- const exvector & idxv_repl)
+ const exvector & idxv_repl)
{
GINAC_ASSERT(idxv_subs.size()==idxv_repl.size());
ex res=e;
indexed::~indexed()
{
debugmsg("indexed destructor",LOGLEVEL_DESTRUCT);
- destroy(0);
+ destroy(false);
}
indexed::indexed(const indexed & other)
{
debugmsg("indexed operator=",LOGLEVEL_ASSIGNMENT);
if (this != &other) {
- destroy(1);
+ destroy(true);
copy(other);
}
return *this;
}
indexed::indexed(const ex & i1, const ex & i2, const ex & i3)
- : inherited(i1,i2,i3)
+ : inherited(i1,i2,i3)
{
debugmsg("indexed constructor from ex,ex,ex",LOGLEVEL_CONSTRUCT);
tinfo_key=TINFO_indexed;
}
indexed::indexed(const ex & i1, const ex & i2, const ex & i3, const ex & i4)
- : inherited(i1,i2,i3,i4)
+ : inherited(i1,i2,i3,i4)
{
debugmsg("indexed constructor from ex,ex,ex,ex",LOGLEVEL_CONSTRUCT);
tinfo_key=TINFO_indexed;
}
void indexed::printcsrc(std::ostream & os, unsigned type,
- unsigned upper_precedence) const
+ unsigned upper_precedence) const
{
debugmsg("indexed print csrc",LOGLEVEL_PRINT);
print(os,upper_precedence);
* @see ex::diff */
ex indexed::derivative(const symbol & s) const
{
- return _ex0();
+ return _ex0();
}
int indexed::compare_same_type(const basic & other) const
}
REGISTER_FUNCTION(abs, eval_func(abs_eval).
- evalf_func(abs_evalf));
+ evalf_func(abs_evalf));
//////////
}
static ex csgn_series(const ex & arg,
- const relational & rel,
- int order,
- unsigned options)
+ const relational & rel,
+ int order,
+ unsigned options)
{
const ex arg_pt = arg.subs(rel);
- if (arg_pt.info(info_flags::numeric) &&
- ex_to_numeric(arg_pt).real().is_zero())
+ if (arg_pt.info(info_flags::numeric)
+ && ex_to_numeric(arg_pt).real().is_zero())
throw (std::domain_error("csgn_series(): on imaginary axis"));
epvector seq;
}
REGISTER_FUNCTION(csgn, eval_func(csgn_eval).
- evalf_func(csgn_evalf).
- series_func(csgn_series));
+ evalf_func(csgn_evalf).
+ series_func(csgn_series));
//////////
}
static ex eta_series(const ex & arg1,
- const ex & arg2,
- const relational & rel,
- int order,
- unsigned options)
+ const ex & arg2,
+ const relational & rel,
+ int order,
+ unsigned options)
{
const ex arg1_pt = arg1.subs(rel);
const ex arg2_pt = arg2.subs(rel);
}
REGISTER_FUNCTION(eta, eval_func(eta_eval).
- evalf_func(eta_evalf).
- series_func(eta_series));
+ evalf_func(eta_evalf).
+ series_func(eta_series));
//////////
}
REGISTER_FUNCTION(Li2, eval_func(Li2_eval).
- evalf_func(Li2_evalf).
- derivative_func(Li2_deriv).
- series_func(Li2_series));
+ evalf_func(Li2_evalf).
+ derivative_func(Li2_deriv).
+ series_func(Li2_series));
//////////
// trilogarithm
}
REGISTER_FUNCTION(factorial, eval_func(factorial_eval).
- evalf_func(factorial_evalf));
+ evalf_func(factorial_evalf));
//////////
// binomial
}
REGISTER_FUNCTION(binomial, eval_func(binomial_eval).
- evalf_func(binomial_evalf));
+ evalf_func(binomial_evalf));
//////////
// Order term function (for truncated power series)
// Differentiation is handled in function::derivative because of its special requirements
REGISTER_FUNCTION(Order, eval_func(Order_eval).
- series_func(Order_series));
+ series_func(Order_series));
//////////
// Inert partial differentiation operator
static ex lgamma_series(const ex & arg,
- const relational & rel,
- int order,
- unsigned options)
+ const relational & rel,
+ int order,
+ unsigned options)
{
// method:
// Taylor series where there is no pole falls back to psi function
REGISTER_FUNCTION(lgamma, eval_func(lgamma_eval).
- evalf_func(lgamma_evalf).
- derivative_func(lgamma_deriv).
- series_func(lgamma_series));
+ evalf_func(lgamma_evalf).
+ derivative_func(lgamma_deriv).
+ series_func(lgamma_series));
//////////
static ex tgamma_series(const ex & arg,
- const relational & rel,
- int order,
- unsigned options)
+ const relational & rel,
+ int order,
+ unsigned options)
{
// method:
// Taylor series where there is no pole falls back to psi function
REGISTER_FUNCTION(tgamma, eval_func(tgamma_eval).
- evalf_func(tgamma_evalf).
- derivative_func(tgamma_deriv).
- series_func(tgamma_series));
+ evalf_func(tgamma_evalf).
+ derivative_func(tgamma_deriv).
+ series_func(tgamma_series));
//////////
static ex beta_series(const ex & arg1,
- const ex & arg2,
- const relational & rel,
- int order,
- unsigned options)
+ const ex & arg2,
+ const relational & rel,
+ int order,
+ unsigned options)
{
// method:
// Taylor series where there is no pole of one of the tgamma functions
const symbol *s = static_cast<symbol *>(rel.lhs().bp);
ex arg1_ser, arg2_ser, arg1arg2_ser;
if ((!arg1_pt.info(info_flags::integer) || arg1_pt.info(info_flags::positive)) &&
- (!arg2_pt.info(info_flags::integer) || arg2_pt.info(info_flags::positive)))
+ (!arg2_pt.info(info_flags::integer) || arg2_pt.info(info_flags::positive)))
throw do_taylor(); // caught by function::series()
// trap the case where arg1 is on a pole:
if (arg1.info(info_flags::integer) && !arg1.info(info_flags::positive))
REGISTER_FUNCTION(beta, eval_func(beta_eval).
- evalf_func(beta_evalf).
- derivative_func(beta_deriv).
- series_func(beta_series));
+ evalf_func(beta_evalf).
+ derivative_func(beta_deriv).
+ series_func(beta_series));
//////////
}
static ex psi1_series(const ex & arg,
- const relational & rel,
- int order,
- unsigned options)
+ const relational & rel,
+ int order,
+ unsigned options)
{
// method:
// Taylor series where there is no pole falls back to polygamma function
const unsigned function_index_psi1 =
function::register_new(function_options("psi").
- eval_func(psi1_eval).
- evalf_func(psi1_evalf).
- derivative_func(psi1_deriv).
- series_func(psi1_series).
- overloaded(2));
+ eval_func(psi1_eval).
+ evalf_func(psi1_evalf).
+ derivative_func(psi1_deriv).
+ series_func(psi1_series).
+ overloaded(2));
//////////
// Psi-functions (aka polygamma-functions) psi(0,x)==psi(x)
}
static ex psi2_series(const ex & n,
- const ex & arg,
- const relational & rel,
- int order,
- unsigned options)
+ const ex & arg,
+ const relational & rel,
+ int order,
+ unsigned options)
{
// method:
// Taylor series where there is no pole falls back to polygamma function
const unsigned function_index_psi2 =
function::register_new(function_options("psi").
- eval_func(psi2_eval).
- evalf_func(psi2_evalf).
- derivative_func(psi2_deriv).
- series_func(psi2_series).
- overloaded(2));
+ eval_func(psi2_eval).
+ evalf_func(psi2_evalf).
+ derivative_func(psi2_deriv).
+ series_func(psi2_series).
+ overloaded(2));
#ifndef NO_NAMESPACE_GINAC
}
REGISTER_FUNCTION(exp, eval_func(exp_eval).
- evalf_func(exp_evalf).
- derivative_func(exp_deriv));
+ evalf_func(exp_evalf).
+ derivative_func(exp_deriv));
//////////
// natural logarithm
}
static ex log_series(const ex &arg,
- const relational &rel,
- int order,
- unsigned options)
+ const relational &rel,
+ int order,
+ unsigned options)
{
GINAC_ASSERT(is_ex_exactly_of_type(rel.lhs(),symbol));
ex arg_pt;
}
REGISTER_FUNCTION(log, eval_func(log_eval).
- evalf_func(log_evalf).
- derivative_func(log_deriv).
- series_func(log_series));
+ evalf_func(log_evalf).
+ derivative_func(log_deriv).
+ series_func(log_series));
//////////
// sine (trigonometric function)
}
REGISTER_FUNCTION(sin, eval_func(sin_eval).
- evalf_func(sin_evalf).
- derivative_func(sin_deriv));
+ evalf_func(sin_evalf).
+ derivative_func(sin_deriv));
//////////
// cosine (trigonometric function)
}
REGISTER_FUNCTION(cos, eval_func(cos_eval).
- evalf_func(cos_evalf).
- derivative_func(cos_deriv));
+ evalf_func(cos_evalf).
+ derivative_func(cos_deriv));
//////////
// tangent (trigonometric function)
}
static ex tan_series(const ex &x,
- const relational &rel,
- int order,
- unsigned options)
+ const relational &rel,
+ int order,
+ unsigned options)
{
// method:
// Taylor series where there is no pole falls back to tan_deriv.
}
REGISTER_FUNCTION(tan, eval_func(tan_eval).
- evalf_func(tan_evalf).
- derivative_func(tan_deriv).
- series_func(tan_series));
+ evalf_func(tan_evalf).
+ derivative_func(tan_deriv).
+ series_func(tan_series));
//////////
// inverse sine (arc sine)
}
REGISTER_FUNCTION(asin, eval_func(asin_eval).
- evalf_func(asin_evalf).
- derivative_func(asin_deriv));
+ evalf_func(asin_evalf).
+ derivative_func(asin_deriv));
//////////
// inverse cosine (arc cosine)
}
REGISTER_FUNCTION(acos, eval_func(acos_eval).
- evalf_func(acos_evalf).
- derivative_func(acos_deriv));
+ evalf_func(acos_evalf).
+ derivative_func(acos_deriv));
//////////
// inverse tangent (arc tangent)
}
REGISTER_FUNCTION(atan, eval_func(atan_eval).
- evalf_func(atan_evalf).
- derivative_func(atan_deriv));
+ evalf_func(atan_evalf).
+ derivative_func(atan_deriv));
//////////
// inverse tangent (atan2(y,x))
}
REGISTER_FUNCTION(atan2, eval_func(atan2_eval).
- evalf_func(atan2_evalf).
- derivative_func(atan2_deriv));
+ evalf_func(atan2_evalf).
+ derivative_func(atan2_deriv));
//////////
// hyperbolic sine (trigonometric function)
}
REGISTER_FUNCTION(sinh, eval_func(sinh_eval).
- evalf_func(sinh_evalf).
- derivative_func(sinh_deriv));
+ evalf_func(sinh_evalf).
+ derivative_func(sinh_deriv));
//////////
// hyperbolic cosine (trigonometric function)
}
REGISTER_FUNCTION(cosh, eval_func(cosh_eval).
- evalf_func(cosh_evalf).
- derivative_func(cosh_deriv));
+ evalf_func(cosh_evalf).
+ derivative_func(cosh_deriv));
//////////
}
static ex tanh_series(const ex &x,
- const relational &rel,
- int order,
- unsigned options)
+ const relational &rel,
+ int order,
+ unsigned options)
{
// method:
// Taylor series where there is no pole falls back to tanh_deriv.
}
REGISTER_FUNCTION(tanh, eval_func(tanh_eval).
- evalf_func(tanh_evalf).
- derivative_func(tanh_deriv).
- series_func(tanh_series));
+ evalf_func(tanh_evalf).
+ derivative_func(tanh_deriv).
+ series_func(tanh_series));
//////////
// inverse hyperbolic sine (trigonometric function)
}
REGISTER_FUNCTION(asinh, eval_func(asinh_eval).
- evalf_func(asinh_evalf).
- derivative_func(asinh_deriv));
+ evalf_func(asinh_evalf).
+ derivative_func(asinh_deriv));
//////////
// inverse hyperbolic cosine (trigonometric function)
}
REGISTER_FUNCTION(acosh, eval_func(acosh_eval).
- evalf_func(acosh_evalf).
- derivative_func(acosh_deriv));
+ evalf_func(acosh_evalf).
+ derivative_func(acosh_deriv));
//////////
// inverse hyperbolic tangent (trigonometric function)
}
REGISTER_FUNCTION(atanh, eval_func(atanh_eval).
- evalf_func(atanh_evalf).
- derivative_func(atanh_deriv));
+ evalf_func(atanh_evalf).
+ derivative_func(atanh_deriv));
#ifndef NO_NAMESPACE_GINAC
} // namespace GiNaC
const unsigned function_index_zeta1 =
function::register_new(function_options("zeta").
- eval_func(zeta1_eval).
- evalf_func(zeta1_evalf).
- derivative_func(zeta1_deriv).
- overloaded(2));
+ eval_func(zeta1_eval).
+ evalf_func(zeta1_evalf).
+ derivative_func(zeta1_deriv).
+ overloaded(2));
//////////
// Derivatives of Riemann's Zeta-function zeta(0,x)==zeta(x)
const unsigned function_index_zeta2 =
function::register_new(function_options("zeta").
- eval_func(zeta2_eval).
- derivative_func(zeta2_deriv).
- overloaded(2));
+ eval_func(zeta2_eval).
+ derivative_func(zeta2_deriv).
+ overloaded(2));
#ifndef NO_NAMESPACE_GINAC
} // namespace GiNaC
isospin::~isospin()
{
debugmsg("isospin destructor",LOGLEVEL_DESTRUCT);
- destroy(0);
+ destroy(false);
}
isospin::isospin(const isospin & other)
{
debugmsg("isospin operator=",LOGLEVEL_ASSIGNMENT);
if (this != &other) {
- destroy(1);
+ destroy(true);
copy(other);
}
return *this;
unsigned isospin::calchash(void) const
{
- hashvalue=golden_ratio_hash(golden_ratio_hash(0x55555556U ^
- golden_ratio_hash(tinfo_key) ^
- serial));
+ hashvalue = golden_ratio_hash(golden_ratio_hash(0x55555556U ^
+ golden_ratio_hash(tinfo_key) ^ serial));
setflag(status_flags::hash_calculated);
return hashvalue;
}
{
debugmsg("lorentzidx default constructor",LOGLEVEL_CONSTRUCT);
// serial is incremented in idx::idx()
- name="mu"+ToString(serial);
- tinfo_key=TINFO_lorentzidx;
+ name = "mu" + ToString(serial);
+ tinfo_key = TINFO_lorentzidx;
}
lorentzidx::~lorentzidx()
{
debugmsg("lorentzidx destructor",LOGLEVEL_DESTRUCT);
- destroy(0);
+ destroy(false);
}
lorentzidx::lorentzidx(const lorentzidx & other)
{
debugmsg("lorentzidx operator=",LOGLEVEL_ASSIGNMENT);
if (this != &other) {
- destroy(1);
+ destroy(true);
copy(other);
}
return *this;
// public
-lorentzidx::lorentzidx(bool cov, bool oonly, unsigned dimp) :
- idx(cov), orthogonal_only(oonly), dim_parallel_space(dimp)
+lorentzidx::lorentzidx(bool cov, bool oonly, unsigned dimp)
+ : idx(cov), orthogonal_only(oonly), dim_parallel_space(dimp)
{
debugmsg("lorentzidx constructor from bool",LOGLEVEL_CONSTRUCT);
// serial is incremented in idx::idx(bool)
}
lorentzidx::lorentzidx(const std::string & n, bool cov, bool oonly, unsigned dimp)
- : idx(n,cov), orthogonal_only(oonly), dim_parallel_space(dimp)
+ : idx(n,cov), orthogonal_only(oonly), dim_parallel_space(dimp)
{
debugmsg("lorentzidx constructor from string,bool,bool,unsigned",
LOGLEVEL_CONSTRUCT);
}
lorentzidx::lorentzidx(const char * n, bool cov, bool oonly, unsigned dimp)
- : idx(n,cov), orthogonal_only(oonly), dim_parallel_space(dimp)
+ : idx(n,cov), orthogonal_only(oonly), dim_parallel_space(dimp)
{
debugmsg("lorentzidx constructor from char*,bool,bool,unsigned",
LOGLEVEL_CONSTRUCT);
tinfo_key=TINFO_lorentzidx;
}
-lorentzidx::lorentzidx(unsigned v, bool cov) : idx(v,cov),
- orthogonal_only(false), dim_parallel_space(0)
+lorentzidx::lorentzidx(unsigned v, bool cov)
+ : idx(v,cov), orthogonal_only(false), dim_parallel_space(0)
{
debugmsg("lorentzidx constructor from unsigned,bool",LOGLEVEL_CONSTRUCT);
tinfo_key=TINFO_lorentzidx;
i_copy.serial=0;
i_copy.name="anonymous_representative";
i_copy.covariant=false;
- i_copy.clearflag(status_flags::dynallocated|
- status_flags::hash_calculated);
+ i_copy.clearflag(status_flags::dynallocated |
+ status_flags::hash_calculated);
return i_copy;
}
lortensor::~lortensor()
{
debugmsg("lortensor destructor",LOGLEVEL_DESTRUCT);
- destroy(0);
+ destroy(false);
}
lortensor::lortensor(const lortensor & other)
{
debugmsg("lortensor operator=",LOGLEVEL_ASSIGNMENT);
if (this != & other) {
- destroy(1);
+ destroy(true);
copy(other);
}
return *this;
{
return return_types::commutative;
}
+
unsigned lortensor::return_type_tinfo(void) const
{
return tinfo_key;
}
+
ex lortensor::thisexprseq(const exvector & v) const
{
return lortensor(type,name,serial,v);
}
+
ex lortensor::thisexprseq(exvector *vp) const
{
return lortensor(type,name,serial,vp);
replacements=0;
if (first_idx.is_symbolic()) {
replacements = subs_index_in_exvector(v_contracted,
- first_idx.toggle_covariant(),second_idx);
+ first_idx.toggle_covariant(),second_idx);
if (replacements==0) {
// not contracted, restore g object
*it=saved_g;
if ((replacements==0)&&(second_idx.is_symbolic())) {
// first index not contracted, *it is again the original g object
replacements = subs_index_in_exvector(v_contracted,
- second_idx.toggle_covariant(),first_idx);
+ second_idx.toggle_covariant(),first_idx);
if (replacements==0) {
// not contracted except in itself, restore g object
*it=saved_g;
// public
/** Default ctor. Initializes to 1 x 1-dimensional zero-matrix. */
-matrix::matrix()
- : inherited(TINFO_matrix), row(1), col(1)
+matrix::matrix() : inherited(TINFO_matrix), row(1), col(1)
{
debugmsg("matrix default constructor",LOGLEVEL_CONSTRUCT);
m.push_back(_ex0());
matrix::~matrix()
{
debugmsg("matrix destructor",LOGLEVEL_DESTRUCT);
+ destroy(false);
}
matrix::matrix(const matrix & other)
{
debugmsg("matrix operator=",LOGLEVEL_ASSIGNMENT);
if (this != &other) {
- destroy(1);
+ destroy(true);
copy(other);
}
return *this;
* @param r number of rows
* @param c number of cols */
matrix::matrix(unsigned r, unsigned c)
- : inherited(TINFO_matrix), row(r), col(c)
+ : inherited(TINFO_matrix), row(r), col(c)
{
debugmsg("matrix constructor from unsigned,unsigned",LOGLEVEL_CONSTRUCT);
m.resize(r*c, _ex0());
/** Ctor from representation, for internal use only. */
matrix::matrix(unsigned r, unsigned c, const exvector & m2)
- : inherited(TINFO_matrix), row(r), col(c), m(m2)
+ : inherited(TINFO_matrix), row(r), col(c), m(m2)
{
debugmsg("matrix constructor from unsigned,unsigned,exvector",LOGLEVEL_CONSTRUCT);
}
return (m[0]*m[3]-m[2]*m[1]).expand();
if (n==3)
return (m[0]*m[4]*m[8]-m[0]*m[5]*m[7]-
- m[1]*m[3]*m[8]+m[2]*m[3]*m[7]+
- m[1]*m[5]*m[6]-m[2]*m[4]*m[6]).expand();
+ m[1]*m[3]*m[8]+m[2]*m[3]*m[7]+
+ m[1]*m[5]*m[6]-m[2]*m[4]*m[6]).expand();
// This algorithm can best be understood by looking at a naive
// implementation of Laplace-expansion, like this one:
for (unsigned r2=r0+1; r2<m; ++r2) {
for (unsigned c=r1+1; c<n; ++c) {
dividend_n = (tmp_n.m[r0*n+r1]*tmp_n.m[r2*n+c]*
- tmp_d.m[r2*n+r1]*tmp_d.m[r0*n+c]
- -tmp_n.m[r2*n+r1]*tmp_n.m[r0*n+c]*
- tmp_d.m[r0*n+r1]*tmp_d.m[r2*n+c]).expand();
+ tmp_d.m[r2*n+r1]*tmp_d.m[r0*n+c]
+ -tmp_n.m[r2*n+r1]*tmp_n.m[r0*n+c]*
+ tmp_d.m[r0*n+r1]*tmp_d.m[r2*n+c]).expand();
dividend_d = (tmp_d.m[r2*n+r1]*tmp_d.m[r0*n+c]*
- tmp_d.m[r0*n+r1]*tmp_d.m[r2*n+c]).expand();
+ tmp_d.m[r0*n+r1]*tmp_d.m[r2*n+c]).expand();
bool check = divide(dividend_n, divisor_n,
- tmp_n.m[r2*n+c], true);
+ tmp_n.m[r2*n+c], true);
check &= divide(dividend_d, divisor_d,
- tmp_d.m[r2*n+c], true);
+ tmp_d.m[r2*n+c], true);
GINAC_ASSERT(check);
}
// fill up left hand side with zeros
// *(x;1) -> x
return recombine_pair_to_ex(*(seq.begin()));
} else if ((seq_size==1) &&
- is_ex_exactly_of_type((*seq.begin()).rest,add) &&
- ex_to_numeric((*seq.begin()).coeff).is_equal(_num1())) {
+ is_ex_exactly_of_type((*seq.begin()).rest,add) &&
+ ex_to_numeric((*seq.begin()).coeff).is_equal(_num1())) {
// *(+(x,y,...);c) -> +(*(x,c),*(y,c),...) (c numeric(), no powers of +())
const add & addref=ex_to_add((*seq.begin()).rest);
epvector distrseq;
distrseq.reserve(addref.seq.size());
for (epvector::const_iterator cit=addref.seq.begin(); cit!=addref.seq.end(); ++cit) {
- distrseq.push_back(addref.combine_pair_with_coeff_to_pair(*cit,
- overall_coeff));
+ distrseq.push_back(addref.combine_pair_with_coeff_to_pair(*cit, overall_coeff));
}
return (new add(distrseq,
- ex_to_numeric(addref.overall_coeff).
- mul_dyn(ex_to_numeric(overall_coeff))))
- ->setflag(status_flags::dynallocated |
- status_flags::evaluated);
+ ex_to_numeric(addref.overall_coeff).
+ mul_dyn(ex_to_numeric(overall_coeff))))
+ ->setflag(status_flags::dynallocated | status_flags::evaluated);
}
return this->hold();
}
--level;
for (epvector::const_iterator it=seq.begin(); it!=seq.end(); ++it) {
s.push_back(combine_ex_with_coeff_to_pair((*it).rest.evalf(level),
- (*it).coeff));
+ (*it).coeff));
}
return mul(s,overall_coeff.evalf(level));
}
// D(a*b*c) = D(a)*b*c + a*D(b)*c + a*b*D(c)
for (unsigned i=0; i!=seq.size(); ++i) {
epvector mulseq = seq;
- mulseq[i] = split_ex_to_pair(power(seq[i].rest,seq[i].coeff - _ex1())*
- seq[i].rest.diff(s));
+ mulseq[i] = split_ex_to_pair(power(seq[i].rest,seq[i].coeff - _ex1()) *
+ seq[i].rest.diff(s));
addseq.push_back((new mul(mulseq,overall_coeff*seq[i].coeff))->setflag(status_flags::dynallocated));
}
return (new add(addseq))->setflag(status_flags::dynallocated);
}
expair mul::combine_ex_with_coeff_to_pair(const ex & e,
- const ex & c) const
+ const ex & c) const
{
// to avoid duplication of power simplification rules,
// we create a temporary power object
}
expair mul::combine_pair_with_coeff_to_pair(const expair & p,
- const ex & c) const
+ const ex & c) const
{
// to avoid duplication of power simplification rules,
// we create a temporary power object
GINAC_ASSERT(is_ex_exactly_of_type(overall_coeff,numeric));
GINAC_ASSERT(is_ex_exactly_of_type(c1,numeric));
GINAC_ASSERT(is_ex_exactly_of_type(c2,numeric));
- overall_coeff = ex_to_numeric(overall_coeff).
- mul_dyn(ex_to_numeric(c1).power(ex_to_numeric(c2)));
+ overall_coeff = ex_to_numeric(overall_coeff).mul_dyn(ex_to_numeric(c1).power(ex_to_numeric(c2)));
}
bool mul::can_make_flat(const expair & p) const
return this->setflag(status_flags::expanded);
else
return ((new mul(expanded_seqp,overall_coeff))->
- setflag(status_flags::dynallocated |
- status_flags::expanded));
+ setflag(status_flags::dynallocated | status_flags::expanded));
}
exvector distrseq;
term[positions_of_adds[l]]=split_ex_to_pair(addref.op(k[l]));
}
distrseq.push_back((new mul(term,overall_coeff))->
- setflag(status_flags::dynallocated |
- status_flags::expanded));
+ setflag(status_flags::dynallocated | status_flags::expanded));
// increment k[]
int l = number_of_adds-1;
ncmul::~ncmul()
{
debugmsg("ncmul destructor",LOGLEVEL_DESTRUCT);
- destroy(0);
+ destroy(false);
}
ncmul::ncmul(const ncmul & other)
{
debugmsg("ncmul operator=",LOGLEVEL_ASSIGNMENT);
if (this != &other) {
- destroy(1);
+ destroy(true);
copy(other);
}
return *this;
// public
-ncmul::ncmul(const ex & lh, const ex & rh) :
- inherited(lh,rh)
+ncmul::ncmul(const ex & lh, const ex & rh) : inherited(lh,rh)
{
debugmsg("ncmul constructor from ex,ex",LOGLEVEL_CONSTRUCT);
tinfo_key = TINFO_ncmul;
}
-ncmul::ncmul(const ex & f1, const ex & f2, const ex & f3) :
- inherited(f1,f2,f3)
+ncmul::ncmul(const ex & f1, const ex & f2, const ex & f3) : inherited(f1,f2,f3)
{
debugmsg("ncmul constructor from 3 ex",LOGLEVEL_CONSTRUCT);
tinfo_key = TINFO_ncmul;
}
ncmul::ncmul(const ex & f1, const ex & f2, const ex & f3,
- const ex & f4) : inherited(f1,f2,f3,f4)
+ const ex & f4) : inherited(f1,f2,f3,f4)
{
debugmsg("ncmul constructor from 4 ex",LOGLEVEL_CONSTRUCT);
tinfo_key = TINFO_ncmul;
}
ncmul::ncmul(const ex & f1, const ex & f2, const ex & f3,
- const ex & f4, const ex & f5) : inherited(f1,f2,f3,f4,f5)
+ const ex & f4, const ex & f5) : inherited(f1,f2,f3,f4,f5)
{
debugmsg("ncmul constructor from 5 ex",LOGLEVEL_CONSTRUCT);
tinfo_key = TINFO_ncmul;
}
ncmul::ncmul(const ex & f1, const ex & f2, const ex & f3,
- const ex & f4, const ex & f5, const ex & f6) :
- inherited(f1,f2,f3,f4,f5,f6)
+ const ex & f4, const ex & f5, const ex & f6) : inherited(f1,f2,f3,f4,f5,f6)
{
debugmsg("ncmul constructor from 6 ex",LOGLEVEL_CONSTRUCT);
tinfo_key = TINFO_ncmul;
// ncmul(...,x1,x2,...,x3,x4,...) (associativity)
// ncmul(x) -> x
// ncmul() -> 1
- // ncmul(...,c1,...,c2,...) ->
+ // ncmul(...,c1,...,c2,...)
// *(c1,c2,ncmul(...)) (pull out commutative elements)
// ncmul(x1,y1,x2,y2) -> *(ncmul(x1,x2),ncmul(y1,y2))
// (collect elements of same type)
noncommutativeseq.push_back(assocseq[i]);
}
}
- commutativeseq.push_back((new ncmul(noncommutativeseq,1))->
- setflag(status_flags::dynallocated));
+ commutativeseq.push_back((new ncmul(noncommutativeseq,1))->setflag(status_flags::dynallocated));
return (new mul(commutativeseq))->setflag(status_flags::dynallocated);
}
exvector splitseq;
splitseq.reserve(evv.size());
for (i=0; i<evv.size(); ++i) {
- splitseq.push_back((new ncmul(evv[i]))->
- setflag(status_flags::dynallocated));
+ splitseq.push_back((new ncmul(evv[i]))->setflag(status_flags::dynallocated));
}
return (new mul(splitseq))->setflag(status_flags::dynallocated);
all_commutative=0;
}
if ((rt==return_types::noncommutative)&&(!all_commutative)) {
- // another nc element found, compare type_infos
+ // another nc element found, compare type_infos
if ((*cit_noncommutative_element).return_type_tinfo()!=(*cit).return_type_tinfo()) {
- // diffent types -> mul is ncc
- return return_types::noncommutative_composite;
+ // diffent types -> mul is ncc
+ return return_types::noncommutative_composite;
}
}
}
return v[0];
}
return (new ncmul(v))->setflag(status_flags::dynallocated |
- status_flags::evaluated);
+ status_flags::evaluated);
}
#ifndef NO_NAMESPACE_GINAC
}
#endif
if (check_args && (!a.info(info_flags::rational_polynomial) ||
- !b.info(info_flags::rational_polynomial)))
+ !b.info(info_flags::rational_polynomial)))
throw(std::invalid_argument("divide: arguments must be polynomials over the rationals"));
// Find first symbol
// as defined by get_first_symbol() is made positive)
const symbol *x;
if (get_first_symbol(den, x)) {
- GINAC_ASSERT(is_ex_exactly_of_type(den.unit(*x),numeric));
+ GINAC_ASSERT(is_ex_exactly_of_type(den.unit(*x),numeric));
if (ex_to_numeric(den.unit(*x)).is_negative()) {
num *= _ex_1();
den *= _ex_1();
*value = ::cl_I(0);
calchash();
setflag(status_flags::evaluated |
- status_flags::expanded |
- status_flags::hash_calculated);
+ status_flags::expanded |
+ status_flags::hash_calculated);
}
numeric::~numeric()
{
debugmsg("numeric destructor" ,LOGLEVEL_DESTRUCT);
- destroy(0);
+ destroy(false);
}
numeric::numeric(const numeric & other)
{
debugmsg("numeric operator=", LOGLEVEL_ASSIGNMENT);
if (this != &other) {
- destroy(1);
+ destroy(true);
copy(other);
}
return *this;
value = new ::cl_I((long) i);
calchash();
setflag(status_flags::evaluated |
- status_flags::expanded |
- status_flags::hash_calculated);
+ status_flags::expanded |
+ status_flags::hash_calculated);
}
value = new ::cl_I((unsigned long)i);
calchash();
setflag(status_flags::evaluated |
- status_flags::expanded |
- status_flags::hash_calculated);
+ status_flags::expanded |
+ status_flags::hash_calculated);
}
value = new ::cl_I(i);
calchash();
setflag(status_flags::evaluated |
- status_flags::expanded |
- status_flags::hash_calculated);
+ status_flags::expanded |
+ status_flags::hash_calculated);
}
value = new ::cl_I(i);
calchash();
setflag(status_flags::evaluated |
- status_flags::expanded |
- status_flags::hash_calculated);
+ status_flags::expanded |
+ status_flags::hash_calculated);
}
/** Ctor for rational numerics a/b.
*value = *value / ::cl_I(denom);
calchash();
setflag(status_flags::evaluated |
- status_flags::expanded |
- status_flags::hash_calculated);
+ status_flags::expanded |
+ status_flags::hash_calculated);
}
*value = cl_float(d, cl_default_float_format);
calchash();
setflag(status_flags::evaluated |
- status_flags::expanded |
- status_flags::hash_calculated);
+ status_flags::expanded |
+ status_flags::hash_calculated);
}
bool imaginary = false;
delim = ss.find_first_of(std::string("+-"),1);
// Do we have an exponent marker like "31.415E-1"? If so, hop on!
- if (delim != std::string::npos &&
- ss.at(delim-1) == 'E')
+ if (delim != std::string::npos
+ && ss.at(delim-1) == 'E')
delim = ss.find_first_of(std::string("+-"),delim+1);
term = ss.substr(0,delim);
if (delim != std::string::npos)
*value = *value + ::cl_R(cs);
} while(delim != std::string::npos);
calchash();
- setflag(status_flags::evaluated|
- status_flags::hash_calculated);
+ setflag(status_flags::evaluated |
+ status_flags::hash_calculated);
}
/** Ctor from CLN types. This is for the initiated user or internal use
value = new ::cl_N(z);
calchash();
setflag(status_flags::evaluated |
- status_flags::expanded |
- status_flags::hash_calculated);
+ status_flags::expanded |
+ status_flags::hash_calculated);
}
//////////
}
calchash();
setflag(status_flags::evaluated |
- status_flags::expanded |
- status_flags::hash_calculated);
+ status_flags::expanded |
+ status_flags::hash_calculated);
}
/** Unarchive the object. */
return true;
if (o.imag().is_zero()) // e.g. scan for 3 in -3*I
return (this->real().is_equal(o) || this->imag().is_equal(o) ||
- this->real().is_equal(-o) || this->imag().is_equal(-o));
+ this->real().is_equal(-o) || this->imag().is_equal(-o));
else {
if (o.is_equal(I)) // e.g scan for I in 42*I
return !this->is_real();
if (o.real().is_zero()) // e.g. scan for 2*I in 2*I+1
return (this->real().has(o*I) || this->imag().has(o*I) ||
- this->real().has(-o*I) || this->imag().has(-o*I));
+ this->real().has(-o*I) || this->imag().has(-o*I));
}
return false;
}
return true;
else if (!this->is_real()) { // complex case, handle n+m*I
if (::instanceof(::realpart(*value), ::cl_I_ring) &&
- ::instanceof(::imagpart(*value), ::cl_I_ring))
+ ::instanceof(::imagpart(*value), ::cl_I_ring))
return true;
}
return false;
return true;
else if (!this->is_real()) { // complex case, handle Q(i):
if (::instanceof(::realpart(*value), ::cl_RA_ring) &&
- ::instanceof(::imagpart(*value), ::cl_RA_ring))
+ ::instanceof(::imagpart(*value), ::cl_RA_ring))
return true;
}
return false;
const numeric atan(const numeric & x)
{
if (!x.is_real() &&
- x.real().is_zero() &&
- abs(x.imag()).is_equal(_num1()))
+ x.real().is_zero() &&
+ abs(x.imag()).is_equal(_num1()))
throw pole_error("atan(): logarithmic pole",0);
return ::atan(*x.value); // -> CLN
}
/*static ::cl_N Li2_series(const ::cl_N & x,
- const ::cl_float_format_t & prec)
+ const ::cl_float_format_t & prec)
{
// Note: argument must be in the unit circle
// This is very inefficient unless we have fast floating point Bernoulli
/** Numeric evaluation of Dilogarithm within circle of convergence (unit
* circle) using a power series. */
static ::cl_N Li2_series(const ::cl_N & x,
- const ::cl_float_format_t & prec)
+ const ::cl_float_format_t & prec)
{
// Note: argument must be in the unit circle
::cl_N aug, acc;
/** Folds Li2's argument inside a small rectangle to enhance convergence. */
static ::cl_N Li2_projection(const ::cl_N & x,
- const ::cl_float_format_t & prec)
+ const ::cl_float_format_t & prec)
{
const ::cl_R re = ::realpart(x);
const ::cl_R im = ::imagpart(x);
if (re > ::cl_F(".5"))
// zeta(2) - Li2(1-x) - log(x)*log(1-x)
return(::cl_zeta(2)
- - Li2_series(1-x, prec)
- - ::log(x)*::log(1-x));
+ - Li2_series(1-x, prec)
+ - ::log(x)*::log(1-x));
if ((re <= 0 && ::abs(im) > ::cl_F(".75")) || (re < ::cl_F("-.5")))
// -log(1-x)^2 / 2 - Li2(x/(x-1))
- return(-::square(::log(1-x))/2
- - Li2_series(x/(x-1), prec));
+ return(- ::square(::log(1-x))/2
+ - Li2_series(x/(x-1), prec));
if (re > 0 && ::abs(im) > ::cl_LF(".75"))
// Li2(x^2)/2 - Li2(-x)
return(Li2_projection(::square(x), prec)/2
- - Li2_projection(-x, prec));
+ - Li2_projection(-x, prec));
return Li2_series(x, prec);
}
if (::abs(*x.value) > 1)
// -log(-x)^2 / 2 - zeta(2) - Li2(1/x)
- return(-::square(::log(-*x.value))/2
- - ::cl_zeta(2, prec)
- - Li2_projection(::recip(*x.value), prec));
+ return(- ::square(::log(-*x.value))/2
+ - ::cl_zeta(2, prec)
+ - Li2_projection(::recip(*x.value), prec));
else
return Li2_projection(*x.value, prec);
}
const numeric lgamma(const numeric & x)
{
std::clog << "lgamma(" << x
- << "): Does anybody know good way to calculate this numerically?"
- << std::endl;
+ << "): Does anybody know good way to calculate this numerically?"
+ << std::endl;
return numeric(0);
}
const numeric tgamma(const numeric & x)
{
std::clog << "tgamma(" << x
- << "): Does anybody know good way to calculate this numerically?"
- << std::endl;
+ << "): Does anybody know good way to calculate this numerically?"
+ << std::endl;
return numeric(0);
}
const numeric psi(const numeric & x)
{
std::clog << "psi(" << x
- << "): Does anybody know good way to calculate this numerically?"
- << std::endl;
+ << "): Does anybody know good way to calculate this numerically?"
+ << std::endl;
return numeric(0);
}
const numeric psi(const numeric & n, const numeric & x)
{
std::clog << "psi(" << n << "," << x
- << "): Does anybody know good way to calculate this numerically?"
- << std::endl;
+ << "): Does anybody know good way to calculate this numerically?"
+ << std::endl;
return numeric(0);
}
cl_I_div_t rem_quo = truncate2(The(::cl_I)(*a.value), The(::cl_I)(*b.value));
q = rem_quo.quotient;
return rem_quo.remainder;
- }
- else {
+ } else {
q = _num0();
return _num0(); // Throw?
}
// be 61 (<64) while cl_float_format(18)=65. We want to have a cl_LF instead
// of cl_SF, cl_FF or cl_DF but everything else is basically arbitrary.
_numeric_digits::_numeric_digits()
- : digits(17)
+ : digits(17)
{
assert(!too_late);
too_late = true;
power::~power()
{
debugmsg("power destructor",LOGLEVEL_DESTRUCT);
- destroy(0);
+ destroy(false);
}
power::power(const power & other)
{
debugmsg("power operator=",LOGLEVEL_ASSIGNMENT);
if (this != &other) {
- destroy(1);
+ destroy(true);
copy(other);
}
return *this;
debugmsg("power print csrc", LOGLEVEL_PRINT);
// Integer powers of symbols are printed in a special, optimized way
- if (exponent.info(info_flags::integer) &&
- (is_ex_exactly_of_type(basis, symbol) ||
- is_ex_exactly_of_type(basis, constant))) {
+ if (exponent.info(info_flags::integer)
+ && (is_ex_exactly_of_type(basis, symbol) || is_ex_exactly_of_type(basis, constant))) {
int exp = ex_to_numeric(exponent).to_int();
if (exp > 0)
os << "(";
mulp->clearflag(status_flags::evaluated);
mulp->clearflag(status_flags::hash_calculated);
return (new mul(power(*mulp,exponent),
- power(num_coeff,*num_exponent)))->
- setflag(status_flags::dynallocated);
+ power(num_coeff,*num_exponent)))->setflag(status_flags::dynallocated);
} else {
GINAC_ASSERT(num_coeff.compare(_num0())<0);
if (num_coeff.compare(_num_1())!=0) {
mulp->clearflag(status_flags::evaluated);
mulp->clearflag(status_flags::hash_calculated);
return (new mul(power(*mulp,exponent),
- power(abs(num_coeff),*num_exponent)))->
- setflag(status_flags::dynallocated);
+ power(abs(num_coeff),*num_exponent)))->setflag(status_flags::dynallocated);
}
}
}
} else {
// D(b^e) = b^e * (D(e)*ln(b) + e*D(b)/b)
return mul(power(basis, exponent),
- add(mul(exponent.diff(s), log(basis)),
- mul(mul(exponent, basis.diff(s)), power(basis, -1))));
+ add(mul(exponent.diff(s), log(basis)),
+ mul(mul(exponent, basis.diff(s)), power(basis, -1))));
}
}
if (are_ex_trivially_equal(basis,expanded_basis)) {
return this->hold();
} else {
- return (new power(expanded_basis,exponent))->
- setflag(status_flags::dynallocated |
- status_flags::expanded);
+ return (new power(expanded_basis,exponent))->setflag(status_flags::dynallocated | status_flags::expanded);
}
}
if (are_ex_trivially_equal(basis,expanded_basis)) {
return this->hold();
} else {
- return (new power(expanded_basis,exponent))->
- setflag(status_flags::dynallocated |
- status_flags::expanded);
+ return (new power(expanded_basis,exponent))->setflag(status_flags::dynallocated | status_flags::expanded);
}
}
for (l=0; l<m-1; l++) {
const ex & b = a.op(l);
GINAC_ASSERT(!is_ex_exactly_of_type(b,add));
- GINAC_ASSERT(!is_ex_exactly_of_type(b,power)||
- !is_ex_exactly_of_type(ex_to_power(b).exponent,numeric)||
- !ex_to_numeric(ex_to_power(b).exponent).is_pos_integer()||
- !is_ex_exactly_of_type(ex_to_power(b).basis,add)||
- !is_ex_exactly_of_type(ex_to_power(b).basis,mul)||
- !is_ex_exactly_of_type(ex_to_power(b).basis,power));
+ GINAC_ASSERT(!is_ex_exactly_of_type(b,power) ||
+ !is_ex_exactly_of_type(ex_to_power(b).exponent,numeric) ||
+ !ex_to_numeric(ex_to_power(b).exponent).is_pos_integer() ||
+ !is_ex_exactly_of_type(ex_to_power(b).basis,add) ||
+ !is_ex_exactly_of_type(ex_to_power(b).basis,mul) ||
+ !is_ex_exactly_of_type(ex_to_power(b).basis,power));
if (is_ex_exactly_of_type(b,mul)) {
term.push_back(expand_mul(ex_to_mul(b),numeric(k[l])));
} else {
const ex & b = a.op(l);
GINAC_ASSERT(!is_ex_exactly_of_type(b,add));
- GINAC_ASSERT(!is_ex_exactly_of_type(b,power)||
- !is_ex_exactly_of_type(ex_to_power(b).exponent,numeric)||
- !ex_to_numeric(ex_to_power(b).exponent).is_pos_integer()||
- !is_ex_exactly_of_type(ex_to_power(b).basis,add)||
- !is_ex_exactly_of_type(ex_to_power(b).basis,mul)||
- !is_ex_exactly_of_type(ex_to_power(b).basis,power));
+ GINAC_ASSERT(!is_ex_exactly_of_type(b,power) ||
+ !is_ex_exactly_of_type(ex_to_power(b).exponent,numeric) ||
+ !ex_to_numeric(ex_to_power(b).exponent).is_pos_integer() ||
+ !is_ex_exactly_of_type(ex_to_power(b).basis,add) ||
+ !is_ex_exactly_of_type(ex_to_power(b).basis,mul) ||
+ !is_ex_exactly_of_type(ex_to_power(b).basis,power));
if (is_ex_exactly_of_type(b,mul)) {
term.push_back(expand_mul(ex_to_mul(b),numeric(n-k_cum[m-2])));
} else {
const ex & c=(*cit0).coeff;
GINAC_ASSERT(!is_ex_exactly_of_type(r,add));
- GINAC_ASSERT(!is_ex_exactly_of_type(r,power)||
- !is_ex_exactly_of_type(ex_to_power(r).exponent,numeric)||
- !ex_to_numeric(ex_to_power(r).exponent).is_pos_integer()||
- !is_ex_exactly_of_type(ex_to_power(r).basis,add)||
- !is_ex_exactly_of_type(ex_to_power(r).basis,mul)||
- !is_ex_exactly_of_type(ex_to_power(r).basis,power));
+ GINAC_ASSERT(!is_ex_exactly_of_type(r,power) ||
+ !is_ex_exactly_of_type(ex_to_power(r).exponent,numeric) ||
+ !ex_to_numeric(ex_to_power(r).exponent).is_pos_integer() ||
+ !is_ex_exactly_of_type(ex_to_power(r).basis,add) ||
+ !is_ex_exactly_of_type(ex_to_power(r).basis,mul) ||
+ !is_ex_exactly_of_type(ex_to_power(r).basis,power));
if (are_ex_trivially_equal(c,_ex1())) {
if (is_ex_exactly_of_type(r,mul)) {
- sum.push_back(expair(expand_mul(ex_to_mul(r),_num2()),_ex1()));
+ sum.push_back(expair(expand_mul(ex_to_mul(r),_num2()),
+ _ex1()));
} else {
sum.push_back(expair((new power(r,_ex2()))->setflag(status_flags::dynallocated),
- _ex1()));
+ _ex1()));
}
} else {
if (is_ex_exactly_of_type(r,mul)) {
sum.push_back(expair(expand_mul(ex_to_mul(r),_num2()),
- ex_to_numeric(c).power_dyn(_num2())));
+ ex_to_numeric(c).power_dyn(_num2())));
} else {
sum.push_back(expair((new power(r,_ex2()))->setflag(status_flags::dynallocated),
- ex_to_numeric(c).power_dyn(_num2())));
+ ex_to_numeric(c).power_dyn(_num2())));
}
}
const ex & r1=(*cit1).rest;
const ex & c1=(*cit1).coeff;
sum.push_back(a.combine_ex_with_coeff_to_pair((new mul(r,r1))->setflag(status_flags::dynallocated),
- _num2().mul(ex_to_numeric(c)).mul_dyn(ex_to_numeric(c1))));
+ _num2().mul(ex_to_numeric(c)).mul_dyn(ex_to_numeric(c1))));
}
}
GINAC_ASSERT(sum.size()==(a_nops*(a_nops+1))/2);
- return (new add(sum))->setflag(status_flags::dynallocated |
- status_flags::expanded );
+ return (new add(sum))->setflag(status_flags::dynallocated | status_flags::expanded);
}
/** Expand factors of m in m^n where m is a mul and n is and integer
} else {
// it is safe not to call mul::combine_pair_with_coeff_to_pair()
// since n is an integer
- distrseq.push_back(expair((*cit).rest,
- ex_to_numeric((*cit).coeff).mul(n)));
+ distrseq.push_back(expair((*cit).rest, ex_to_numeric((*cit).coeff).mul(n)));
}
++cit;
}
- return (new mul(distrseq,ex_to_numeric(m.overall_coeff).power_dyn(n)))
- ->setflag(status_flags::dynallocated);
+ return (new mul(distrseq,ex_to_numeric(m.overall_coeff).power_dyn(n)))->setflag(status_flags::dynallocated);
}
/*
ex power::expand_commutative_3(const ex & basis, const numeric & exponent,
- unsigned options) const
+ unsigned options) const
{
// obsolete
int n=exponent.to_int();
for (int k=0; k<=n; k++) {
- distrseq.push_back(binomial(n,k)*power(first_operands,numeric(k))*
- power(last_operand,numeric(n-k)));
+ distrseq.push_back(binomial(n,k) * power(first_operands,numeric(k))
+ * power(last_operand,numeric(n-k)));
}
- return ex((new add(distrseq))->setflag(status_flags::expanded |
- status_flags::dynallocated )).
- expand(options);
+ return ex((new add(distrseq))->setflag(status_flags::expanded | status_flags::dynallocated)).expand(options);
}
*/
ex power::expand_noncommutative(const ex & basis, const numeric & exponent,
unsigned options) const
{
- ex rest_power=ex(power(basis,exponent.add(_num_1()))).
- expand(options | expand_options::internal_do_not_expand_power_operands);
+ ex rest_power = ex(power(basis,exponent.add(_num_1()))).
+ expand(options | expand_options::internal_do_not_expand_power_operands);
return ex(mul(rest_power,basis),0).
- expand(options | expand_options::internal_do_not_expand_mul_operands);
+ expand(options | expand_options::internal_do_not_expand_mul_operands);
}
*/
* @param rel_ expansion variable and point (must hold a relational)
* @param ops_ vector of {coefficient, power} pairs (coefficient must not be zero)
* @return newly constructed pseries */
-pseries::pseries(const ex &rel_, const epvector &ops_)
- : basic(TINFO_pseries), seq(ops_)
+pseries::pseries(const ex &rel_, const epvector &ops_) : basic(TINFO_pseries), seq(ops_)
{
debugmsg("pseries constructor from ex,epvector", LOGLEVEL_CONSTRUCT);
GINAC_ASSERT(is_ex_exactly_of_type(rel_, relational));
for (epvector::const_iterator i=seq.begin(); i!=seq.end(); ++i)
newseq.push_back(expair(i->rest.expand(), i->coeff));
return (new pseries(relational(var,point), newseq))
- ->setflag(status_flags::dynallocated |
- status_flags::expanded);
+ ->setflag(status_flags::dynallocated | status_flags::expanded);
}
* false otherwise. */
bool pseries::is_terminating(void) const
{
- return !is_order_function((seq.end()-1)->rest);
+ return seq.size() == 0 || !is_order_function((seq.end()-1)->rest);
}
relational::~relational()
{
debugmsg("relational destructor",LOGLEVEL_DESTRUCT);
- destroy(0);
+ destroy(false);
}
relational::relational(const relational & other)
{
debugmsg("relational operator=",LOGLEVEL_ASSIGNMENT);
if (this != &other) {
- destroy(1);
+ destroy(true);
copy(other);
}
return *this;
if (level == -max_recursion_level) {
throw(std::runtime_error("max recursion level reached"));
}
- return (new relational(lh.eval(level-1),rh.eval(level-1),o))->
- setflag(status_flags::dynallocated |
- status_flags::evaluated );
+ return (new relational(lh.eval(level-1),rh.eval(level-1),o))->setflag(status_flags::dynallocated | status_flags::evaluated);
}
ex relational::evalf(int level) const
if (level == -max_recursion_level) {
throw(std::runtime_error("max recursion level reached"));
}
- return (new relational(lh.eval(level-1),rh.eval(level-1),o))->
- setflag(status_flags::dynallocated);
+ return (new relational(lh.eval(level-1),rh.eval(level-1),o))->setflag(status_flags::dynallocated);
}
ex relational::simplify_ncmul(const exvector & v) const
// class remember_table_entry
//////////
-remember_table_entry::remember_table_entry(function const & f, ex const & r) :
- hashvalue(f.gethash()), seq(f.seq), result(r)
+remember_table_entry::remember_table_entry(function const & f, ex const & r)
+ : hashvalue(f.gethash()), seq(f.seq), result(r)
{
++last_access=access_counter;
successful_hits=0;
remember_strategy=remember_strategies::delete_never;
}
-remember_table::remember_table(unsigned s, unsigned as, unsigned strat) :
- max_assoc_size(as), remember_strategy(strat)
+remember_table::remember_table(unsigned s, unsigned as, unsigned strat)
+ : max_assoc_size(as), remember_strategy(strat)
{
// we keep max_assoc_size and remember_strategy if we need to clear
// all entries
simp_lor::~simp_lor()
{
debugmsg("simp_lor destructor",LOGLEVEL_DESTRUCT);
- destroy(0);
+ destroy(false);
}
simp_lor::simp_lor(const simp_lor & other)
{
debugmsg("simp_lor operator=",LOGLEVEL_ASSIGNMENT);
if (this != &other) {
- destroy(1);
+ destroy(true);
copy(other);
}
return *this;
tinfo_key=TINFO_simp_lor;
}
-simp_lor::simp_lor(simp_lor_types const t, const ex & i1, const ex & i2) :
- indexed(i1,i2), type(t)
+simp_lor::simp_lor(simp_lor_types const t, const ex & i1, const ex & i2)
+ : indexed(i1,i2), type(t)
{
debugmsg("simp_lor constructor from simp_lor_types,ex,ex",LOGLEVEL_CONSTRUCT);
tinfo_key=TINFO_simp_lor;
GINAC_ASSERT(all_of_type_lorentzidx());
}
-simp_lor::simp_lor(simp_lor_types const t, const std::string & n, const ex & i1) :
- indexed(i1), type(t), name(n)
+simp_lor::simp_lor(simp_lor_types const t, const std::string & n, const ex & i1)
+ : indexed(i1), type(t), name(n)
{
debugmsg("simp_lor constructor from simp_lor_types,string,ex",LOGLEVEL_CONSTRUCT);
tinfo_key=TINFO_simp_lor;
GINAC_ASSERT(all_of_type_lorentzidx());
}
-simp_lor::simp_lor(simp_lor_types const t, const std::string & n, const exvector & iv) :
- indexed(iv), type(t), name(n)
+simp_lor::simp_lor(simp_lor_types const t, const std::string & n, const exvector & iv)
+ : indexed(iv), type(t), name(n)
{
debugmsg("simp_lor constructor from simp_lor_types,string,exvector",LOGLEVEL_CONSTRUCT);
tinfo_key=TINFO_simp_lor;
GINAC_ASSERT(all_of_type_lorentzidx());
}
-simp_lor::simp_lor(simp_lor_types const t, const std::string & n, exvector * ivp) :
- indexed(ivp), type(t), name(n)
+simp_lor::simp_lor(simp_lor_types const t, const std::string & n, exvector * ivp)
+ : indexed(ivp), type(t), name(n)
{
debugmsg("simp_lor constructor from simp_lor_types,string,exvector*",LOGLEVEL_CONSTRUCT);
tinfo_key=TINFO_simp_lor;
return _ex0();
}
} else if (idx1.is_symbolic() &&
- idx1.is_co_contra_pair(idx2)) {
+ idx1.is_co_contra_pair(idx2)) {
return Dim()-idx1.get_dim_parallel_space();
}
}
// try to contract first index
replacements=0;
if (first_idx.is_symbolic()) {
- replacements = subs_index_in_exvector(v_contracted,
- first_idx.toggle_covariant(),second_idx);
+ replacements = subs_index_in_exvector(v_contracted, first_idx.toggle_covariant(),second_idx);
if (replacements==0) {
// not contracted, restore g object
*it=saved_g;
// try second index only if first was not contracted
if ((replacements==0)&&(second_idx.is_symbolic())) {
// first index not contracted, *it is again the original g object
- replacements = subs_index_in_exvector(v_contracted,
- second_idx.toggle_covariant(),first_idx);
+ replacements = subs_index_in_exvector(v_contracted, second_idx.toggle_covariant(),first_idx);
if (replacements==0) {
// not contracted except in itself, restore g object
*it=saved_g;
ex sum=_ex0();
for (unsigned i=0; i<e_expanded.nops(); ++i)
sum += simplify_simp_lor(e_expanded.op(i),sp);
-
+
return sum;
}
//////////
void scalar_products::reg(const simp_lor & v1, const simp_lor & v2,
- const ex & sp)
+ const ex & sp)
{
if (v1.compare_same_type(v2)>0) {
reg(v2,v1,sp);
for (spmap::const_iterator cit=spm.begin(); cit!=spm.end(); ++cit) {
const spmapkey & k=(*cit).first;
std::cerr << "item key=((" << k.first.first
- << "," << k.first.second << "),";
+ << "," << k.first.second << "),";
k.second.printraw(cerr);
cerr << ") value=" << (*cit).second << std::endl;
}
structure::~structure()
{
debugmsg("structure destructor",LOGLEVEL_DESTRUCT);
- destroy(0);
+ destroy(false);
}
structure::structure(const structure & other)
{
debugmsg("structure operator=",LOGLEVEL_ASSIGNMENT);
if (this != &other) {
- destroy(1);
+ destroy(true);
copy(other);
}
return *this;
${STRUCTURE}::~${STRUCTURE}()
{
debugmsg("${STRUCTURE} destructor",LOGLEVEL_DESTRUCT);
- destroy(0);
+ destroy(false);
}
${STRUCTURE}::${STRUCTURE}(${STRUCTURE} const & other)
{
debugmsg("${STRUCTURE} operator=",LOGLEVEL_ASSIGNMENT);
if (this != &other) {
- destroy(1);
+ destroy(true);
copy(other);
}
return *this;
{
if (inf==info_flags::symbol) return true;
if (inf==info_flags::polynomial ||
- inf==info_flags::integer_polynomial ||
- inf==info_flags::cinteger_polynomial ||
- inf==info_flags::rational_polynomial ||
- inf==info_flags::crational_polynomial ||
- inf==info_flags::rational_function) {
+ inf==info_flags::integer_polynomial ||
+ inf==info_flags::cinteger_polynomial ||
+ inf==info_flags::rational_polynomial ||
+ inf==info_flags::crational_polynomial ||
+ inf==info_flags::rational_function) {
return true;
} else {
return inherited::info(inf);
/** ctor for pole_error exception class. */
pole_error::pole_error(const std::string& what_arg, int degree)
- : domain_error(what_arg)
+ : domain_error(what_arg)
{
deg = degree;
}