Skip to content

Instantly share code, notes, and snippets.

Pablo Winant albop

Block or report user

Report or block albop

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View interpolation_performance_comparison
# 2d comparison
import numpy as np
x = np.linspace(-1,1,100)
y = np.linspace(-1,1,100)
f = lambda x,y: np.sinc(x**2+y**2)
vals = np.array( [[f(xx,yy) for yy in y] for xx in x] )
N = 1000000 # number of points to evaluate
eval_points = -1+2*np.random.rand(N*2).reshape((N,2))
View test_mul_22.py
from numpy import *
from numba import jit
N = 1000000
A = random.random((N,2,2))
B = random.random((N,2,2))
@jit(nopython=True)
def mulvec(A,B):
N = A.shape[0]
View compare_products.py
import numpy as np
import quantecon
from numba import jit
from numba import njit, prange
@njit
def cartesian_2d(x,y,out=None):
p = x.shape[0]
q = y.shape[0]
View erfc_libm vs erfc_python
from cffi import FFI
ffi = FFI()
ffi.cdef('double erfc(double x);')
libm = ffi.dlopen("m")
erfc = libm.erfc
from math import erfc as p_erfc
from numba import njit
from numpy import linspace
@albop
albop / generated_interp.py
Last active Jan 21, 2016
Half working generated interpolation example
View generated_interp.py
from math import floor
from numba import njit
####
#### Working
####
@njit
def native_index_1d(mat, vec):
return mat[vec[0]]
@albop
albop / eval_cubic_cuda.py
Last active Jan 19, 2016
interpolation with numba.cuda
View eval_cubic_cuda.py
from __future__ import division
from numba import double, int64
from numba import jit, njit
import numpy as np
from numpy import zeros, array
@albop
albop / interpolation_speed.jl
Created Jan 7, 2016
splines.jl vs interpolations.jl
View interpolation_speed.jl
d = 3 # number of dimensions
K = 50 # number of points along each dimension
N = 100000 # number of points at which to interpolate
A = rand([K for i = 1:d]...) # filtered coefficients
B = rand(N,d) # points at which to evaluate the splines
max(B, minimum(A)+0.01)
min(B, maximum(A)-0.01)
@albop
albop / index.html
Last active Aug 29, 2015
mc_sample_path: numba annotate
View index.html
<html>
<head>
<style>
.annotation_table {
color: #000000;
font-family: monospace;
margin: 5px;
View watcher.py
"""
Filename: watcher.py
Authors: Pablo Winant
Time long computation and send a message when finished.
"""
import contextlib
@contextlib.contextmanager
def watcher(task_name=None, email=None):
@albop
albop / gist:ab49de476b6bcbdd689c
Last active Aug 29, 2015
Functions needed for vfi with dolo
View gist:ab49de476b6bcbdd689c
from dolo import yaml_import
model = yaml_import('examples/models/rbc.yaml')
s = model.calibration['states']
x = model.calibration['controls']
y = model.calibration['auxiliaries']
e = model.calibration['shocks']
v = model.calibration['values']
p = model.calibration['parameters']
You can’t perform that action at this time.