In this chapter, the user will learn how to use SciPy
to perform scientific computations. The Numba
package will then be introduced as a way to accelerate computations. Finally, the NumbaPro
capabilities of parallel execution in the GPU will be presented.
In this chapter, we will cover the following topics:
SciPy
SciPy
Numba
and NumbaPro
Before running the examples in this chapter, load pylab
by running the following command in a computing cell:
%pylab inline
SciPy
is an extensive library for applied mathematics and scientific computation. The following is the complete list of all the modules available in the library:
Module |
Functionality |
---|---|
|
Clustering algorithms |
|
Physical and mathematical constants |
|
Fast Fourier Transform |
|
Integration and ordinary differential equations |
|
Interpolation and splines |
|
Input and output |
|
Linear algebra |
|
Image processing |
|
Orthogonal distance regression |
|
Optimization and root-finding |
|
Signal processing |
|
Sparse matrices |
|
Spatial data structures |
|
Special functions |
|
Statistical distributions |
|
C/C++ integration |
The standard way to import SciPy
modules in scripts is using the following command line:
from scipy import signal
Then, individual functions can be called with the usual module reference syntax, as follows:
signal.correlate(…)
However, many of the most used functions are available at the top level of the SciPy
hierarchy. Also, we use IPython in the interactive mode and use (as we assume in this book) the magic, as follows:
%pylab inline
Many of the functions will be available without explicit module reference.
In the next section, we present a sample of the functions available in SciPy
. The reader is not expected to know the mathematical techniques and algorithms that will be used in the examples in depth.