Matrices

Matrices#

Note

Source: Python-specific — no equivalent in the C# edition.

Todo

Write the matrices section covering:

  • A matrix as a list of row lists; indexing with m[row][col]

  • Constructing a matrix: literals and helper (e.g. zeros(rows, cols))

  • Element-wise addition and scalar multiplication

  • Transpose: swapping rows and columns

  • Matrix–vector multiplication: each output element is a dot product

  • Matrix–matrix multiplication: the general case using nested loops

  • Identity matrix and its role

  • Code examples for each operation as standalone functions

  • Sample runs showing input/output

  • Nested-loop complexity discussion (O(n³) for matrix multiply)

  • Review questions / exercises