MCPcopy Create free account
hub / github.com/AnswerDotAI/gpu.cpp / flip

Function flip

utils/array_utils.hpp:291–305  ·  view source on GitHub ↗

* @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). */

Source from the content-addressed store, hash-verified

289 * @param horizontal Whether to flip horizontally (true) or vertically (false).
290 */
291inline 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.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected