I need to minimize the total amount of flops in the following code, can anyone please take a quick look and tell me where to put my effort? I've tried several perfomance analyzers, but the results were irrelevant..
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;
}
Thanks, Cho