Calculate rowSums in Chapel for a matrix
Continuing my Chapel adventures... I have a matrix A. var idx = {1..n}; var adom = {idx, idx}; var A: [adom] int; //populate A; var rowsums: [idx] int; What is the most efficient way to populate rowsums? The most efficient solution is hard to define. However, here is one way to compute rowsums that is both parallel and elegant: config const n = 8; // "naked" n would cause compilation to fail const indices = 1..n; // tio.chpl:1: error: 'n' undeclared (first use this function) const adom = {indices, indices}; var A: [adom] int; // Populate A [(i,j) in adom] A[i, j] = i*j; var rowsums: [indices]