Addition operation on the matrix
There are a variety of operations on matrices such as:
- Sum
- Reduction
- Multiplication
- Transpose
- Inverse
- Etc.
the discussion this time will be explained about the sum matrix.
A (m, n) is called a matrix A with row m and column n.
On the position of rows and columns can be put matrix elements. For example in row 1 and column to be written A-1 (1.1) can be given a value. Illustration of the matrix elements of the matrix A (3.3) are:
A1, 1 A1, 2 A1, 3
A2, 1 A2, 2 A2, 3
A3, 1 A3, 2 A3, 3
In the example above that there is a matrix A (3.3) which means that the matrix A consists of 3 rows and 3 columns.
For example, elements of the matrix A (3.3):
2 4 5
6 7 8
9 10 11
To add two matrices can be written as follows:
C = A + B, which means that the matrix A plus a matrix B the result is a matrix C
In the previous explanation mentioned that every matrix has rows and columns that form the sum above we can write to:
C (m, n) = A (m, n) + B (m, n)
where m is a count of line matrix
n is a count of the column matrix
In summing two or more matrices that many rows and columns of the matrix that will be summed to be the same.
For example there is a matrix A (2.2) and B (2.2) as below:
Matrix A
2 3
4 2
Matrix B
5 6
7 8
Perjumlahan matrix A and B are
Matrix A Matrix B
2 3 5 6
4 2 7 8
C (1,1) = A (1,1) + B (1,1)
= 2 + 5
= 7
C (1,2) = A (1,2) + B (1,2)
= 3 + 6
= 9
and so on
Matrix implementation in the programming language we can do by using the Array.
Suppose there is a matrix A (2,2)-elemenya that element is an integer, then the declaration of the matrix A in Visual Basic can be done as follows:
Dim A (2,2) As Byte
Above declaration states that there are four identifiers as follows:
A (1,1)
A (1,2)
A (2,1)
A (2.2)
Algorithm sum of two matrices
0. Start
1. Determine the matrices A and B
2. Repeat I started from 1 to many lines of matrix A
3. Repeat J ranging from 1 to many columns matrix A
4. Matrix C = Matrix A + Matrix B
5. Repeat J
6. Repeat I
7. Completed
Private Sub Form_Activate ()
Dim I, J As Byte
Dim A (2,2), B (2.2), C (2.2) As Byte
A (1,1) = 2: A (1,2) = 3: A (2,1) = 4: A (2,2) = 2
B (1,1) = 5: B (1,2) = 6: B (2,1) = 7: B (2,2) = 8
'Sum of Matrix A and B
For I = 1 To 2 Step 1
For J = 1 To 2 Step 1
C (I, J) = A (I, J) + B (I, J)
Next J
Next I
'Print matrix C
For I = 1 To 2 Step 1
For J = 1 To 2 Step 1
Print C (I, J);
Next J
Print
Next I
End Sub
Monday, June 6, 2011
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment