[sympy] Re: RAM, stack, and polynomial manipulation

2010-05-02 Thread Ben Goodrich
Hi Mateusz, This works with the high-level code but does not work with the low- level code in polys9: from sympy.polys.monomialtools import monomial_lex_key as O_lex from sympy.polys.groebnertools import * from sympy.polys.polytools import basic_from_dict gens = [x,y] u = 1 f =

[sympy] Re: RAM, stack, and polynomial manipulation

2010-05-02 Thread Mateusz Paprocki
Hi, On Sun, May 02, 2010 at 08:29:44AM -0700, Ben Goodrich wrote: Hi Mateusz, This works with the high-level code but does not work with the low- level code in polys9: from sympy.polys.monomialtools import monomial_lex_key as O_lex from sympy.polys.groebnertools import * from

[sympy] Re: RAM, stack, and polynomial manipulation

2010-05-02 Thread Ben Goodrich
Sorry. You had said that already, but it did not stick in my brain. -- Ben -- You received this message because you are subscribed to the Google Groups sympy group. To post to this group, send email to sy...@googlegroups.com. To unsubscribe from this group, send email to

[sympy] Re: RAM, stack, and polynomial manipulation

2010-04-20 Thread smichr
I hope that too. Chris, is it ready for review? 1778 is on the docket waiting right now. All the other commits have been squashed together and the whole thing passes all tests. Part of he question is how fine you want the commit history to be. This all started with trying to get rid of

[sympy] Re: RAM, stack, and polynomial manipulation

2010-04-19 Thread Ben Goodrich
Hi, Okay, I got the domain thing figured out, but now I am running into a separate problem when the polynomial in sdp form is inside of a matrix. All this is fine: from sympy.polys.monomialtools import monomial_lex_key as O_lex from sympy.polys.groebnertools import * from sympy.polys.polytools

[sympy] Re: RAM, stack, and polynomial manipulation

2010-04-19 Thread Mateusz Paprocki
Hi, On Mon, Apr 19, 2010 at 08:28:21AM -0700, Ben Goodrich wrote: Hi, Okay, I got the domain thing figured out, but now I am running into a separate problem when the polynomial in sdp form is inside of a matrix. All this is fine: from sympy.polys.monomialtools import monomial_lex_key

[sympy] Re: RAM, stack, and polynomial manipulation

2010-04-19 Thread Ben Goodrich
Hi Mateusz, I think I understand but ... On Apr 19, 12:13 pm, Mateusz Paprocki matt...@gmail.com wrote: They look identical, but they're not. As you use F.as_dict(), then in both cases c_i are of type Integer. However, keys of _50 and _51 are different. In _50 M_i are tuples of Integer

[sympy] Re: RAM, stack, and polynomial manipulation

2010-04-19 Thread smichr
FF = sdp_from_dict(Poly(F, *gens, domain = 'QQ').as_dict(), O_lex) or specify any option after the *gens without getting the above syntax error. I am using Python 2.5. See Mateusz's 11:50 comment above. It's the same reason you ran into problems with my branch. I have fixed my branch,

Re: [sympy] Re: RAM, stack, and polynomial manipulation

