Sie sind auf Seite 1von 31

Intro to Matrices

Don’t be scared…
What is a matrix?
A Matrix is just rectangular arrays of items
A typical matrix is a rectangular array of numbers
arranged in rows and columns.

 21 62 33 93
 
A   44 95 66 13 
3x4
77 38 79 33
Sizing a matrix
By convention matrices are “sized” using the
number of rows (m) by number of columns (n).
 21 62 33 93 7 3 2 
A   44 95 66 13  B  8 4 1 
3x4 3x3
77 38 79 33  6 5 9 
11 4 
14 7 
C   D   17 
4x2 16 8  1 x1
 
 22 3 
“Special” Matrices
Square matrix: a square matrix is an mxn matrix in
which m = n.
7 3 2 
B  8 4 1 
3x3
 6 5 9 
Vector: a vector is an mxn matrix where either m
OR n = 1 (but not both). 12 
9
X   Y   7 22 14
4 x1  4  1x 3
 
0
“Special” Matrices
Scalar: a scalar is an mxn matrix where BOTH m
and n = 1.
D   17 
1 x1 0 0 
Zero matrix: an mxn matrix of zeros. 0  0 0 
3x 2
0 0 
Identity Matrix: a square (mxm) matrix with 1s on
the diagonal and zeros everywhere else.
1 0 0 
I  0 1 0 
3x3
0 0 1 
Transposing a Matrix
Matrix Transpose: is the mxn matrix obtained by
interchanging the rows and columns of a matrix
(converting it to an nxm matrix)
12 
9
X   X '   12 9 4 0 
4 x1  4  1x 4
 
0
 21 44 77 
 21 62 33 93  62 95 38 
A   44 95 66 13  A'  
3x4 4 x3  33 66 79 
77 38 79 33  
 93 13 33 
Matrix Addition
Matrices can be added (or subtracted) as long as
the 2 matrices are the same size
Simply add or subtract the corresponding components of
each matrix.
1 2 3 5 6 7
A   B 
2 x3
7 8 9  2 x3
3 4 5 
1 2 3 5 6 7  1  5 2  6 3  7   6 8 10 
A B      
7 8 9 3 4 5  7  3 8  4 9  5  10 12 14 
 

A B  B  A
1 2 3 5 6 7  1  5 2  6 3  7   4 4 4 
A B     3 4 5    7  3 8  4 9  5    4 4 4 
 7 8 9       
Matrix Multiplication
Multiplying a matrix by a scalar: each element in
the matrix is multiplied by the scalar.

1 2 3
A   and x = 5; then
2 x3
7 8 9 1 x1

 5*1 5* 2 5*3  5 10 15 
xA   
5*7 5*8 5*9  35 40 45

Matrix Multiplication
 1. The order makes a difference…AB is different from BA.

 2. The number of columns in first matrix must equal number of rows in second matrix.
 In other words, the inner dimensions must be equal.

 3. The answer will be number of rows in first matrix by number of columns in second matrix.
 In other words, the outside dimensions.

Are the following matrix multiplications possible?

4   4  
2   3 1  
 3 1   2    
   
 
2x1 1x2 1x2 2x1
Are the following matrix multiplications possible?

 1 1  1 1 0 1 
0 2   0 2  1 2 4  
NO 
3 9 9   1 4 YES
      5 8 
 1 5   1 5   
3x2 3x2 2x3 3x2

7 0  3 
 2     0 0 1  1  2 1 2
   
YES
  2 4 3  YES
3 1 8 
3x2 2x3 3x1 1x3

1 0 2
 2 1  3 5   3 1 4    0 1
0 0    4 2 
YES
      2 7  NO
5 7 2 
2x2 2x2
3x3 2x2
What is the dimension of the following products, if possible?

 1 1  1 1 0 1 
0 2   0 2  1 2 4  
NO 
3 9 9   1 4 YES
      5 8  2x2
 1 5   1 5   
3x2 3x2 2x3 3x2

7 0  3 
 2     0 0 1  1  2 1 2
   
YES
  2 4 3  YES
3 1 3x3 8  3x3
3x2 2x3 3x1 1x3

1 0 2
 2 1  3 5   3 1 4    0 1
0 0    4 2 
YES
      2 7  NO
2x2 5 7 2 
2x2 2x2
3x3 2x2
0 1    0 1 
1 2 4   1 2 4    22 
3 9 9    1 4     3 9 9    1 4    
      5 8  54 
5 8   
 1  0    2   1   4   5   22  1  1   2   4    4   8   41

0 1  0 1 
1 2 4    22  1 2 4    22 41
3 9 9    1 4     3 9 9    1 4    
  5 8      5 8  54 
   

 3   0    9   1   9   5   54  3   1   9   4    9   8   111
22 41 
54 111
 
