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 : L2NormPow2<data_t>::L2NormPow2(const DataDescriptor& domainDescriptor) 12 : : Functional<data_t>(domainDescriptor) 13 126 : { 14 126 : } 15 : 16 : template <typename data_t> 17 : L2NormPow2<data_t>::L2NormPow2(const Residual<data_t>& residual) : Functional<data_t>(residual) 18 1322 : { 19 1322 : } 20 : 21 : template <typename data_t> 22 : L2NormPow2<data_t>::L2NormPow2(const LinearOperator<data_t>& A, const DataContainer<data_t>& b) 23 : : Functional<data_t>(LinearResidual<data_t>(A, b)) 24 0 : { 25 0 : } 26 : 27 : template <typename data_t> 28 : data_t L2NormPow2<data_t>::evaluateImpl(const DataContainer<data_t>& Rx) 29 54 : { 30 54 : return static_cast<data_t>(0.5) * Rx.squaredL2Norm(); 31 54 : } 32 : 33 : template <typename data_t> 34 : void L2NormPow2<data_t>::getGradientInPlaceImpl([[maybe_unused]] DataContainer<data_t>& Rx) 35 10834 : { 36 : // gradient is Rx itself (no need for self-assignment) 37 10834 : } 38 : 39 : template <typename data_t> 40 : LinearOperator<data_t> L2NormPow2<data_t>::getHessianImpl(const DataContainer<data_t>& Rx) 41 87 : { 42 87 : return leaf(Identity<data_t>(Rx.getDataDescriptor())); 43 87 : } 44 : 45 : template <typename data_t> 46 : L2NormPow2<data_t>* L2NormPow2<data_t>::cloneImpl() const 47 994 : { 48 994 : return new L2NormPow2(this->getResidual()); 49 994 : } 50 : 51 : template <typename data_t> 52 : bool L2NormPow2<data_t>::isEqual(const Functional<data_t>& other) const 53 67 : { 54 67 : if (!Functional<data_t>::isEqual(other)) 55 0 : return false; 56 : 57 67 : return is<L2NormPow2<data_t>>(other); 58 67 : } 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