## SciPy – 29 – algebra lineare – 1

Continuo da qui, copio qui.

Nota: salto tutto il capitolo sui segnali, troppo specifico e lontano dai miei interessi

When SciPy is built using the optimized ATLAS LAPACK and BLAS libraries, it has very fast linear algebra capabilities. If you dig deep enough, all of the raw `lapack` and `blas` libraries are available for your use for even more speed. In this section, some easier-to-use interfaces to these routines are described.

All of these linear algebra routines expect an object that can be converted into a 2-dimensional array. The output of these routines is also a two-dimensional array.

`scipy.linalg` vs `numpy.linalg`
`scipy.linalg` contains all the functions in `numpy.linalg`. plus some other more advanced ones not contained in `numpy.linalg`.

Another advantage of using `scipy.linalg` over `numpy.linalg` is that it is always compiled with BLAS/LAPACK support, while for `numpy` this is optional. Therefore, the `scipy` version might be faster depending on how `numpy` was installed.

Therefore, unless you don’t want to add `scipy` as a dependency to your `numpy` program, use `scipy.linalg` instead of `numpy.linalg`.

`numpy.matrix` vs 2D `numpy.ndarray`
The classes that represent matrices, and basic operations such as matrix multiplications and transpose are a part of `numpy`. For convenience, we summarize the differences between `numpy.matrix` and `numpy.ndarray` here.

`numpy.matrix` is matrix class that has a more convenient interface than `numpy.ndarray` for matrix operations. This class supports for example MATLAB-like creation syntax via the [non mi è chiaro cosa vuol dire], has matrix multiplication as default for the `*` operator, and contains `I` and `T` members that serve as shortcuts for inverse and transpose:

Despite its convenience, the use of the `numpy.matrix` class is discouraged, since it adds nothing that cannot be accomplished with 2D `numpy.ndarray` objects, and may lead to a confusion of which class is being used. For example, the above code can be rewritten as:

`scipy.linalg` operations can be applied equally to `numpy.matrix` or to 2D `numpy.ndarray` objects.

Matrici inverse
The inverse of a matrix `A` is the matrix `B` such that `AB=I` where `I` is the identity matrix consisting of ones down the main diagonal. Usually `B` is denoted B=A§−1 . In SciPy, the matrix inverse of the Numpy array, `A`, is obtained using `linalg.inv(A)`, or using `A.I` if `A` is a Matrix. For example, let

then

The following example demonstrates this computation in SciPy

Annunci
Posta un commento o usa questo indirizzo per il trackback.