Skip to content

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