dkahle / dkahle/mpoly

Type instability

Open
#23 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
HTML
Stars
12
Forks
12
PR merge metrics
No merged PRs in 30d

Description

Not sure if this is a bug or a design issue, but certain operations are not type-stable. Say I am working with a model in which the solution can be expressed as a polynomial in (x,y), and that I need to have this polynomial as a function. In certain edge cases of the model, one of the variables (say, "y") will drop out. The problem from a programmer's perspective is that the polynomial in this case cannot be converted to a function of two variables, so one must resort to tedious case-checking. Example:

# First a typical case in which f1() remains a function of two variables.
p <- mp("3 + x + 2 y + x^2 y + y^2", varorder = c("y", "x"))
f1 <- as.function(deriv(p, "y"), vars=c("y", "x"))

# Now an edge case in which f1() becomes a function of only x.
p <- mp("3 + x + 2 y + x^2 y", varorder = c("y", "x"))
f1 <- as.function(deriv(p, "y"), vars=c("y", "x"))

When vars is specified (as in the above example), it seems desirable that the resulting function should accept the specified arguments, even if one or both inputs do not influence the output.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.