Skip to content

Instantly share code, notes, and snippets.

View jasigal's full-sized avatar

Jesse Sigal jasigal

View GitHub Profile
@jasigal
jasigal / approx-recip.kk
Last active January 5, 2024 19:59
Reverse mode AD in Koka
pub module approx-recip
import smooth
fun approx-recip(iters : int, x : a) : <smooth<a>,div> a {
var acc := c(1.0)
var prev := c(1.0)
repeat(iters) {
prev := (prev *. (~.)(x -. c(1.0)))
acc := (acc +. prev)
@jasigal
jasigal / Main.hs
Last active January 2, 2018 21:57
Accelerate LLVM FP contract bug
module Main where
import Data.Array.Accelerate as A
import Data.Array.Accelerate.LLVM.Native
g :: Scalar Double -> Scalar Double
g = (runN (A.map f :: Acc (Scalar Double) -> Acc (Scalar Double)))
where
f x = let y = recip x
b = (-y) * y