Serch

Translate

Follower

free counters
Get this Widget and Desaign!
Jumat, 02 Desember 2011
Matriks Merupakan array 2 dimensi, setiap elemen Matriks diidentifikasi oleh nama, indeks baris dan indeks kolom.

Pendeklarasian Matriks (array 2 dimensi) :
Const
             Idxawal = 1;
             Idxakhir = 100;
Type
             TipeInfo = …;
             TabInfo = Array [ Idxawal .. Idxakhir, Idxawal .. Idxakhir] of TipeInfo;
Var
             <identifikasi_variabel> : TabInfo;

Proses – proses/operasi terhadap Matriks :
  1. Pengisian elemen matriks dari fil
  2. Pengisian elemen matriks khusus dengan assignment
  3. Penulisan elemen matriks
  4. Penjumlahan matriks
  5. Perkalian matriks
Algoritma-algoritma Operasi Matriks :

1. Pengisian elemen matriks dari fil
      
       Read N1, N2 {N1 : jumlah baris, N2 : jumlah kolom}
        I ← 1
       While I <= N1 do
             J ← 1
            While J <= N2 do
                       Read M [I,J]
                       J ← J+1
            EndWhile
            I ← I+1
     EndWhile

2. Pengisian elemen matriks khusus dengan assignment

a. Matriks N1 x N2 yang semua elemennya 1 :
      I ← 1
     While I <= N1 do
                 J ← 1
               While J <= N2 do
                          M [I,J] ← 1
                          J ← J+1
                  EndWhile
                  I ← I+1
         EndWhile

b. Matriks identitas ordo N
     Read N
      I ← 1
     While I <= N do
                 J ← 1
                While J <= N do
                          If I = J then
                                   M[I,J] ← 1
                          Else
                                   M[I,J] ← 0
                          Endif
                          J ← J+1
                  EndWhile
                  I ← I+1
            EndWhile

3. Penulisan elemen matriks
      I ← 1
    While I <= N1 do
                J ← 1
              While J <= N2 do
                        Write M[I,J]
                        J ← J+1
               EndWhile
               I ← I+1
       EndWhile

4. Penjumlahan matriks
      I ← 1
      While I <= N1 do
                  J ← 1
                  While J <= N2 do
                             C[I,J] ← A[I,J] + B[I,J]
                             J ← J+1
                   EndWhile
                   I ← I+1
          EndWhile
5. Perkalian matriks
     I ← 1
     While I <= N1 do {N1 = baris Matriks A}
                 J ← 1
                While J <= N2 do {N2 = baris Matriks B}
                            C[I,J] ← 0
                                     K ← 1
                            While K <= N do {N = kolom matriks A = baris matriks B}
                                         C[I,J] ← C[(I,J] + A[I,K] * B[K,J]
                                                  K ← K + 1
                                       EndWhile
                                       J ← J+1
                              EndWhile
                              I ← I + 1
                     EndWhile



Sumber dari : http://www.yudasy.web.id

0 comments: