NumPy, Arrays, and Vectorized Functions
numpy arrays
- Compare and contrast
lists and numpy arrays.
- Generate a
numpy array using np.array().
- Query the shape of a
numpy array using the shape attribute.
1D numpy arrays
- State the mental picture for thinking about a 1D
numpy array.
- Explain what element-wise means with respect to binary arithmetic operators with
numpy arrays.
Generating Structured numpy arrays
- Use
np.arange() to generate a given numpy array.
- Use
np.linspace() to generate a given numpy array.
Indexing and Slicing numpy arrays
- Use indexing and slicing to access elements and sub-arrays of a
numpy array.
Vectorization
- Define vectorization.
- Explain the advantages of vectorized functions.
- Use vectorized functions from
numpy, e.g. np.sin(), np.exp(), np.log(), etc.
- Use
np.sum() and np.prod() to evaluate sums and products.
Quadrature via Vectorized Code
- Implement:
- left / right Riemann sums
- the midpoint rule
- the trapezoidal rule
using numpy arrays and vectorized functions.