From gwright at comcast.net Tue Sep 7 17:11:02 2004 From: gwright at comcast.net (Gregory Wright) Date: Tue Sep 7 17:11:02 2004 Subject: [GiNaC-devel] GiNaC-1.2.3 and nestedsums-1.4.5 on Mac OS X Message-ID: Hi, Since Bruno Haible posted his patches to cln-1.1.8, it's built cleanly on Mac OS X, and allowed me to build GiNaC-1.2.3. On my machine, an 800 MHz tiBook running OS X 10.3.5, and using g++ 3.3 from Xcode 1.5, it passes all the tests in 'make check'. When I try to build nestedsums-1.4.5, I get build failures caused by the inability to adjust pointers in convariant returns: make all-recursive Making all in nestedsums if /bin/sh ../libtool --mode=compile g++ -DHAVE_CONFIG_H -I. -I. -I.. -I/opt/local/include -I/opt/local/include -I/opt/local/include -I/opt/local/include -g -O2 -MT root_of_unity.lo -MD -MP -MF ".deps/root_of_unity.Tpo" -c -o root_of_unity.lo root_of_unity.cc; \ then mv -f ".deps/root_of_unity.Tpo" ".deps/root_of_unity.Plo"; else rm -f ".deps/root_of_unity.Tpo"; exit 1; fi g++ -DHAVE_CONFIG_H -I. -I. -I.. -I/opt/local/include -I/opt/local/include -I/opt/local/include -I/opt/local/include -g -O2 -MT root_of_unity.lo -MD -MP -MF .deps/root_of_unity.Tpo -c root_of_unity.cc -fno-common -DPIC -o .libs/root_of_unity.o Euler_Zagier_sum.h:48: sorry, unimplemented: adjusting pointers for covariant returns Euler_Zagier_sum.h:48: sorry, unimplemented: adjusting pointers for covariant returns harmonic_sum.h:49: sorry, unimplemented: adjusting pointers for covariant returns harmonic_sum.h:49: sorry, unimplemented: adjusting pointers for covariant returns multiple_polylog.h:54: sorry, unimplemented: adjusting pointers for covariant returns multiple_polylog.h:54: sorry, unimplemented: adjusting pointers for covariant returns harmonic_polylog.h:50: sorry, unimplemented: adjusting pointers for covariant returns (There are more header files that it complains about; I can send the full output if you wish.) I emailed Stefan Weinzierl and he pointed out that this comes from the macros GINAC_DECLARE_REGISTERED_CLASS and GINAC_IMPLEMENT_REGISTERED_CLASS Two questions: 1. Is there a workaround for this? (Since I am trying to port xloops/nestedsums/GiNac/cln to the darwinports system, I would prefer no to have to add build another g++ compiler. I could, if absolutely necessary, do that.) 2. Why does this happen for the nestedsums library and not for GiNaC? Does GiNaC allow covariant returns but not actually use them? Any help is appreciated. Best Wishes, Greg Gregory Wright Antiope Associates gwright at antiope.com From Christian.Bauer at uni-mainz.de Tue Sep 7 17:15:05 2004 From: Christian.Bauer at uni-mainz.de (Christian Bauer) Date: Tue Sep 7 17:15:05 2004 Subject: [GiNaC-devel] GiNaC-1.2.3 and nestedsums-1.4.5 on Mac OS X In-Reply-To: References: Message-ID: <20040907151459.GD14381@thep.physik.uni-mainz.de> Hi! On Mon, Sep 06, 2004 at 11:54:45PM -0400, Gregory Wright wrote: > Euler_Zagier_sum.h:48: sorry, unimplemented: adjusting pointers for > covariant > returns > 1. Is there a workaround for this? You need g++ 3.4. Earlier versions are missing a needed feature here. > 2. Why does this happen for the nestedsums library and not for GiNaC? Because nestedsums uses multiple inheritance. Bye, Christian -- / Physics is an algorithm \/ http://www.uni-mainz.de/~bauec002/ From C.Dams at science.ru.nl Wed Sep 22 11:06:03 2004 From: C.Dams at science.ru.nl (Chris Dams) Date: Wed Sep 22 11:06:03 2004 Subject: [GiNaC-devel] patch for power Message-ID: Dear all, I found that the program #include #include using namespace std; using namespace GiNaC; int main(int argc, char** argv) { symbol x("x"),y("y"); ex e=sin(x)*sin(x); if(e.info(info_flags::polynomial)) cout << e << " is polynomial" << endl; else cout << e << " is not polynomial" << endl; e=sin(x)*sin(y); if(e.info(info_flags::polynomial)) cout << e << " is polynomial" << endl; else cout << e << " is not polynomial" << endl; return 0; } gives the output sin(x)^2 is polynomial sin(x)*sin(y) is not polynomial which I find very awkward. The attached patch unpolynomializes sin(x)^2. Best, Chris -------------- next part -------------- Index: power.cpp =================================================================== RCS file: /home/cvs/GiNaC/ginac/power.cpp,v retrieving revision 1.93 diff -r1.93 power.cpp 225c225 < return exponent.info(info_flags::nonnegint); --- > return exponent.info(info_flags::nonnegint) && basis.info(inf); 227c227 < return exponent.info(info_flags::integer); --- > return exponent.info(info_flags::integer) && basis.info(inf); From C.Dams at science.ru.nl Thu Sep 23 16:04:04 2004 From: C.Dams at science.ru.nl (Chris Dams) Date: Thu Sep 23 16:04:04 2004 Subject: [GiNaC-devel] problem with dbgprint. Message-ID: Dear all, I found out that the program #include #include using namespace std; using namespace GiNaC; int main(int argc, char** argv) { symbol x("x"); ex_to(x*x).dbgprint(); return 0; } gives the output [power object] This is because in basic::dbgprint a print_context is constructed from std::cerr and not a print_dflt. Changing, in basic::dbgprint, the line this->print(std::cerr); into this->print(print_dflt(std::cerr)); solves this problem. Now the output is x^2 as expected. Best, Chris From kreckel at thep.physik.uni-mainz.de Thu Sep 23 23:50:05 2004 From: kreckel at thep.physik.uni-mainz.de (Richard B. Kreckel) Date: Thu Sep 23 23:50:05 2004 Subject: [GiNaC-devel] patch for power In-Reply-To: Message-ID: Dear Chris, On Tue, 21 Sep 2004, Chris Dams wrote: > Dear all, > > I found that the program [...] > gives the output > > sin(x)^2 is polynomial > sin(x)*sin(y) is not polynomial > > which I find very awkward. The attached patch unpolynomializes sin(x)^2. Thanks for your patch wich aligns power::info() with mul::info() in the obvious way. I've applied it to CVS. One minor nitpick: could you please use unified or context diffs with some lines of copied context in future patches? It makes life easier for the person that's going to apply them. (Use diff -u, for instance.) Best wishes -richy. -- Richard B. Kreckel From C.Dams at science.ru.nl Sun Sep 26 14:50:04 2004 From: C.Dams at science.ru.nl (Chris Dams) Date: Sun Sep 26 14:50:04 2004 Subject: [GiNaC-devel] symbolic integration. Message-ID: Dear all, Here's a patch plus two new files for GiNaC that add a class to symbolically represent an integral. Details can be found in the patch, since it also patches the documentation. Best, Chris -------------- next part -------------- Index: doc/tutorial/ginac.texi =================================================================== RCS file: /home/cvs/GiNaC/doc/tutorial/ginac.texi,v retrieving revision 1.155 diff -c -r1.155 ginac.texi *** doc/tutorial/ginac.texi 20 Aug 2004 16:14:10 -0000 1.155 --- doc/tutorial/ginac.texi 24 Sep 2004 11:36:26 -0000 *************** *** 693,698 **** --- 693,699 ---- * Lists:: Lists of expressions. * Mathematical functions:: Mathematical functions. * Relations:: Equality, Inequality and all that. + * Integrals:: Symbolic integrals. * Matrices:: Matrices. * Indexed objects:: Handling indexed quantities. * Non-commutative objects:: Algebras with non-commutative products. *************** *** 1807,1813 **** wrapped inside an @code{ex}. ! @node Relations, Matrices, Mathematical functions, Basic Concepts @c node-name, next, previous, up @section Relations @cindex @code{relational} (class) --- 1808,1814 ---- wrapped inside an @code{ex}. ! @node Relations, Integrals, Mathematical functions, Basic Concepts @c node-name, next, previous, up @section Relations @cindex @code{relational} (class) *************** *** 1833,1840 **** however, that @code{==} here does not perform any simplifications, hence @code{expand()} must be called explicitly. ! @node Matrices, Indexed objects, Relations, Basic Concepts @c node-name, next, previous, up @section Matrices @cindex @code{matrix} (class) --- 1834,1901 ---- however, that @code{==} here does not perform any simplifications, hence @code{expand()} must be called explicitly. + @node Integrals, Matrices, Relations, Basic Concepts + @c node-name, next, previous, up + @section Integrals + @cindex @code{integral} (class) + + An object of class @dfn{integral} can be used to hold a symbolic integral. + If you want to symbolically represent the integral of @code{x*x} from 0 to + 1, you would write this as + @example + integral(x, 0, 1, x*x) + @end example + The first argument is the integration variable. It should be noted that + GiNaC is not very good (yet?) at symbolically evaluating integrals. In + fact, it can only integrate polynomials. An expression containing integrals + can be evaluated symbolically by calling the + @example + .eval_integ() + @end example + method on it. Numerical evaluation is available by calling the + @example + .evalf() + @end example + method on an expression containing the integral. This will only evaluate + integrals into a number if @code{subs}ing the integration variable by a + number in the fourth argument of an integral and then @code{evalf}ing the + result always results in a number. Of course, also the boundaries of the + integration domain must @code{evalf} into numbers. It should be noted that + trying to @code{evalf} a function with discontinuities in the integration + domain is not recommended. The accuracy of the numeric evaluation of + integrals is determined by the static member variable + @example + ex integral::relative_integration_error + @end example + of the class @code{integral}. The default value of this is 10^-8. + The integration works by halving the interval of integration, until numeric + stability of the answer indicates that the requested accuracy has been + reached. The maximum depth of the halving can be set via the static member + variable + @example + int integral::max_integration_level + @end example + The default value is 15. If this depth is exceeded, @code{evalf} will simply + return the integral unevaluated. The function that performs the numerical + evaluation, is also available as + @example + ex adaptivesimpson(const ex&x, const ex &a, const ex &b, const ex &f, + const ex &error) + @end example + This function will throw an exception if the maximum depth is exceeded. The + last parameter of the function is optional and defaults to the + @code{relative_integration_error}. To make sure that we do not do too + much work if an expression contains the same integral multiple times, + a lookup table is used. + + If you know that an expression holds an integral, you can get the + integration variable, the left boundary, right boundary and integrant by + respectively calling @code{.op(0)}, @code{.op(1)}, @code{.op(2)}, and + @code{.op(3)}. Differentiating integrals with respect to variables works + as expected. Note that it makes no sense to differentiate an integral + with respect to the integration variable. ! @node Matrices, Indexed objects, Integrals, Basic Concepts @c node-name, next, previous, up @section Matrices @cindex @code{matrix} (class) Index: ginac/Makefile.am =================================================================== RCS file: /home/cvs/GiNaC/ginac/Makefile.am,v retrieving revision 1.32 diff -c -r1.32 Makefile.am *** ginac/Makefile.am 18 Dec 2003 22:28:01 -0000 1.32 --- ginac/Makefile.am 24 Sep 2004 11:36:26 -0000 *************** *** 5,14 **** constant.cpp ex.cpp expair.cpp expairseq.cpp exprseq.cpp fail.cpp \ fderivative.cpp function.cpp idx.cpp indexed.cpp inifcns.cpp \ inifcns_trans.cpp inifcns_gamma.cpp inifcns_nstdsums.cpp \ ! lst.cpp matrix.cpp mul.cpp ncmul.cpp normal.cpp numeric.cpp operators.cpp \ ! power.cpp registrar.cpp relational.cpp remember.cpp pseries.cpp print.cpp \ ! structure.cpp symbol.cpp symmetry.cpp tensor.cpp utils.cpp wildcard.cpp \ ! input_parser.yy input_lexer.ll \ input_lexer.h remember.h tostring.h utils.h libginac_la_LDFLAGS = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \ -release $(LT_RELEASE) --- 5,14 ---- constant.cpp ex.cpp expair.cpp expairseq.cpp exprseq.cpp fail.cpp \ fderivative.cpp function.cpp idx.cpp indexed.cpp inifcns.cpp \ inifcns_trans.cpp inifcns_gamma.cpp inifcns_nstdsums.cpp \ ! integral.cpp lst.cpp matrix.cpp mul.cpp ncmul.cpp normal.cpp numeric.cpp \ ! operators.cpp power.cpp registrar.cpp relational.cpp remember.cpp \ ! pseries.cpp print.cpp structure.cpp symbol.cpp symmetry.cpp tensor.cpp \ ! utils.cpp wildcard.cpp input_parser.yy input_lexer.ll \ input_lexer.h remember.h tostring.h utils.h libginac_la_LDFLAGS = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \ -release $(LT_RELEASE) *************** *** 16,24 **** ginacinclude_HEADERS = ginac.h add.h archive.h assertion.h basic.h class_info.h \ clifford.h color.h constant.h container.h ex.h expair.h expairseq.h exprseq.h \ fail.h fderivative.h flags.h function.h hash_map.h idx.h indexed.h inifcns.h \ ! lst.h matrix.h mul.h ncmul.h normal.h numeric.h operators.h power.h print.h \ ! pseries.h ptr.h registrar.h relational.h structure.h symbol.h symmetry.h \ ! tensor.h tinfos.h version.h wildcard.h AM_LFLAGS = -Pginac_yy -olex.yy.c AM_YFLAGS = -p ginac_yy -d EXTRA_DIST = function.pl input_parser.h version.h.in --- 16,24 ---- ginacinclude_HEADERS = ginac.h add.h archive.h assertion.h basic.h class_info.h \ clifford.h color.h constant.h container.h ex.h expair.h expairseq.h exprseq.h \ fail.h fderivative.h flags.h function.h hash_map.h idx.h indexed.h inifcns.h \ ! integral.h lst.h matrix.h mul.h ncmul.h normal.h numeric.h operators.h \ ! power.h print.h pseries.h ptr.h registrar.h relational.h structure.h \ ! symbol.h symmetry.h tensor.h tinfos.h version.h wildcard.h AM_LFLAGS = -Pginac_yy -olex.yy.c AM_YFLAGS = -p ginac_yy -d EXTRA_DIST = function.pl input_parser.h version.h.in Index: ginac/basic.cpp =================================================================== RCS file: /home/cvs/GiNaC/ginac/basic.cpp,v retrieving revision 1.87 diff -c -r1.87 basic.cpp *** ginac/basic.cpp 3 Aug 2004 15:20:37 -0000 1.87 --- ginac/basic.cpp 24 Sep 2004 11:36:26 -0000 *************** *** 207,213 **** * @see basic::dbgprinttree */ void basic::dbgprint() const { ! this->print(std::cerr); std::cerr << std::endl; } --- 207,213 ---- * @see basic::dbgprinttree */ void basic::dbgprint() const { ! this->print(print_dflt(std::cerr)); std::cerr << std::endl; } *************** *** 480,485 **** --- 480,499 ---- return *this; else return map(map_evalm); + } + + /** Function object to be applied by basic::eval_integ(). */ + struct eval_integ_map_function : public map_function { + ex operator()(const ex & e) { return eval_integ(e); } + } map_eval_integ; + + /** Evaluate integrals, if result is known. */ + ex basic::eval_integ() const + { + if(nops() == 0) + return *this; + else + return map(map_eval_integ); } /** Perform automatic symbolic evaluations on indexed expression that Index: ginac/basic.h =================================================================== RCS file: /home/cvs/GiNaC/ginac/basic.h,v retrieving revision 1.69 diff -c -r1.69 basic.h *** ginac/basic.h 25 May 2004 13:59:32 -0000 1.69 --- ginac/basic.h 24 Sep 2004 11:36:26 -0000 *************** *** 136,141 **** --- 136,142 ---- virtual ex eval(int level = 0) const; virtual ex evalf(int level = 0) const; virtual ex evalm() const; + virtual ex eval_integ() const; protected: virtual ex eval_ncmul(const exvector & v) const; public: Index: ginac/ex.h =================================================================== RCS file: /home/cvs/GiNaC/ginac/ex.h,v retrieving revision 1.78 diff -c -r1.78 ex.h *** ginac/ex.h 20 Aug 2004 16:14:12 -0000 1.78 --- ginac/ex.h 24 Sep 2004 11:36:26 -0000 *************** *** 117,122 **** --- 117,123 ---- ex evalf(int level = 0) const { return bp->evalf(level); } ex evalm() const { return bp->evalm(); } ex eval_ncmul(const exvector & v) const { return bp->eval_ncmul(v); } + ex eval_integ() const { return bp->eval_integ(); } // printing void print(const print_context & c, unsigned level = 0) const; *************** *** 806,811 **** --- 807,815 ---- inline ex evalm(const ex & thisex) { return thisex.evalm(); } + + inline ex eval_integ(const ex & thisex) + { return thisex.eval_integ(); } inline ex diff(const ex & thisex, const symbol & s, unsigned nth = 1) { return thisex.diff(s, nth); } Index: ginac/ginac.h =================================================================== RCS file: /home/cvs/GiNaC/ginac/ginac.h,v retrieving revision 1.22 diff -c -r1.22 ginac.h *** ginac/ginac.h 8 Jan 2004 15:06:48 -0000 1.22 --- ginac/ginac.h 24 Sep 2004 11:36:26 -0000 *************** *** 34,39 **** --- 34,40 ---- #include "constant.h" #include "fail.h" + #include "integral.h" #include "lst.h" #include "matrix.h" #include "numeric.h" Index: ginac/indexed.cpp =================================================================== RCS file: /home/cvs/GiNaC/ginac/indexed.cpp,v retrieving revision 1.92 diff -c -r1.92 indexed.cpp *** ginac/indexed.cpp 5 Aug 2004 17:06:16 -0000 1.92 --- ginac/indexed.cpp 24 Sep 2004 11:36:26 -0000 *************** *** 36,41 **** --- 36,42 ---- #include "lst.h" #include "archive.h" #include "utils.h" + #include "integral.h" namespace GiNaC { *************** *** 520,525 **** --- 521,533 ---- return really_free; } else return basis_indices; + } + + exvector integral::get_free_indices() const + { + if(a.get_free_indices().size() || b.get_free_indices().size()) + throw (std::runtime_error("integral::get_free_indices: boundary values should not have free indices")); + return f.get_free_indices(); } /** Rename dummy indices in an expression. Index: ginac/tinfos.h =================================================================== RCS file: /home/cvs/GiNaC/ginac/tinfos.h,v retrieving revision 1.26 diff -c -r1.26 tinfos.h *** ginac/tinfos.h 29 Apr 2004 17:25:29 -0000 1.26 --- ginac/tinfos.h 24 Sep 2004 11:36:26 -0000 *************** *** 38,43 **** --- 38,44 ---- const unsigned TINFO_function = 0x00031001U; const unsigned TINFO_fderivative = 0x00032001U; const unsigned TINFO_ncmul = 0x00031002U; + const unsigned TINFO_integral = 0x00033001U; const unsigned TINFO_lst = 0x00040001U; Index: ginac/wildcard.cpp =================================================================== RCS file: /home/cvs/GiNaC/ginac/wildcard.cpp,v retrieving revision 1.17 diff -c -r1.17 wildcard.cpp *** ginac/wildcard.cpp 8 Jan 2004 15:06:53 -0000 1.17 --- ginac/wildcard.cpp 24 Sep 2004 11:36:26 -0000 *************** *** 119,122 **** --- 119,132 ---- return is_equal(ex_to(pattern)); } + bool haswild(const ex&x) + { + if(is_a(x)) + return true; + for(int i=0; i -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: integral.cpp URL: From kisilv at maths.leeds.ac.uk Sun Sep 26 14:50:23 2004 From: kisilv at maths.leeds.ac.uk (Vladimir Kisil) Date: Sun Sep 26 14:50:23 2004 Subject: [GiNaC-devel] (no subject) Message-ID: Dear All, I wish to propose a further patches for clifford.cpp and clifford.h. Its make: 1. Fixes a nasty behaviour when a simplification creates nested indexed objects like (eta.psi.xi).nu.mu. 2. Contains two new functions described in the clifford.h. Hope they will be useful, at least I employ them to create some graphics of conformal maps already. 3. Other bits are small improvements and spaces fixed. I hope to contribute some documentation for expanded clifford.cpp as well. Best wishes, Vladimir -- Vladimir V. Kisil email: kisilv at maths.leeds.ac.uk -- www: http://maths.leeds.ac.uk/~kisilv/ -------------- next part -------------- Index: ginac/clifford.h =================================================================== RCS file: /home/cvs/GiNaC/ginac/clifford.h,v retrieving revision 1.51 diff -r1.51 clifford.h 278c278 < ex delete_ONE(const ex &e); --- > ex delete_ONE(const ex & e); 294a295,318 > /** An inverse function to lst_to_clifford(). For given Clifford vector extracts > * its components with respect to given Clifford unit. Obtained components may > * contain Clifford units with a different metric. Extraction is based on > * the algebraic formula (e * c.i + c.i * e)/ pow(e.i, 2) for non-degenerate cases > * (i.e. neither pow(e.i, 2) = 0). > * > * @param e Clifford expresion to be decomposed into components > * @param c Clifford unit defining the metric for splitting (should have numeric dimension of indices) > * @param algebraic Use algebraic or symbolic algorythm for extractions */ > lst clifford_to_lst(const ex & e, const ex & c, bool algebraic=true); > > /** Calculations of Moebius transformations (conformal map) defined by a 2x2 Clifford matrix > * (a b\\c d) in linear spaces with arbitrary signature. The expression is > * (a * x + b)/(c * x + d), where x is a vector buid from list v with metric G. > * (see Jan Cnops. An introduction to {D}irac operators on manifolds, v.24 of > * Progress in Mathematical Physics. Birkhauser Boston Inc., Boston, MA, 2002.) > * > * @param a (1,1) entry of the defining matrix > * @param b (1,2) entry of the defining matrix > * @param c (2,1) entry of the defining matrix > * @param d (2,2) entry of the defining matrix > * @param v Vector to be transformed > * @param G Metric of the surrounding space */ > ex moebius(const ex & a, const ex & b, const ex & c, const ex & d, const ex & v, const ex & G); Index: ginac/clifford.cpp =================================================================== RCS file: /home/cvs/GiNaC/ginac/clifford.cpp,v retrieving revision 1.79 diff -r1.79 clifford.cpp 680c680,685 < return clifford(unit, mu, metr, rl); --- > if (is_a(metr)) > return clifford(unit, mu, metr.op(0), rl); > else if(is_a(metr) || is_a(metr)) > return clifford(unit, mu, metr, rl); > else > throw(std::invalid_argument("metric for Clifford unit must be of type indexed, tensormetric or matrix")); 990c995 < ex clifford_prime(const ex &e) --- > ex clifford_prime(const ex & e) 1005c1010 < ex delete_ONE(const ex &e) --- > ex delete_ONE(const ex & e) 1022c1027 < ex clifford_norm(const ex &e) --- > ex clifford_norm(const ex & e) 1024c1029 < return sqrt(delete_ONE((e * clifford_bar(e)).simplify_indexed())); --- > return sqrt(delete_ONE(canonicalize_clifford(e * clifford_bar(e)).simplify_indexed())); 1027c1032 < ex clifford_inverse(const ex &e) --- > ex clifford_inverse(const ex & e) 1031a1037,1038 > else > throw(std::invalid_argument("Cannot find inverse of Clifford number with zero norm!")); 1068a1076,1158 > /** Auxiliary structure to define a function for striping one Clifford unit > * from vectors. Used in clifford_to_lst(). */ > ex get_clifford_comp(const ex & e, const ex & c) > { > pointer_to_map_function_1arg fcn(get_clifford_comp, c); > > if (is_a(e)) > return e.map(fcn); > else if (is_a(e) || is_a(e)) { > //find a Clifford unit with the same metric, delete it and substitute its index > size_t ind = e.nops() + 1; > for (size_t j = 0; j < e.nops(); j++) > if (is_a(e.op(j)) && ex_to(c).same_metric(e.op(j))) > if (ind > e.nops()) > ind = j; > else > throw(std::invalid_argument("Expression is a Clifford multi-vector")); > if (ind < e.nops()) { > ex S = 1; > for(size_t j=0; j < e.nops(); j++) > if (j != ind) { > exvector ind_vec = ex_to(e.op(j)).get_dummy_indices(ex_to(e.op(ind))); > if (ind_vec.size() > 0) { > exvector::const_iterator it = ind_vec.begin(), itend = ind_vec.end(); > while (it != itend) { > S = S * e.op(j).subs(ex_to(*it) == ex_to(c.op(1)).get_value()); > it++; > } > } else > S = S * e.op(j); > } > return S; > } else > throw(std::invalid_argument("Expression is not a Clifford vector to the given units")); > } else { > throw(std::invalid_argument("Expression is not handlable as a Clifford vector")); > } > } > > > lst clifford_to_lst (const ex & e, const ex & c, bool algebraic) > { > GINAC_ASSERT(is_a(c)); > varidx mu = ex_to(c.op(1)); > if (! mu.is_dim_numeric()) > throw(std::invalid_argument("Index should have a numeric dimension")); > unsigned int D = ex_to(mu.get_dim()).to_int(); > > if (algebraic) // check if algebraic method is applicable > for (unsigned int i = 0; i < D; i++) > if (pow(c.subs(mu == i), 2) == 0) > algebraic = false; > lst V; > if (algebraic) > for (unsigned int i = 0; i < D; i++) > V.append(delete_ONE(simplify_indexed(canonicalize_clifford(e * c.subs(mu == i) + c.subs(mu == i) * e))/(2*pow(c.subs(mu == i), 2)))); > else { > ex e1 = canonicalize_clifford(e); > for (unsigned int i = 0; i < D; i++) > V.append(get_clifford_comp(e1, c.subs(c.op(1) == i))); > } > return V; > } > > > ex moebius(const ex & a, const ex & b, const ex & c, const ex & d, const ex & v, const ex & G) > { > ex x, D; > if (is_a(G)) > D = ex_to(G.op(1)); > else > throw(std::invalid_argument("metric should be an indexed object")); > > varidx mu ((new symbol)->setflag(status_flags::dynallocated), ex_to(D).get_dim()); > > if (! is_a(v) && ! is_a(v)) > throw(std::invalid_argument("parameter v should be either vector or list")); > > x = lst_to_clifford(v, mu, G); > ex e = simplify_indexed(canonicalize_clifford((a * x + b) * clifford_inverse(c * x + d))); > ex cu = clifford_unit(mu, G); > return clifford_to_lst(e, cu); > } From C.Dams at science.ru.nl Mon Sep 27 14:04:03 2004 From: C.Dams at science.ru.nl (Chris Dams) Date: Mon Sep 27 14:04:03 2004 Subject: [GiNaC-devel] segmentation fault in substituting. Message-ID: Dear GiNaCers, I found that basic::subs_one_level sometimes gives a segementation fault. This is because the branch that takes care of the no_pattern option, tries to find *this in the exmap that contains the substitution. This invokes the construction of a temporary ex from *this. If it turns out that .eval() wants to change the ex in something else, the this pointer is going to be deleted, because, presumably, it was allocated with the dynallocated flag set, by basic::subs. If no substitution is found, it is tried to return the just deleted this pointer. Not a good idea... I suggest the change below in the basic::subs_one_level function in basic.cpp. *************** *** 603,611 **** exmap::const_iterator it; if (options & subs_options::no_pattern) { ! it = m.find(*this); if (it != m.end()) return it->second; } else { for (it = m.begin(); it != m.end(); ++it) { lst repl_lst; --- 617,627 ---- exmap::const_iterator it; if (options & subs_options::no_pattern) { ! ex thisex=*this; ! it = m.find(thisex); if (it != m.end()) return it->second; + return thisex; } else { for (it = m.begin(); it != m.end(); ++it) { lst repl_lst; Best, Chris From Christian.Bauer at uni-mainz.de Thu Sep 30 15:31:04 2004 From: Christian.Bauer at uni-mainz.de (Christian Bauer) Date: Thu Sep 30 15:31:04 2004 Subject: [GiNaC-devel] problem with dbgprint. In-Reply-To: References: Message-ID: <20040930133057.GD2928@thep.physik.uni-mainz.de> Hi! On Thu, Sep 23, 2004 at 11:58:23AM +0200, Chris Dams wrote: > This is because in basic::dbgprint a print_context is constructed from > std::cerr and not a print_dflt. Changing, in basic::dbgprint, the line > this->print(std::cerr); > into > this->print(print_dflt(std::cerr)); > solves this problem. Ok. Thanks! Bye, Christian -- / Physics is an algorithm \/ http://www.uni-mainz.de/~bauec002/ From Christian.Bauer at uni-mainz.de Thu Sep 30 15:34:04 2004 From: Christian.Bauer at uni-mainz.de (Christian Bauer) Date: Thu Sep 30 15:34:04 2004 Subject: [GiNaC-devel] segmentation fault in substituting. In-Reply-To: References: Message-ID: <20040930133336.GE2928@thep.physik.uni-mainz.de> Hi! On Mon, Sep 27, 2004 at 01:59:07PM +0200, Chris Dams wrote: > I found that basic::subs_one_level sometimes gives a segementation fault. Do you have a test case? Bye, Christian -- / Physics is an algorithm \/ http://www.uni-mainz.de/~bauec002/ From C.Dams at science.ru.nl Thu Sep 30 17:09:05 2004 From: C.Dams at science.ru.nl (Chris Dams) Date: Thu Sep 30 17:09:05 2004 Subject: [GiNaC-devel] segmentation fault in substituting. In-Reply-To: <20040930133336.GE2928@thep.physik.uni-mainz.de> Message-ID: Dear Christian, On Thu, 30 Sep 2004, Christian Bauer wrote: > > I found that basic::subs_one_level sometimes gives a segementation fault. > > Do you have a test case? Do you have any doubts then, after reading my description? Not that many of GiNaCs classes with a non-trivial eval method actually use basic::subs, do they? As a matter of fact, my new integral class seems to be the first. Well okay then, here is a program that needs the patch in order not to segfault on my system. In this case the integral evals into zero. #include #include using namespace std; using namespace GiNaC; int main(int argc, char** argv) { symbol x("x"),y("y"); ex f=integral(x,0,y,sin(x)); f=f.subs(y==0,subs_options::no_pattern); cout << f << endl; return 0; } Best, Chris From kreckel at thep.physik.uni-mainz.de Thu Sep 30 21:51:03 2004 From: kreckel at thep.physik.uni-mainz.de (Richard B. Kreckel) Date: Thu Sep 30 21:51:03 2004 Subject: [GiNaC-devel] problem with dbgprint. In-Reply-To: <20040930133057.GD2928@thep.physik.uni-mainz.de> Message-ID: On Thu, 30 Sep 2004, Christian Bauer wrote: > On Thu, Sep 23, 2004 at 11:58:23AM +0200, Chris Dams wrote: > > This is because in basic::dbgprint a print_context is constructed from > > std::cerr and not a print_dflt. Changing, in basic::dbgprint, the line > > this->print(std::cerr); > > into > > this->print(print_dflt(std::cerr)); > > solves this problem. > > Ok. Thanks! Oh, maybe I'm just dense, but I fail to see why it worked fine with mul or add or any other object. Since basic::dbgprint isn't overridden anywhere, why did it fail with power objects only? Curious -richy. -- Richard B. Kreckel