Copyright | (c) Kimiyuki Onaka 2021 |
---|---|
License | Apache License 2.0 |
Maintainer | kimiyuki95@gmail.com |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- run :: (MonadAlpha m, MonadError Error m) => Program -> m Program
Documentation
run :: (MonadAlpha m, MonadError Error m) => Program -> m Program Source #
run
simplifies an affine functions from vectors to vectors in iterate
(Iterate
) functions.
Examples
This makes matrix multiplication. Before:
iterate n (fun xs -> (xs[0] + 2 * xs[1], xs[1])) xs
After:
matap (matpow ((1, 2), (0, 1)) n) xs
Also this works on integers. Before:
iterate n (fun x -> (2 x + 1)) x
After:
(2 ** n) * x + (2 ** n - 1) / (n - 1)