Skip to content

Commit

Permalink
Figured out non-allocating profile functor instantiation
Browse files Browse the repository at this point in the history
  • Loading branch information
kapple19 committed Aug 6, 2024
1 parent cfa6104 commit f2fc277
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions scripts/prototype.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
density_profile(::Val{:one}, x::Real; a::Real)::Float64 = x + a

struct DensityProfile{F <: Function}
profile::F

function DensityProfile(model::Val; pars...)
profile(x::Real)::Float64 = density_profile(model, x; pars...)
new{typeof(profile)}(profile)
end
end

function (den::DensityProfile{F} where {F <: Function})(x::Real)
den.profile(x)::Float64
end

0 comments on commit f2fc277

Please sign in to comment.