1 / 27

Kuliah Ke-2

Kuliah Ke-2. Matriks Jarang dan Pengalamatan Matriks (Bab 2) Informatics Engineering Department TRUNOJOYO UNIVERSITY. PENGALAMATAN. Array / Larik. LOK(LA[K]) = Awal(LA) + W(K - LB) Contoh: Misalkan Awal (Jual) = 100 dan W= 4, maka LOK (JUAL[1990]) = 100 LOK (JUAL[1991]) = 104

zlata
Download Presentation

Kuliah Ke-2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Kuliah Ke-2 Matriks Jarang dan Pengalamatan Matriks (Bab 2) Informatics Engineering Department TRUNOJOYO UNIVERSITY

  2. PENGALAMATAN Array / Larik LOK(LA[K]) = Awal(LA) + W(K - LB) Contoh:Misalkan Awal (Jual) = 100 dan W= 4, maka LOK (JUAL[1990]) = 100 LOK (JUAL[1991]) = 104 LOK (JUAL[1992]) = 108 Berapa lokasi JUAL[2000] ? untuk mendapat lokasi tersebut LOK(LA[K]) = Awal(LA) + W(K - LB) = 100 + 4 * (2000 – 1990) = 140 Review

  3. PENGALAMATAN Array / Larik Review

  4. Struktur Data : Matriks Definisi • struktur data yang mengacu pada sekumpulan elemen yang diakses melalui indeks • Array dua dimensi, yang memiliki indeks baris dan kolom Review

  5. Proses Matriks • Elemen Matriks diproses Baris demi Baris • Elemen Matriks diproses Baris demi Baris Review

  6. PROSES MATRIKS Matriks Review 18 3 69 24 8 70

  7. PROSES MATRIKS Matriks Review 18 3 69 24 8 70

  8. INISIALISASI Matriks For Baris = 1 to 2 do For Kolom = 1 to 3 do A(Baris, Kolom) = 0 Endfor Endfor Review 0 0 0 0 0 0

  9. Isi dengan 1,2,3,4,5,6 Matriks Indeks = 1 For Baris = 1 to 2 do For Kolom = 1 to 3 do A(Baris, Kolom) = Indeks Indeks = Indeks + 1 Endfor Endfor Review 1 2 3 4 5 6

  10. Isi dengan 1,3,5,7,9,11 Matriks Indeks = ??? For Baris = 1 to 2 do For Kolom = 1 to 3 do A(Baris, Kolom) = ??? Indeks = ??? Endfor Endfor Review 1 3 5 7 9 13

  11. Menjumlahkan setiap baris Matriks For Baris = 1 to 2 do TotalBaris = 0 For Kolom = 1 to 3 do TotalBaris = TotalBaris + A[Baris,Kolom] Endfor Print Total Baris Endfor Review 18 3 69 90 24 8 70 102

  12. 18 1 3 2 69 3 24 4 5 8 70 6 Menjumlahkan C = A + B Dua buah Matriks For Baris = 1 to 2 do For Kolom = 1 to 3 do C[Baris,Kolom] =A[Baris,Kolom]+ B[Baris,Kolom] Endfor Endfor Review +

  13. 18 3 69 24 8 70 Mengalikan Matriks For Baris = 1 to 2 do For Kolom = 1 to 3 do C[Baris, Kolom] = 0 For K = 1 to P do C[Baris,Kolom] =C[Baris,Kolom]+ A[Baris,K] + B[K,Kolom] Endfor Endfor Endfor

  14. Kita lanjutkan untuk yang satu ini …..

  15. Matriks Jarang Sparse Matrix matriks yang elemennya banyak bernilai o (nol). Idenya : bgm mengkonversinya supaya lebih hemat memori

  16. Contoh Matriks Jarang Sparse Matrix Matriks Segitiga Matriks Tridiagonal

  17. Konversi Matriks Jarang Sparse Matrix 9 data menjadi 6 data

  18. Konversi Matriks Jarang Sparse Matrix 16 data menjadi 10 data

  19. Ubah Matriks Segitiga jadi Array Sparse Matrix

  20. Lokasi Elemen Matriks Segitiga Sparse Matrix Lokasi pada array : L = Baris ( Baris – 1 ) ________________ + Kolom 2

  21. Pengalamatan Matriks Ordering A[1,1], A[1,2], A[1,3], A[2,1], A[2,2],A[2,3]…... jika row major A[1,1], A[2,1], A[1,2], A[2,2], A[1,3],A[2,3]….. jika column major 18 3 69 90 24 8 70 102

  22. Pengalamatan Matriks Row Ordering A[1,1], A[1,2], A[1,3], A[2,1], A[2,2],A[2,3]…... jika row major A[1,1], A[2,1], A[1,2], A[2,2], A[2,2],A[2,3]….. jika column major

  23. Pengalamatan Matriks Column Ordering A[1,1], A[1,2], A[1,3], A[2,1], A[2,2],A[2,3]…... jika row major A[1,1], A[2,1], A[1,2], A[2,2], A[2,2],A[2,3]….. jika column major

  24. Cari Alamat Elemen Matriks Row Ordering Loncat 2

  25. Pengalamatan Matriks Ordering Mencari lokasi memori pada Row-major order Lokasi (A[B,K] = Base(A) + w [ N ( B-1) + (K-1) ] Mencari lokasi memori pada Column-major order Lokasi (A[B,K] = Base(A) + w [ M ( B-1) + (K-1) ] Base (a) : lokasi awal di memori (alamat A[1,1]) W : jumlah word/byte utk menyimpan 1 elemen M : jumlah baris pada matriks A N : jumlah kolom pada matriks A

  26. Cari Alamat Elemen Matriks Column Ordering

  27. Cari Alamat Elemen Matriks

More Related