1#ifndef PRDC_CUDA_C_FIELD_COMPARISON_TPP
2#define PRDC_CUDA_C_FIELD_COMPARISON_TPP
11#include "CFieldComparison.h"
12#include <pscf/cuda/HostDArray.h>
28 double CFieldComparison<D>::compare(CField<D>
const& a,
33 int capacity = a.capacity();
36 HostDArray<cudaComplex> ha;
37 HostDArray<cudaComplex> hb;
38 ha.allocate(capacity);
39 hb.allocate(capacity);
46 double diffSq, diff, d0, d1;
49 for (
int i = 0; i < capacity; ++i) {
50 d0 = ha[i].x - hb[i].x;
51 d1 = ha[i].y - hb[i].y;
52 diffSq = d0*d0 + d1*d1;
54 if (diff > maxDiff_) {
59 rmsDiff_ = rmsDiff_/double(capacity);
60 rmsDiff_ = sqrt(rmsDiff_);
66 double CFieldComparison<D>::compare(
DArray< CField<D> >
const & a,
67 DArray< CField<D> >
const & b)
72 int capacity = a[0].capacity();
73 int nFields = a.capacity();
80 for (
int i = 0; i < nFields; i++) {
86 for (
int i = 0; i < nFields; i++) {
92 double diffSq, diff, d0, d1;
96 for (i = 0; i < nFields; ++i) {
97 for (j = 0; j < capacity; ++j) {
98 d0 = ha[i][j].x - hb[i][j].x;
99 d1 = ha[i][j].y - hb[i][j].y;
100 diffSq = d0*d0 + d1*d1;
102 if (diff > maxDiff_) {
108 rmsDiff_ = rmsDiff_/double(nFields*capacity);
109 rmsDiff_ = sqrt(rmsDiff_);
CFieldComparison()
Default constructor.
Dynamically allocatable contiguous array template.
void allocate(int capacity)
Allocate the underlying C array.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
PSCF package top-level namespace.