Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty PolynomialSystem #50

Open
projekter opened this issue Mar 31, 2023 · 1 comment
Open

Empty PolynomialSystem #50

projekter opened this issue Mar 31, 2023 · 1 comment

Comments

@projekter
Copy link

Sometimes, it is convenient to create an empty polynomial system (for example, in my case the input polynomials are of two possible kinds, each will be assembled into a PolynomialSystem, but it might very well be the case that one of the two kinds is not available).
This can be done manually: PolynomialSystem{0,NVars,NParams,Tuple{}}(Tuple{}()), but using the convenience constructors will fail, as they try to access the first polynomial in the system.
Note here that just because the systems does not have any polynomials does not mean that it also has no variables or parameters if they were specified manually.
Of course, it then remains to think about the behavior of the functions (which is why I don't do a pull request but would like to discuss this first):

  • The mutating variants (I checked evaluate!, jacobian!, hessian!) all work nicely; they check that the output is large enough to hold the number of variables and then are no-ops. They do not check that the number of inputs is equal to the number of variables.
  • The allocating variants are more difficult: evaluate on such an empty system will always give Union{}[] (if the argument was an arbitrarly-typed AbstractVector), or SVector{0,Union{}}() (if the argument was an arbitrarily-typed SVector). Given that the type of coefficients is unknown, this is probably the most general thing that can be returned, though there could be two alternatives: nothing or a Vector/SVector typed with the eltype of the input. No check on the length of the input is performed.
  • The allocating jacobian currently fails, as assemble_matrix does not work with a zero dimension.
@LordThunder333
Copy link

I think it would be nice also to be able to define constant polynomials as part of the polynomial system (including just a polynomial system containing only constant polynomials).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants