Book Image

Learning SciPy for Numerical and Scientific Computing Second Edition

Book Image

Learning SciPy for Numerical and Scientific Computing Second Edition

Overview of this book

Table of Contents (15 chapters)
Learning SciPy for Numerical and Scientific Computing Second Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Matrix methods


Besides inheriting all the array methods, matrices enjoy four extra attributes: T for transpose, H for conjugate transpose, I for inverse, and A to cast as ndarray:

>>> A = numpy.matrix("1+1j, 2-1j; 3-1j, 4+1j")
>>> print (A.T); print (A.H)

The output is shown as follows:

[[ 1.+1.j  3.-1.j]
 [ 2.-1.j  4.+1.j]]
[[ 1.-1.j  3.+1.j]
 [ 2.+1.j  4.-1.j]]

Operations between matrices

We have briefly covered the most basic operation between two matrices; the matrix product. For any other kind of product, we resort to the basic utilities in the NumPy libraries, as: dot product for arrays or vectors (dot, vdot), inner and outer products of two arrays (inner, outer), tensor dot product along specified axes (tensordot), or the Kronecker product of two arrays (kron).

Let's see an example of creating an orthonormal basis.

Create an orthonormal basis in the nine-dimensional real space from an orthonormal basis of the three-dimensional real space.

Let's choose, for example, the...