Transformations

The transformation of matrices can easily be done with the use of matrices. A matrix is an array of elements as follows:

In general, the matrix itself is specified using capital letters such as A and the elements of the matrix is specified using lower case letters with subscripts such as aij where i is the row and j is the column.

A[m n] is a matrix that contains m rows and n columns.

We can view a matrix as a collection of vectors. Consider the matrix A[3 4] which is composed of 3 row vectors each consisting of 4 elements. We also note that A[3 4] is composed of 4 column vectors each consisting of 3 elements.

Please note the following:

Problems:
1) What is the notation to denote the tanspose of a matrix?
2) Give an example of a matrix A and its transpose.
3) What is the Pascal code for finding the transpose?
4) What is the C code for finding the transpose of matrix A?
5) What are the rules for adding two matrices A and B?
6) Give an example of adding two matrices A and B.
7) What is the Pascal code for adding two matrices?
8) What is the C code for adding two matrices?
9) What are the rules for multipying two matrices A and B?
10) Give and example of multiplying two matrices A and B.
11) What is the Pascal code to multiplying two matrices A and B.
12) What is the C code to multiplying two matrices A and B.

The C code will be discussed on Tuesday. Make your solutions as efficient as possible!!

1) The transpose At of an MxN matrix A is an NxM matrix.

2) A=

   0  -2
   1   3
At=

   0  1
  -2  3
3)
for i := 1 to m do
  for j := 1 to n do
    At[j,i] := A[i,j]
4) For this solution, use only pointer arithmetic!!

5) Two matrices A and B can be added provided they have the same number of rows and columns.

6)

   2  1  +  5  2  =  2+5  1+2  =  7  3
  -1  3     7  3    -1+7  3+3     6  6
7)
for i := 1 to m do
  for j := 1 to n do
    C[i,j] := A[i,j] + B[i,j]
8) Again, use only pointer arithmetic.

9) Two matrices A and B can be multiplied if the number of elements in any row of A equals the number of elements in any column of B. Given, A[m n] and B[x y], the multiplication AB can be performed iff n=x. The result of the matrix multiplication C is C[m y].

Note1: Matrices are commutative over addition: A+B=B+A

Note2: Matrices are not commutative over multiplication: AB<>BA

What about associativity?

10)

   2  1  +  5  2  =  2*5+1*7  2*2+1*3  =  17  7
  -1  3     7  3    -1*5+3*7 -1*2+3*3     15  7
11)

12) Use only pointer arithmetic.

Identity Matrices have the following general form:

I = 1 0 0 0 ......
    0 1 0 0 ......
    0 0 1 0 ......
    0 0 0 1 ......
    .....
    
It is the case that AI=IA=A

We define inv(A) where A(inv(A))=(inv(A)A)=I. That is, a matrix A is said to be invertible iff there exists a matrix B such that AB=BA=I.

So how do we find inv(A)? First, let's remember how to find the determinant of a matrix.

Associated with an arbitrary element aij of A, we get an (n-1)x(n-1) matrix by deleting the ith row and the jth column. The determinant of this submatrix is called the minor of aij.

Given A=

1   0   3
4  -1   2
0   1   1

The minor of the element a11 is A11 = -3. Why?

Note1: A square matrix is said to be singular if it has a zero determinant; otherwise, it is nonsingular.

Note2: A square NxN matrix is invertible iff it is nonsingular.

Problem: Is the following matrix invertible or not?

1  -2
3   5
Problem: Given the matrix A below, find inv(A).

1  2
3  4
1) First, is A invertible?

det(A)=-2

2) A11=4 A12=3 A21=2 A22=1

The matrix of signed minors is:

 4  -3
-2   1
3) The transpose of this matrix (also called the adjoint matrix) is:

 4  -2
-3   1
4) The inverse of A is (1/determinant)(adjoint matrix). So in this case:

1/(-2)  4  -2
       -3   1

which is

       -2      1
      3/2   -1/2

Does (inv(A))A=A(inv(A))=I? Problem: Given the matrix A below, find inv(A) if it exists.

1   2   0
2   1  -1
3   1   1

©1995 Douglas J. Ryan
Douglas J. Ryan/ryand@pacificu.edu