Line data Source code
1 : #include "L2NormPow2.h" 2 : 3 : #include "LinearOperator.h" 4 : #include "LinearResidual.h" 5 : #include "Identity.h" 6 : #include "TypeCasts.hpp" 7 : 8 : namespace elsa 9 : { 10 : template <typename data_t> 11 0 : L2NormPow2<data_t>::L2NormPow2(const DataDescriptor& domainDescriptor) 12 0 : : Functional<data_t>(domainDescriptor) 13 : { 14 0 : } 15 : 16 : template <typename data_t> 17 0 : L2NormPow2<data_t>::L2NormPow2(const Residual<data_t>& residual) : Functional<data_t>(residual) 18 : { 19 0 : } 20 : 21 : template <typename data_t> 22 0 : L2NormPow2<data_t>::L2NormPow2(const LinearOperator<data_t>& A, const DataContainer<data_t>& b) 23 0 : : Functional<data_t>(LinearResidual<data_t>(A, b)) 24 : { 25 0 : } 26 : 27 : template <typename data_t> 28 0 : data_t L2NormPow2<data_t>::evaluateImpl(const DataContainer<data_t>& Rx) 29 : { 30 0 : return static_cast<data_t>(0.5) * Rx.squaredL2Norm(); 31 : } 32 : 33 : template <typename data_t> 34 0 : void L2NormPow2<data_t>::getGradientInPlaceImpl([[maybe_unused]] DataContainer<data_t>& Rx) 35 : { 36 : // gradient is Rx itself (no need for self-assignment) 37 0 : } 38 : 39 : template <typename data_t> 40 0 : LinearOperator<data_t> L2NormPow2<data_t>::getHessianImpl(const DataContainer<data_t>& Rx) 41 : { 42 0 : return leaf(Identity<data_t>(Rx.getDataDescriptor())); 43 : } 44 : 45 : template <typename data_t> 46 0 : L2NormPow2<data_t>* L2NormPow2<data_t>::cloneImpl() const 47 : { 48 0 : return new L2NormPow2(this->getResidual()); 49 : } 50 : 51 : template <typename data_t> 52 0 : bool L2NormPow2<data_t>::isEqual(const Functional<data_t>& other) const 53 : { 54 0 : if (!Functional<data_t>::isEqual(other)) 55 0 : return false; 56 : 57 0 : return is<L2NormPow2<data_t>>(other); 58 : } 59 : 60 : // ------------------------------------------ 61 : // explicit template instantiation 62 : template class L2NormPow2<float>; 63 : template class L2NormPow2<double>; 64 : template class L2NormPow2<complex<float>>; 65 : template class L2NormPow2<complex<double>>; 66 : 67 : } // namespace elsa