本文整理汇总了C++中Epetra_Vector::Flops方法的典型用法代码示例。如果您正苦于以下问题:C++ Epetra_Vector::Flops方法的具体用法?C++ Epetra_Vector::Flops怎么用?C++ Epetra_Vector::Flops使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Epetra_Vector
的用法示例。
在下文中一共展示了Epetra_Vector::Flops方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: powerMethodTests
int powerMethodTests(Epetra_RowMatrix & A, Epetra_RowMatrix & JadA, Epetra_Map & Map,
Epetra_Vector & q, Epetra_Vector & z, Epetra_Vector & resid, bool verbose) {
// variable needed for iteration
double lambda = 0.0;
// int niters = 10000;
int niters = 300;
double tolerance = 1.0e-2;
int ierr = 0;
/////////////////////////////////////////////////////////////////////////////////////////////////
// Iterate
Epetra_Time timer(Map.Comm());
double startTime = timer.ElapsedTime();
EPETRA_TEST_ERR(power_method(false, A, q, z, resid, &lambda, niters, tolerance, verbose),ierr);
double elapsed_time = timer.ElapsedTime() - startTime;
double total_flops = q.Flops();
double MFLOPs = total_flops/elapsed_time/1000000.0;
double lambdaref = lambda;
double flopsref = total_flops;
if (verbose)
cout << "\n\nTotal MFLOPs for reference first solve = " << MFLOPs << endl
<< "Total FLOPS = " <<total_flops <<endl<<endl;
lambda = 0.0;
startTime = timer.ElapsedTime();
EPETRA_TEST_ERR(power_method(false, JadA, q, z, resid, &lambda, niters, tolerance, verbose),ierr);
elapsed_time = timer.ElapsedTime() - startTime;
total_flops = q.Flops();
MFLOPs = total_flops/elapsed_time/1000000.0;
if (verbose)
cout << "\n\nTotal MFLOPs for candidate first solve = " << MFLOPs << endl
<< "Total FLOPS = " <<total_flops <<endl<<endl;
EPETRA_TEST_ERR(checkValues(lambda,lambdaref," No-transpose Power Method result", verbose),ierr);
EPETRA_TEST_ERR(checkValues(total_flops,flopsref," No-transpose Power Method flop count", verbose),ierr);
/////////////////////////////////////////////////////////////////////////////////////////////////
// Solve transpose problem
if (verbose) cout << "\n\nUsing transpose of matrix and solving again (should give same result).\n\n"
<< endl;
// Iterate
lambda = 0.0;
startTime = timer.ElapsedTime();
EPETRA_TEST_ERR(power_method(true, A, q, z, resid, &lambda, niters, tolerance, verbose),ierr);
elapsed_time = timer.ElapsedTime() - startTime;
total_flops = q.Flops();
MFLOPs = total_flops/elapsed_time/1000000.0;
lambdaref = lambda;
flopsref = total_flops;
if (verbose)
cout << "\n\nTotal MFLOPs for reference transpose solve = " << MFLOPs << endl
<< "Total FLOPS = " <<total_flops <<endl<<endl;
lambda = 0.0;
startTime = timer.ElapsedTime();
EPETRA_TEST_ERR(power_method(true, JadA, q, z, resid, &lambda, niters, tolerance, verbose),ierr);
elapsed_time = timer.ElapsedTime() - startTime;
total_flops = q.Flops();
MFLOPs = total_flops/elapsed_time/1000000.0;
if (verbose)
cout << "\n\nTotal MFLOPs for candidate transpose solve = " << MFLOPs << endl
<< "Total FLOPS = " <<total_flops <<endl<<endl;
EPETRA_TEST_ERR(checkValues(lambda,lambdaref,"Transpose Power Method result", verbose),ierr);
EPETRA_TEST_ERR(checkValues(total_flops,flopsref,"Transpose Power Method flop count", verbose),ierr);
EPETRA_TEST_ERR(check(A, JadA, verbose),ierr);
return(0);
}