1__version__ = '1.2.1' 2 3from .usertools import monitor, timing 4 5from .ctx_fp import FPContext 6from .ctx_mp import MPContext 7from .ctx_iv import MPIntervalContext 8 9fp = FPContext() 10mp = MPContext() 11iv = MPIntervalContext() 12 13fp._mp = mp 14mp._mp = mp 15iv._mp = mp 16mp._fp = fp 17fp._fp = fp 18mp._iv = iv 19fp._iv = iv 20iv._iv = iv 21 22# XXX: extremely bad pickle hack 23from . import ctx_mp as _ctx_mp 24_ctx_mp._mpf_module.mpf = mp.mpf 25_ctx_mp._mpf_module.mpc = mp.mpc 26 27make_mpf = mp.make_mpf 28make_mpc = mp.make_mpc 29 30extraprec = mp.extraprec 31extradps = mp.extradps 32workprec = mp.workprec 33workdps = mp.workdps 34autoprec = mp.autoprec 35maxcalls = mp.maxcalls 36memoize = mp.memoize 37 38mag = mp.mag 39 40bernfrac = mp.bernfrac 41 42qfrom = mp.qfrom 43mfrom = mp.mfrom 44kfrom = mp.kfrom 45taufrom = mp.taufrom 46qbarfrom = mp.qbarfrom 47ellipfun = mp.ellipfun 48jtheta = mp.jtheta 49kleinj = mp.kleinj 50eta = mp.eta 51 52qp = mp.qp 53qhyper = mp.qhyper 54qgamma = mp.qgamma 55qfac = mp.qfac 56 57nint_distance = mp.nint_distance 58 59plot = mp.plot 60cplot = mp.cplot 61splot = mp.splot 62 63odefun = mp.odefun 64 65jacobian = mp.jacobian 66findroot = mp.findroot 67multiplicity = mp.multiplicity 68 69isinf = mp.isinf 70isnan = mp.isnan 71isnormal = mp.isnormal 72isint = mp.isint 73isfinite = mp.isfinite 74almosteq = mp.almosteq 75nan = mp.nan 76rand = mp.rand 77 78absmin = mp.absmin 79absmax = mp.absmax 80 81fraction = mp.fraction 82 83linspace = mp.linspace 84arange = mp.arange 85 86mpmathify = convert = mp.convert 87mpc = mp.mpc 88 89mpi = iv._mpi 90 91nstr = mp.nstr 92nprint = mp.nprint 93chop = mp.chop 94 95fneg = mp.fneg 96fadd = mp.fadd 97fsub = mp.fsub 98fmul = mp.fmul 99fdiv = mp.fdiv 100fprod = mp.fprod 101 102quad = mp.quad 103quadgl = mp.quadgl 104quadts = mp.quadts 105quadosc = mp.quadosc 106 107invertlaplace = mp.invertlaplace 108invlaptalbot = mp.invlaptalbot 109invlapstehfest = mp.invlapstehfest 110invlapdehoog = mp.invlapdehoog 111 112pslq = mp.pslq 113identify = mp.identify 114findpoly = mp.findpoly 115 116richardson = mp.richardson 117shanks = mp.shanks 118levin = mp.levin 119cohen_alt = mp.cohen_alt 120nsum = mp.nsum 121nprod = mp.nprod 122difference = mp.difference 123diff = mp.diff 124diffs = mp.diffs 125diffs_prod = mp.diffs_prod 126diffs_exp = mp.diffs_exp 127diffun = mp.diffun 128differint = mp.differint 129taylor = mp.taylor 130pade = mp.pade 131polyval = mp.polyval 132polyroots = mp.polyroots 133fourier = mp.fourier 134fourierval = mp.fourierval 135sumem = mp.sumem 136sumap = mp.sumap 137chebyfit = mp.chebyfit 138limit = mp.limit 139 140matrix = mp.matrix 141eye = mp.eye 142diag = mp.diag 143zeros = mp.zeros 144ones = mp.ones 145hilbert = mp.hilbert 146randmatrix = mp.randmatrix 147swap_row = mp.swap_row 148extend = mp.extend 149norm = mp.norm 150mnorm = mp.mnorm 151 152lu_solve = mp.lu_solve 153lu = mp.lu 154qr = mp.qr 155unitvector = mp.unitvector 156inverse = mp.inverse 157residual = mp.residual 158qr_solve = mp.qr_solve 159cholesky = mp.cholesky 160cholesky_solve = mp.cholesky_solve 161det = mp.det 162cond = mp.cond 163hessenberg = mp.hessenberg 164schur = mp.schur 165eig = mp.eig 166eig_sort = mp.eig_sort 167eigsy = mp.eigsy 168eighe = mp.eighe 169eigh = mp.eigh 170svd_r = mp.svd_r 171svd_c = mp.svd_c 172svd = mp.svd 173gauss_quadrature = mp.gauss_quadrature 174 175expm = mp.expm 176sqrtm = mp.sqrtm 177powm = mp.powm 178logm = mp.logm 179sinm = mp.sinm 180cosm = mp.cosm 181 182mpf = mp.mpf 183j = mp.j 184exp = mp.exp 185expj = mp.expj 186expjpi = mp.expjpi 187ln = mp.ln 188im = mp.im 189re = mp.re 190inf = mp.inf 191ninf = mp.ninf 192sign = mp.sign 193 194eps = mp.eps 195pi = mp.pi 196ln2 = mp.ln2 197ln10 = mp.ln10 198phi = mp.phi 199e = mp.e 200euler = mp.euler 201catalan = mp.catalan 202khinchin = mp.khinchin 203glaisher = mp.glaisher 204apery = mp.apery 205degree = mp.degree 206twinprime = mp.twinprime 207mertens = mp.mertens 208 209ldexp = mp.ldexp 210frexp = mp.frexp 211 212fsum = mp.fsum 213fdot = mp.fdot 214 215sqrt = mp.sqrt 216cbrt = mp.cbrt 217exp = mp.exp 218ln = mp.ln 219log = mp.log 220log10 = mp.log10 221power = mp.power 222cos = mp.cos 223sin = mp.sin 224tan = mp.tan 225cosh = mp.cosh 226sinh = mp.sinh 227tanh = mp.tanh 228acos = mp.acos 229asin = mp.asin 230atan = mp.atan 231asinh = mp.asinh 232acosh = mp.acosh 233atanh = mp.atanh 234sec = mp.sec 235csc = mp.csc 236cot = mp.cot 237sech = mp.sech 238csch = mp.csch 239coth = mp.coth 240asec = mp.asec 241acsc = mp.acsc 242acot = mp.acot 243asech = mp.asech 244acsch = mp.acsch 245acoth = mp.acoth 246cospi = mp.cospi 247sinpi = mp.sinpi 248sinc = mp.sinc 249sincpi = mp.sincpi 250cos_sin = mp.cos_sin 251cospi_sinpi = mp.cospi_sinpi 252fabs = mp.fabs 253re = mp.re 254im = mp.im 255conj = mp.conj 256floor = mp.floor 257ceil = mp.ceil 258nint = mp.nint 259frac = mp.frac 260root = mp.root 261nthroot = mp.nthroot 262hypot = mp.hypot 263fmod = mp.fmod 264ldexp = mp.ldexp 265frexp = mp.frexp 266sign = mp.sign 267arg = mp.arg 268phase = mp.phase 269polar = mp.polar 270rect = mp.rect 271degrees = mp.degrees 272radians = mp.radians 273atan2 = mp.atan2 274fib = mp.fib 275fibonacci = mp.fibonacci 276lambertw = mp.lambertw 277zeta = mp.zeta 278altzeta = mp.altzeta 279gamma = mp.gamma 280rgamma = mp.rgamma 281factorial = mp.factorial 282fac = mp.fac 283fac2 = mp.fac2 284beta = mp.beta 285betainc = mp.betainc 286psi = mp.psi 287#psi0 = mp.psi0 288#psi1 = mp.psi1 289#psi2 = mp.psi2 290#psi3 = mp.psi3 291polygamma = mp.polygamma 292digamma = mp.digamma 293#trigamma = mp.trigamma 294#tetragamma = mp.tetragamma 295#pentagamma = mp.pentagamma 296harmonic = mp.harmonic 297bernoulli = mp.bernoulli 298bernfrac = mp.bernfrac 299stieltjes = mp.stieltjes 300hurwitz = mp.hurwitz 301dirichlet = mp.dirichlet 302bernpoly = mp.bernpoly 303eulerpoly = mp.eulerpoly 304eulernum = mp.eulernum 305polylog = mp.polylog 306clsin = mp.clsin 307clcos = mp.clcos 308gammainc = mp.gammainc 309gammaprod = mp.gammaprod 310binomial = mp.binomial 311rf = mp.rf 312ff = mp.ff 313hyper = mp.hyper 314hyp0f1 = mp.hyp0f1 315hyp1f1 = mp.hyp1f1 316hyp1f2 = mp.hyp1f2 317hyp2f1 = mp.hyp2f1 318hyp2f2 = mp.hyp2f2 319hyp2f0 = mp.hyp2f0 320hyp2f3 = mp.hyp2f3 321hyp3f2 = mp.hyp3f2 322hyperu = mp.hyperu 323hypercomb = mp.hypercomb 324meijerg = mp.meijerg 325appellf1 = mp.appellf1 326appellf2 = mp.appellf2 327appellf3 = mp.appellf3 328appellf4 = mp.appellf4 329hyper2d = mp.hyper2d 330bihyper = mp.bihyper 331erf = mp.erf 332erfc = mp.erfc 333erfi = mp.erfi 334erfinv = mp.erfinv 335npdf = mp.npdf 336ncdf = mp.ncdf 337expint = mp.expint 338e1 = mp.e1 339ei = mp.ei 340li = mp.li 341ci = mp.ci 342si = mp.si 343chi = mp.chi 344shi = mp.shi 345fresnels = mp.fresnels 346fresnelc = mp.fresnelc 347airyai = mp.airyai 348airybi = mp.airybi 349airyaizero = mp.airyaizero 350airybizero = mp.airybizero 351scorergi = mp.scorergi 352scorerhi = mp.scorerhi 353ellipk = mp.ellipk 354ellipe = mp.ellipe 355ellipf = mp.ellipf 356ellippi = mp.ellippi 357elliprc = mp.elliprc 358elliprj = mp.elliprj 359elliprf = mp.elliprf 360elliprd = mp.elliprd 361elliprg = mp.elliprg 362agm = mp.agm 363jacobi = mp.jacobi 364chebyt = mp.chebyt 365chebyu = mp.chebyu 366legendre = mp.legendre 367legenp = mp.legenp 368legenq = mp.legenq 369hermite = mp.hermite 370pcfd = mp.pcfd 371pcfu = mp.pcfu 372pcfv = mp.pcfv 373pcfw = mp.pcfw 374gegenbauer = mp.gegenbauer 375laguerre = mp.laguerre 376spherharm = mp.spherharm 377besselj = mp.besselj 378j0 = mp.j0 379j1 = mp.j1 380besseli = mp.besseli 381bessely = mp.bessely 382besselk = mp.besselk 383besseljzero = mp.besseljzero 384besselyzero = mp.besselyzero 385hankel1 = mp.hankel1 386hankel2 = mp.hankel2 387struveh = mp.struveh 388struvel = mp.struvel 389angerj = mp.angerj 390webere = mp.webere 391lommels1 = mp.lommels1 392lommels2 = mp.lommels2 393whitm = mp.whitm 394whitw = mp.whitw 395ber = mp.ber 396bei = mp.bei 397ker = mp.ker 398kei = mp.kei 399coulombc = mp.coulombc 400coulombf = mp.coulombf 401coulombg = mp.coulombg 402barnesg = mp.barnesg 403superfac = mp.superfac 404hyperfac = mp.hyperfac 405loggamma = mp.loggamma 406siegeltheta = mp.siegeltheta 407siegelz = mp.siegelz 408grampoint = mp.grampoint 409zetazero = mp.zetazero 410riemannr = mp.riemannr 411primepi = mp.primepi 412primepi2 = mp.primepi2 413primezeta = mp.primezeta 414bell = mp.bell 415polyexp = mp.polyexp 416expm1 = mp.expm1 417log1p = mp.log1p 418powm1 = mp.powm1 419unitroots = mp.unitroots 420cyclotomic = mp.cyclotomic 421mangoldt = mp.mangoldt 422secondzeta = mp.secondzeta 423nzeros = mp.nzeros 424backlunds = mp.backlunds 425lerchphi = mp.lerchphi 426stirling1 = mp.stirling1 427stirling2 = mp.stirling2 428 429# be careful when changing this name, don't use test*! 430def runtests(): 431 """ 432 Run all mpmath tests and print output. 433 """ 434 import os.path 435 from inspect import getsourcefile 436 from .tests import runtests as tests 437 testdir = os.path.dirname(os.path.abspath(getsourcefile(tests))) 438 importdir = os.path.abspath(testdir + '/../..') 439 tests.testit(importdir, testdir) 440 441def doctests(filter=[]): 442 import sys 443 from timeit import default_timer as clock 444 for i, arg in enumerate(sys.argv): 445 if '__init__.py' in arg: 446 filter = [sn for sn in sys.argv[i+1:] if not sn.startswith("-")] 447 break 448 import doctest 449 globs = globals().copy() 450 for obj in globs: #sorted(globs.keys()): 451 if filter: 452 if not sum([pat in obj for pat in filter]): 453 continue 454 sys.stdout.write(str(obj) + " ") 455 sys.stdout.flush() 456 t1 = clock() 457 doctest.run_docstring_examples(globs[obj], {}, verbose=("-v" in sys.argv)) 458 t2 = clock() 459 print(round(t2-t1, 3)) 460 461if __name__ == '__main__': 462 doctests() 463