cpp: void kernel_gramschmidt(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, k;\n\nDATA_TYPE nrm;\n\n#pragma scop\nfor (k = 0; k < _PB_NJ; k++)\n{\nnrm = 0;\nfor (i = 0; i < _PB_NI; i++)\nnrm += A[i][k] * A[i][k];\nR[k][k] = sqrt(nrm);\nfor (i = 0; i < _PB_NI; i++)\nQ[i][k] = A[i][k] / R[k][k];\nfor (j = k + 1; j < _PB_NJ; j++)\n{\nR[k][j] = 0;\nfor (i = 0; i < _PB_NI; i++)\nR[k][j] += Q[i][k] * A[i][j];\nfor (i = 0; i < _PB_NI; i++)\nA[i][j] = A[i][j] - Q[i][k] * R[k][j];\n}\n}\n#pragma endscop\n\n}
fortran: subroutine kernel_gramschmidt(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\nDATA_TYPE :: nrm\ninteger :: ni, nj\ninteger :: i, j, k\n\n!$pragma scop\ndo k = 1, _PB_NJ\nnrm = 0.0D0\ndo i = 1, _PB_NI\nnrm = nrm + (a(k, i) * a(k, i))\nend do\nr(k, k) = sqrt(nrm)\ndo i = 1, _PB_NI\nq(k, i) = a(k, i) / r(k, k)\nend do\ndo j = k + 1, _PB_NJ\nr(j, k) = 0.0D0\ndo i = 1, _PB_NI\nr(j, k) = r(j, k) + (q(k, i) * a(j, i))\nend do\ndo i = 1, _PB_NI\na(j, i) = a(j, i) - (q(k, i) * r(j, k))\nend do\nend do\nend do\n!$pragma endscop\nend subroutine