This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Roots | |
# Alternative "mean" definition that operates on the binary representation | |
# of a float. Using this definition, bisection will never take more than | |
# 64 steps. | |
function _middle(x::Float64, y::Float64) | |
# Use the usual float rules for combining non-finite numbers | |
if !isfinite(x) || !isfinite(y) | |
return x + y | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const states = ["Healthy", "Fever"] | |
const obsnames = ["normal", "cold", "dizzy"] | |
const start_probability = [0.6, 0.4] | |
const transition_probability = [ | |
0.7 0.3 | |
0.4 0.6 | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function graythresh_kmeans(img) | |
# Note, without the type annotation, this is slow because | |
# mean appears not to be type stable here | |
thresh = mean(img)::Gray{Float32} | |
while true | |
lastthresh = thresh | |
nplus = 0 | |
nminus = 0 | |
splus = zero(typeof(thresh)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9345,9351c9345,9374 | |
- var previousDrawId = 0; | |
- function domUpdate(newScene) { | |
- previousDrawId = ElmRuntime.draw(previousDrawId, function(_) { | |
- Render.update(elm.node.firstChild, savedScene, newScene); | |
- if (elm.Native.Window) elm.Native.Window.values.resizeIfNeeded(); | |
- savedScene = newScene; | |
- }); | |
+ | |
+ // domUpdate is called whenever the main Signal changes. On domUpdate, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var Elm = {}; Elm.Native = {}; Elm.Native.Graphics = {}; | |
var ElmRuntime = {}; ElmRuntime.Render = {}; | |
Elm.Native.Array = {}; | |
Elm.Native.Array.make = function(elm) { | |
elm.Native = elm.Native || {}; | |
elm.Native.Array = elm.Native.Array || {}; | |
if (elm.Native.Array.values) return elm.Native.Array.values; | |
if ('values' in Elm.Native.Array) | |
return elm.Native.Array.values = Elm.Native.Array.values; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jwm@jason ~/s/elm-platform> runhaskell src/BuildFromSource.hs master | |
Writing a default package environment file to | |
/Users/jwm/src/elm-platform/Elm-Platform/master/cabal.sandbox.config | |
Creating a new sandbox at /Users/jwm/src/elm-platform/Elm-Platform/master | |
Cloning into 'elm-compiler'... | |
remote: Counting objects: 17753, done. | |
remote: Compressing objects: 100% (100/100), done. | |
remote: Total 17753 (delta 56), reused 0 (delta 0) | |
Receiving objects: 100% (17753/17753), 5.44 MiB | 1.20 MiB/s, done. | |
Resolving deltas: 100% (10044/10044), done. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GC(T+97773.6) Reason: TOO_MUCH_MALLOC, Total Time: 16.9ms, Zones Collected: 1, Total Zones: 30, Total Compartments: 417, Minor GCs: 2, Store Buffer Overflows: 0, MMU (20ms): 15%, MMU (50ms): 66%, SCC Sweep Total: 0.3ms, SCC Sweep Max Pause: 0.3ms, Nonincremental Reason: malloc bytes trigger, Allocated: 178MB, +Chunks: 0, -Chunks: 0 | |
Totals: | |
The connection to http://jsbin.com/piyeye/1?0.44316687606709093 was interrupted while the page was loading. spike.js:232:0 | |
GC(T+97775.4) Reason: TOO_MUCH_MALLOC, Total Time: 26.6ms, Zones Collected: 1, Total Zones: 32, Total Compartments: 420, Minor GCs: 3, Store Buffer Overflows: 0, MMU (20ms): 0%, MMU (50ms): 46%, SCC Sweep Total: 0.5ms, SCC Sweep Max Pause: 0.5ms, Nonincremental Reason: malloc bytes trigger, Allocated: 179MB, +Chunks: 0, -Chunks: 0 | |
Totals: | |
GC(T+97777.0) Max Pause: 37.6ms, Total Time: 309.2ms, Zones Collected: 32, Total Zones: 32, Total Compartments: 420, Minor GCs: 25, Store Buffer Overflows: 0, MMU (20ms): 0%, MMU (50ms): 16%, SCC Sweep Total: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Represent a set of digits 1-9 as an Int16, where the binary digits of the | |
# integer form a mask determining whether the associated digit is present in | |
# the set | |
immutable DigitSet | |
d::Int16 | |
end | |
function DigitSet(a::AbstractArray) | |
d = Int16(0) | |
for n in a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
julia> function fn(x1::Float64, x2::Float64) | |
x1_int = reinterpret(UInt64, x1) | |
x2_int = reinterpret(UInt64, x2) | |
reinterpret(Float64, (x1_int + x2_int) >> 1) | |
end | |
fn (generic function with 1 method) | |
julia> @code_native fn(3.0, 4.0) | |
.section __TEXT,__text,regular,pure_instructions | |
Filename: none |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
run(`wget http://julialang.org/images/logo.png`) | |
# Open png file for reading | |
fp = ccall(:fopen, Ptr{Uint8}, (Ptr{Uint8}, Ptr{Uint8}), "logo.png", "r") | |
# Read first 8 bytes | |
initial_bytes = Array(Uint8, 8) | |
ccall(:fread, Ptr{Uint8}, (Ptr{Uint8}, Uint8, Uint8, Ptr{Uint8}), initial_bytes, 1, 8, fp) | |
# Check that we actually have a png file |
OlderNewer