From 5750d0cc7616a9510dc69027ede9bf7002bd4ca6 Mon Sep 17 00:00:00 2001 From: david-cortes Date: Mon, 26 Jun 2023 20:44:52 +0200 Subject: [PATCH] more efficient looping for transposes --- src/helpers.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/helpers.c b/src/helpers.c index a917c93..8ed2a6b 100644 --- a/src/helpers.c +++ b/src/helpers.c @@ -1263,8 +1263,8 @@ void sum_mat void transpose_mat2(real_t *restrict A, size_t m, size_t n, real_t *restrict outp) { - for (size_t row = 0; row < m; row++) - for (size_t col = 0; col < n; col++) + for (size_t col = 0; col < n; col++) + for (size_t row = 0; row < m; row++) outp[row + col*m] = A[col + row*n]; } @@ -1275,8 +1275,8 @@ void transpose_mat3 real_t *restrict outp, size_t ldb ) { - for (size_t row = 0; row < m; row++) - for (size_t col = 0; col < n; col++) + for (size_t col = 0; col < n; col++) + for (size_t row = 0; row < m; row++) outp[row + col*ldb] = A[col + row*lda]; }