Вы находитесь на странице: 1из 4

BASKOM-7 (YAKNI IDRIS) 1

Matrices
A matrix is a two-dimensional array which may be used in a wide variety of representations. For
example, a distance array representing the lengths of direct connections in a network is a matrix.
We will deal mainly with square matrices in this chapter (i.e. matrices having the same number of
rows as columns), although in principle a matrix can have any number of rows or columns. A
matrix with only one column is also called a vector.
A matrix is usually denoted by a bold capital letter, e.g. A. Each entry, or element, of the matrix is
denoted by the small letter of the same name followed by two subscripts, the first indicating the
row of the element, and the second indicating the column. So a general element of the matrix A is
called , meaning it may be found in row i and column j. If A has three rows and columns
(3 times 3) for shortit will look like this in general:



a
ij
a a a
a a a
a a a
11 12 13
21 22 23
31 32 33

(
(
(
BASKOM-7 (YAKNI IDRIS) 2
A special matrix which we will come across later is the identity matrix. This has ones on the main
diagonal, and zeros everywhere else. E.g. the (3 times 3) identity matrix is






Various mathematical operations are defined on matrices. Addition and subtraction are obvious,
and may be done with the intrinsic operators in Fortran 90. So the matrix addition
[A = B + C]
translates directly into

A = B + C

where the arrays must clearly all have the same shape, i.e. the same extent along corresponding
dimensions.
1 0 0
0 1 0
0 0 1

(
(
(
BASKOM-7 (YAKNI IDRIS) 3
Matrix multiplication
Probably the most important matrix operation is matrix multiplication. It is used widely in such
areas as network theory, solution of linear systems of equations, transformation of co-ordinate
systems, and population modelling, for examples. The rules for multiplying matrices look a little
weird if you've never seen them before, but will be justified by the applications that follow.
When two matrices A and B are multiplied together, their product is a third matrix C. The
operation is written as
C = AB
and the general element of C is formed by taking the scalar product of the ith row of
A with the jth column of B.
(The scalar product of two vectors x and y is , where and
are the components of the vectors.)
cij
x y x y
1 1 2 2
+ +...
x
i
y
i
BASKOM-7 (YAKNI IDRIS) 4
It follows that A and B can only be successfully multiplied (in that order) if the number of
columns in A is the same as the number of rows in B.
The general definition of matrix multiplication is as follows: If A is a (n x m) matrix and B is a (m
x p) matrix, their product C will be a (n x p) matrix such that the general element of C is
given by



cij
c a b
ij ik kj
k
m
=
=

1
Note that in general AB is not equal to BA (matrix multiplication is not commutative).
Example:
1 2
3 4
5 6
0 1

(
=
5 4
15 14
Matrix multiplication

Вам также может понравиться