// 転置行列を得る関数
void transpose_matrix(const float *mat_b,
                            float *mat_b_trans)
{
    int x, y;
    
    for (y = 0; y < N; y++) {
        for (x = 0; x < N; x++) {
            mat_b_trans_(y, x) = mat_b_(x, y);
        }
    }
}

// 4x4 行列の掛け算を計算する関数：メモリ・アクセス改善版
void mat_mul_opt(const float *mat_a,
            const float *mat_b_trans, float *mat_c)
{
    int x, y;
    
    for (y = 0; y < N; y++) {
        for (x = 0; x < N; x++) {
            mat_c_(x, y) = dot_product(&mat_a_(
                       0, y), &mat_b_trans_(0, x));
        }
    }
}

// floatx4 ベクトルの内積を求める下請け関数：メモリ・アクセス改善版
INLINE float dot_product(const float *a, const float *b)
{
    return a[0] * b[0] +
           a[1] * b[1] +
           a[2] * b[2] +
           a[3] * b[3];
}
