[GiNaC-devel] AsyForGiNaC - an output extension producing Asymptote files

Vladimir V. Kisil kisilv at maths.leeds.ac.uk
Wed Aug 23 00:52:58 CEST 2006


		Dear Daniel,

		I will be at Uni on Wed and Fri, so you can see me and take your
  updated certificate. In relation to "printing" methods for Asymptote
  please consider the example below. In fact a lot of GiNaC expressions
  may be directly "printed" to Asy without any evaluations at all.

  Best wishes, 
  Vladimir
-- 
Vladimir V. Kisil     email: kisilv at maths.leeds.ac.uk
--                      www: http://maths.leeds.ac.uk/~kisilv/

include <iostream>
#include <ginac/ginac.h>
#include <ext/stdio_filebuf.h>
using namespace std;
using namespace GiNaC;

int main(){
        FILE* s=popen("asy > /dev/null","w");
        __gnu_cxx::stdio_filebuf<char> fb(s,ios::out);
        ostream asy(&fb);
        realsymbol t("t"), x("z.x"), y("z.y");

        ex parabola=pow(t,2), sadle=pow(x,2)-pow(y,2);

        asy << "import graph;"
                << "size(200);"
                << "real f(real t) {return " << parabola << ";}"
                << "xaxis(\"x\"); yaxis(\"y\");"
                << "draw(graph(f, -2, 2, operator ..),red);"
                << "shipout(\"parabola\");"
                << "erase();"<< endl;
        asy.flush();

        asy << "import graph3;"
                << "real f(pair z) {return " << sadle << ";}"
                << "add(surface(f, 10, (-1,-1), (1,1), 10));"
                << "shipout(\"sadle\");" << endl;
        asy.flush();

        asy << "exit;" << endl;
        asy.flush();
        pclose(s);
}


More information about the GiNaC-devel mailing list