Skip to content

Instantly share code, notes, and snippets.

@ewmoore
ewmoore / jacobi.py
Last active July 19, 2020 00:52
roots_sh_jacobi using mpmath ref scipy ticket 12425
import numpy as np
from mpmath import mp
from scipy import special
def an_func(a, b, k):
if a + b == 0:
if k == 0:
return (b-a)/(2+a+b)
else:
return 0
#define NPY_NO_DEPRECATED_API NPY_API_VERSION
#include <Python.h>
#include <numpy/arrayobject.h>
#include "numpy/npy_3kcompat.h"
PyObject* sum_and_prod(PyArrayObject *arr, int *axis, int naxis)
{
NpyIter *iter_outer, *iter_inner;
NpyIter_IterNextFunc *iternext_outer, *iternext_inner;
@ewmoore
ewmoore / bench_inf_norm.py
Created February 25, 2015 14:02
Benchmark script for numpy#5509
from __future__ import print_function
import numpy as np
from numpy.testing import measure
def bench_inf_norm_1d(dtype='d', strided=False, with_nan=False):
vec_size = [10, 100, 1000, 10000, 100000, 1000000 ]
repeat = [100000, 100000, 100000, 40000, 7500, 1000]
call_both = lambda x: abs(x).max()
call_norm = lambda x: np.linalg.norm(x, np.inf)
@ewmoore
ewmoore / README
Last active October 18, 2020 09:22
Chirp z-transform
This is the contents of the attachment from http://mail.scipy.org/pipermail/scipy-user/2009-March/020331.html
See also https://github.com/scipy/scipy/issues/4288
@ewmoore
ewmoore / hroots_test.py
Last active August 29, 2015 14:06
hroots_test, scipy pr 3987
import numpy as np
import scipy.special as cephes
import scipy.linalg as linalg
from mpmath import mp
# current scipy routine
def _gen_roots_and_weights(n, mu0, an_func, bn_func, f, df, symmetrize, mu):
"""[x,w] = gen_roots_and_weights(n,an_func,sqrt_bn_func,mu)
Returns the roots (x) of an nth order orthogonal polynomial,
@ewmoore
ewmoore / check
Last active December 25, 2015 07:28
#!/bin/bash
if [ $# -eq 2 ]
then
funcs=($2)
else
funcs=(CCOS CSIN CTAN CCOSH CSINH CTANH CACOS CASIN CATAN CACOSH CASINH CATANH CEXP CLOG CSQRT CPOW)
fi
for f in ${funcs[*]}
@ewmoore
ewmoore / test_c99complex.c
Last active December 15, 2015 16:19
Sanity Checks for c99 complex math functions.
#include <fenv.h>
#include <float.h>
#include <stdio.h>
#include <math.h>
#include <complex.h>
#ifdef FLOAT
#define TYPE float
#define SUFFIX f
#define EPS FLT_EPSILON