As far as I understand, Poly is mostly a smart wrapper that figures out
what domains to use, and translates highlevel operations on polynomials
into low-level operations.
So the Matrix class should not /use/ Poly instances, but parallel Poly
in the sense that it is a container, figuring out what domains to use,
and dispatching operation to low-level implementations.
Again, I should have prefixed this by saying that Mateusz is the expert
and I'm just using polys a bit...
DMF is already higher level. The things you should probably be looking
at are in polys/domains. There's a lot there, and it's a bit of a shame
that there's not much documentation. I think construct_domain should
somehow construct a domain that can hold your data. If you need to
divide, or take square roots, etc, you presumably have to figure out
what larger domain you need. There are probably functions for this, but
I don't know about them. Ask Mateusz about anything specific.
As for ground types, they work roughly like this:
>>> from sympy.polys.domains import FF
This imports a constructor for finite fields. As I understand it, this
will automatically use gmpy or python types depending on what is available.
Construct a domain for arithmetic mod 5:
>>> F5 = FF(5)
Do some arithmetic:
>>> F5(3) + F5(8)
1 mod 5
>>> F5(3)/F5(2)
4 mod 5
Funny things can happen if you do division where you should not:
>>> from sympy.polys.domains import ZZ
>>> ZZ(2)/ZZ(3)
0.666666666667
But this works:
>>> Q = ZZ.get_field()
>>> Q(2)/Q(3)
2/3
I suppose to see how to do this sort of stuff automatically, you have to
read polytools.py.
DMF is already higher level. The things you should probably be looking at are in polys/domains.On May 30, 12:13 am, Tom Bachmann<e_mc...@web.de> wrote:
How is this at all different from what Polys does? I'm not saying it's
bad, I'm just not seeing your point. Basically what you call ground
types are called domains in polys, and they are in polys/domains ...
I need usable types. For example, you mentioned that one usable type
is DMF, and it is in poly/polyclasses.
How many other such types exist and where ?
There's a lot there, and it's a bit of a shame that there's not much documentation.
I think construct_domain should somehow construct a domain that can hold your data. If you need to divide, or take square roots, etc, you presumably have to figure out what larger domain you need. There are probably functions for this, but I don't know about them. Ask Mateusz about anything specific.
As for ground types, they work roughly like this:
>>> from sympy.polys.domains import FF
This imports a constructor for finite fields. As I understand it, this will automatically use gmpy or python types depending on what is available.
Construct a domain for arithmetic mod 5:
>>> F5 = FF(5)
Do some arithmetic:
>>> F5(3) + F5(8)
1 mod 5
>>> F5(3)/F5(2)
4 mod 5
Funny things can happen if you do division where you should not:
>>> from sympy.polys.domains import ZZ
>>> ZZ(2)/ZZ(3)
0.666666666667
But this works:
>>> Q = ZZ.get_field()
>>> Q(2)/Q(3)
2/3
I suppose to see how to do this sort of stuff automatically, you have to read polytools.py.
--
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+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sympy?hl=en.
On Sun, May 29, 2011 at 3:44 PM, Mateusz Paprocki <mat...@gmail.com> wrote:
> Hi,
>
> On 29 May 2011 23:10, Tom Bachmann <e_m...@web.de> wrote:
>>>
>>> On May 30, 12:13 am, Tom Bachmann<e_mc...@web.de> wrote:
>>>>
>>>> How is this at all different from what Polys does? I'm not saying it's
>>>> bad, I'm just not seeing your point. Basically what you call ground
>>>> types are called domains in polys, and they are in polys/domains ...
>>>
>>> I need usable types. For example, you mentioned that one usable type
>>> is DMF, and it is in poly/polyclasses.
>>> How many other such types exist and where ?
>>>
>>
>> DMF is already higher level. The things you should probably be looking at
>> are in polys/domains.
>
> Well, DMF is low-level. In domains you will find FractionField domain that
> uses DMF a ground type.
>
>>
>> There's a lot there, and it's a bit of a shame that there's not much
>> documentation.
>
> There isn't that much, but main ideas are described in my thesis (ch. 2). If
> more information is needed, I can always provide it (as long as a question
> is specific).
There would be more, as I wrote doctests for all those things back in
https://github.com/asmeurer/sympy/tree/polydocs. But the domains code
was all moved to polys/domains and the API changed so much that I
never bothered to transfer the doctests.
If you need to know how a module works and there is no documentation,
writing doctests for all the functions/methods is a great way to fix
both problems. This is how I learned how the polys in general worked
at the beginning of last summer (see the above linked branch). In
this case, you could just work on transferring my doctests that were
never transferred.
Aaron Meurer
--
Brian E. Granger
Cal Poly State University, San Luis Obispo
bgra...@calpoly.edu and elli...@gmail.com
Is there a link somewhere to documentation about the groundtypes in
polys? I am interested why such things are needed? It sort of sounds
like there are two semi-independent code bases living here...
scipy.sparse implements a dtype kwarg argument, but which currently
cannot take in arbitrary unknown types though.
--
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+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sympy?hl=en.
Then I don't understand what polys has to do with Matrices. Surely
matrices can contain expressions other than polynomials. This is
really what I am wondering about. Are we talking about a special
Matrix subclass that *only* contains polynomials?
Are you considering adding a dtype argument to sympy.Matrix?
Are you consider making sympy.Expr objects work inside numpy matrices?
Are you considering making sympy.Expr work inside scipy.sparse matrices?
Cheers,
Brian
> On Thu, Jun 2, 2011 at 1:28 AM, Mateusz Paprocki <mat...@gmail.com> wrote:
>> Hi,
>>
>> On 2 June 2011 04:09, Brian Granger <elli...@gmail.com> wrote:
>>>
>>> Is there a link somewhere to documentation about the groundtypes in
>>> polys? I am interested why such things are needed? It sort of sounds
>>> like there are two semi-independent code bases living here...
>>
>> See my previous response. Unfortunately, currently there isn't much
>> documentation on this topic. As to two code bases, there are actually two
>> cores, one (should be) purely symbolic (sympy.core) and the other algebraic
>> (sympy.polys and sympy.polys.domains, later should be extracted to a
>> separate top-level module, to make it reusable in other parts of SymPy).
>
> Then I don't understand what polys has to do with Matrices. Surely
> matrices can contain expressions other than polynomials. This is
> really what I am wondering about. Are we talking about a special
> Matrix subclass that *only* contains polynomials?
It isn't related to the polys in the sense the that matrix elements are polynomials. Rather, think of the coefficients of a polynomial. Poly(2*x**3 + x + 4) is stored internally as [2, 0, 1, 4]. The problems that arise when working with coefficients of polynomials are very similar to the ones that arise when working with matrices. Mateusz has modularized the coefficients of Poly pretty well so that there are different classes for integer coefficients or rational coefficients or even rational function coefficients (like Poly((1 + y)/y**2*x, x)). The integer and rational number coefficient domains are written so that they can use gmpy if it's installed, or else it uses Python, and all automatically. This should all be adapted to the matrices, because it makes the code cleaner and, more importantly, it makes things much faster.
Aaron Meurer
> Yes and no and no.
> Numpy/scipy matrices have their backend in C/fortran types. Arbitrary objects can't be put inside them.
>
> That's where sympy comes in and finds a market for its use. I'm adding a dtype(the usgae of this name might be wrong) argument to sympy matrices. 6 basic types, ints, rationals, reals, polys, rational functions, and finally Exprs will be built in. It will have an 'other' option which will the user to put in any arbitrary type as elements of the matrix which support the fundamental operations required for matrix algorithms.
>
> Possibly, a template could be provided to the user to have provide the sympy matrix with domain.sum, domain.typify, etc..
I'd say this already exists as the super class of the poly domains.
Aaron Meurer