cpp: void init_array(int ni, int nj,\nDATA_TYPE POLYBENCH_2D(A,NI,NJ,ni,nj),\nDATA_TYPE POLYBENCH_2D(R,NJ,NJ,nj,nj),\nDATA_TYPE POLYBENCH_2D(Q,NI,NJ,ni,nj))\n{\nint i, j;\n\nfor (i = 0; i < ni; i++)\nfor (j = 0; j < nj; j++) {\nA[i][j] = ((DATA_TYPE) i*j) / ni;\nQ[i][j] = ((DATA_TYPE) i*(j+1)) / nj;\n}\nfor (i = 0; i < nj; i++)\nfor (j = 0; j < nj; j++)\nR[i][j] = ((DATA_TYPE) i*(j+2)) / nj;\n}
fortran: subroutine init_array(ni, nj, a, r, q)\nimplicit none\n\nDATA_TYPE, dimension(nj, ni) :: a\nDATA_TYPE, dimension(nj, nj) :: r\nDATA_TYPE, dimension(nj, ni) :: q\ninteger :: ni, nj\ninteger :: i, j\n\ndo i = 1, ni\ndo j = 1, nj\na(j, i) = (DBLE(i - 1) * DBLE(j - 1)) / DBLE(ni)\nq(j, i) = (DBLE(i - 1) * DBLE(j)) / DBLE(nj)\nend do\nend do\n\ndo i = 1, ni\ndo j = 1, nj\nr(j, i) = (DBLE(i - 1) * DBLE(j + 1)) / DBLE(nj)\nend do\nend do\nend subroutine