Skip to content

Instantly share code, notes, and snippets.

View simonbyrne's full-sized avatar
🦘

Simon Byrne simonbyrne

🦘
View GitHub Profile
@simonbyrne
simonbyrne / Make.user
Created March 2, 2017 20:26
Julia Makefile for Raspbian
# sudo apt install llvm-3.9-dev libopenblas-dev libfftw3-dev libgmp3-dev libmpfr-dev libarpack2-dev libopenspecfun-dev libssh2-1-dev libcurl4-openssl-dev
USE_SYSTEM_LLVM:=1
LLVM_CONFIG:=llvm-config-3.9
USE_SYSTEM_BLAS:=1
LIBBLAS:=-lopenblas
LIBBLASNAME:=libopenblas
USE_SYSTEM_LAPACK:=1
USE_SYSTEM_LIBM:=1
const HI = prevfloat(log10(prevfloat(Inf)))
function test(n)
xx = 0.0
zz = 0.0
for i = 1:n
x = reinterpret(Float64, rand(reinterpret(UInt64, 1e-18):reinterpret(UInt64, HI)))
if rand(Bool)
x = -x
end
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
using SenseHat
function newblob(snake)
while true
x = rand(1:8)
y = rand(1:8)
if (x,y) ∉ snake
return (x,y)
end
end
#include <stdio.h>
#include <gmp.h>
#include <mpfr.h>
int main (void)
{
unsigned int i;
mpfr_t u;
@simonbyrne
simonbyrne / fisher.jl
Created October 4, 2017 05:25
Computing Fisher information via forward-mode automatic differentiation
using Distributions
import ForwardDiff: Dual, value, partials
@generated function get_values(a::NTuple{N}) where {N}
return ForwardDiff.tupexpr(i -> :(value(a[$i])),N)
end
ForwardDiff.value(p::ForwardDiff.Partials) =
ForwardDiff.Partials(get_values(p.values))
@simonbyrne
simonbyrne / gitprob.sh
Created October 4, 2017 20:46
Create a bad git repository
git init --bare gitprob
git clone gitprob gitprobwork
cd gitprobwork
echo "good" > aaaa
GOOD=$(git hash-object -w aaaa)
git add aaaa
git commit -m "1"
rm aaaa
n = 2_500_000
p = 1.9e-5
X = sprand(n,n,p)
v = sprand(n,8/n)
function fast_A_mul_B(X::SparseMatrixCSC{TX,IX},v::SparseVector{TV,IV}) where {TX,IX,TV,IV}
X.n == v.n || throw(DimensionMismatch())
ind_out = promote_type(IX,IV)[]
val_out = promote_type(TX,TV)[]
module Intrinsics
tname(::Type{Float64}) = "double"
tname(::Type{Float32}) = "float"
fname(::Type{Float64}) = "f64"
fname(::Type{Float32}) = "f32"
for f in [:add, :sub, :mul, :div, :rem]