Evo ovako, pokusavam vec neko vreme da pronadjem logiku u ovoj postavci:
Imamo matricu:
3.1 | 2.3 | 1.4
5.0 | 1.1 |
Zadate su i definicije:
cnt: an array of length number of columns; the jth entry specifies the number of non-zeros in the jth column.
beg: an array of length number of columns; the jth entry specifies the location of the start of the entries for the jth column in the arrays "ind" and "val".
ind: an array that contains the row indices of the non-zero entries in the matrix. The indices of the jth column must be stored consecutively starting at entry number beg[j] (there are cnt[j] entries for the jth column).
val: an array that contains the values of the non-zero entries in the matrix. The non-zero values of the jth column must be stored consecutively starting at entry number beg[j] (there are cnt[j] entries for the jth column).
Data su i resenja:
cnt[3] = { 2, 2, 1 }
beg[3] = { 0, 2, 4 }
ind[5] = { 0, 1, 0, 1, 0 }
val[5] = { 3.1, 5.0, 2.3, 1.1, 1.4 }
E, sad za niz "cnt" razumem: postoje tri kolone, pa samim tim i 3 clana niza. Clanovi niza predstavljaju brojeve ne nultih vrednosti u kolonama, dakle u prvoj koloni imamo dve ne nulte vrednosti, u drugoj takodje i u trecoj jednu. (2,2,1)
Takodje razumem i niz "val": sam niz predstavljaju vrednosti matrice, dakle: 3.1, 5.0, 2.3, 1.1, 1.4
Ono sto ne razumem jeste kako se doslo do resenja za nizove "beg" i "ind"???
Evo jos jedan primer, ali sa drugim vrednostima, pa ukoliko neko vidi vezu izmedju ova dva primera i otkrije sta predstavljaju nizovi "beg" i "ind" zamolio bih ga da postuje odgovor. Hvala unapred!
3.5 | 2.1
___ | 3.0
cnt[2] = { 1, 2 }
beg[2] = { 0, 1 }
ind[3] = { 0, 0, 1 }
val[3] = { 3.5, 2.1, 3.0 }