## 16.6. Auxiliary Numeric ModulesMany other modules are built on top of Here are the key auxiliary modules that come with 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. |