aimsalgo
6.0.0
Neuroimaging image processing
lm2gauss.h
Go to the documentation of this file.
1
/* This software and supporting documentation are distributed by
2
* Institut Federatif de Recherche 49
3
* CEA/NeuroSpin, Batiment 145,
4
* 91191 Gif-sur-Yvette cedex
5
* France
6
*
7
* This software is governed by the CeCILL-B license under
8
* French law and abiding by the rules of distribution of free software.
9
* You can use, modify and/or redistribute the software under the
10
* terms of the CeCILL-B license as circulated by CEA, CNRS
11
* and INRIA at the following URL "http://www.cecill.info".
12
*
13
* As a counterpart to the access to the source code and rights to copy,
14
* modify and redistribute granted by the license, users are provided only
15
* with a limited warranty and the software's author, the holder of the
16
* economic rights, and the successive licensors have only limited
17
* liability.
18
*
19
* In this respect, the user's attention is drawn to the risks associated
20
* with loading, using, modifying and/or developing or reproducing the
21
* software by the user in light of its specific status of free software,
22
* that may mean that it is complicated to manipulate, and that also
23
* therefore means that it is reserved for developers and experienced
24
* professionals having in-depth computer knowledge. Users are therefore
25
* encouraged to load and test the software's suitability as regards their
26
* requirements in conditions enabling the security of their systems and/or
27
* data to be ensured and, more generally, to use and operate it in the
28
* same conditions as regards security.
29
*
30
* The fact that you are presently reading this means that you have had
31
* knowledge of the CeCILL-B license and that you accept its terms.
32
*/
33
34
35
#ifndef AIMS_OPTIMIZATION_LM2GAUSS_H
36
#define AIMS_OPTIMIZATION_LM2GAUSS_H
37
38
#include <
aims/optimization/lmfunc.h
>
39
40
41
template
<
class
T >
42
class
LM2Gaussian
:
public
LMFunction
< T >
43
{
44
public
:
45
46
LM2Gaussian
( T k1=(T)1.0, T m1=(T)0.0, T s1=(T)1.0,
47
T k2=(T)1.0, T m2=(T)0.0, T s2=(T)1.0 );
48
49
T
apply
( T );
50
T
eval
( T );
51
};
52
53
54
template
<
class
T >
inline
55
LM2Gaussian< T >::LM2Gaussian
( T k1, T m1, T s1, T k2, T m2, T s2 )
56
:
LMFunction
< T >()
57
{
58
this->
par
.push_back( k1 );
59
this->
par
.push_back( m1 );
60
this->
par
.push_back( s1 );
61
this->
par
.push_back( k2 );
62
this->
par
.push_back( m2 );
63
this->
par
.push_back( s2 );
64
65
this->
der
= std::vector< T >( 6 );
66
}
67
68
69
70
template
<
class
T >
inline
71
T
LM2Gaussian< T >::eval
( T x )
72
{
73
T y = (T)0;
74
75
for
(
int
i=0; i<6; i+=3 )
76
{
77
T arg = ( x - this->
par
[ i + 1 ] ) / this->
par
[ i + 2 ];
78
T ex = (T)exp( -1.0 * ( arg * arg ) );
79
T fac = (T)2 * this->
par
[ i ] * ex * arg;
80
81
y += this->
par
[ i ] * ex;
82
83
this->
der
[ i ] = ex;
84
this->
der
[ i + 1 ] = fac / this->
par
[ i + 2 ];
85
this->
der
[ i + 2 ] = fac * arg / this->
par
[ i + 2 ];
86
}
87
88
return
y;
89
}
90
91
92
template
<
class
T >
inline
93
T
LM2Gaussian< T >::apply
( T x )
94
{
95
T y = (T)0;
96
97
for
(
int
i=0; i<6; i+=3 )
98
{
99
T arg = ( x - this->
par
[ i + 1 ] ) / this->
par
[ i + 2 ];
100
101
y += this->
par
[ i ] * (T)exp( -1.0 * ( arg * arg ) );
102
}
103
104
return
y;
105
}
106
107
#endif
LM2Gaussian::eval
T eval(T)
Definition
lm2gauss.h:71
LM2Gaussian::apply
T apply(T)
Definition
lm2gauss.h:93
LM2Gaussian::LM2Gaussian
LM2Gaussian(T k1=(T) 1.0, T m1=(T) 0.0, T s1=(T) 1.0, T k2=(T) 1.0, T m2=(T) 0.0, T s2=(T) 1.0)
Definition
lm2gauss.h:55
LMFunction::LMFunction
LMFunction()
Definition
lmfunc.h:46
LMFunction::der
std::vector< T > der
Definition
lmfunc.h:59
LMFunction::par
std::vector< T > par
Definition
lmfunc.h:58
lmfunc.h
aims
optimization
lm2gauss.h
Generated by
1.13.2