References

Clock

RecordedArrays.DiscreteClockType
DiscreteClock([start], timelist)
DiscreteClock(stop)

Clock for discrete-time process, time of which muse be increased with given step and can't be updated manually. The timelist must be a non-empty and monotonically increasing AbstractVector. If the start is not specified, the first item of timelist will be deleted and set as start. During iteration, the current time will be updated automatically and returned as iteration item. When the iteration finished without break, init! will be applied. DiscreteClock(stop) will create a clock with start=0 and timelist=Base.OneTo(stop)

Examples

julia> c = DiscreteClock(0:3);

julia> currenttime(c)
0

julia> [(t, currenttime(c)) for t in c]
3-element Vector{Tuple{Int64, Int64}}:
 (1, 1)
 (2, 2)
 (3, 3)

julia> currenttime(c)
0

julia> c = DiscreteClock(3); # similar to DiscreteClock(0:3)

julia> (currenttime(c), collect(c))
(0, [1, 2, 3])
source
RecordedArrays.ContinuousClockType
ContinuousClock{T, I<:Union{Nothing, DiscreteClock}} <: AbstractClock{T}
ContinuousClock(stop, [start=zero(stop)]; [max_epoch=nothing])

A clock for continuous-time process. Unlike the DiscreteClock, during iteration, the current time will not be update automatically, but update by increase! manually. Besides the epoch of current iteration instead of current time will be returned. If the max_epoch is specified, the iteration will break when epoch reach to the max_epoch, even currenttime(c) < limit(c), and break in this way the init!(c) will not be applied.

Examples

julia> c = ContinuousClock(3.0; max_epoch=2);

julia> for epoch in c
           increase!(c, 1)
           println(currenttime(c), '	', epoch)
       end
1.0	1
2.0	2

julia> for epoch in c
           increase!(c, 1)
           println(currenttime(c), '	', epoch)
       end
3.0	1

julia> for epoch in c
           increase!(c, 1)
           println(currenttime(c), '	', epoch)
       end
1.0	1
2.0	2
source
RecordedArrays.limitFunction
limit(c::AbstractClock)

Return the limit of clock c. For a ContinuousClock c, the max time might larger than limit(c).

source

Entries

RecordedArrays.AbstractEntryType
AbstractEntry{V,T<:Real}

Supertype of all entry types, which store changes of a specified variable of type V with timestamps of type T.

source
RecordedArrays.StaticEntryType
StaticEntry{V,T} <: AbstractEntry{V,T}

Entry type to store changing history of a variable whose value not changing overtime.

source
RecordedArrays.gettimeFunction
gettime([alg::AbstractSearch], e::AbstractEntry, t::Real)
gettime([alg::AbstractSearch], e::AbstractEntry, ts)
gettime([alg::AbstractSearch], es::AbstractArray{<:AbstractEntry}, t::Real)
gettime([alg::AbstractSearch], es::AbstractArray{<:AbstractEntry}, ts)

Get the value of e at t::Real or values at each time t in an iterate ts. If t is not a timestamp in getts(e), return value at time getts(e)[i] where getts(e)[i] < t < getts(e)[i+1]. The alg is a search algorithm that finds the index i of a target time t, which can be LinearSearch or BinarySearch (by default). For es, an array of entries, return values at t as a similar array.

Note

ts must be monotonically increasing.

source
RecordedArrays.del!Function
del!(e::AbstractEntry, t::Union{Real,AbstractClock})

Marks a entry e deleted at time t. If an AbstractClock c is given, t = currenttime(c).

source

Recorded Types

RecordedArrays.AbstractRecArrayType
AbstractRecArray{T,N}

Supertype of recorded N-dimensional arrays with elements of type T, whose changes will be recorded automatically.

Note

Avoid to mutate recorded arrays out of loop, because clocks will initial automatically during loop.

source
RecordedArrays.RecordedNumberType
RecordedNumber{T}

A Union of recorded numbers with type T.

Info

RecordedNumber{S} <: T will always return false where T is a subtype of Number, even if S <: T. There is a function issubtype(RecordedNumber{S}, T) which would return true if S <: T. Besides, isnum(T, n::RecordedNumber{S}) would return true if S <: T.

Note

Store a value v to an RecordedNumber x by x[] = v or x[1] = v instead of x = v.

source
RecordedArrays.stateFunction
state(A::AbstractRecArray{T,N}) -> Array{T,N}
state(x::RecordedNumber{T}) -> T

Get current state of a recorded array A or a recorded number x.

Note

state for AbstractRecArray{V,T,N} where N >= 2 may be unsafe because of unsafe_wrap and unsafe_convert.

source
RecordedArrays.isnumFunction
isnum(T, x) -> Bool

Similar to x is T, but for x where x::RecordedNumber{S}, return true if S <:T.

source

Utilities

RecordedArrays.MCIndicesType
MCIndices(sz::NTuple{N,AbstractVector{Int}}) -> R
MCIndices(A::AbstractArray) -> R

A CartesianIndices like type defines mutable and disconnected region R.

Examples

julia> im = MCIndices(([1, 3], [2, 4]))
2×2 MCIndices{2}:
 (1, 2)  (1, 4)
 (3, 2)  (3, 4)

julia> im[1]
(1, 2)

julia> im[1, 2]
(1, 4)
source