Loading...
Searching...
No Matches
GaussianEnvironmentWeights.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// Copyright (c) gpridge developers
3#pragma once
4
5// The work items run on the host everywhere. A device compiler that also
6// builds them for its own execution space needs the portability qualifier.
7#ifndef GPR_ENVIRONMENT_FUNCTION
8#if defined(__CUDACC__) || defined(__HIPCC__)
9#define GPR_ENVIRONMENT_FUNCTION __host__ __device__
10#else
11#define GPR_ENVIRONMENT_FUNCTION
12#endif
13#endif
14
15namespace gpr::detail {
16
19struct GaussianEnvironmentWeights {
20 double distance;
21 double kernel;
22
23 GPR_ENVIRONMENT_FUNCTION constexpr double energy(
24 bool derivative) const noexcept
25 {
26 return derivative ? distance : 1.0;
27 }
28 GPR_ENVIRONMENT_FUNCTION constexpr double gradient(
29 bool derivative) const noexcept
30 {
31 return derivative ? distance - 2.0 : 1.0;
32 }
33 GPR_ENVIRONMENT_FUNCTION constexpr double product(
34 bool derivative) const noexcept
35 {
36 return derivative ? distance - 4.0 : 1.0;
37 }
38};
39
40} // namespace gpr::detail
#define GPR_ENVIRONMENT_FUNCTION