Matrices and shapes
Read a matrix as a table of rows and columns, state its shape, index rows and columns, transpose it.
Builds on: Vectors
What the animation says
Twenty numbers, one table
Here's a sentence of five words. Each word is a vector of four numbers. That's twenty numbers floating around. We need to say things like: the third number of word two. Or: every word's third number. So stack the vectors as rows of one table. Row two is word two's vector. That table is a matrix. Its shape is rows by columns, and rows always come first. So what shape is this one?
Rows, columns, one entry
Five by four it is: five rows, one per word, then four columns. A row is one word's whole vector, so it holds four numbers. A column is the same position from every word, so it holds five numbers. To point at one number, give its row, then its column. Row first, counting from one. Tap the number in row two, column three.
A small one, then flip it
Here's a smaller case. Two rows: one, two, three, and four, five, six. Its shape is two by three. Row one, column two holds two. Row two, column one holds four. Row two is four, five, six: length three. Column three is three and six: length two. Now transpose it: flip the table so each row becomes a column. After the flip, what's the shape?
Reading the flipped table
Three by two. Row one, one two three, stands up as column one. Row two becomes column two. It's the same six numbers, just rearranged. To read the flipped table, swap the two indices: its row and column are the original's column and row. Check: the flipped table's row three, column one holds three. The original's row one, column three: also three. Your turn: in the flipped table, tap row two, column one.
Shapes to carry forward
In this course, a list of items, each a vector of length d, stacks into a matrix: one row per item. Its shape is always rows by columns, and an entry is named row first, then column. Transposing swaps rows and columns. An m by n matrix becomes n by m, and the two indices swap. Same numbers, new arrangement. The formulas ahead lean on exactly these shapes.
A matrix is a table of numbers
Shape, entries, rows, columns, transpose
Reading and flipping a 2×3 matrix
Remember
On Bytewise this lesson comes in small steps with a check at the end, and the app brings it back right before you would forget it.
Bytewise
All courses