Skip to content

Instantly share code, notes, and snippets.

View athas's full-sized avatar
🐈
how did this get here i am not good with compute

Troels Henriksen athas

🐈
how did this get here i am not good with compute
View GitHub Profile
@athas
athas / tabs2spaces.sml
Created September 8, 2012 09:52
SML tabs2spaces
local
val tabWidth = 2
fun tabsToSpaces' #"\t" = implode(List.tabulate(tabWidth, fn _ => #" "))
| tabsToSpaces' c = str c
in
val tabsToSpaces = String.concat o map tabsToSpaces' o explode
end
fun tabsToSpacesInFile f =
let val ih = TextIO.openIn f
(* Lidt ændret type... *)
fun relativePrime 0 q = q = 1
| relativePrime p q = relativePrime (q mod p) p;
(* Og en hjælpefunktion der allerede burde være i SML...*)
fun range (from,to) = List.tabulate(to-from+1, fn x => x + from);
(* Så kan den skrives abstrakt. *)
fun nextNotRelativePrime p =
Option.getOpt (List.find (not o relativePrime p) (range(p+1,p*2-1)),
@athas
athas / keybase.md
Created September 26, 2014 11:42
Keybase gist

Keybase proof

I hereby claim:

  • I am athas on github.
  • I am athas (https://keybase.io/athas) on keybase.
  • I have a public key whose fingerprint is EF4B 78D5 2412 EC13 7593 B76C 9C69 4EF9 2FDC 6BD7

To claim this, I am signing this object:

{-# LANGUAGE BangPatterns #-}
import Control.Arrow (first, second)
import Data.Char
import Control.Monad.ST
import Data.Array.ST
import Data.Array.Unboxed
import qualified Data.Text as T
import qualified Data.Text.Read as TR
import qualified Data.Text.IO as TIO
{-# LANGUAGE BangPatterns #-}
import Control.Arrow (first, second)
import Data.Char
import Control.Monad.ST
import Data.Vector.Unboxed.Mutable (STVector)
import qualified Data.Vector.Unboxed.Mutable as UMVec
import qualified Data.Vector.Unboxed as UVec
import Data.Vector.Generic (freeze)
import qualified Data.Text as T
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE OverloadedStrings #-}
module Main(main) where
import Control.Monad
import Control.Arrow ((***))
import Data.Int (Int8, Int16, Int32, Int64)
import Data.Char (isSpace, isDigit, isAlpha)
import qualified Data.Vector.Unboxed.Mutable as UMVec
import qualified Data.Vector.Unboxed as UVec
{-# LANGUAGE OverloadedStrings #-}
-- | This module defines an efficient value representation as well as
-- parsing and comparison functions. This is because the standard
-- Futhark parser is not able to cope with large values (like arrays
-- that are tens of megabytes in size). The representation defined
-- here does not support tuples, so don't use those as input/output
-- for your test programs.
module Futhark.Test.Values
( Value
@athas
athas / bh.py
Created February 23, 2018 10:12
Heat equation in Bohrium/Numpy and Futhark
#!/usr/bin/env python
import bohrium
import bohrium as np
import pyopencl as cl
import time
w = 1000
h = 1000
epsilon=(42.0)*(np.sqrt(w*h)/10)
This file has been truncated, but you can view the full file.
fun {i32} num_bits_698f() = {
{8i32}
}
fun {i32} num_bits_864f() = {
{16i32}
}
fun {i32} num_bits_1034f() = {
{32i32}
type pixel = { z: f32
, colour: i32
}
let closest (a: pixel) (b: pixel): pixel =
if a.z < b.z
then a
else b
let raster_onepass (w: i32) (pixel_pos: []i32) (pixels: []pixel) =