Yampa-0.14.1: Elegant Functional Reactive Programming Language for Hybrid Systems
Copyright(c) Ivan Perez 2014-2022
(c) George Giorgidze 2007-2012
(c) Henrik Nilsson 2005-2006
(c) Antony Courtney and Henrik Nilsson Yale University 2003-2004
LicenseBSD-style (see the LICENSE file in the distribution)
Maintainerivan.perez@keera.co.uk
Stabilityprovisional
Portabilitynon-portable (GHC extensions)
Safe HaskellSafe-Inferred
LanguageHaskell2010

FRP.Yampa.Integration

Description

Integration and derivation of input signals.

In continuous time, these primitives define SFs that integrate/derive the input signal. Since this is subject to the sampling resolution, simple versions are implemented (like the rectangle rule for the integral).

In discrete time, all we do is count the number of events.

The combinator iterFrom gives enough flexibility to program your own leak-free integration and derivation SFs.

Many primitives and combinators in this module require instances of simple-affine-spaces's VectorSpace. Yampa does not enforce the use of a particular vector space implementation, meaning you could use integral for example with other vector types like V2, V1, etc. from the library linear. For an example, see this gist.

Synopsis

Integration

integral :: (Fractional s, VectorSpace a s) => SF a a Source #

Integration using the rectangle rule.

imIntegral :: (Fractional s, VectorSpace a s) => a -> SF a a Source #

"Immediate" integration (using the function's value at the current time)

impulseIntegral :: (Fractional k, VectorSpace a k) => SF (a, Event a) a Source #

Integrate the first input signal and add the discrete accumulation (sum) of the second, discrete, input signal.

count :: Integral b => SF (Event a) (Event b) Source #

Count the occurrences of input events.

>>> embed count (deltaEncode 1 [Event 'a', NoEvent, Event 'b'])
[Event 1,NoEvent,Event 2]

Differentiation

derivative :: (Fractional s, VectorSpace a s) => SF a a Source #

A very crude version of a derivative. It simply divides the value difference by the time difference. Use at your own risk.

iterFrom :: (a -> a -> DTime -> b -> b) -> b -> SF a b Source #

Integrate using an auxiliary function that takes the current and the last input, the time between those samples, and the last output, and returns a new output.