Abstract
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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
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.
- 2.
This does not necessarily need to be the case for Python lists, which therefore can be heterogeneous.
- 3.
Note that this is not a complete list of the available elementwise functions in NumPy. See the NumPy reference documentation for comprehensive lists.
- 4.
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.
- 5.
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).
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 2015 Robert Johansson
About this chapter
Cite this chapter
Johansson, R. (2015). Vectors, Matrices, and Multidimensional Arrays. In: Numerical Python. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-0553-2_2
Download citation
DOI: https://doi.org/10.1007/978-1-4842-0553-2_2
Published:
Publisher Name: Apress, Berkeley, CA
Print ISBN: 978-1-4842-0554-9
Online ISBN: 978-1-4842-0553-2
eBook Packages: Professional and Applied ComputingApress Access BooksProfessional and Applied Computing (R0)