Matrix Multiplication
Multiplying a matrix by a matrix:
the product of matrices A and B (AB) is defined if the
number of columns in A equals the number of rows in B.
Assuming A has ixj dimensions and B has jxk
dimensions, the resulting matrix, C, will have dimensions
ixk
In other words, in order to multiply them the inner
dimensions must match and the result is the outer
dimensions.
Each element in C can by computed by:
Cik   j Aij B jk
Matrix Multiplication
Multiplying a matrix by a matrix:
5 3
1 2 3
A   B '   6 4 
2 x3
7 8 9 3x2
 7 5 
c c12  Matching inner dimensions!!
A B '  C   11
2 x3 3x 2 2 x2
c21 c22  Resulting matrix has outer dimensions!!!

c11   A1 j B j1   1*5    2*6    3*7   38


c12   A1 j B j 2   1*3   2* 4    3*5   26
c21   A2 j B j1   7 *5    8*6    9*7   155
c22   A2 j B j 2   7 *3   8* 4    9*5   98
 38 26 
A B'  C   
2 x3 3x 2 2 x2
155 98 
Matrix Inverse
Matrix Inverse: Needed to perform the “division” of
2 square matrices
In scalar terms A/B is the same as A * 1/B
When we want to divide matrix A by matrix B we simply
multiply by A by the inverse of B
An inverse matrix is defined as

1 1 1
A  A A  I AND A
Defined
A I
nxn nxn nxn nxn nxn nxn nxn
Matrix Inverse
Matrix Inverse: Needed to perform the “division” of
2 square matrices
In scalar terms A/B is the same as A * 1/B
When we want to divide matrix A by matrix B we simply
multiply by A by the inverse of B
An inverse matrix is defined as

1 1 1
A  A A  I AND A
Defined
A I
nxn nxn nxn nxn nxn nxn nxn
Matrix Inverse
Matrix Inverse:
For a 2x2 matrix the inverse is relatively simple

 a1 b1  11  a1 b1 
C   C   a
2x2 a
 2 2b 2x2 C  2 b2 
3 2 
C   C  7
2x2
 5 1 
  3 2 
1 1  3 2   7 7 
C  
2x2 7  5 1   5 1 
 7 7
For anything else, use a computer…
Singular Matrix
Singular Matrix: A matrix is considered singular if
the determinant of the matrix is zero
The matrix cannot be inverted

 2 6
A   A   2*3   1*6   0
2x2
1 3
Finite Fields
• Finite fields play a crucial role in many
cryptographic algorithms
• It can be shown that the order of a finite field must
be a power of a prime pn, where n is a positive
integer
• The only positive integers that are divisors of p are p and
1
• The finite field of order pn is generally written
GF(pn )
• GF stands for Galois field, in honor of the mathematician
who first studied finite fields
Finite Fields

Galois showed that for a field to be finite, the number


of elements should be pn, where p is a prime and n
is a positive integer.

Note

A Galois field, GF(pn), is a finite field with pn


elements.
Example

A very common field in this category is GF(2) with the set {0, 1} and two operations,
addition and multiplication, as shown in Figure ...

Figure GF(2) field

4.21
Example

We can define GF(5) on the set Z5 (5 is a prime) with addition and multiplication
operators as shown in Figure 4.7.

Figure GF(5) field

4.22
GF(2n) FIELDS

In cryptography, we often need to use four


operations (addition, subtraction, multiplication,
and division). In other words, we need to use
fields. We can work in GF(2n) and uses a set of 2n
elements. The elements in this set are n-bit words.

4.23
Example

Let us define a GF(22) field in which the set has four 2-bit words: {00, 01, 10, 11}. We
can redefine addition and multiplication for this field in such a way that all properties
of these operations are satisfied, as shown in Figure 4.8.

2
Figure An example of GF(2 ) field

4.24
Polynomials

A polynomial of degree n − 1 is an expression


of the form

4.25
Example

Figure show how we can represent the 8-bit word (10011001) using a polynomials.

Figure Representation of an 8-bit word by a polynomial

4.26
Example

To find the 8-bit word related to the polynomial x5 + x2 + x, we first supply the omitted
terms. Since n = 8, it means the polynomial is of degree 7. The expanded polynomial
is

This is related to the 8-bit word 00100110.

4.27
n
GF(2 ) Fields

Note

Polynomials representing n-bit words use


two fields: GF(2) and GF(2n).

4.28
Addition

Note

Addition and subtraction operations on


polynomials are the same operation.

4.29
Example

Let us do (x5 + x2 + x) Å (x3 + x2 + 1) in GF(28). We use the symbol Å to show that we


mean polynomial addition. The following shows the procedure:

4.30
Example

There is also another short cut. Because the


addition in GF(2) means the exclusive-or (XOR)
operation. So we can exclusive-or the two
words, bits by bits, to get the result. In the
previous example, x5 + x2 + x is 00100110 and
x3 + x2 + 1 is 00001101. The result is 00101011
or in polynomial notation x5 + x3 + x + 1.

4.31

Das könnte Ihnen auch gefallen