行列の転置演算を関数として以下のように実装する。
/* 行列の転置 */
void WH_Matrix__whTrans_whM_OUT_whM
(int nRows_A, int nColumns_A, void *whM_A,
int nRows_B, int nColumns_B, void *OUT__whM_B)
/*
入力引数:
nRows_A は行列 whM_A の行数
nColumns_A は行列 whM_A の列数
whM_A は行列
nRows_B は行列 OUT__whM_B の行数
nColumns_B は行列 OUT__whM_B の列数
出力引数:
OUT__whM_B は行列で、whM_A の転置
*/
{
int i, j;
assert(nRows_B == nColumns_A);
assert(nColumns_B == nRows_A);
for (i = 0; i < nRows_B; i++) {
for (j = 0; j < nColumns_B; j++) {
WH_MATRIX__AT(OUT__whM_B, nRows_B, nColumns_B, i, j)
= WH_MATRIX__AT(whM_A, nRows_A, nColumns_A, j, i);
}
}
}