Skip to content

Piecewise should be compileable #424

Closed
Closed

Description

@WhiteBlackGoose

The package I want to suggest the idea to: AngouriMath

Piecewise should be compiled in a chain of if else if else....

Activity

  1. added this to the Future milestone on May 20, 2021
  2. changed the title [-]Piecewise to compilation[/-] [+]`Piecewise` should be compileable[/+] on May 20, 2021
  3. Happypig375 commented on Aug 3, 2026

    @Happypig375
    Member

    @Rafael-SOWNet This isn't about the Provided node, this is about the Piecewise node. It was an incorrect test.

  4. added a commit that references this issue on Aug 4, 2026
  5. Rafael-SOWNet commented on Aug 5, 2026

    @Rafael-SOWNet
    Member

    Piecewise compiles on current master:

    var f = "piecewise(x provided x > 0, 0 provided x <= 0)".ToEntity().Compile<double, double>("x");
    f(2)  =>  2
    f(-2) =>  0

    Closing. Matrix is still uncompilable, which is #425 / #526.

  6. Rafael-SOWNet commented on Aug 5, 2026

    @Rafael-SOWNet
    Member

    Works on master:

    var f = "piecewise(x provided x > 0, 0 provided x <= 0)".ToEntity().Compile<double, double>("x");
    f(2)   =>  2
    f(-2)  =>  0

    Piecewise compiles to the stack machine and picks the first branch whose predicate holds. Closing.

    Matrix compilation is still unsupported and is tracked separately in #425 / #526.

  7. modified the milestones: Future, 2.6.0 on Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions