Ponca  40f245e28b920cbb763a1c6282156c87c626f24c
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#pragma once
7
8#include "./defines.h"
9#include PONCA_MULTIARCH_INCLUDE_CU_STD(cmath)
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
85template <typename _Scalar, int m, int n>
87{
88public:
89
91 typedef _Scalar Scalar;
92 // Functor
94 PONCA_MULTIARCH inline Scalar f (const Scalar& _x) const {
95 PONCA_MULTIARCH_STD_MATH(pow);
96 return pow(
97 pow(_x, Scalar(n)) - Scalar(1.),
98 Scalar(m)
99 );
100 }
102 PONCA_MULTIARCH inline Scalar df (const Scalar& _x) const {
103 PONCA_MULTIARCH_STD_MATH(pow);
104 return pow(
105 Scalar(m*n)*_x,
106 Scalar(n-1)) * pow(pow(_x, Scalar(n)) -1, Scalar(m-1)
107 );
108 }
110 PONCA_MULTIARCH inline Scalar ddf(const Scalar& _x) const {
111 PONCA_MULTIARCH_STD_MATH(pow);
112 return Scalar((m-1)*m*n*n)
113 * pow( _x, Scalar(2*n-2))
114 * pow(
115 pow(_x, Scalar(n))-Scalar(1),
116 Scalar(m-2)
117 )
118 + Scalar(m*(n-1)*n)
119 * pow(
120 _x,
121 Scalar(n-2)
122 )
123 * pow(
124 pow(_x, Scalar(n))-Scalar(1),
125 Scalar(m-1)
126 );
127 }
129 static constexpr bool isDValid = true;
131 static constexpr bool isDDValid = true;
132};//class PolynomialSmoothWeightKernel
133
142template <typename _Scalar>
144{
145public:
147 typedef _Scalar Scalar;
148
149 // Functor
151 PONCA_MULTIARCH inline Scalar f (const Scalar& _x) const {
152 const Scalar v = Scalar(1.) - _x;
153 return v * v * v * v * ((Scalar(4.) * _x) + Scalar(1.));
154 }
156 PONCA_MULTIARCH inline Scalar df (const Scalar& _x) const {
157 const Scalar v = _x - Scalar(1.);
158 return Scalar(20.) * _x * v * v * v;
159 }
161 PONCA_MULTIARCH inline Scalar ddf(const Scalar& _x) const {
162 const Scalar v = _x - Scalar(1.);
163 return v * v * (Scalar(80.) * _x - Scalar(20));
164 }
166 static constexpr bool isDValid = true;
168 static constexpr bool isDDValid = true;
169};//class WendlandWeightKernel
170
171
180template <typename _Scalar>
182{
183public:
185 typedef _Scalar Scalar;
186
187 // Functor
189 PONCA_MULTIARCH inline Scalar f (const Scalar& _x) const {
190 return Scalar(1.) / (_x * _x);
191 }
193 PONCA_MULTIARCH inline Scalar df (const Scalar& _x) const {
194 return Scalar(-2.) / (_x * _x * _x);
195 }
197 PONCA_MULTIARCH inline Scalar ddf(const Scalar& _x) const {
198 return Scalar(6.) / (_x * _x * _x * _x);
199 }
201 static constexpr bool isDValid = true;
203 static constexpr bool isDDValid = true;
204};//class SingularWeightKernel
205
206
216template <typename _Scalar>
218{
219public:
221 typedef _Scalar Scalar;
222
223 // Functor
227 PONCA_MULTIARCH inline Scalar f (const Scalar& _x) const { Scalar v = _x*_x; return exp(-v/(Scalar(1)-v)); }
231 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); }
236 PONCA_MULTIARCH inline Scalar ddf(const Scalar& _x) const {
237 Scalar v = _x*_x; // x^2
238 Scalar mv = v-Scalar(1); // x^2-1
239 Scalar mvpow = Scalar(2)/mv; // 2/(x^2-1)
240 Scalar cmvpow = pow(_x,mvpow); // x^{2/(x^2-1)}
241 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);
242 }
243
245 static constexpr bool isDValid = true;
247 static constexpr bool isDDValid = false;
248};//class CompactExpWeightKernel
249
250
251}// namespace Ponca
Compact Exponential WeightKernel defined in .
Scalar f(const Scalar &_x) const
Defines the smooth weighting function .
static constexpr bool isDValid
df is defined and valid on the definition interval
static constexpr bool isDDValid
ddf is not defined and valid on the definition interval
Scalar ddf(const Scalar &_x) const
Defines the smooth second order weighting function .
_Scalar Scalar
Scalar type defined outside the class.
Scalar df(const Scalar &_x) const
Defines the smooth first order weighting function .
Concept::WeightKernelConcept returning a constant value.
static constexpr bool isDDValid
ddf is defined and valid on the definition interval
Scalar df(const Scalar &) const
Return .
Scalar ddf(const Scalar &) const
Return .
Scalar f(const Scalar &) const
Return the constant value.
static constexpr bool isDValid
df is defined and valid on the definition interval
void setValue(const Scalar &_value)
Set the returned value.
_Scalar Scalar
Scalar type defined outside the class.
ConstantWeightKernel(const Scalar &_value=Scalar(1.))
Default constructor that could be used to set the returned value.
Generalised version of SmoothWeightKernel with arbitrary degrees : .
static constexpr bool isDValid
df is defined and valid on the definition interval
_Scalar Scalar
Scalar type defined outside the class.
Scalar df(const Scalar &_x) const
Defines the smooth first order weighting function .
Scalar ddf(const Scalar &_x) const
Defines the smooth second order weighting function .
static constexpr bool isDDValid
ddf is defined and valid on the definition interval
Scalar f(const Scalar &_x) const
Defines the smooth weighting function .
Singular WeightKernel defined in .
Scalar ddf(const Scalar &_x) const
Defines the Singular second order weighting function .
static constexpr bool isDDValid
ddf is defined and valid on the definition interval
Scalar df(const Scalar &_x) const
Defines the Singular first order weighting function .
Scalar f(const Scalar &_x) const
Defines the Singular weighting function .
_Scalar Scalar
Scalar type defined outside the class.
static constexpr bool isDValid
df is defined and valid on the definition interval
Smooth WeightKernel of 2nd degree, defined in Special case of PolynomialSmoothWeightKernel<Scalar,...
Scalar df(const Scalar &_x) const
Defines the smooth first order weighting function .
Scalar f(const Scalar &_x) const
Defines the smooth weighting function .
static constexpr bool isDValid
df is defined and valid on the definition interval
static constexpr bool isDDValid
ddf is defined and valid on the definition interval
Scalar ddf(const Scalar &_x) const
Defines the smooth second order weighting function .
_Scalar Scalar
Scalar type defined outside the class.
Wendland WeightKernel defined in .
_Scalar Scalar
Scalar type defined outside the class.
static constexpr bool isDValid
df is defined and valid on the definition interval
static constexpr bool isDDValid
ddf is defined and valid on the definition interval
Scalar df(const Scalar &_x) const
Defines the Wendland first order weighting function .
Scalar ddf(const Scalar &_x) const
Defines the Wendland second order weighting function .
Scalar f(const Scalar &_x) const
Defines the Wendland weighting function .
This Source Code Form is subject to the terms of the Mozilla Public License, v.