1 / 6

ADT MATRIK

ADT MATRIK. ADT Matrik. Class Rep ADT Matrik. Refresentasi ADT Matrik. double []A = {3,4,1,10,5,2,10,20,16}; double []B = {4,3,1,11,7}; Larik L1 = new Larik (A); Larik L2 = new Larik (B); Matrik A,B,C; double [][]data1 = {{1,2,3},{3,4,7}}; double [][]data2 = {{4,5,1},{6,1,9}};

Download Presentation

ADT MATRIK

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. ADT MATRIK

  2. ADT Matrik • Class Rep ADT Matrik • Refresentasi ADT Matrik

  3. double []A = {3,4,1,10,5,2,10,20,16}; double []B = {4,3,1,11,7}; Larik L1 = new Larik(A); Larik L2 = new Larik(B); • Matrik A,B,C; • double [][]data1 = {{1,2,3},{3,4,7}}; • double [][]data2 = {{4,5,1},{6,1,9}}; • A = new Matrik(data1); • B = new Matrik(data2);

  4. Constructor Matrik /** * constructor untukmembuatsuatumatrikdari array 2 dimensi * @param A : array duadimensi */ public Matrik(double [][]A){ this.nBaris = A.length; this.nKolom = A[0].length; itemDt = new int [this.nBaris][this.nKolom]; for (inti=0; i<nBaris; i++){ for (int j=0; j<nKolom; j++){ this.itemDt[i][j] = A[i][j]; } } }

  5. Matrik.tambah /** * fungsitambahantaraduamatrik A dan B * @param A : Matrik * @param B : Matrik * @return Matrikhasil */ public static Matriktambah(Matrik A, Matrik B){ Matrik C = null; int b1, b2, k1, k2; b1 = A.getNBaris(); b2 = B.getNBaris(); k1 = A.getNKolom(); k2 = B.getNKolom(); if ((b1 == b2) && (k1 == k2)){ C = new Matrik(b1,k1); for (int i=0; i<b1; i++){ for (int j=0; j<k1; j++){ double hasilTambah = A.getItem(i, j)+B.getItem(i, j); C.setItem(i,j, hasilTambah); } } } return C; } tambah

  6. Tugas (kelompok) • Buatlah ADT representasiMatrik (array 2 dimensi) menjadi array 1 dimensi. • Tambahkanoperasidasarpada ADT tersebutmeliputi : • Constructor dasar • Constructor konversi array 2 dimensikestrukturmatrik • Cetak data matrik • Ambilvektorbarispadabaristertentu • Ambillvektorkolompadakolomtertentu • Penjumlahanantaraduabuahmatrik • Tranposmatrik • Perkalianantaravektordenganmatrik • Perkalianantaramatrikdenganmatrik

More Related