public void updateD(final double[] D) {
    int h,i,j,k,l,m=a.nrows,n=a.ncols;
    double[] temp = new double[n];
    double[] temp2 = new double[m];
    for (i=0;i<m;i++) {
      for (j=at.col_ptr[i];j< at.col_ptr[i+1];j++) {
        k=at.row_ind[j];
        temp[k]=at.val[j]*D[k];
      }
      for (j=at.col_ptr[i];j<at.col_ptr[i+1];j++) {
        k=at.row_ind[j];
        for (l=a.col_ptr[k];l<a.col_ptr[k+1];l++) {
          h=a.row_ind[l];
          temp2[h] += temp[k]*a.val[l];
        }
      }
      for (j=adat.col_ptr[i];j<adat.col_ptr[i+1];j++) {
        k=adat.row_ind[j];
        adat.val[j]=temp2[k];
        temp2[k]=0.0;
      }
    }
  }