Numerical integration over 3D domain of vector-valued function

There are probably two reasons why nested quadgk allocates:

  1. The quadgk algorithm may allocate a heap to perform adaptive refinement via the segbuf keyword. If you don’t pre-allocate and reuse it then it may be allocated once per inner integrand
  2. The Julia compiler gives up on recursive code such as nested quadgk. The compilation time for triply-nested quadgk can take up to a minute in my experience. For a related discussion see Make Julia complete the inference of some recursive code

How does AutoBZCore.jl address these issues?

  1. AutoBZCore.jl will automatically pre-allocate the intermediate segbufs for you
  2. AutoBZCore.jl will wrap your inner integrals using FunctionWrappers.jl to stop inference from taking so long