Skip to content

Instantly share code, notes, and snippets.

@nbecker
nbecker / test_slice3.py
Last active December 14, 2015 12:09
numba test. Array 'inp' is overwritten somehow
import numpy as np
from numba import *
f8_array_ty = f8[:]
@jit
class fir (object):
@void(f8[:])
def __init__ (self, coef):
self.coef = coef
@nbecker
nbecker / test_slice4.py
Created March 5, 2013 15:51
This version is 10x slower than c++ code. Without the '.copy', it's only 3x slower, but produces incorrect result
import numpy as np
from numba import *
f8_array_ty = f8[:]
@jit
class fir (object):
@void(f8[:])
def __init__ (self, coef):
self.coef = coef
@nbecker
nbecker / log_exp_sum.py
Created April 3, 2013 12:00
causes numba segfault
import numpy as np
from numba import *
from numba.vectorize import vectorize
from math import exp, log1p
@vectorize([f8(f8,f8)])
def log_exp_sum2 (a, b):
if a >= b:
return a + log1p (exp (-(a-b)))
@nbecker
nbecker / gist:5395649
Created April 16, 2013 12:51
testing autojit class
import numpy as np
from numba import *
f8_array_ty = f8[:]
@autojit
class fir (object):
## @void(f8[:])
def __init__ (self, coef):
self.coef = coef
import numpy as np
class extensible_array (object):
def __init__(self, ndims=0, dtype=int, init=None):
if init is not None:
self.arr = init
else:
self.arr = np.zeros ([0]*ndims, dtype=dtype)
def __getitem__ (self, indices):
@nbecker
nbecker / error
Created May 27, 2016 11:52
error on testing matplotlib-1.5.2
Python 3.5.1 |Anaconda custom (64-bit)| (default, Dec 7 2015, 11:16:01)
Type "copyright", "credits" or "license" for more information.
IPython 4.2.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: python.el: native completion setup loaded
@nbecker
nbecker / test.tex
Created July 1, 2016 18:08
minimal test case
\makeatletter
\def\input@path{{/home/nbecker/interference/}}
\makeatother
\documentclass[english]{beamer}
\usepackage{amsmath}
\usepackage{fontspec}
\usepackage{unicode-math}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
@nbecker
nbecker / acc.jl
Last active September 15, 2016 14:30
outline of complex 2nd order accumulator
type var{T,S}
sum::T
sumsqr::S
nobjs::Int64
var() = new(0,0,0)
end
var_cmplx(T=Float64) = var{Complex{T},T}()
var_scalar(T=Float64) = var{T,T}()
@nbecker
nbecker / FHT.cc
Created April 5, 2017 13:57
FHT test
#include <numpy/arrayobject.h>
#include "pybind11/pybind11.h"
#include "pybind11/complex.h" // needed to return std::complex
#include "ndarray/pybind11.h"
#include <cmath>
#include <complex>
namespace nd=ndarray;
namespace py = pybind11;
@nbecker
nbecker / logsumexp.cc
Last active April 17, 2017 12:49
logsumexp.cc
#include <numpy/arrayobject.h>
#include "pybind11/pybind11.h"
#include "pybind11/stl.h"
#include "xtensor/xarray.hpp"
#include "xtensor/xtensor.hpp"
#include "xtensor/xcontainer.hpp"
#include "xtensor/xbroadcast.hpp"
//#include "xtensor/xbuilder.hpp"
#include "xtensor/xview.hpp"
#include "xtensor/xeval.hpp"