These are chat archives for bluescarni/piranha

20th
Jan 2018
Andrew Corrigan
@andrewcorrigan
Jan 20 2018 05:00
I tried it... it appears to be (and gives a solid speed-up!)
but it'd be great to confirm that I'm not potentially running into race conditions. thanks in advance
Andrew Corrigan
@andrewcorrigan
Jan 20 2018 06:07
I have a polynomial, where I can cancel out "e0":
_x(2)_z(1)e0e1-_y(2)_z(1)e0**2+_x(1)_y(2)e0e2+_y(1)_z(2)e0*2-_x(2)_y(1)e0e2-_x(1)_z(2)e0*e1
but division gives the error: what: divisor in series division does not consist of a single coefficient
is there any other way to remove e0 from each term?
Francesco Biscani
@bluescarni
Jan 20 2018 13:42
@andrewcorrigan that type of multithreaded usage is supported by piranha, so you should be safe
for that simple case of division, what you can do is to raise "e0" to -1 and multiply the polynomial by it
ah but you want to remove different powers of e0 from the expression? In that case you can substitute "e0" with 1 as an alternative
Andrew Corrigan
@andrewcorrigan
Jan 20 2018 18:43
I want to just divide by e0, sorry my wording was imprecise, I'll try multiplying by e0^-1
Hmm. so I have: d *= m.pow(-1); and get: "what: invalid argument for series exponentiation: negative integral value"
d and m are both: piranha::polynomial<piranha::rational,piranha::monomial<int>>
Francesco Biscani
@bluescarni
Jan 20 2018 19:32
how is m defined?
Andrew Corrigan
@andrewcorrigan
Jan 20 2018 20:45
let me try to put together a simple reproducer
OK: so I put together a simple reproducer and your suggestion worked, what happened is that it then stopped later, where the denominator is a more complex polynomial
and for that the .pow(-1) also fails
I am guessing I need to do polynomial division?
Andrew Corrigan
@andrewcorrigan
Jan 20 2018 20:51
it failed specifically for dividing by a polynomial: ye0-xe1
thanks for your help with this, and sorry for moving the goalposts
I tried to use piranha::math::div3, same error
Francesco Biscani
@bluescarni
Jan 20 2018 21:10
right, the negative exponentiation works only for monomials, it's not a real division algorithm
so the story here is that at one point piranha did implement a real polynomial division algorithm, but I removed the functionality eventually for a variety of reasons (but mostly because with piranha's data structures it is tricky to implement division efficiently, and I felt piranha was starting to stray too far away from its original focus)
Francesco Biscani
@bluescarni
Jan 20 2018 21:16
in the specific case you mention above, perhaps you could do a substitution such as:
$m = ye_0-xe_1 \rightarrow y = \left(m + xe_1\right) e_0^{-1}$
and then multiply the original expression by $m^{-1}$?
Andrew Corrigan
@andrewcorrigan
Jan 20 2018 21:21
the problem is these are all procedurally generated expressions, so I think the general algorithm would be needed
but I understand if general polynomial division is outside of the scope of piranha
thank you for explaining the background to me
Francesco Biscani
@bluescarni
Jan 20 2018 21:22
you know beforehand all polynomial divisions are exact or are there remainders as well?
Andrew Corrigan
@andrewcorrigan
Jan 20 2018 21:23
I think they would all be exact... basically I'm computing a determinant using the bareiss algorithm (in sympy/symengine), but on a matrix of piranha polynomials
so I'm not sure why this division even arises
Francesco Biscani
@bluescarni
Jan 20 2018 21:24
I thought the Bareiss algorithm actually employs divisions (guaranteed to be exact)?
but in any case you could use a piranha version in which the poly division is available
are you using the latest git?
Andrew Corrigan
@andrewcorrigan
Jan 20 2018 21:25
I think I am
are you suggesting to revert to an older version of Piranha?
Francesco Biscani
@bluescarni
Jan 20 2018 21:27
the latest official version still has the division code: https://github.com/bluescarni/piranha/releases/tag/v0.10
Andrew Corrigan
@andrewcorrigan
Jan 20 2018 21:29
thank you -- for now, I hand-coded a 4x4 determinant, which is high as I need at the moment, but if it comes up again I will definitely try that out
Francesco Biscani
@bluescarni
Jan 20 2018 21:29
ok, no problem. I might consider re-adding the division code if I can figure out how to make it good enough. At the time it felt like I was getting into feature-creep mode, but if it turns out that it's useful.. why not
Andrew Corrigan
@andrewcorrigan
Jan 20 2018 21:31
that's a tough balance to strike
thank you
Francesco Biscani
@bluescarni
Jan 20 2018 21:32
just for historical context... the division code was part of an attempt to implement rational functions in piranha, together with polynomial GCD. As it turns out, efficient polynomial GCD is still pretty much a research topic, and piranha's data structures are not the best for this type of application. I got it working eventually, but it was far from optimal and I decided to ditch the whole subject to refocus on the core bits of piranha
sure no problem! any time just drop by and ask here, I should be able to reply relatively fast normally