Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
IP
elsa
Commits
fe4260bb
Commit
fe4260bb
authored
Oct 31, 2019
by
Jens Petit
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename internal virtual _method() to methodImpl()
parent
26e0c6bd
Pipeline
#171490
passed with stages
in 4 minutes and 53 seconds
Changes
52
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
52 changed files
with
165 additions
and
162 deletions
+165
-162
elsa/core/LinearOperator.cpp
elsa/core/LinearOperator.cpp
+6
-6
elsa/core/LinearOperator.h
elsa/core/LinearOperator.h
+6
-6
elsa/core/tests/test_LinearOperator.cpp
elsa/core/tests/test_LinearOperator.cpp
+2
-2
elsa/functionals/EmissionLogLikelihood.cpp
elsa/functionals/EmissionLogLikelihood.cpp
+3
-3
elsa/functionals/EmissionLogLikelihood.h
elsa/functionals/EmissionLogLikelihood.h
+3
-3
elsa/functionals/Functional.cpp
elsa/functionals/Functional.cpp
+8
-8
elsa/functionals/Functional.h
elsa/functionals/Functional.h
+3
-3
elsa/functionals/Huber.cpp
elsa/functionals/Huber.cpp
+3
-3
elsa/functionals/Huber.h
elsa/functionals/Huber.h
+3
-3
elsa/functionals/L1Norm.cpp
elsa/functionals/L1Norm.cpp
+3
-3
elsa/functionals/L1Norm.h
elsa/functionals/L1Norm.h
+3
-3
elsa/functionals/L2NormPow2.cpp
elsa/functionals/L2NormPow2.cpp
+3
-3
elsa/functionals/L2NormPow2.h
elsa/functionals/L2NormPow2.h
+3
-3
elsa/functionals/LInfNorm.cpp
elsa/functionals/LInfNorm.cpp
+3
-3
elsa/functionals/LInfNorm.h
elsa/functionals/LInfNorm.h
+3
-3
elsa/functionals/LinearResidual.cpp
elsa/functionals/LinearResidual.cpp
+3
-3
elsa/functionals/LinearResidual.h
elsa/functionals/LinearResidual.h
+2
-2
elsa/functionals/PseudoHuber.cpp
elsa/functionals/PseudoHuber.cpp
+3
-3
elsa/functionals/PseudoHuber.h
elsa/functionals/PseudoHuber.h
+3
-3
elsa/functionals/Quadric.cpp
elsa/functionals/Quadric.cpp
+3
-3
elsa/functionals/Quadric.h
elsa/functionals/Quadric.h
+3
-3
elsa/functionals/Residual.cpp
elsa/functionals/Residual.cpp
+2
-2
elsa/functionals/Residual.h
elsa/functionals/Residual.h
+3
-2
elsa/functionals/TransmissionLogLikelihood.cpp
elsa/functionals/TransmissionLogLikelihood.cpp
+3
-3
elsa/functionals/TransmissionLogLikelihood.h
elsa/functionals/TransmissionLogLikelihood.h
+3
-3
elsa/functionals/WeightedL2NormPow2.cpp
elsa/functionals/WeightedL2NormPow2.cpp
+4
-3
elsa/functionals/WeightedL2NormPow2.h
elsa/functionals/WeightedL2NormPow2.h
+3
-3
elsa/functionals/tests/test_LinearResidual.cpp
elsa/functionals/tests/test_LinearResidual.cpp
+2
-2
elsa/operators/FiniteDifferences.cpp
elsa/operators/FiniteDifferences.cpp
+4
-4
elsa/operators/FiniteDifferences.h
elsa/operators/FiniteDifferences.h
+3
-3
elsa/operators/Identity.cpp
elsa/operators/Identity.cpp
+4
-3
elsa/operators/Identity.h
elsa/operators/Identity.h
+3
-3
elsa/operators/Scaling.cpp
elsa/operators/Scaling.cpp
+3
-3
elsa/operators/Scaling.h
elsa/operators/Scaling.h
+3
-3
elsa/problems/Problem.cpp
elsa/problems/Problem.cpp
+6
-6
elsa/problems/Problem.h
elsa/problems/Problem.h
+3
-3
elsa/projectors/BinaryMethod.cpp
elsa/projectors/BinaryMethod.cpp
+4
-4
elsa/projectors/BinaryMethod.h
elsa/projectors/BinaryMethod.h
+3
-3
elsa/projectors/JosephsMethod.cpp
elsa/projectors/JosephsMethod.cpp
+6
-6
elsa/projectors/JosephsMethod.h
elsa/projectors/JosephsMethod.h
+4
-4
elsa/projectors/SiddonsMethod.cpp
elsa/projectors/SiddonsMethod.cpp
+4
-4
elsa/projectors/SiddonsMethod.h
elsa/projectors/SiddonsMethod.h
+3
-3
elsa/projectors_cuda/JosephsMethodCUDA.cpp
elsa/projectors_cuda/JosephsMethodCUDA.cpp
+4
-4
elsa/projectors_cuda/JosephsMethodCUDA.h
elsa/projectors_cuda/JosephsMethodCUDA.h
+3
-3
elsa/projectors_cuda/SiddonsMethodCUDA.cpp
elsa/projectors_cuda/SiddonsMethodCUDA.cpp
+4
-4
elsa/projectors_cuda/SiddonsMethodCUDA.h
elsa/projectors_cuda/SiddonsMethodCUDA.h
+3
-3
elsa/solvers/CG.cpp
elsa/solvers/CG.cpp
+1
-1
elsa/solvers/CG.h
elsa/solvers/CG.h
+1
-1
elsa/solvers/GradientDescent.cpp
elsa/solvers/GradientDescent.cpp
+1
-1
elsa/solvers/GradientDescent.h
elsa/solvers/GradientDescent.h
+1
-1
elsa/solvers/Solver.cpp
elsa/solvers/Solver.cpp
+1
-1
elsa/solvers/Solver.h
elsa/solvers/Solver.h
+1
-1
No files found.
elsa/core/LinearOperator.cpp
View file @
fe4260bb
...
...
@@ -77,12 +77,12 @@ namespace elsa
void
LinearOperator
<
data_t
>::
apply
(
const
DataContainer
<
data_t
>&
x
,
DataContainer
<
data_t
>&
Ax
)
const
{
_
apply
(
x
,
Ax
);
apply
Impl
(
x
,
Ax
);
}
template
<
typename
data_t
>
void
LinearOperator
<
data_t
>::
_
apply
(
const
DataContainer
<
data_t
>&
x
,
DataContainer
<
data_t
>&
Ax
)
const
void
LinearOperator
<
data_t
>::
apply
Impl
(
const
DataContainer
<
data_t
>&
x
,
DataContainer
<
data_t
>&
Ax
)
const
{
if
(
_isLeaf
)
{
if
(
_isAdjoint
)
{
...
...
@@ -150,12 +150,12 @@ namespace elsa
void
LinearOperator
<
data_t
>::
applyAdjoint
(
const
DataContainer
<
data_t
>&
y
,
DataContainer
<
data_t
>&
Aty
)
const
{
_
applyAdjoint
(
y
,
Aty
);
applyAdjoint
Impl
(
y
,
Aty
);
}
template
<
typename
data_t
>
void
LinearOperator
<
data_t
>::
_
applyAdjoint
(
const
DataContainer
<
data_t
>&
y
,
DataContainer
<
data_t
>&
Aty
)
const
void
LinearOperator
<
data_t
>::
applyAdjoint
Impl
(
const
DataContainer
<
data_t
>&
y
,
DataContainer
<
data_t
>&
Aty
)
const
{
if
(
_isLeaf
)
{
if
(
_isAdjoint
)
{
...
...
elsa/core/LinearOperator.h
View file @
fe4260bb
...
...
@@ -23,7 +23,7 @@ namespace elsa
* This class represents a linear operator A, expressed through its apply/applyAdjoint methods,
* which implement Ax and A^ty for DataContainers x,y of appropriate sizes. Concrete
* implementations of linear operators will derive from this class and override the
*
_
apply/
_
applyAdjoint methods.
* apply
Impl
/applyAdjoint
Impl
methods.
*
* LinearOperator also provides functionality to support constructs like the operator expression
* A^t*B+C, where A,B,C are linear operators. This operator composition is implemented via
...
...
@@ -79,7 +79,7 @@ namespace elsa
* \param[in] x input DataContainer (in the domain of the operator)
* \param[out] Ax output DataContainer (in the range of the operator)
*
* Please note: this method calls the method
_
apply that has to be overridden in derived
* Please note: this method calls the method apply
Impl
that has to be overridden in derived
* classes. (Why is this method not virtual itself? Because you cannot have a non-virtual
* function overloading a virtual one [apply with one vs. two arguments]).
*/
...
...
@@ -103,7 +103,7 @@ namespace elsa
* \param[in] y input DataContainer (in the range of the operator)
* \param[out] Aty output DataContainer (in the domain of the operator)
*
* Please note: this method calls the method
_
applyAdjoint that has to be overridden in
* Please note: this method calls the method applyAdjoint
Impl
that has to be overridden in
* derived classes. (Why is this method not virtual itself? Because you cannot have a
* non-virtual function overloading a virtual one [applyAdjoint with one vs. two args]).
*/
...
...
@@ -149,11 +149,11 @@ namespace elsa
bool
isEqual
(
const
LinearOperator
<
data_t
>&
other
)
const
override
;
/// the apply method that has to be overridden in derived classes
virtual
void
_
apply
(
const
DataContainer
<
data_t
>&
x
,
DataContainer
<
data_t
>&
Ax
)
const
;
virtual
void
apply
Impl
(
const
DataContainer
<
data_t
>&
x
,
DataContainer
<
data_t
>&
Ax
)
const
;
/// the applyAdjoint method that has to be overridden in derived classes
virtual
void
_
applyAdjoint
(
const
DataContainer
<
data_t
>&
y
,
DataContainer
<
data_t
>&
Aty
)
const
;
virtual
void
applyAdjoint
Impl
(
const
DataContainer
<
data_t
>&
y
,
DataContainer
<
data_t
>&
Aty
)
const
;
private:
/// pointers to nodes in the evaluation tree
...
...
elsa/core/tests/test_LinearOperator.cpp
View file @
fe4260bb
...
...
@@ -24,12 +24,12 @@ public:
}
protected:
void
_
apply
(
const
DataContainer
<
data_t
>&
x
,
DataContainer
<
data_t
>&
Ax
)
const
override
void
apply
Impl
(
const
DataContainer
<
data_t
>&
x
,
DataContainer
<
data_t
>&
Ax
)
const
override
{
Ax
=
1
;
}
void
_
applyAdjoint
(
const
DataContainer
<
data_t
>&
y
,
DataContainer
<
data_t
>&
Aty
)
const
override
void
applyAdjoint
Impl
(
const
DataContainer
<
data_t
>&
y
,
DataContainer
<
data_t
>&
Aty
)
const
override
{
Aty
=
3
;
}
...
...
elsa/functionals/EmissionLogLikelihood.cpp
View file @
fe4260bb
...
...
@@ -58,7 +58,7 @@ namespace elsa
}
template
<
typename
data_t
>
data_t
EmissionLogLikelihood
<
data_t
>::
_
evaluate
(
const
DataContainer
<
data_t
>&
Rx
)
data_t
EmissionLogLikelihood
<
data_t
>::
evaluate
Impl
(
const
DataContainer
<
data_t
>&
Rx
)
{
auto
result
=
static_cast
<
data_t
>
(
0.0
);
...
...
@@ -74,7 +74,7 @@ namespace elsa
}
template
<
typename
data_t
>
void
EmissionLogLikelihood
<
data_t
>::
_
getGradientInPlace
(
DataContainer
<
data_t
>&
Rx
)
void
EmissionLogLikelihood
<
data_t
>::
getGradientInPlace
Impl
(
DataContainer
<
data_t
>&
Rx
)
{
for
(
index_t
i
=
0
;
i
<
Rx
.
getSize
();
++
i
)
{
data_t
temp
=
Rx
[
i
];
...
...
@@ -87,7 +87,7 @@ namespace elsa
template
<
typename
data_t
>
LinearOperator
<
data_t
>
EmissionLogLikelihood
<
data_t
>::
_
getHessian
(
const
DataContainer
<
data_t
>&
Rx
)
EmissionLogLikelihood
<
data_t
>::
getHessian
Impl
(
const
DataContainer
<
data_t
>&
Rx
)
{
DataContainer
<
data_t
>
scaleFactors
(
Rx
.
getDataDescriptor
());
for
(
index_t
i
=
0
;
i
<
Rx
.
getSize
();
++
i
)
{
...
...
elsa/functionals/EmissionLogLikelihood.h
View file @
fe4260bb
...
...
@@ -69,13 +69,13 @@ namespace elsa
protected:
/// the evaluation of the emission log-likelihood
data_t
_
evaluate
(
const
DataContainer
<
data_t
>&
Rx
)
override
;
data_t
evaluate
Impl
(
const
DataContainer
<
data_t
>&
Rx
)
override
;
/// the computation of the gradient (in place)
void
_
getGradientInPlace
(
DataContainer
<
data_t
>&
Rx
)
override
;
void
getGradientInPlace
Impl
(
DataContainer
<
data_t
>&
Rx
)
override
;
/// the computation of the Hessian
LinearOperator
<
data_t
>
_
getHessian
(
const
DataContainer
<
data_t
>&
Rx
)
override
;
LinearOperator
<
data_t
>
getHessian
Impl
(
const
DataContainer
<
data_t
>&
Rx
)
override
;
/// implement the polymorphic clone operation
EmissionLogLikelihood
<
data_t
>*
cloneImpl
()
const
override
;
...
...
elsa/functionals/Functional.cpp
View file @
fe4260bb
...
...
@@ -40,11 +40,11 @@ namespace elsa
// optimize for trivial LinearResiduals (no extra copy for residual result needed then)
if
(
auto
*
linearResidual
=
dynamic_cast
<
LinearResidual
<
data_t
>*>
(
_residual
.
get
()))
{
if
(
!
linearResidual
->
hasOperator
()
&&
!
linearResidual
->
hasDataVector
())
return
_
evaluate
(
x
);
return
evaluate
Impl
(
x
);
}
// in all other cases: evaluate the residual first, then call our virtual _evaluate
return
_
evaluate
(
_residual
->
evaluate
(
x
));
return
evaluate
Impl
(
_residual
->
evaluate
(
x
));
}
template
<
typename
data_t
>
...
...
@@ -69,7 +69,7 @@ namespace elsa
// if trivial, no extra copy for residual result needed (and no chain rule)
if
(
!
linearResidual
->
hasOperator
()
&&
!
linearResidual
->
hasDataVector
())
{
result
=
x
;
_
getGradientInPlace
(
result
);
getGradientInPlace
Impl
(
result
);
return
;
}
...
...
@@ -77,14 +77,14 @@ namespace elsa
if
(
!
linearResidual
->
hasOperator
())
{
linearResidual
->
evaluate
(
x
,
result
);
// sizes of x and result will match in this case
_
getGradientInPlace
(
result
);
getGradientInPlace
Impl
(
result
);
return
;
}
}
// the general case
auto
temp
=
_residual
->
evaluate
(
x
);
_
getGradientInPlace
(
temp
);
getGradientInPlace
Impl
(
temp
);
_residual
->
getJacobian
(
x
).
applyAdjoint
(
temp
,
result
);
// apply the chain rule
}
...
...
@@ -95,16 +95,16 @@ namespace elsa
if
(
auto
*
linearResidual
=
dynamic_cast
<
LinearResidual
<
data_t
>*>
(
_residual
.
get
()))
{
// if trivial, no extra copy for residual result needed (and no chain rule)
if
(
!
linearResidual
->
hasOperator
()
&&
!
linearResidual
->
hasDataVector
())
return
_
getHessian
(
x
);
return
getHessian
Impl
(
x
);
// if no operator, no need for chain rule
if
(
!
linearResidual
->
hasOperator
())
return
_
getHessian
(
_residual
->
evaluate
(
x
));
return
getHessian
Impl
(
_residual
->
evaluate
(
x
));
}
// the general case (with chain rule)
auto
jacobian
=
_residual
->
getJacobian
(
x
);
auto
hessian
=
adjoint
(
jacobian
)
*
(
_
getHessian
(
_residual
->
evaluate
(
x
)))
*
(
jacobian
);
auto
hessian
=
adjoint
(
jacobian
)
*
(
getHessian
Impl
(
_residual
->
evaluate
(
x
)))
*
(
jacobian
);
return
hessian
;
}
...
...
elsa/functionals/Functional.h
View file @
fe4260bb
...
...
@@ -125,7 +125,7 @@ namespace elsa
* Please note: the evaluation of the residual is already performed in evaluate, so this
* method only has to compute the functional's value itself.
*/
virtual
data_t
_
evaluate
(
const
DataContainer
<
data_t
>&
Rx
)
=
0
;
virtual
data_t
evaluate
Impl
(
const
DataContainer
<
data_t
>&
Rx
)
=
0
;
/**
* \brief the _getGradientInPlace method that has to be overridden in derived classes
...
...
@@ -137,7 +137,7 @@ namespace elsa
* as the application of the chain rule. This method here only has to compute the gradient
* of the functional itself, in an in-place manner (to avoid unnecessary DataContainers).
*/
virtual
void
_
getGradientInPlace
(
DataContainer
<
data_t
>&
Rx
)
=
0
;
virtual
void
getGradientInPlace
Impl
(
DataContainer
<
data_t
>&
Rx
)
=
0
;
/**
* \brief the _getHessian method that has to be overridden in derived classes
...
...
@@ -150,6 +150,6 @@ namespace elsa
* as the application of the chain rule. This method here only has to compute the Hessian of
* the functional itself.
*/
virtual
LinearOperator
<
data_t
>
_
getHessian
(
const
DataContainer
<
data_t
>&
Rx
)
=
0
;
virtual
LinearOperator
<
data_t
>
getHessian
Impl
(
const
DataContainer
<
data_t
>&
Rx
)
=
0
;
};
}
// namespace elsa
elsa/functionals/Huber.cpp
View file @
fe4260bb
...
...
@@ -25,7 +25,7 @@ namespace elsa
}
template
<
typename
data_t
>
data_t
Huber
<
data_t
>::
_
evaluate
(
const
DataContainer
<
data_t
>&
Rx
)
data_t
Huber
<
data_t
>::
evaluate
Impl
(
const
DataContainer
<
data_t
>&
Rx
)
{
// note: this is currently not a reduction in DataContainer, but implemented here "manually"
...
...
@@ -43,7 +43,7 @@ namespace elsa
}
template
<
typename
data_t
>
void
Huber
<
data_t
>::
_
getGradientInPlace
(
DataContainer
<
data_t
>&
Rx
)
void
Huber
<
data_t
>::
getGradientInPlace
Impl
(
DataContainer
<
data_t
>&
Rx
)
{
for
(
index_t
i
=
0
;
i
<
Rx
.
getSize
();
++
i
)
{
data_t
value
=
Rx
[
i
];
...
...
@@ -56,7 +56,7 @@ namespace elsa
}
template
<
typename
data_t
>
LinearOperator
<
data_t
>
Huber
<
data_t
>::
_
getHessian
(
const
DataContainer
<
data_t
>&
Rx
)
LinearOperator
<
data_t
>
Huber
<
data_t
>::
getHessian
Impl
(
const
DataContainer
<
data_t
>&
Rx
)
{
DataContainer
<
data_t
>
scaleFactors
(
Rx
.
getDataDescriptor
());
for
(
index_t
i
=
0
;
i
<
Rx
.
getSize
();
++
i
)
{
...
...
elsa/functionals/Huber.h
View file @
fe4260bb
...
...
@@ -47,13 +47,13 @@ namespace elsa
protected:
/// the evaluation of the Huber norm
data_t
_
evaluate
(
const
DataContainer
<
data_t
>&
Rx
)
override
;
data_t
evaluate
Impl
(
const
DataContainer
<
data_t
>&
Rx
)
override
;
/// the computation of the gradient (in place)
void
_
getGradientInPlace
(
DataContainer
<
data_t
>&
Rx
)
override
;
void
getGradientInPlace
Impl
(
DataContainer
<
data_t
>&
Rx
)
override
;
/// the computation of the Hessian
LinearOperator
<
data_t
>
_
getHessian
(
const
DataContainer
<
data_t
>&
Rx
)
override
;
LinearOperator
<
data_t
>
getHessian
Impl
(
const
DataContainer
<
data_t
>&
Rx
)
override
;
/// implement the polymorphic clone operation
Huber
<
data_t
>*
cloneImpl
()
const
override
;
...
...
elsa/functionals/L1Norm.cpp
View file @
fe4260bb
...
...
@@ -16,19 +16,19 @@ namespace elsa
}
template
<
typename
data_t
>
data_t
L1Norm
<
data_t
>::
_
evaluate
(
const
DataContainer
<
data_t
>&
Rx
)
data_t
L1Norm
<
data_t
>::
evaluate
Impl
(
const
DataContainer
<
data_t
>&
Rx
)
{
return
Rx
.
l1Norm
();
}
template
<
typename
data_t
>
void
L1Norm
<
data_t
>::
_
getGradientInPlace
(
DataContainer
<
data_t
>&
Rx
)
void
L1Norm
<
data_t
>::
getGradientInPlace
Impl
(
DataContainer
<
data_t
>&
Rx
)
{
throw
std
::
logic_error
(
"L1Norm: not differentiable, so no gradient! (busted!)"
);
}
template
<
typename
data_t
>
LinearOperator
<
data_t
>
L1Norm
<
data_t
>::
_
getHessian
(
const
DataContainer
<
data_t
>&
Rx
)
LinearOperator
<
data_t
>
L1Norm
<
data_t
>::
getHessian
Impl
(
const
DataContainer
<
data_t
>&
Rx
)
{
throw
std
::
logic_error
(
"L1Norm: not differentiable, so no Hessian! (busted!)"
);
}
...
...
elsa/functionals/L1Norm.h
View file @
fe4260bb
...
...
@@ -43,13 +43,13 @@ namespace elsa
protected:
/// the evaluation of the l1 norm
data_t
_
evaluate
(
const
DataContainer
<
data_t
>&
Rx
)
override
;
data_t
evaluate
Impl
(
const
DataContainer
<
data_t
>&
Rx
)
override
;
/// the computation of the gradient (in place)
void
_
getGradientInPlace
(
DataContainer
<
data_t
>&
Rx
)
override
;
void
getGradientInPlace
Impl
(
DataContainer
<
data_t
>&
Rx
)
override
;
/// the computation of the Hessian
LinearOperator
<
data_t
>
_
getHessian
(
const
DataContainer
<
data_t
>&
Rx
)
override
;
LinearOperator
<
data_t
>
getHessian
Impl
(
const
DataContainer
<
data_t
>&
Rx
)
override
;
/// implement the polymorphic clone operation
L1Norm
<
data_t
>*
cloneImpl
()
const
override
;
...
...
elsa/functionals/L2NormPow2.cpp
View file @
fe4260bb
...
...
@@ -17,19 +17,19 @@ namespace elsa
}
template
<
typename
data_t
>
data_t
L2NormPow2
<
data_t
>::
_
evaluate
(
const
DataContainer
<
data_t
>&
Rx
)
data_t
L2NormPow2
<
data_t
>::
evaluate
Impl
(
const
DataContainer
<
data_t
>&
Rx
)
{
return
static_cast
<
data_t
>
(
0.5
)
*
Rx
.
squaredL2Norm
();
}
template
<
typename
data_t
>
void
L2NormPow2
<
data_t
>::
_
getGradientInPlace
(
DataContainer
<
data_t
>&
Rx
)
void
L2NormPow2
<
data_t
>::
getGradientInPlace
Impl
(
DataContainer
<
data_t
>&
Rx
)
{
// gradient is Rx itself (no need for self-assignment)
}
template
<
typename
data_t
>
LinearOperator
<
data_t
>
L2NormPow2
<
data_t
>::
_
getHessian
(
const
DataContainer
<
data_t
>&
Rx
)
LinearOperator
<
data_t
>
L2NormPow2
<
data_t
>::
getHessian
Impl
(
const
DataContainer
<
data_t
>&
Rx
)
{
return
leaf
(
Identity
<
data_t
>
(
Rx
.
getDataDescriptor
()));
}
...
...
elsa/functionals/L2NormPow2.h
View file @
fe4260bb
...
...
@@ -42,13 +42,13 @@ namespace elsa
protected:
/// the evaluation of the l2 norm (squared)
data_t
_
evaluate
(
const
DataContainer
<
data_t
>&
Rx
)
override
;
data_t
evaluate
Impl
(
const
DataContainer
<
data_t
>&
Rx
)
override
;
/// the computation of the gradient (in place)
void
_
getGradientInPlace
(
DataContainer
<
data_t
>&
Rx
)
override
;
void
getGradientInPlace
Impl
(
DataContainer
<
data_t
>&
Rx
)
override
;
/// the computation of the Hessian
LinearOperator
<
data_t
>
_
getHessian
(
const
DataContainer
<
data_t
>&
Rx
)
override
;
LinearOperator
<
data_t
>
getHessian
Impl
(
const
DataContainer
<
data_t
>&
Rx
)
override
;
/// implement the polymorphic clone operation
L2NormPow2
<
data_t
>*
cloneImpl
()
const
override
;
...
...
elsa/functionals/LInfNorm.cpp
View file @
fe4260bb
...
...
@@ -16,19 +16,19 @@ namespace elsa
}
template
<
typename
data_t
>
data_t
LInfNorm
<
data_t
>::
_
evaluate
(
const
DataContainer
<
data_t
>&
Rx
)
data_t
LInfNorm
<
data_t
>::
evaluate
Impl
(
const
DataContainer
<
data_t
>&
Rx
)
{
return
Rx
.
lInfNorm
();
}
template
<
typename
data_t
>
void
LInfNorm
<
data_t
>::
_
getGradientInPlace
(
DataContainer
<
data_t
>&
Rx
)
void
LInfNorm
<
data_t
>::
getGradientInPlace
Impl
(
DataContainer
<
data_t
>&
Rx
)
{
throw
std
::
logic_error
(
"LInfNorm: not differentiable, so no gradient! (busted!)"
);
}
template
<
typename
data_t
>
LinearOperator
<
data_t
>
LInfNorm
<
data_t
>::
_
getHessian
(
const
DataContainer
<
data_t
>&
Rx
)
LinearOperator
<
data_t
>
LInfNorm
<
data_t
>::
getHessian
Impl
(
const
DataContainer
<
data_t
>&
Rx
)
{
throw
std
::
logic_error
(
"LInfNorm: not differentiable, so no Hessian! (busted!)"
);
}
...
...
elsa/functionals/LInfNorm.h
View file @
fe4260bb
...
...
@@ -43,13 +43,13 @@ namespace elsa
protected:
/// the evaluation of the linf norm
data_t
_
evaluate
(
const
DataContainer
<
data_t
>&
Rx
)
override
;
data_t
evaluate
Impl
(
const
DataContainer
<
data_t
>&
Rx
)
override
;
/// the computation of the gradient (in place)
void
_
getGradientInPlace
(
DataContainer
<
data_t
>&
Rx
)
override
;
void
getGradientInPlace
Impl
(
DataContainer
<
data_t
>&
Rx
)
override
;
/// the computation of the Hessian
LinearOperator
<
data_t
>
_
getHessian
(
const
DataContainer
<
data_t
>&
Rx
)
override
;
LinearOperator
<
data_t
>
getHessian
Impl
(
const
DataContainer
<
data_t
>&
Rx
)
override
;
/// implement the polymorphic clone operation
LInfNorm
<
data_t
>*
cloneImpl
()
const
override
;
...
...
elsa/functionals/LinearResidual.cpp
View file @
fe4260bb
...
...
@@ -119,8 +119,8 @@ namespace elsa
}
template
<
typename
data_t
>
void
LinearResidual
<
data_t
>::
_
evaluate
(
const
DataContainer
<
data_t
>&
x
,
DataContainer
<
data_t
>&
result
)
void
LinearResidual
<
data_t
>::
evaluate
Impl
(
const
DataContainer
<
data_t
>&
x
,
DataContainer
<
data_t
>&
result
)
{
if
(
_hasOperator
)
_operator
->
apply
(
x
,
result
);
...
...
@@ -132,7 +132,7 @@ namespace elsa
}
template
<
typename
data_t
>
LinearOperator
<
data_t
>
LinearResidual
<
data_t
>::
_
getJacobian
(
const
DataContainer
<
data_t
>&
x
)
LinearOperator
<
data_t
>
LinearResidual
<
data_t
>::
getJacobian
Impl
(
const
DataContainer
<
data_t
>&
x
)
{
if
(
_hasOperator
)
return
leaf
(
*
_operator
);
...
...
elsa/functionals/LinearResidual.h
View file @
fe4260bb
...
...
@@ -72,7 +72,7 @@ namespace elsa
bool
isEqual
(
const
Residual
<
data_t
>&
other
)
const
override
;
/// the evaluate method, evaluating the residual at x and placing the value in result
void
_
evaluate
(
const
DataContainer
<
data_t
>&
x
,
DataContainer
<
data_t
>&
result
)
override
;
void
evaluate
Impl
(
const
DataContainer
<
data_t
>&
x
,
DataContainer
<
data_t
>&
result
)
override
;
/**
* \brief return the Jacobian (first derivative) of the linear residual at x.
...
...
@@ -84,7 +84,7 @@ namespace elsa
* If A is set, then the Jacobian is A and this returns a copy of A.
* If A is not set, then an Identity operator is returned.
*/
LinearOperator
<
data_t
>
_
getJacobian
(
const
DataContainer
<
data_t
>&
x
)
override
;
LinearOperator
<
data_t
>
getJacobian
Impl
(
const
DataContainer
<
data_t
>&
x
)
override
;
private:
/// flag if operator A is present
...
...
elsa/functionals/PseudoHuber.cpp
View file @
fe4260bb
...
...
@@ -25,7 +25,7 @@ namespace elsa
}
template
<
typename
data_t
>
data_t
PseudoHuber
<
data_t
>::
_
evaluate
(
const
DataContainer
<
data_t
>&
Rx
)
data_t
PseudoHuber
<
data_t
>::
evaluate
Impl
(
const
DataContainer
<
data_t
>&
Rx
)
{
// note: this is currently not a reduction in DataContainer, but implemented here "manually"
...
...
@@ -42,7 +42,7 @@ namespace elsa
}
template
<
typename
data_t
>
void
PseudoHuber
<
data_t
>::
_
getGradientInPlace
(
DataContainer
<
data_t
>&
Rx
)
void
PseudoHuber
<
data_t
>::
getGradientInPlace
Impl
(
DataContainer
<
data_t
>&
Rx
)
{
for
(
index_t
i
=
0
;
i
<
Rx
.
getSize
();
++
i
)
{
data_t
temp
=
Rx
[
i
]
/
_delta
;
...
...
@@ -51,7 +51,7 @@ namespace elsa
}
template
<
typename
data_t
>
LinearOperator
<
data_t
>
PseudoHuber
<
data_t
>::
_
getHessian
(
const
DataContainer
<
data_t
>&
Rx
)
LinearOperator
<
data_t
>
PseudoHuber
<
data_t
>::
getHessian
Impl
(
const
DataContainer
<
data_t
>&
Rx
)
{
DataContainer
<
data_t
>
scaleFactors
(
Rx
.
getDataDescriptor
());
for
(
index_t
i
=
0
;
i
<
Rx
.
getSize
();
++
i
)
{
...
...
elsa/functionals/PseudoHuber.h
View file @
fe4260bb
...
...
@@ -48,13 +48,13 @@ namespace elsa
protected:
/// the evaluation of the Huber norm
data_t
_
evaluate
(
const
DataContainer
<
data_t
>&
Rx
)
override
;
data_t
evaluate
Impl
(
const
DataContainer
<
data_t
>&
Rx
)
override
;
/// the computation of the gradient (in place)
void
_
getGradientInPlace
(
DataContainer
<
data_t
>&
Rx
)
override
;
void
getGradientInPlace
Impl
(
DataContainer
<
data_t
>&
Rx
)
override
;
/// the computation of the Hessian
LinearOperator
<
data_t
>
_
getHessian
(
const
DataContainer
<
data_t
>&
Rx
)
override
;
LinearOperator
<
data_t
>
getHessian
Impl
(
const
DataContainer
<
data_t
>&
Rx
)
override
;
/// implement the polymorphic clone operation
PseudoHuber
<
data_t
>*
cloneImpl
()
const
override
;
...
...
elsa/functionals/Quadric.cpp
View file @
fe4260bb
...
...
@@ -36,7 +36,7 @@ namespace elsa
}
template
<
typename
data_t
>
data_t
Quadric
<
data_t
>::
_
evaluate
(
const
DataContainer
<
data_t
>&
Rx
)
data_t
Quadric
<
data_t
>::
evaluate
Impl
(
const
DataContainer
<
data_t
>&
Rx
)
{
data_t
xtAx
;
...
...
@@ -55,13 +55,13 @@ namespace elsa
}
template
<
typename
data_t
>
void
Quadric
<
data_t
>::
_
getGradientInPlace
(
DataContainer
<
data_t
>&
Rx
)
void
Quadric
<
data_t
>::
getGradientInPlace
Impl
(
DataContainer
<
data_t
>&
Rx
)
{
Rx
=
_linearResidual
.
evaluate
(
Rx
);
}
template
<
typename
data_t
>
LinearOperator
<
data_t
>
Quadric
<
data_t
>::
_
getHessian
(
const
DataContainer
<
data_t
>&
Rx
)
LinearOperator
<
data_t
>
Quadric
<
data_t
>::
getHessian
Impl
(
const
DataContainer
<
data_t
>&
Rx
)
{
if
(
_linearResidual
.
hasOperator
())
return
leaf
(
_linearResidual
.
getOperator
());
...
...
elsa/functionals/Quadric.h
View file @
fe4260bb
...
...
@@ -68,13 +68,13 @@ namespace elsa
protected:
/// the evaluation of the Quadric functional
data_t
_
evaluate
(
const
DataContainer
<
data_t
>&
Rx
)
override
;
data_t
evaluate
Impl
(
const
DataContainer
<
data_t
>&
Rx
)
override
;
/// the computation of the gradient (in place)
void
_
getGradientInPlace
(
DataContainer
<
data_t
>&
Rx
)
override
;
void
getGradientInPlace
Impl
(
DataContainer
<
data_t
>&
Rx
)
override
;
/// the computation of the Hessian
LinearOperator
<
data_t
>
_
getHessian
(
const
DataContainer
<
data_t
>&
Rx
)
override
;
LinearOperator
<
data_t
>
getHessian
Impl
(
const
DataContainer
<
data_t
>&
Rx
)
override
;
/// implement the polymorphic clone operation
Quadric
<
data_t
>*
cloneImpl
()
const
override
;
...
...
elsa/functionals/Residual.cpp
View file @
fe4260bb
...
...
@@ -38,13 +38,13 @@ namespace elsa
||
result
.
getDataDescriptor
()
!=
getRangeDescriptor
())
throw
std
::
invalid_argument
(
"Residual::evaluate: argument sizes do not match residual"
);
_
evaluate
(
x
,
result
);
evaluate
Impl
(
x
,
result
);
}
template
<
typename
data_t
>
LinearOperator
<
data_t
>
Residual
<
data_t
>::
getJacobian
(
const
DataContainer
<
data_t
>&
x
)
{
return
_
getJacobian
(
x
);
return
getJacobian
Impl
(
x
);
}
template
<
typename
data_t
>
...
...
elsa/functionals/Residual.h
View file @
fe4260bb
...
...
@@ -91,9 +91,10 @@ namespace elsa
bool
isEqual
(
const
Residual
<
data_t
>&
other
)
const
override
;
/// the evaluate method that has to be overridden in derived classes
virtual
void
_evaluate
(
const
DataContainer
<
data_t
>&
x
,
DataContainer
<
data_t
>&
result
)
=
0
;
virtual
void
evaluateImpl
(
const
DataContainer
<
data_t
>&
x
,
DataContainer
<
data_t
>&
result
)
=
0
;
/// the getJacobian method that has to be overriden in derived classes
virtual
LinearOperator
<
data_t
>
_
getJacobian
(
const
DataContainer
<
data_t
>&
x
)
=
0
;
virtual
LinearOperator
<
data_t
>
getJacobian
Impl
(
const
DataContainer
<
data_t
>&
x
)
=
0
;
};
}
// namespace elsa
elsa/functionals/TransmissionLogLikelihood.cpp
View file @
fe4260bb
...
...
@@ -71,7 +71,7 @@ namespace elsa
}
template
<
typename
data_t
>
data_t
TransmissionLogLikelihood
<
data_t
>::
_
evaluate
(
const
DataContainer
<
data_t
>&
Rx
)
data_t
TransmissionLogLikelihood
<
data_t
>::
evaluate
Impl
(
const
DataContainer
<
data_t
>&
Rx
)
{
auto
result
=
static_cast
<
data_t
>
(
0.0
);
...
...
@@ -87,7 +87,7 @@ namespace elsa
}
template
<
typename
data_t
>
void
TransmissionLogLikelihood
<
data_t
>::
_
getGradientInPlace
(
DataContainer
<
data_t
>&
Rx
)
void
TransmissionLogLikelihood
<
data_t
>::
getGradientInPlace
Impl
(
DataContainer
<
data_t
>&
Rx
)
{
for
(
index_t
i
=
0
;
i
<
Rx
.
getSize
();
++
i
)
{
data_t
temp
=
(
*
_b
)[
i
]
*
std
::
exp
(
-
Rx
[
i
]);
...
...
@@ -102,7 +102,7 @@ namespace elsa
template
<
typename
data_t
>
LinearOperator
<
data_t
>
TransmissionLogLikelihood
<
data_t
>::
_
getHessian
(
const
DataContainer
<
data_t
>&
Rx
)
TransmissionLogLikelihood
<
data_t
>::
getHessian
Impl
(
const
DataContainer
<
data_t
>&
Rx
)
{
DataContainer
<
data_t
>
scaleFactors
(
Rx
.
getDataDescriptor
());
for
(
index_t
i
=
0
;
i
<
Rx
.
getSize
();
++
i
)
{
...
...
elsa/functionals/TransmissionLogLikelihood.h
View file @
fe4260bb
...
...
@@ -78,13 +78,13 @@ namespace elsa
protected:
/// the evaluation of the transmission log-likelihood
data_t
_
evaluate
(
const
DataContainer
<
data_t
>&
Rx
)
override
;
data_t
evaluate
Impl
(
const
DataContainer
<
data_t
>&
Rx
)
override
;
/// the computation of the gradient (in place)
void
_
getGradientInPlace
(
DataContainer
<
data_t
>&
Rx
)
override
;
void
getGradientInPlace
Impl
(
DataContainer
<
data_t
>&
Rx
)
override
;