Swipe to navigate through the chapters of this book
Vectors, matrices, and arrays of higher dimensions are essential tools in numerical computing. When a computation must be repeated for a set of input values, it is natural and advantageous to represent the data as arrays and the computation in terms of array operations. Computations that are formulated this way are said to be vectorized. Many modern processors provide instructions that operate on arrays. These are also known as vectorized operations, but here vectorized refers to high-level array-based operations, regardless of how they are implemented at the processor level. Vectorized computing eliminates the need for many explicit loops over the array elements by applying batch operations on the array data. The result is concise and more maintainable code, and it enables delegating the implementation of (for example, elementwise) array operations to more efficient low-level libraries. Vectorized computations can therefore be significantly faster than sequential element-by-element computations. This is particularly important in an interpreted language such as Python, where looping over arrays element-by-element entails a significant performance overhead.
Please log in to get access to this content
Many modern processors provide instructions that operate on arrays. These are also known as vectorized operations, but here vectorized refers to high-level array-based operations, regardless of how they are implemented at the processor level.
This does not necessarily need to be the case for Python lists, which therefore can be heterogeneous.
Note that this is not a complete list of the available elementwise functions in NumPy. See the NumPy reference documentation for comprehensive lists.
Python recently adopted the @ symbol for denoting matrix multiplication. However, at the time of writing, this proposal has not yet been implemented. See http://legacy.python.org/dev/peps/pep-0465 for details.
With the new proposed infix matrix multiplication operator this same expression could be expressed as the considerably more readable: Ap = B @ A @ np.linalg.inv(B).
- Vectors, Matrices, and Multidimensional Arrays
- Sequence number
- Chapter number
- Chapter 2