Matrices
Matrices are the mathematical building blocks for quantum bits, quantum gates, and quantum circuits.
This quick review of matrices will prime you to learn what qubits actually represent—including a concrete, non-woo-woo definition of superposition. Let’s get started.
Grid of numbers
A matrix is just a grid of numbers; rows and columns containing values. Matrices can be of any size. Here’s an example of a matrix. It is columns wide and rows tall, containing the values through .
When describing the dimensions of a matrix we always specify the number of rows first, then the number of columns. The above is an example of a matrix, while below is a matrix containing similar data, but in a configuration.
Order matters
For our purposes, we’ll express our matrices in row-major order. This means we read the values just as they are ordered above, starting with the top-most row, reading values from left to right, then proceeding to the next row down and repeating that process. Our choice of row-major order makes reading and writing matrix values more akin to reading and writing in English; easier to type and program here.
Vectors are slices
While a matrix is a two-dimensional grid of numbers, a vector is more like a slice of numbers—such as a “skinny” matrix that is only one column wide, or a “flat” matrix that is only one row high. Let’s look at some examples of matrices that are simultaneously vectors.
While the above matrix is not a vector, you could say that it contains vectors: Two column vectors or two row vectors. Because vectors are just a type of matrix we can add them, multiply them, and so on—just like any other matrix. Vectors will play a prominent role in defining qubits and expressing the state of a quantum circuit.
Complex numbers
In addition to storing regular numbers, matrices can contain complex numbers. This is both useful and necessary: Qubits are really just a pair of complex numbers that we store in a matrix. So, yes—the example matrices above are each larger than a qubit!