Skip to content

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

Open
pitx-perf wants to merge 1 commit into
JuliaSymbolics:masterfrom
pitx-perf:Feature_register_provided_types
Open

Feature: give the opportunity to explicitly pass the list of arguments to register#1455
pitx-perf wants to merge 1 commit into
JuliaSymbolics:masterfrom
pitx-perf:Feature_register_provided_types

Conversation

@pitx-perf
Copy link
Copy Markdown

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
Copy Markdown
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