home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 November / CHIP_2011_11.iso / Programy / Narzedzia / Inkscape / Inkscape-0.48.2-1-win32.exe / python / Lib / site-packages / numpy / dual.py < prev    next >
Encoding:
Python Source  |  2010-05-29  |  1.7 KB  |  70 lines

  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. # This module should be used for functions both in numpy and scipy if
  14. #  you want to use the numpy version if available but the scipy version
  15. #  otherwise.
  16. #  Usage  --- from numpy.dual import fft, inv
  17.  
  18. __all__ = ['fft','ifft','fftn','ifftn','fft2','ifft2',
  19.            'norm','inv','svd','solve','det','eig','eigvals',
  20.            'eigh','eigvalsh','lstsq', 'pinv','cholesky','i0']
  21.  
  22. import numpy.linalg as linpkg
  23. import numpy.fft as fftpkg
  24. from numpy.lib import i0
  25. import sys
  26.  
  27.  
  28. fft = fftpkg.fft
  29. ifft = fftpkg.ifft
  30. fftn = fftpkg.fftn
  31. ifftn = fftpkg.ifftn
  32. fft2 = fftpkg.fft2
  33. ifft2 = fftpkg.ifft2
  34.  
  35. norm = linpkg.norm
  36. inv = linpkg.inv
  37. svd = linpkg.svd
  38. solve = linpkg.solve
  39. det = linpkg.det
  40. eig = linpkg.eig
  41. eigvals = linpkg.eigvals
  42. eigh = linpkg.eigh
  43. eigvalsh = linpkg.eigvalsh
  44. lstsq = linpkg.lstsq
  45. pinv = linpkg.pinv
  46. cholesky = linpkg.cholesky
  47.  
  48. _restore_dict = {}
  49.  
  50. def register_func(name, func):
  51.     if name not in __all__:
  52.         raise ValueError, "%s not a dual function." % name
  53.     f = sys._getframe(0).f_globals
  54.     _restore_dict[name] = f[name]
  55.     f[name] = func
  56.  
  57. def restore_func(name):
  58.     if name not in __all__:
  59.         raise ValueError, "%s not a dual function." % name
  60.     try:
  61.         val = _restore_dict[name]
  62.     except KeyError:
  63.         return
  64.     else:
  65.         sys._getframe(0).f_globals[name] = val
  66.  
  67. def restore_all():
  68.     for name in _restore_dict.keys():
  69.         restore_func(name)
  70.