RobinHankin / mvp

https://robinhankin.github.io/mvp/
8 stars 3 forks source link

constant term in multinomials #1

Closed RobinHankin closed 5 years ago

RobinHankin commented 5 years ago

currently broken:

> (a <- as.mvp(mp("1+x")))
mvp object algebraically equal to
1  +  x
> dput(a)
structure(list(names = list(character(0), "x"), power = list(
    integer(0), 1L), coeffs = c(1, 1)), class = "mvp")
> a*a*a
mvp object algebraically equal to
1  +  4 x  +  5 x^2  +  2 x^3
> 

Currently weighing up whether it is better to deal with the constant one the C side or the R side. Probably the R side is easier to deal with, without breaking the nice use of the STL

RobinHankin commented 5 years ago

A better example, showing (I think) that there is an allocation issue:

> a <- as.mvp(mp("1+x"))
> a*(a*a)
mvp object algebraically equal to
coef  +  2 x  +  x^2  +  6.896486e-314 x^3
> 
RobinHankin commented 5 years ago

After more thought, this issue must be dealt with on the C side, because of the possibility that two mvp objects, both of which have zero constant term might have a product with a nonzero constant term.

RobinHankin commented 5 years ago

didn't mean to close this, reopening as it is not resolved

RobinHankin commented 5 years ago

It's not just the constant:

> a <- as.mvp(mp("x+y"))
> (a*a)*a
mvp object algebraically equal to
4 x y^2  +  5 x^2 y  +  2 x^3  +  y^3
> a*(a*a)
mvp object algebraically equal to
x y^2  +  2 x^2 y  +  x^3  +  7.0374e-314 y^3
> 

So there is something deeply deeply wrong somewhere