Skip to content

Commit

Permalink
Change scan so that compiler specialisation will be active
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelBrand1 committed Feb 28, 2024
1 parent 8b9edf9 commit c4b6a9a
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions EpiAware/src/utilities.jl
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
"""
scan(f, init, xs)
Apply a function `f` to each element of `xs` along with an accumulator hidden state with intial
value `init`. The function `f` takes the current accumulator value and the current element of `xs` as
arguments, and returns a new accumulator value and a result value. The function `scan` returns a tuple
`(ys, carry)`, where `ys` is an array containing the result values and `carry` is the final accumulator
value. This is similar to the JAX function `jax.lax.scan`.
# Arguments
- `f`: A function that takes an accumulator value and an element of `xs` as arguments and returns a new
hidden state.
- `init`: The initial accumulator value.
- `xs`: An iterable collection of elements.

# Returns
- `ys`: An array containing the result values of applying `f` to each element of `xs`.
- `carry`: The final accumulator value.
"""
function scan(f, init, xs::Vector{T}) where {T <: Union{Integer, AbstractFloat}}
function scan(f::F, init, xs) where {F}
carry = init
ys = similar(xs)
for (i, x) in enumerate(xs)
Expand Down

0 comments on commit c4b6a9a

Please sign in to comment.