-
Notifications
You must be signed in to change notification settings - Fork 7
/
numint_.py
32 lines (23 loc) · 937 Bytes
/
numint_.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import numpy as np
import scipy
import scipy.integrate
def int_quad_real (gf_fn, mu, x0=-np.inf, delta=1.e-5, \
epsabs=1.49e-08, epsrel=1.49e-08):
assert (callable(gf_fn))
def real_fn(w):
return -1./np.pi * np.imag(gf_fn(w, delta))
int_ = scipy.integrate.quad(real_fn, x0, +mu, epsabs=epsabs, \
epsrel=epsrel, full_output=1)
print 'neval = ', int_[2]['neval']
print 'integ = ', int_[0], int_[1]
return int_[0]
def int_quad_imag (gf_fn, mu, delta=1.e-5, \
epsabs=1.49e-08, epsrel=1.49e-08):
assert (callable(gf_fn))
def imag_fn(w):
return -2./np.pi * np.real(gf_fn(1j*w+mu, delta))
int_ = scipy.integrate.quad(imag_fn, 0, +np.inf, epsabs=epsabs, \
epsrel=epsrel, full_output=1)
print 'neval = ', int_[2]['neval']
print 'integ = ', int_[0], int_[1]
return int_[0]