Skip to content

Instantly share code, notes, and snippets.

View dagss's full-sized avatar

Dag Sverre Seljebotn dagss

  • mCASH AS and University of Oslo
  • Oslo
View GitHub Profile
/* DO NOT EDIT THIS FILE, IT IS GENERATED */
/*!*/
/*!*/
/*!*/
/*!*/
/*!*/
/*!*/
/*!*/ #include <stdio.h>
/*!*/ #include <string.h>
/*!*/
from __future__ import division
import numpy as np
import sys
def simulate(nitems, nslots, nsims=100):
k = int(np.log2(nslots))
assert 2**k == nslots
success_count = 0
for isim in range(nsims):
hashes = np.random.randint(2**32, size=nitems).astype(np.uint64)
@dagss
dagss / gist:2862255
Created June 3, 2012 06:38 — forked from anonymous/gist:2862091
simulated hash vtable call
cdef extern from *:
void* malloc(long)
void free(void*)
double sin(double)
from random import randint
from time import clock
cdef extern from "time.h":
cdef struct timespec:
@dagss
dagss / gist:2908876
Created June 11, 2012 07:18
Notes for NOTUR Python tutorial
An IPython notebook running on Amazon EC2:
http://ec2-54-247-153-111.eu-west-1.compute.amazonaws.com:8888/
Where to find help:
- numpy-discussion: http://www.scipy.org/Mailing_Lists
- cython-users: https://groups.google.com/forum/?fromgroups#!forum/cython-users
- http://scicomp.stackexchange.com
- http://stackoverflow.com/
PyHeapExtensibleTypeObject MyProvider_Type =
{
/* PyHeapTypeObject etp_heaptype */
{
/* PyTypeObject ht_type */
{
PyVarObject_HEAD_INIT(0, 0),
"myprovidertype", /*tp_name*/,
sizeof(MyProvider_Object), /* tp_basicsize */
0, /* tp_itemsize */
from __future__ import division
import numpy as np
import os
import commander as cm
#
# Parameters (just variables that are reused further down)\
#
output_filename = 'sync-dust-priors-%d.h5' % os.getpid()
from __future__ import division
import numpy as np
import os
import commander as cm
#
# Parameters (just variables that are reused further down)\
#
output_filename = 'newmonodip-em7-%d.h5' % os.getpid()
from __future__ import division
import numpy as np
from matplotlib import pyplot as plt
import cPickle as pickle
import scipy.linalg as la
import scipy
from commander.sphere.mmajor import lm_to_idx
nside = 16
!/bin/sh
# start multi-line shebang
if "true" : '''\'; then
p=`pwd`; f="$0"; b=`basename $f`
while [ -L "$f" ]; do
f=`readlink $f`; cd `dirname $f`; f=`basename $f`
done
f=`pwd -P`
cd "$f/../../../../usr/bin"
i=`pwd -P`
@dagss
dagss / gist:4996687
Last active December 14, 2015 00:09
Kent-Andre and Dag Sverre playing with simple linear system
from numpy import *
from scipy.linalg import eig, eigh
N = 100
M = 40
noise = 0.01
i = arange(M, dtype=float)
cinv = 1 + i**2