MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / cpu_norm_pq_impl

Function cpu_norm_pq_impl

test/norm.cpp:52–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50
51template<typename T>
52double cpu_norm_pq_impl(af::dim4 &dims, std::vector<T> &value, double p, double q) {
53 int N = dims[0];
54 int M = dims[1];
55
56 double norm = 0;
57 for (int n = 0; n < N; n++) {
58 T *columnN = value.data() + n * M;
59 double sum = 0;
60
61 for (int m = 0; m < M; m++) { sum += std::pow(std::abs(columnN[m]), p); }
62
63 norm += std::pow(sum, q / p);
64 }
65 norm = std::pow(norm, 1.0 / q);
66
67 return norm;
68}
69
70double cpu_norm1(af::array &value) {
71 double norm1;

Callers

nothing calls this directly

Calls 2

powFunction · 0.85
absFunction · 0.70

Tested by

no test coverage detected