Week 2 • Wednesday

Block 16: Vectorized Operations & Broadcasting

Apply operations to entire arrays without loops.

Concepts

Code Examples

See exercise below.

Exercise

Convert an array of Celsius temps to Fahrenheit vectorized. Given a 3×4 matrix of exam scores, subtract each student's mean (row-wise) using broadcasting.

Homework

Draw (or write) the shape diagram for adding a (3,1) array to a (1,4) array. What shape results? Thursday