Skip to content

Feature: give the opportunity to explicitly pass the list of arguments to register #1455

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pitx-perf
Copy link

Facing similar problems to: SciML/ModelingToolkit.jl#2251
and https://discourse.julialang.org/t/registering-functions-with-several-arguments-in-symbolics/96359

I wanted to register a function with a lot of arguments and explicitly provide the types instead of relying on the 'full factorial' approach.

using Symbolics

function my_calc(a, b, c, d)
    [a + b, c + d]
end

@register_array_symbolic my_calc(a, b, c, d) begin
    size = (2,)
end
# methods(my_calc)
# my_calc(a::Num, b::Num, c::Num, d::Num)
# my_calc(a::Num, b::Num, c::Num, d::SymbolicUtils.Symbolic{<:Real})
# my_calc(a::Num, b::Num, c::Num, d::Real)
# ...
# 81 methods

function my_calc2(a, b, c, d)
    a + b + c + d
end

@register_array_symbolic my_calc2(a, b, c, d) begin
    size = (2,)
end true true [(Num, Num, Num, Num), (Num, Num, Real, Real)]
# methods(my_calc2)
#  [1] my_calc2(a::Num, b::Num, c::Num, d::Num)
#  [2] my_calc2(a::Num, b::Num, c::Real, d::Real)
#  [3] my_calc2(a, b, c, d)
# 3 methods

@ChrisRackauckas
Copy link
Member

Needs a test.

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.

2 participants