Hello !!!

I am writing the patch to move from InfinitePolynomialRing to just "var
()", and I am having several annoying problems :
To obtain the coefficients of each variable, I have to write
for v in expression.variables():
     c = expression.coefficient(v)

And I wonder if this is not a quadratic algorithm while it should be
linear to get "all" the coefficients

The coefficients are not assumed to be "real values". They are assumed
to be "expression", and I have to evaluate them using n() to get the
value.

 This things transforms all the equations from 2 * x[1] - 3 * x[2] to
2.0000000000 x[1] - 3.0000000000 * x[2] which makes all the outputs
clearly unreadable...

How could I get these values without such things happening ?

Thank you !!!

Nathann

On Nov 26, 12:11 pm, Burcin Erocal <bur...@erocal.org> wrote:
> On Thu, 26 Nov 2009 02:51:17 -0800 (PST)
>
> Nathann Cohen <nathann.co...@gmail.com> wrote:
> > Hmmmmmm.... After thinking about it for a bit, is using var() really a
> > good solution ? It is fast and everything, but I use my variables in
> > functions that should not spoil the userspace with them ! When I
> > define symbolic variables, they are global and could even be accessed
> > in the userspace... Can this be avoided ?
>
> If you're using Cython you can bypass the global symbol registry and
> construct your symbols using pynac directly.
>
> This untested function (based on sage.symbolic.ring.SymbolicRing.symbol)
> might work:
>
>     def my_symbol(name):
>         cdef GSymbol symb
>         GSymbol_construct_str(&symb, name)
>         cdef Expression e
>         e = <Expression>PY_NEW(Expression)
>         GEx_construct_symbol(&e._gobj, symb)
>         e._parent = SR
>         return e
>
> You need to include sage/libs/ginac/decl.pxi to get the declarations of
> GSymbol, GSymbol_construct_str, etc.
>
> Cheers,
> Burcin

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to