| 150 | char *LogFileName = getenv("MEEP_ARRAY_METADATA_LOGFILE"); |
| 151 | FILE *LogFile = (LogFileName ? fopen(LogFileName, "w") : 0); |
| 152 | LOOP_OVER_IVECS(gv, is, ie, idx) { |
| 153 | // get the (correct) coordinates and weight for the current grid point, |
| 154 | // or (for collapsed dimensions) the sum of the weights of the two |
| 155 | // points from which we interpolate to get values at the array slice coordinate |
| 156 | double xyzw_loop[4] = {0.0, 0.0, 0.0, 0.0}; |
| 157 | IVEC_LOOP_LOC(gv, loc); |
| 158 | xyzw_loop[0] = has_direction(gv.dim, X) ? loc.x() : 0.0; |
| 159 | xyzw_loop[1] = has_direction(gv.dim, Y) ? loc.y() : 0.0; |
| 160 | xyzw_loop[2] = has_direction(gv.dim, Z) ? loc.z() : 0.0; |
| 161 | xyzw_loop[3] = IVEC_LOOP_WEIGHT(s0, s1, e0, e1, dV0 + dV1 * loop_i2); |
| 162 | |
| 163 | // coordinates and weight for current grid point according to metadata |
| 164 | double xyzw_meta[4] = {0.0, 0.0, 0.0, 0.0}; |
| 165 | IVEC_LOOP_ILOC(gv, iloc); |
| 166 | ivec two_n = iloc - is; |
| 167 | int nx = 0, ny = 0, nz = 0, index = 0; |
| 168 | if (has_direction(gv.dim, X)) { |
| 169 | nx = two_n.in_direction(X) / 2; |
| 170 | xyzw_meta[0] = tics[0][nx]; |
| 171 | index += nx * stride[0]; |
| 172 | } |
| 173 | if (has_direction(gv.dim, Y)) { |
| 174 | ny = two_n.in_direction(Y) / 2; |
| 175 | xyzw_meta[1] = tics[1][ny]; |
| 176 | index += ny * stride[1]; |
| 177 | } |
| 178 | if (has_direction(gv.dim, Z)) { |
| 179 | nz = two_n.in_direction(Z) / 2; |
| 180 | xyzw_meta[2] = tics[2][nz]; |
| 181 | index += nz * stride[2]; |
| 182 | } |
| 183 | xyzw_meta[3] = weights[index]; |
| 184 | |
| 185 | bool mismatch = !equal_float(xyzw_loop, xyzw_meta, 4); |
| 186 | if (mismatch) num_mismatches++; |
| 187 | if (LogFile) { |
| 188 | fprintf(LogFile, "%i %i ", num_points++, mismatch ? 0 : 1); |
| 189 | fprintf(LogFile, "%e %e %e %e ", xyzw_loop[0], xyzw_loop[1], xyzw_loop[2], xyzw_loop[3]); |
| 190 | fprintf(LogFile, "%e %e %e %e ", xyzw_meta[0], xyzw_meta[1], xyzw_meta[2], xyzw_meta[3]); |
| 191 | fprintf(LogFile, "\n"); |
| 192 | } |
| 193 | |
| 194 | } // LOOP_OVER_IVECS(gv, is, ie, idx) |
| 195 | if (LogFile) fclose(LogFile); |
| 196 | printf("%i/%i mismatches\n", num_mismatches, num_points); |
| 197 | return (num_mismatches == 0); |
nothing calls this directly
no test coverage detected