1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
...
int arrN[] = { 100, 500, 968, 1000, 2000, 3000, 5000 };
int nSize = sizeof(arrN[0])/sizeof(int);
cout << "Jacobi:" << endl;
for (int i = 0; i < nSize; i++) {
Rownanie X(arrN[i]);
cout << "N = " << arrN[i] << " czas: " << countTime(X, &Rownanie::initA, &Rownanie::metodaJacobiego) << "s" << endl;
}
cout << endl << "Gauss-Seidl:" << endl;
for (int i = 0; i < nSize; i++) {
Rownanie X(arrN[i]);
cout << "N = " << arrN[i] << " czas: " << countTime(X, &Rownanie::initA, &Rownanie::metodaGaussaSeidla) << "s" << endl;
}
cout << endl << "LU:" << endl;
for (int i = 0; i < nSize; i++) {
Rownanie X(arrN[i]);
cout << "N = " << arrN[i] << " czas: " << countTime(X, &Rownanie::initA, &Rownanie::metodaLU) << "s" << endl;
}
return 0;
}
float countTime(Rownanie& eq, void(Rownanie::* initF)(), double(Rownanie::* methodF)())
{
(eq.*initF)();
int start = clock();
cout << "Norma: " << (eq.*methodF)() << ". ";
return (float)(clock() - start) / CLOCKS_PER_SEC;
}
|