-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify.h
More file actions
31 lines (25 loc) · 1.09 KB
/
verify.h
File metadata and controls
31 lines (25 loc) · 1.09 KB
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
29
30
31
#pragma once
#include <cstddef>
#include <cstdint>
#include <cufft.h>
#include <vector>
namespace sbfft {
// Aggregate statistics over a complex N x N output. Computed on device.
struct OutputStats {
double sum_sq_mag = 0; // SIGMA |Y[u,v]|^2 (Parseval check: equals N^2 * K)
float max_mag = 0.f;
double mean_mag = 0.0;
};
// Compute aggregate stats from a device-resident N x N complex array.
OutputStats compute_stats(const cufftComplex* d_out, size_t N);
// Compute max absolute element-wise difference between two host arrays of
// length len. Returns max |a[i] - b[i]| measured on the complex magnitude
// of the element difference (so it's robust to phase-only error reporting).
double max_abs_diff(const std::vector<cufftComplex>& a,
const std::vector<cufftComplex>& b);
// Parseval's identity for a binary input matrix with K ones produces:
// SIGMA_uv |Y[u,v]|^2 = N^2 * K
// for the un-normalized forward DFT. Returns the relative error.
double parseval_relative_error(const OutputStats& stats,
int N, int64_t nnz);
} // namespace sbfft