Section 16.6. Auxiliary Numeric Modules


16.6. Auxiliary Numeric Modules

Many other modules are built on top of Numeric or cooperate with it. Some of these extra modules are included in the Numeric package, and their documentation is also part of Numeric's documentation. A rich collection of scientific and engineering computing tools that work with Numeric is available at http://www.scipy.org; have a look at it if you are using Python for any kind of scientific or engineering computing.

Here are the key auxiliary modules that come with Numeric:


MLab

MLab supplies many Python functions, written on top of Numeric, but is similar in name and operation to functions supplied by the product Matlab.


FFT

FFT supplies Python-callable Fast Fourier Transforms (FFTs) of data held in Numeric arrays. FFT can wrap either the well-known FFTPACK Fortran-coded library or the compatible C-coded fftpack library, which comes with FFT.


LinearAlgebra

LinearAlgebra supplies Python-callable functions, operating on data held in Numeric arrays, wrapping either the LAPACK Fortran-coded library or the compatible C-coded lapack_lite library. LinearAlgebra lets you invert matrices, solve linear systems, compute eigenvalues and eigenvectors, perform singular value decomposition, and least-squares-solve overdetermined linear systems.


RandomArray

RandomArray supplies fast, high-quality pseudorandom number generators to build Numeric arrays with various random distributions.


MA

MA supports masked arrays (i.e., arrays that can have missing or invalid values). MA supplies a large subset of Numeric's functionality, albeit sometimes at reduced speed. MA also lets you associate to each array an optional mask, which is an auxiliary array of Booleans, where TRue indicates array elements that are missing, unknown, or invalid. Computations propagate masks; you can turn masked arrays into plain Numeric ones by supplying a fill-in value for invalid elements. MA is widely applicable because experimental data often has missing or inapplicable elements. Should you need to extend or specialize some aspect of Numeric's behavior for your application's purposes, it may be simplest and most effective to start with MA's sources rather than with Numeric's. The latter are often quite hard to understand and modify due to the degree of optimization applied to them over the years.

These modules' performance is generally quite good. For example:

 import RandomArray x = RandomArray.random((13,23)) 

On my laptop, this takes 109 microseconds. The pure-Python equivalent:

 from random import random x = [[random( ) for i in xrange(13)] for j in xrange(23)] 

takes 230 microseconds, over twice as long.




Python in a Nutshell
Python in a Nutshell, Second Edition (In a Nutshell)
ISBN: 0596100469
EAN: 2147483647
Year: 2004
Pages: 192
Authors: Alex Martelli

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net