Skip to content

feat: add SemilinearODEFunction and SemilinearODEProblem #3739

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

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

AayushSabharwal
Copy link
Member

Generates

f1 = B * x2 + C
f2 = A * x

Where x2 is the upper triangle of x * x' as a linear vector with unnecessary elements zeroed. This is what Symbolics.semiquadratic_form returns.

In terms of codegen, the IIP form uses a DiffCache to avoid allocating a new buffer for x2 each time (and to allow passing duals) and generates the equivalent of

x2 = view(PreallocationTools.get_tmp(...), ...)
x2[1] = ...
x2[2] = ...
...
out[1] = C[1]
out[2] = C[2]
...
mul!(C, B, x2, true, true)

The jacobian for f1 is B * x2' + C' where x2' is the jacobian of x2 and C' that of C. This again uses the DiffCache and generates code with the same structure as above. For sparse forms, it is basically identical except the array from the DiffCache is used as the nzvals of a SparseMatrixCSC.

Still needs a little more implementation for the sparse form, tests and docs.

@AayushSabharwal AayushSabharwal marked this pull request as draft June 16, 2025 08:18
@AayushSabharwal
Copy link
Member Author

No point running CI right now if no tests or docs are changed.

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

Successfully merging this pull request may close these issues.

1 participant