liveBook · Manning

Matrix-matrix multiplication

As explained in Geometry for Programmers

Matrix multiplication is an operation that combines matrices by taking row-column dot products to produce a new matrix or vector.

Matrix-matrix multiplication combines transformations, equations, and data into one operation. Each entry of the result comes from one row of the first matrix and one column of the second: multiply matching elements, then add the products. This turns a grid of numbers into a useful geometric or algebraic action. section 2.5.2

Two rules prevent most multiplication mistakes:

  • Match inner dimensions: a matrix of width N can multiply only a matrix of height N. section 2.5.2
  • Keep the order: A × B generally differs from B × A, and one order may not even be dimensionally valid. section 2.5.2
  • Treat vector multiplication as a special case using a thin matrix; in geometry, it transforms a point into another point. section 2.5.2

From equations to a computed vector

An N-dimensional row vector written as a 1 × N matrix can multiply an N × N matrix to yield another 1 × N matrix. Reversing the arrangement gives a matrix-by-column-vector product, the compact form used for a system of linear equations. section 3.5 section 3.5.4

For geometry, multiplication provides a common language for translation, rotation, scaling, and shear. Homogeneous coordinates let these transformations share one matrix-based form, so several operations can be composed into a single transformation matrix. Inverse transformations provide an undo operation. section 4.0 section 4.3.3

Figure 1.2 In 2D, creating a projection is essentially the same as transforming a quadrilateral into some other quadrilateral.
01-02

A 2D projection can be viewed as transforming one quadrilateral into another, making the geometric purpose of a transformation concrete. section 1.3

This direct view also matters in production code. A point projection needs only a small amount of arithmetic and can often be expressed as one matrix-multiplication call. Profiling remains essential: wrapper routines and repeated point-representation conversions can cost far more than the arithmetic itself. section 1.3

How Geometry for Programmers covers it

How deep it goes
Defines row-column products, dimension constraints, noncommutativity, vector cases, and composable projective transformations.
Examples
Uses point projection, quadrilateral transformation, vector-matrix products, and matrix forms of linear systems.
What it assumes
Introduces multiplication as one of the few operations needed to use matrices properly.
What you can do after
Apply it via transformation routines or write direct routines when framework overhead or missing operations demand it.
How it connects
Connects homogeneous coordinates, projective transformations, linear equations, translation, rotation, scaling, shear, and inverse transformations.

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 Geometry for Programmers. The section links point to the parts of the book it draws on.