On 26 Nov, 21:40, "Ondrej Certik" <[EMAIL PROTECTED]> wrote:
> On Nov 26, 2007 12:09 PM, Ondrej Certik <[EMAIL PROTECTED]> wrote:
>
>
>
> > > I have tried SyFi on several real examples like the Bidomain
> > > equations, Navier-Stokes etc.
> > > But I only use SyFi for generating the C++ code for the finite
> > > elements,  element matrices etc.
> > > The generated code is usually very fast, orders of magnitude faster
> > > than traditional quadrature.
> > > Its code and efficiency is similar to FFC.  Assembly is typically done
> > > in Dolfin/PyCC and solving
> > > the linear systems is done in Hypre/Trilinos.
>
> > Assembly is enough for me, I need to solve the eigenproblem anyway, so
> > I use blzpack/arpack/primme for that.
> > I'll try it, this sounds pretty exciting.
>
> > > Many of the  Fenics projects have been in a state of flux for the last
> > > year. But this
> > > is improving. The future plan of SyFi is to come up with a nice user
> > > interface/language such
> > > that SyFi will work as a compiler translating high-level finite
> > > element python code
> > > to efficient low-level C++ code.
>
> > > The reason why I am looking at Sympy is that although I am fairly
> > > happy with GiNaC, it has its issues.
>
> > Could you be more specific what issues GiNaC has? The only problem
> > with ginac that I know of is that it is very difficult to create new
> > functions,
> > but as far as I know, SyFi just needs polynomials.
>
> > > Still, I think I'd prefer Sympy (except the efficiency).
>
> > > Can sympy generate C++ code ?
>
> > Not yet, but this is fairly easy to do. We can generate a Python code:
>
> > In [1]: e = sin(x)**4/y**(-2)
>
> > In [2]: e
> > Out[2]:
> >  2    4
> > y *sin (x)
>
> > In [3]: Basic.set_repr_level(0)
> > Out[3]: 2
>
> > In [4]: e
> > Out[4]: Mul(Pow(Symbol('y'), Integer(2)), Pow(sin(Symbol('x')), Integer(4)))
>
> > So we can generate C++ code as well. But of course only a subset of
> > sympy features can be exported to C++. Mainly just an expression and a
> > way to substitute to that
> > expression. So the above should translate to something like this:
>
> > float x;
> > float y;
> > e = pow(sin(x), 4)*pow(y,2);
>
> > is that correct? If you could give me more info what exactly you need,
> > I'll implement that.
>
> > > > From profiling your code, it appears that nearly all the time is spent
> > > > in integrate().
> > > > This shows quite clearly that we need to optimize the integration code 
> > > > for
> > > > polynomials.
>
> > > > Fredrik
>
> > > Ok thanks, is this easy to do ?
>
> > I think it should be fairly easy, that's why I wrote SymPy, so that
> > those things are easy. We just need to go to:
>
> >http://hg.sympy.org/sympy/file/c8da4f2b2324/sympy/integrals/integrals.py
>
> > line 122, and we use a general (slow) algorithm to integrate a lot of
> > functions. So we just check, if we got a polynomial, extract the
> > coefficients and integrate it. We can use functions from:
>
> >http://hg.sympy.org/sympy/file/132066377866/sympy/polynomials/base.py
>
> > There is a Polynomial class in there, so my bet is just to implement
> > .integrate() in that class, to be as efficient as possible and than
> > just fix ingetrals.py, to try to convert to polynomial if it is a
> > polynomial.
>
> > I'll try it in the evening, if it speeds things up.
>
> So indeed I sped things up by a factor of 10x. See:
>
> http://code.google.com/p/sympy/issues/detail?id=470
>
> for details and a patch. Now it needs to be polished and committed.
> Your example now runs for 2.3s. How fast is ginac on this exactly?


Great!!

SyFi/GiNaC runs in 0.3s on my computer.


Kent
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sympy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to