Ponca  aa50bfdf187919869239c5b44b748842569114c1
Point Cloud Analysis library
Loading...
Searching...
No Matches
weightKernel.h
1/*
2 This Source Code Form is subject to the terms of the Mozilla Public
3 License, v. 2.0. If a copy of the MPL was not distributed with this
4 file, You can obtain one at http://mozilla.org/MPL/2.0/.
5*/
6
7#pragma once
8
9#include "./defines.h"
10
16namespace Ponca
17{
23template <typename _Scalar>
25{
26public:
28 typedef _Scalar Scalar;
29
30 // Init
32 PONCA_MULTIARCH inline ConstantWeightKernel(const Scalar& _value = Scalar(1.)) : m_y(_value){}
34 PONCA_MULTIARCH inline void setValue(const Scalar& _value){ m_y = _value; }
35
36 // Functor
38 PONCA_MULTIARCH inline Scalar f (const Scalar&) const { return m_y; }
40 PONCA_MULTIARCH inline Scalar df (const Scalar&) const { return Scalar(0.); }
42 PONCA_MULTIARCH inline Scalar ddf(const Scalar&) const { return Scalar(0.); }
43
45 static constexpr bool isDValid = true;
47 static constexpr bool isDDValid = true;
48
49private:
50 Scalar m_y;
51};// class ConstantWeightKernel
52
53
60template <typename _Scalar>
62{
63public:
65 typedef _Scalar Scalar;
66
67 // Functor
69 PONCA_MULTIARCH inline Scalar f (const Scalar& _x) const { Scalar v = _x*_x - Scalar(1.); return v*v; }
71 PONCA_MULTIARCH inline Scalar df (const Scalar& _x) const { return Scalar(4.)*_x*(_x*_x-Scalar(1.)); }
73 PONCA_MULTIARCH inline Scalar ddf(const Scalar& _x) const { return Scalar(12.)*_x*_x - Scalar(4.); }
75 static constexpr bool isDValid = true;
77 static constexpr bool isDDValid = true;
78};//class SmoothWeightKernel
79
80
89template <typename _Scalar>
91{
92public:
94 typedef _Scalar Scalar;
95
96 // Functor
98 PONCA_MULTIARCH inline Scalar f (const Scalar& _x) const {
99 const Scalar v = Scalar(1.) - _x;
100 return v * v * v * v * ((Scalar(4.) * _x) + Scalar(1.));
101 }
103 PONCA_MULTIARCH inline Scalar df (const Scalar& _x) const {
104 const Scalar v = _x - Scalar(1.);
105 return Scalar(20.) * _x * v * v * v;
106 }
108 PONCA_MULTIARCH inline Scalar ddf(const Scalar& _x) const {
109 const Scalar v = _x - Scalar(1.);
110 return v * v * (Scalar(80.) * _x - Scalar(20));
111 }
113 static constexpr bool isDValid = true;
115 static constexpr bool isDDValid = true;
116};//class WendlandWeightKernel
117
118
127template <typename _Scalar>
129{
130public:
132 typedef _Scalar Scalar;
133
134 // Functor
136 PONCA_MULTIARCH inline Scalar f (const Scalar& _x) const {
137 return Scalar(1.) / (_x * _x);
138 }
140 PONCA_MULTIARCH inline Scalar df (const Scalar& _x) const {
141 return Scalar(-2.) / (_x * _x * _x);
142 }
144 PONCA_MULTIARCH inline Scalar ddf(const Scalar& _x) const {
145 return Scalar(6.) / (_x * _x * _x * _x);
146 }
148 static constexpr bool isDValid = true;
150 static constexpr bool isDDValid = true;
151};//class SingularWeightKernel
152
153
163template <typename _Scalar>
165{
166public:
168 typedef _Scalar Scalar;
169
170 // Functor
174 PONCA_MULTIARCH inline Scalar f (const Scalar& _x) const { Scalar v = _x*_x; return exp(-v/(Scalar(1)-v)); }
178 PONCA_MULTIARCH inline Scalar df (const Scalar& _x) const { Scalar v = _x*_x; Scalar mv = v-Scalar(1); return -(Scalar(2) * exp(v/mv) * _x)/(mv*mv); }
183 PONCA_MULTIARCH inline Scalar ddf(const Scalar& _x) const {
184 Scalar v = _x*_x; // x^2
185 Scalar mv = v-Scalar(1); // x^2-1
186 Scalar mvpow = Scalar(2)/mv; // 2/(x^2-1)
187 Scalar cmvpow = pow(_x,mvpow); // x^{2/(x^2-1)}
188 return Scalar(2) * exp(cmvpow) * ((Scalar(4) * pow(_x,mvpow + Scalar(2)) * log(_x) - mv * (-Scalar(3) * v + Scalar(2) * cmvpow - Scalar(1))))/(mv*mv*mv*mv);
189 }
190
192 static constexpr bool isDValid = true;
194 static constexpr bool isDDValid = false;
195};//class CompactExpWeightKernel
196
197
198}// namespace Ponca
Compact Exponential WeightKernel defined in .
Definition: weightKernel.h:165
Scalar f(const Scalar &_x) const
Defines the smooth weighting function .
Definition: weightKernel.h:174
static constexpr bool isDValid
df is defined and valid on the definition interval
Definition: weightKernel.h:192
static constexpr bool isDDValid
ddf is not defined and valid on the definition interval
Definition: weightKernel.h:194
Scalar ddf(const Scalar &_x) const
Defines the smooth second order weighting function .
Definition: weightKernel.h:183
_Scalar Scalar
Scalar type defined outside the class.
Definition: weightKernel.h:168
Scalar df(const Scalar &_x) const
Defines the smooth first order weighting function .
Definition: weightKernel.h:178
Concept::WeightKernelConcept returning a constant value.
Definition: weightKernel.h:25
static constexpr bool isDDValid
ddf is defined and valid on the definition interval
Definition: weightKernel.h:47
Scalar df(const Scalar &) const
Return .
Definition: weightKernel.h:40
Scalar ddf(const Scalar &) const
Return .
Definition: weightKernel.h:42
Scalar f(const Scalar &) const
Return the constant value.
Definition: weightKernel.h:38
static constexpr bool isDValid
df is defined and valid on the definition interval
Definition: weightKernel.h:45
void setValue(const Scalar &_value)
Set the returned value.
Definition: weightKernel.h:34
_Scalar Scalar
Scalar type defined outside the class.
Definition: weightKernel.h:28
ConstantWeightKernel(const Scalar &_value=Scalar(1.))
Default constructor that could be used to set the returned value.
Definition: weightKernel.h:32
Singular WeightKernel defined in .
Definition: weightKernel.h:129
Scalar ddf(const Scalar &_x) const
Defines the Singular second order weighting function .
Definition: weightKernel.h:144
static constexpr bool isDDValid
ddf is defined and valid on the definition interval
Definition: weightKernel.h:150
Scalar df(const Scalar &_x) const
Defines the Singular first order weighting function .
Definition: weightKernel.h:140
Scalar f(const Scalar &_x) const
Defines the Singular weighting function .
Definition: weightKernel.h:136
_Scalar Scalar
Scalar type defined outside the class.
Definition: weightKernel.h:132
static constexpr bool isDValid
df is defined and valid on the definition interval
Definition: weightKernel.h:148
Smooth WeightKernel defined in .
Definition: weightKernel.h:62
Scalar df(const Scalar &_x) const
Defines the smooth first order weighting function .
Definition: weightKernel.h:71
Scalar f(const Scalar &_x) const
Defines the smooth weighting function .
Definition: weightKernel.h:69
static constexpr bool isDValid
df is defined and valid on the definition interval
Definition: weightKernel.h:75
static constexpr bool isDDValid
ddf is defined and valid on the definition interval
Definition: weightKernel.h:77
Scalar ddf(const Scalar &_x) const
Defines the smooth second order weighting function .
Definition: weightKernel.h:73
_Scalar Scalar
Scalar type defined outside the class.
Definition: weightKernel.h:65
Wendland WeightKernel defined in .
Definition: weightKernel.h:91
_Scalar Scalar
Scalar type defined outside the class.
Definition: weightKernel.h:94
static constexpr bool isDValid
df is defined and valid on the definition interval
Definition: weightKernel.h:113
static constexpr bool isDDValid
ddf is defined and valid on the definition interval
Definition: weightKernel.h:115
Scalar df(const Scalar &_x) const
Defines the Wendland first order weighting function .
Definition: weightKernel.h:103
Scalar ddf(const Scalar &_x) const
Defines the Wendland second order weighting function .
Definition: weightKernel.h:108
Scalar f(const Scalar &_x) const
Defines the Wendland weighting function .
Definition: weightKernel.h:98
This Source Code Form is subject to the terms of the Mozilla Public License, v.