Skip to content

Commit 0cf8a79

Browse files
committed
allow integrand_prototype for non-iip integral functions
1 parent d45b79a commit 0cf8a79

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

src/scimlfunctions.jl

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2088,9 +2088,10 @@ out-of-place handling.
20882088
IntegralFunction{iip,specialize}(f, [integrand_prototype])
20892089
```
20902090
2091-
Note that only `f` is required, and in the case of inplace integrands a mutable container
2091+
Note that only `f` is required, and in the case of inplace integrands a mutable array
20922092
`integrand_prototype` to store the result of the integrand. If `integrand_prototype` is
2093-
present, `f` is interpreted as in-place, and otherwise `f` is assumed to be out-of-place.
2093+
present for either in-place or out-of-place integrands it is used to infer the return type
2094+
of the integrand.
20942095
20952096
## iip: In-Place vs Out-Of-Place
20962097
@@ -2148,14 +2149,14 @@ BatchIntegralFunction{iip,specialize}(bf, [integrand_prototype];
21482149
max_batch=typemax(Int))
21492150
```
21502151
Note that only `bf` is required, and in the case of inplace integrands a mutable
2151-
container `integrand_prototype` to store a batch of integrand evaluations, with
2152+
array `integrand_prototype` to store a batch of integrand evaluations, with
21522153
a last "batching" dimension.
21532154
21542155
The keyword `max_batch` is used to set a soft limit on the number of points to
21552156
batch at the same time so that memory usage is controlled.
21562157
2157-
If `integrand_prototype` is present, `bf` is interpreted as in-place, and
2158-
otherwise `bf` is assumed to be out-of-place.
2158+
If `integrand_prototype` is present for either in-place or out-of-place integrands it is
2159+
used to infer the return type of the integrand.
21592160
21602161
## iip: In-Place vs Out-Of-Place
21612162
@@ -3890,10 +3891,7 @@ function IntegralFunction(f)
38903891
end
38913892
function IntegralFunction(f, integrand_prototype)
38923893
calculated_iip = isinplace(f, 3, "integral", true)
3893-
if !calculated_iip
3894-
throw(IntegrandMismatchFunctionError(calculated_iip, true))
3895-
end
3896-
IntegralFunction{true}(f, integrand_prototype)
3894+
IntegralFunction{calculated_iip}(f, integrand_prototype)
38973895
end
38983896

38993897
function BatchIntegralFunction{iip, specialize}(f, integrand_prototype;
@@ -3926,10 +3924,7 @@ function BatchIntegralFunction(f; kwargs...)
39263924
end
39273925
function BatchIntegralFunction(f, integrand_prototype; kwargs...)
39283926
calculated_iip = isinplace(f, 3, "batchintegral", true)
3929-
if !calculated_iip
3930-
throw(IntegrandMismatchFunctionError(calculated_iip, true))
3931-
end
3932-
BatchIntegralFunction{true}(f, integrand_prototype; kwargs...)
3927+
BatchIntegralFunction{calculated_iip}(f, integrand_prototype; kwargs...)
39333928
end
39343929

39353930
########## Utility functions

0 commit comments

Comments
 (0)