次のコードでフロップの総数を最小限に抑える必要があります。だれか簡単に見て、どこに力を注ぐべきか教えてもらえますか? いくつかのパフォーマンス アナライザーを試しましたが、結果は適切ではありませんでした..
int twoDToOneD(int i, int j, int nRows)
{
return j*nRows + i;
}
double* addMatrices(int m, int n, double* A, double* B, bool add)
{
double* C = new double[m*n];
double* pA = A;
double* pB = B;
double* pC = C;
int i = m*n;
while(i--)
{
if(add)
{
*pC = *pA + *pB;
} else
{
*pC = *pA - *pB;
}
pC++;
pA++;
pB++;
}
return C;
}
ありがとう、チョー