liveBook · Manning

Matrix-matrix multiplication

As explained in Learn Concurrent Programming with Go

Matrix multiplication is the linear-algebra operation that computes a matrix product from weighted sums of rows and columns.

Matrix multiplication combines each row of matrix A with each column of matrix B. Each result cell is a weighted sum of corresponding values. The simple iterative method for two square n × n matrices takes O(n³) time, so doubling n multiplies the work by eight. section 6.2.3

Parallel computation assigns one result row to each goroutine. A barrier first waits until the input matrices are loaded, and a second barrier waits until every row is complete before printing the result. This separates shared input preparation from concurrent calculation.

Repeated random matrices

A Go program generates 3 × 3 matrices with values from −5 through 4, multiplies them concurrently, and prints both inputs alongside each computed result.

How Learn Concurrent Programming with Go covers it

How deep it goes
Explains the cubic algorithm, row-column calculation, faster alternatives, and a barrier-based concurrent implementation.
Examples
Uses 3 × 3 matrices, random entries from −5 through 4, row workers, and printed multiplication results.
What it assumes
Assumes basic matrix notation and develops the row-column calculation before introducing concurrent execution.
What you can do after
Build it from scratch using nested loops, then parallelize rows with goroutines and coordinate them with barriers.
How it connects
Connects matrix multiplication to linear algebra, graph theory, artificial intelligence, computer graphics, parallel computing, goroutines, and barriers.

Also explained in

Compare how 8 books explain matrix-matrix multiplication →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Concurrent Programming with Go. The section links point to the parts of the book it draws on.