2010-04-19 Thread Aaron S. Meurer
Lists are unhashable in every Python. If you want to use them as keys in a dictionary, you have to use tuples instead. You can probably fix it by doing dict([ (tuple(map(int, monom)), coeff) for monom, coeff in M[0,0] ]) (though I haven't tried it). Aaron Meurer On Apr 19, 2010, at 1:43 PM,

[sympy] Re: RAM, stack, and polynomial manipulation

2010-04-19 Thread Mateusz Paprocki
Hi, On Mon, Apr 19, 2010 at 02:09:04PM -0600, Aaron S. Meurer wrote: Lists are unhashable in every Python. If you want to use them as keys in a dictionary, you have to use tuples instead. You can probably fix it by doing dict([ (tuple(map(int, monom)), coeff) for monom, coeff in M[0,0]

[sympy] Re: RAM, stack, and polynomial manipulation

2010-04-19 Thread Ben Goodrich
Thanks Aaron, that works. One of these days, I will actually learn Python and be able to come up with such fixes myself. On Apr 19, 4:09 pm, Aaron S. Meurer asmeu...@gmail.com wrote: Lists are unhashable in every Python.  If you want to use them as keys in a dictionary, you have to use tuples

[sympy] Re: RAM, stack, and polynomial manipulation

2010-04-19 Thread Ben Goodrich
Hi Chris, On Apr 19, 3:48 pm, smichr smi...@gmail.com wrote: FF = sdp_from_dict(Poly(F, *gens, domain = 'QQ').as_dict(), O_lex) or specify any option after the *gens without getting the above syntax error. I am using Python 2.5. See Mateusz's 11:50 comment above. It's the same reason

Re: [sympy] Re: RAM, stack, and polynomial manipulation

2010-04-19 Thread Ondrej Certik
On Mon, Apr 19, 2010 at 10:21 PM, Ben Goodrich goodrich@gmail.com wrote: Hi Chris, On Apr 19, 3:48 pm, smichr smi...@gmail.com wrote: FF = sdp_from_dict(Poly(F, *gens, domain = 'QQ').as_dict(), O_lex) or specify any option after the *gens without getting the above syntax error. I

[sympy] Re: RAM, stack, and polynomial manipulation

2010-04-18 Thread smichr
Hi Ben, I tried the original expressions that you posted and this takes 9 minutes on my pretty modest machine with branch 1766 (on which I've reworked the expand quite a bit). Try numer = (first*second - third**2).expand(mul=1) and see what you get there. /c -- You received this message

[sympy] Re: RAM, stack, and polynomial manipulation

2010-04-18 Thread Ben Goodrich
Hi Chris, On Apr 18, 12:01 pm, smichr smi...@gmail.com wrote: Hi Ben, I tried the original expressions that you posted and this takes 9 minutes on my pretty modest machine with branch 1766 (on which I've reworked the expand quite a bit).  Try numer = (first*second - third**2).expand(mul=1)

Re: [sympy] Re: RAM, stack, and polynomial manipulation

2010-04-18 Thread Ondrej Certik
Hi Ben! On Sun, Apr 18, 2010 at 7:06 PM, Ben Goodrich goodrich@gmail.com wrote: Hi Chris, On Apr 18, 12:01 pm, smichr smi...@gmail.com wrote: Hi Ben, I tried the original expressions that you posted and this takes 9 minutes on my pretty modest machine with branch 1766 (on which I've

[sympy] Re: RAM, stack, and polynomial manipulation

2010-04-18 Thread Mateusz Paprocki
Hi, On Sun, Apr 18, 2010 at 11:06:38AM -0700, Ben Goodrich wrote: Hi Chris, On Apr 18, 12:01 pm, smichr smi...@gmail.com wrote: Hi Ben, I tried the original expressions that you posted and this takes 9 minutes on my pretty modest machine with branch 1766 (on which I've reworked the

[sympy] Re: RAM, stack, and polynomial manipulation

2010-04-18 Thread Ben Goodrich
Hi Mateusz, On Apr 18, 2:06 pm, Ben Goodrich goodrich@gmail.com wrote: Mateusz's suggestions are working well for me, just ugly.  And it is still slow and RAM-hungry when you convert a big sdp polynomial back into basic SymPy form at the end, but maybe your work on expand / core will help

Re: [sympy] Re: RAM, stack, and polynomial manipulation

2010-04-18 Thread Mateusz Paprocki
Hi, fgh = Poly(dict(FGH), domain = 'QQ', *gens) the above should read Poly(dict(FGH), *gens, domain='ZZ') (or domain='QQ' if you used the rational field in previous steps). On 18 April 2010 14:33, Ben Goodrich goodrich@gmail.com wrote: Hi Mateusz, On Apr 18, 2:06 pm, Ben Goodrich

Re: [sympy] Re: RAM, stack, and polynomial manipulation

2010-04-18 Thread Aaron S. Meurer
This is for the same reason mentioned earlier. f(*args, kwarg=value) syntax isn't supported until Python 2.6 or greater. The solution is to use Poly(dict(FGH), *gens, **{domain:'QQ'}) (or update to Python 2.6). Aaron Meurer On Apr 18, 2010, at 5:24 PM, Ben Goodrich wrote: Hi Mateusz, On

Re: [sympy] Re: RAM, stack, and polynomial manipulation

2010-04-18 Thread Mateusz Paprocki
Hi, missing quotes around domain, should be: Poly(dict(FGH), *gens, **{'domain':'QQ'}) it works correctly, except it defaults to ZZ. You can add field=True (**{'ffield': True} in your system) instead of domain, to force Poly to use a field always instead of deriving minimal domain

[sympy] Re: RAM, stack, and polynomial manipulation

2010-04-17 Thread Mateusz Paprocki
Hi, On Fri, Apr 16, 2010 at 08:09:28PM -0700, Ben Goodrich wrote: Hi Mateusz, On Apr 16, 6:43 pm, Mateusz Paprocki matt...@gmail.com wrote: This is all correct, because you are using top-level quo() function with FGH, which is a low-level polynomial representation. Ah, now I

[sympy] Re: RAM, stack, and polynomial manipulation

2010-04-16 Thread Ben Goodrich
Hi again, Things are a bit better now, but I still can't get as far as I'd like with the polys8 branch (as of a few days ago). I didn't rigorously benchmark the attached, but just a rough impression from looking at top implies that thing = first * second - third.sqr() where first, second, and

[sympy] Re: RAM, stack, and polynomial manipulation

2010-04-16 Thread Mateusz Paprocki
Hi, On Fri, Apr 16, 2010 at 10:16:58AM -0400, Ben Goodrich wrote: Hi again, Things are a bit better now, but I still can't get as far as I'd like with the polys8 branch (as of a few days ago). I didn't rigorously benchmark the attached, but just a rough impression from looking at top

Re: [sympy] Re: RAM, stack, and polynomial manipulation

2010-04-16 Thread Akshay Srinivasan
Forgot to expand the terms in the program, [neptune ~/bench] time g++ -lcln -lginac RAMspeed.cc -o RAMspeed real0m57.911s user0m55.526s sys0m0.780s [neptune ~/bench] time ./RAMspeed expr real0m11.153s user0m10.786s sys0m0.253s

[sympy] Re: RAM, stack, and polynomial manipulation

2010-04-16 Thread Ben Goodrich
Hi Mateusz, On Apr 16, 11:46 am, Mateusz Paprocki matt...@gmail.com wrote: SymPy can compute things like F*G - H**2 fast, unfortunately not on the user level. Below you will find a short tutorial how to do it fast but messy way. Thank you for the tutorial and all your work on the

[sympy] Re: RAM, stack, and polynomial manipulation

2010-04-16 Thread Ben Goodrich
Hi Akshay, On Apr 16, 11:51 am, Akshay Srinivasan akshaysriniva...@gmail.com wrote: Forgot to expand the terms in the program, [neptune ~/bench] time g++ -lcln -lginac RAMspeed.cc -o RAMspeed real    0m57.911s user    0m55.526s sys    0m0.780s

[sympy] Re: RAM, stack, and polynomial manipulation

2010-04-16 Thread Ben Goodrich
Hi Mateusz On Apr 16, 11:46 am, Mateusz Paprocki matt...@gmail.com wrote: SymPy can compute things like F*G - H**2 fast, unfortunately not on the user level. Below you will find a short tutorial how to do it fast but messy way. Lets assume you have polynomial-like expressions F, G, H. For my

Re: [sympy] Re: RAM, stack, and polynomial manipulation

2010-04-16 Thread Mateusz Paprocki
Hi, On 16 April 2010 13:03, Ben Goodrich goodrich@gmail.com wrote: Hi Mateusz On Apr 16, 11:46 am, Mateusz Paprocki matt...@gmail.com wrote: SymPy can compute things like F*G - H**2 fast, unfortunately not on the user level. Below you will find a short tutorial how to do it fast but

[sympy] Re: RAM, stack, and polynomial manipulation

2010-04-16 Thread Ben Goodrich
Hi Mateusz, On Apr 16, 4:10 pm, Mateusz Paprocki matt...@gmail.com wrote: What exactly is gens here? I thought it was supposed to be a list that contains all the symbols in the polynomials, but then I eventually run into this error

Re: [sympy] Re: RAM, stack, and polynomial manipulation

2010-04-16 Thread Mateusz Paprocki
Hi, On 16 April 2010 14:39, Ben Goodrich goodrich@gmail.com wrote: Hi Mateusz, On Apr 16, 4:10 pm, Mateusz Paprocki matt...@gmail.com wrote: What exactly is gens here? I thought it was supposed to be a list that contains all the symbols in the polynomials, but then I eventually run

[sympy] Re: RAM, stack, and polynomial manipulation

2010-04-16 Thread Ben Goodrich
Hi Mateusz, On Apr 16, 6:43 pm, Mateusz Paprocki matt...@gmail.com wrote: This is all correct, because you are using top-level quo() function with FGH, which is a low-level polynomial representation. Ah, now I understand. Thanks. Ben -- You received this message because you are subscribed

[sympy] Re: RAM, stack, and polynomial manipulation

2010-04-09 Thread Ben Goodrich
On Apr 9, 3:09 pm, Ondrej Certik ond...@certik.cz wrote: And if this helps, we can then try to think how to make this automatic, so that you can just write: first * second - third**2 and it will be the same fast. Ondrej Okay, I had already assumed that if first * second - third**2 was

Re: [sympy] Re: RAM, stack, and polynomial manipulation

2010-04-09 Thread Ondrej Certik
On Fri, Apr 9, 2010 at 1:07 PM, Ben Goodrich goodrich@gmail.com wrote: On Apr 9, 3:09 pm, Ondrej Certik ond...@certik.cz wrote: And if this helps, we can then try to think how to make this automatic, so that you can just write: first * second - third**2 and it will be the same fast.

[sympy] Re: RAM, stack, and polynomial manipulation

2010-04-09 Thread Ben Goodrich
On Apr 9, 7:05 pm, Ondrej Certik ond...@certik.cz wrote: On Fri, Apr 9, 2010 at 1:07 PM, Ben Goodrich goodrich@gmail.com wrote: So far, that is only using a small amount of RAM, but it is still calculating. I will report back when it finishes or errors. Yep, report back. Ondrej Okay,