#include "cg.h"

__kernel void makea_6(__global double *a,
                      __global double *v,
                      __global int *rowstr,
                      __global int *colidx,
                      __global int *iv,
                      int nz,
                      int nrows)
{
  int j1, j2, nza;
  int j = get_global_id(0);
  if (j >= nrows) return;

  __global int *nzloc = &iv[nz];

  if (j > 0) {
    j1 = rowstr[j] - nzloc[j-1];
  } else {
    j1 = 0;
  }
  j2 = rowstr[j+1] - nzloc[j];
  nza = rowstr[j];
  for (int k = j1; k < j2; k++) {
    a[k] = v[nza];
    colidx[k] = iv[nza];
    nza = nza + 1;
  }
}

