Hi at all,
Aaron S. Meurer wrote:
>
> So the problem is large rational coefficients. You might want to try
> setting the environment variable SYMPY_GROUND_TYPES=gmpy (you will
> need to install gmpy). Assuming you are working in master with the
> new polys, this should make things faster, especially if you are
> using Poly()'s. ZZ.dtype will tell you the ground type. Integer is
> SymPy (slowest), int is Python (next slowest), and mpz is gmpy (the
> fastest).
Thank you for the suggestion. I'll keep that in mind. But currently I
dont have the time for this. Because for the current task this would not
help. The reason is: at the end I want to cope with symbolic
coefficients. I just used random integers for testing. These result in
rational coefficients because I apply the sympy.gcdex algorithm
repeatedly. I think I have to concentrate on this point. If I could
simplify the results here (and I think I have some degrees of freedom),
I can avoid the huge expressions in the coefficients.
The overall goal is to compute an unimodular polynomial matrix U
(unimodular means U.det() is a degree zero polynomial) which transforms
a given Matrix in hermitian normal form.
To be more precise: The computation of U is easy but I also need its
inverse V. The computation of V still is quite fast. But the Problem is:
the elements of V seem to be very complex. As stated earlier count_ops
results in ca. 1.5e5 (for one element). Printing an element of V takes
too long. (But it would not give much insight I guess).
While playing around with those matrices: I came across the following
question/issue:
It happens that U.det() is 1. So I can compute the inverse just by
U.adjugate(). Now I would think that U.inverse_ADJ() leads to the same
result, but it does not. It returns a more complex one.
Reason: it uses .berkowitz_det() which in my case is a quite complex
expression. Only when it is expanded it simplifies to 1.
So I would suggest in /matrices/matrices.py to replace
d = self.berkowitz_det()
by
d = expand(self.berkowitz_det())
and/or to introduce an optional method argument like .det, .adjugate and
related methods already have.
smichr wrote:
> Bastian: regarding the hang in expansion...please try it on branch
> 1766 at my smichr account at github. Ronan timed it recently and it
> looks like it's doing well.
>
Thanks for the suggestion. I'll try that at the weekend
Regarding the more or less the original topic:
Would it be useful to test if .count_ops (or some other (fast) measure
for complexity) exceeds a pre-determined value and in this case print a
warning that the operation (e.g. expand) could take very long? I
sometimes feel like missing this. How about other users?
Regards,
Bastian.