本文整理汇总了C++中CollOfScalar::copyToHost方法的典型用法代码示例。如果您正苦于以下问题:C++ CollOfScalar::copyToHost方法的具体用法?C++ CollOfScalar::copyToHost怎么用?C++ CollOfScalar::copyToHost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CollOfScalar
的用法示例。
在下文中一共展示了CollOfScalar::copyToHost方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compare
int compare(CollOfScalar scal, double sol[],
int sol_size,
std::string test)
{
// Test size:
if ( scal.size() != sol_size ) {
std::cout << "Error in valsOnGrid.cpp - testing " << test << "\n";
std::cout << "\tThe collection is of wrong size!\n";
std::cout << "\tSize is " << scal.size() << " but should be " << sol_size << "\n";
return 1;
}
// Testing indices
std::vector<double> host = scal.copyToHost();
std::cout << "CollOfScalar " << test << " is the following:\n";
bool correct = true;
for (int i = 0; i < host.size(); ++i) {
std::cout << host[i] << " ";
if (i < sol_size) {
//if (host[i] != sol[i]) {
if ( fabs(host[i] - sol[i]) > 1000*std::numeric_limits<double>::epsilon() ) {
std::cout << "(<- " << sol[i] << ") ";
correct = false;
}
}
}
if (correct) {
std::cout << "\n\tThis is correct\n";
} else {
std::cout << "\n\tThis is wrong\n";
std::cout << "Error in valsOnGrid.cpp - testing " << test << "\n";
std::cout << "\tThe indices in the collection is wrong\n";
return 1;
}
return 0;
}