Chapter 27. Matrices

Table of Contents

27.. Motivation
Tables
Grids
Bricks
Systems of Equations
Matrix Representation
27.. Multidimensional Arrays
27.. Reading and Writing Matrices
27.. Importance of Traversal Order
27.. Multidimensional Arrays as Arguments
27.. Fortran Intrinsic Functions
27.. Homework

Assigned readings: Sec 9.1, 9.2

Motivation

We have seen how to use arrays to store one-dimensional lists in memory.

Often there is a need to store and manage data which is conceptually multidimensional.

Tables

A table is any two-dimensional arrangement of data. Common uses are timetables, score tables, etc.

Table 27.1. Time Table

 SunMonTueWedThuFriSat
8:00am       
9:00       
10:00       
11:00       

Grids

Grids are representations of values at physical locations in two dimensions. Grids are commonly used to represent weather data.

Table 27.2. Temperature

Lat/Long86878889909192
4456545355595254
4357565860555458
4259615855565657

Bricks

A brick is like a grid, but with more than two dimensions. Bricks of data can represent things like MRI images, or weather data including altitude as well as latitude and longitude.

Systems of Equations

Systems of polynomial equations are commonly stored as a matrix of coefficients, which can then be solved using techniques such as Gaussian elimination.

Matrix Representation

In all of the examples above, we wish to identify one piece of data in a collection using multiple coordinates. For example, we may want to check our schedule for (Mon, 10:00), find the temperature at latitude, longitude (43o, 78o), or measure brain activity at 10mm sagittal, 8mm coronal, and 12mm transverse (10, 8, 12).

Multidimensional data can be represented as a matrix, which is a multidimensional collection of numbers. A vector, defined in Chapter 24, Arrays is a is simply a matrix where only one dimension has a measurement greater than 1. For a two-dimensional matrix, the row subscript is first by convention.

Table 27.3. Generic 2D Matrix

A =
a1,1a1,2a1,3
a2,1a2,2a2,3
a3,1a3,2a3,3