* @brief Flip a matrix horizontally or vertically. * @param a The matrix to flip. * @param R The number of rows in the matrix. * @param C The number of columns in the matrix. * @param horizontal Whether to flip horizontally (true) or vertically (false). */
| 289 | * @param horizontal Whether to flip horizontally (true) or vertically (false). |
| 290 | */ |
| 291 | inline void flip(float *a, size_t R, size_t C, bool horizontal = true) { |
| 292 | if (horizontal) { |
| 293 | for (size_t i = 0; i < R; i++) { |
| 294 | for (size_t j = 0; j < C / 2; j++) { |
| 295 | std::swap(a[i * C + j], a[i * C + C - j - 1]); |
| 296 | } |
| 297 | } |
| 298 | } else { |
| 299 | for (size_t i = 0; i < R / 2; i++) { |
| 300 | for (size_t j = 0; j < C; j++) { |
| 301 | std::swap(a[i * C + j], a[(R - i - 1) * C + j]); |
| 302 | } |
| 303 | } |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | /** |
| 308 | * @brief Determine if the values of two arrays are close to each other. |
nothing calls this directly
no outgoing calls
no test coverage detected