Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/mingw32/Python27/Lib/site-packages/numpy/dual.py @ 87:2a2c65a20a8b
Add Python libs and headers
author | Chris Cannam |
---|---|
date | Wed, 25 Feb 2015 14:05:22 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
86:413a9d26189e | 87:2a2c65a20a8b |
---|---|
1 """ | |
2 Aliases for functions which may be accelerated by Scipy. | |
3 | |
4 Scipy_ can be built to use accelerated or otherwise improved libraries | |
5 for FFTs, linear algebra, and special functions. This module allows | |
6 developers to transparently support these accelerated functions when | |
7 scipy is available but still support users who have only installed | |
8 Numpy. | |
9 | |
10 .. _Scipy : http://www.scipy.org | |
11 | |
12 """ | |
13 from __future__ import division, absolute_import, print_function | |
14 | |
15 # This module should be used for functions both in numpy and scipy if | |
16 # you want to use the numpy version if available but the scipy version | |
17 # otherwise. | |
18 # Usage --- from numpy.dual import fft, inv | |
19 | |
20 __all__ = ['fft', 'ifft', 'fftn', 'ifftn', 'fft2', 'ifft2', | |
21 'norm', 'inv', 'svd', 'solve', 'det', 'eig', 'eigvals', | |
22 'eigh', 'eigvalsh', 'lstsq', 'pinv', 'cholesky', 'i0'] | |
23 | |
24 import numpy.linalg as linpkg | |
25 import numpy.fft as fftpkg | |
26 from numpy.lib import i0 | |
27 import sys | |
28 | |
29 | |
30 fft = fftpkg.fft | |
31 ifft = fftpkg.ifft | |
32 fftn = fftpkg.fftn | |
33 ifftn = fftpkg.ifftn | |
34 fft2 = fftpkg.fft2 | |
35 ifft2 = fftpkg.ifft2 | |
36 | |
37 norm = linpkg.norm | |
38 inv = linpkg.inv | |
39 svd = linpkg.svd | |
40 solve = linpkg.solve | |
41 det = linpkg.det | |
42 eig = linpkg.eig | |
43 eigvals = linpkg.eigvals | |
44 eigh = linpkg.eigh | |
45 eigvalsh = linpkg.eigvalsh | |
46 lstsq = linpkg.lstsq | |
47 pinv = linpkg.pinv | |
48 cholesky = linpkg.cholesky | |
49 | |
50 _restore_dict = {} | |
51 | |
52 def register_func(name, func): | |
53 if name not in __all__: | |
54 raise ValueError("%s not a dual function." % name) | |
55 f = sys._getframe(0).f_globals | |
56 _restore_dict[name] = f[name] | |
57 f[name] = func | |
58 | |
59 def restore_func(name): | |
60 if name not in __all__: | |
61 raise ValueError("%s not a dual function." % name) | |
62 try: | |
63 val = _restore_dict[name] | |
64 except KeyError: | |
65 return | |
66 else: | |
67 sys._getframe(0).f_globals[name] = val | |
68 | |
69 def restore_all(): | |
70 for name in _restore_dict.keys(): | |
71 restore_func(name) |