[GiNaC-devel] Substitution of wildcards
Vladimir V. Kisil
kisilv at maths.leeds.ac.uk
Mon Jun 12 16:42:21 CEST 2017
>>>>> On Fri, 09 Jun 2017 16:58:37 +0100, "Vladimir V. Kisil" <kisilv at maths.leeds.ac.uk> said:
>>>>> On Wed, 7 Jun 2017 18:26:47 +0200, Jan Rheinländer <jrheinlaender at gmx.de> said:
JR> Hi, I'm wondering what is going on here (ginsh output):
>>> subs($1 * x + 1/2 * x^2 * $2, match(a * x + b, $1 + x * $2));
JR> b*a+1/2*a^3
JR> What happened to "x" ? The match by itself correctly finds
The effect, which you are expecting, is achieved by by
subs_options::no_pattern
#include <ginac/ginac.h>
using namespace std;
using namespace GiNaC;
int main(){
realsymbol x("x"), a("a"), b("b");
wildcard w0(0), w1(1);
exmap repl;
(a * x + b).match(w0 + x * w1,repl);
cout << (w0 * x + pow(x,2) * w1 / 2).subs(repl,subs_options::no_pattern) << endl;
// -> b*x+1/2*a*x^2
}
--
Vladimir V. Kisil http://www.maths.leeds.ac.uk/~kisilv/
Book: Geometry of Mobius Transformations http://goo.gl/EaG2Vu
Software: Geometry of cycles http://moebinv.sourceforge.net/
More information about the GiNaC-devel
mailing list