Skip to content

Empty PolynomialSystem #50

@projekter

Description

@projekter

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions