feat(mat4): add arm to transpose function

This commit is contained in:
2025-08-07 08:09:24 +02:00
parent 2b1e00305c
commit 8a4fbd8449

View File

@@ -254,7 +254,36 @@ Mat4f_t* mat4f_tpo_r(Mat4f_t *__restrict out)
#elif defined (SIMD_ARCH) #elif defined (SIMD_ARCH)
float32x4_t row[4];
for (int i = 0; i < MAT_DIM; i++) {
row[i] = vld1q_f32(&clone.m[i * MAT_DIM]);
}
float32x4x2_t t01 = vtrnq_f32(row[0], row[1]);
float32x4x2_t t23 = vtrnq_f32(row[2], row[3]);
float32x2_t r0_low = vget_low_f32(t01.val[0]);
float32x2_t r0_high = vget_low_f32(t23.val[0]);
float32x4_t r0 = vcombine_f32(r0_low, r0_high);
float32x2_t r1_low = vget_low_f32(t01.val[1]);
float32x2_t r1_high = vget_low_f32(t23.val[1]);
float32x4_t r1 = vcombine_f32(r1_low, r1_high);
float32x2_t r2_low = vget_high_f32(t01.val[0]);
float32x2_t r2_high = vget_high_f32(t23.val[0]);
float32x4_t r2 = vcombine_f32(r2_low, r2_high);
float32x2_t r3_low = vget_high_f32(t01.val[1]);
float32x2_t r3_high = vget_high_f32(t23.val[1]);
float32x4_t r3 = vcombine_f32(r3_low, r3_high);
vst1q_f32(&out->m[0 * MAT_DIM], r0);
vst1q_f32(&out->m[1 * MAT_DIM], r1);
vst1q_f32(&out->m[2 * MAT_DIM], r2);
vst1q_f32(&out->m[3 * MAT_DIM], r3);
#else #else
for(int i = 0; i < MAT_DIM; i++) { for(int i = 0; i < MAT_DIM; i++) {
int dim_i = i * MAT_DIM; int dim_i = i * MAT_DIM;