Skip to main content

Vectors, Matrices, and Multidimensional Arrays

  • Chapter
  • First Online:
Numerical Python
  • 12k Accesses

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 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. 2.

    This does not necessarily need to be the case for Python lists, which therefore can be heterogeneous.

  3. 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. 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. 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

Authors

Rights and permissions

Reprints 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

Publish with us

Policies and ethics