Open stla opened 5 years ago
hello, thanks for this. As you point out, mvp objects with rational coefficients are perfectly well-defined (and indeed the complex generalization might be interesting too), and this would certainly be possible in principle. The problem is that, in the mvp
package coefficient addition (and potential cancellation) has to be done in C, not R; so implementing this idea would need a major restructuring of the package. On the other hand, there is no problem having coefficients which are themselves mvp objects, or indeed multiplying everything by the LCD of the denominators, in the example you post this would be 9. But I know that this is an awkward and poor thing. What is your application?
What is your application?
Sorry I forgot to link my package: https://github.com/stla/jackR
Hi Robin,
I improved my package. I'm using Ryacas to evaluate polynomials with rational variables and coefficients.
Hi Robin,
I did a new package, gmpoly, for multivariate polynomials with gmp rational coefficients. Everything is programmed in R, no C/C++.
> library(gmpoly)
>
> pol <- gmpoly("4 x^(2, 1, 1) + 1/2 x^(0,1,0)")
> +pol
[1] "1/2 x^(0,1,0) + 4 x^(2,1,1)"
> -pol
[1] "-1/2 x^(0,1,0) - 4 x^(2,1,1)"
> 2 * pol
[1] "1 x^(0,1,0) + 8 x^(2,1,1)"
> pol / 2
[1] "1/4 x^(0,1,0) + 2 x^(2,1,1)"
> pol + 5
[1] "5 x^(0,0,0) + 1/2 x^(0,1,0) + 4 x^(2,1,1)"
> pol - 5
[1] "-5 x^(0,0,0) + 1/2 x^(0,1,0) + 4 x^(2,1,1)"
> pol^2
[1] "1/4 x^(0,2,0) + 4 x^(2,2,1) + 16 x^(4,2,2)"
> pol1 <- gmpoly("2 x^(1,1) - 5/3 x^(0,1)")
> pol2 <- gmpoly("-2 x^(1,1) + 3 x^(2,1)")
> pol1 + pol2
[1] "-5/3 x^(0,1) + 3 x^(2,1)"
> pol1 * pol2
[1] "10/3 x^(1,2) - 9 x^(2,2) + 6 x^(3,2)"
that is a great piece of work. It is cool to have everything in R. I've been playing with it, why do you not allow negative powers?
@.***>
On Fri, Feb 18, 2022 at 2:26 AM stla @.***> wrote:
Hi Robin,
I did a new package, gmpoly https://github.com/stla/gmpoly, for multivariate polynomials with gmp rational coefficients. Everything is programmed in R, no C/C++.
library(gmpoly)> > pol <- gmpoly("4 x^(2, 1, 1) + 1/2 x^(0,1,0)")> +pol [1] "1/2 x^(0,1,0) + 4 x^(2,1,1)"> -pol [1] "-1/2 x^(0,1,0) - 4 x^(2,1,1)"> 2 pol [1] "1 x^(0,1,0) + 8 x^(2,1,1)"> pol / 2 [1] "1/4 x^(0,1,0) + 2 x^(2,1,1)"> pol + 5 [1] "5 x^(0,0,0) + 1/2 x^(0,1,0) + 4 x^(2,1,1)"> pol - 5 [1] "-5 x^(0,0,0) + 1/2 x^(0,1,0) + 4 x^(2,1,1)"> pol^2 [1] "1/4 x^(0,2,0) + 4 x^(2,2,1) + 16 x^(4,2,2)"> pol1 <- gmpoly("2 x^(1,1) - 5/3 x^(0,1)")> pol2 <- gmpoly("-2 x^(1,1) + 3 x^(2,1)")> pol1 + pol2 [1] "-5/3 x^(0,1) + 3 x^(2,1)"> pol1 pol2 [1] "10/3 x^(1,2) - 9 x^(2,2) + 6 x^(3,2)"
— Reply to this email directly, view it on GitHub https://github.com/RobinHankin/mvp/issues/19#issuecomment-1042947792, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADFFZUT37J573ZZPLN5O46DU3TZQPANCNFSM4IHVX3BQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you commented.Message ID: @.***>
Good suggestion. I will think about it. Thanks.
Hello,
I've just done a package which implements some polynomials. Their coefficients are rational in general, I calculate them with
gmp
. It would be nice ifmvp
could deal with gmp coefficients. Is it doable ?