Sparse Data Patterns
Coordinate Row Sum
Grouping Sparse Entries
Coordinate sparse storage keeps row, column, and value arrays side by side.
Program
Play the program to sum entries from a different sparse row.
coordinate_row_sum.f90
program coordinate_row_sum_demo
implicit none
integer :: rows(4)
integer :: cols(4)
integer :: values(4)
integer :: target_row
integer :: i
integer :: count
integer :: total
rows = [1, 2, 2, 3]
cols = [1, 1, 3, 2]
values = [5, 7, 4, 6]
target_row =
count = 0
total = 0
do i = 1, 4
if (rows(i) == target_row) then
count = count + 1
total = total + values(i)
end if
end do
print '(I0, 1X, I0, 1X, I0)', target_row, count, total
end program coordinate_row_sum_demo
program coordinate_row_sum_demo
implicit none
integer :: rows(4)
integer :: cols(4)
integer :: values(4)
integer :: target_row
integer :: i
integer :: count
integer :: total
rows = [1, 2, 2, 3]
cols = [1, 1, 3, 2]
values = [5, 7, 4, 6]
target_row =
count = 0
total = 0
do i = 1, 4
if (rows(i) == target_row) then
count = count + 1
total = total + values(i)
end if
end do
print '(I0, 1X, I0, 1X, I0)', target_row, count, total
end program coordinate_row_sum_demo
program coordinate_row_sum_demo
implicit none
integer :: rows(4)
integer :: cols(4)
integer :: values(4)
integer :: target_row
integer :: i
integer :: count
integer :: total
rows = [1, 2, 2, 3]
cols = [1, 1, 3, 2]
values = [5, 7, 4, 6]
target_row =
count = 0
total = 0
do i = 1, 4
if (rows(i) == target_row) then
count = count + 1
total = total + values(i)
end if
end do
print '(I0, 1X, I0, 1X, I0)', target_row, count, total
end program coordinate_row_sum_demo
coordinate arrays
`rows`, `cols`, and `values` describe each stored entry.
row filter
Only entries whose row matches `target_row` contribute to the summary.
sparse row total
`count` and `total` describe the selected sparse row.