STIR 6.4.0
GeneralisedPrior.inl
Go to the documentation of this file.
1//
2//
12/*
13 Copyright (C) 2000- 2009, Hammersmith Imanet Ltd
14 This file is part of STIR.
15
16 SPDX-License-Identifier: Apache-2.0
17
18 See STIR/LICENSE.txt for details
19*/
20
21START_NAMESPACE_STIR
22
23template <typename elemT>
24GeneralisedPrior<elemT>::GeneralisedPrior()
25{
26 penalisation_factor = 0;
27}
28
29template <typename elemT>
30float
31GeneralisedPrior<elemT>::get_penalisation_factor() const
32{
33 return penalisation_factor;
34}
35
39template <typename elemT>
40void
41GeneralisedPrior<elemT>::set_penalisation_factor(const float new_penalisation_factor)
42{
43 penalisation_factor = new_penalisation_factor;
44}
45
46template <typename TargetT>
47void
49{
50 this->parser.add_key("penalisation factor", &this->penalisation_factor);
51}
52
53template <typename TargetT>
54void
56{
57 _already_set_up = false;
58 this->penalisation_factor = 0;
59}
60
61template <typename TargetT>
63GeneralisedPrior<TargetT>::set_up(shared_ptr<const TargetT> const&)
64{
65 _already_set_up = true;
66 return Succeeded::yes;
67}
68
69template <typename TargetT>
70double
71GeneralisedPrior<TargetT>::compute_gradient_times_input(const TargetT& input, const TargetT& current_estimate)
72{
73 error("GeneralisedPrior:\n compute_gradient_times_input is not implemented by your prior.");
74 return 0;
75}
77template <typename TargetT>
78void
80 const BasicCoordinate<3, int>& coords,
81 const TargetT& current_image_estimate) const
82{
83 if (this->is_convex())
84 error("GeneralisedPrior:\n compute_Hessian implementation is not overloaded by your convex prior.");
85 else
86 error("GeneralisedPrior:\n compute_Hessian is not implemented for this (non-convex) prior.");
88
89template <typename TargetT>
90void
91GeneralisedPrior<TargetT>::compute_Hessian_diagonal(TargetT& Hessian_diagonal, const TargetT& current_estimate) const
92{
93 error("GeneralisedPrior:\n compute_Hessian_diagonal is not implemented by your prior.");
94}
95
96template <typename TargetT>
97void
99{
100 error("GeneralisedPrior:\n"
101 "add_multiplication_with_approximate_Hessian implementation is not overloaded by your prior.");
102}
104template <typename TargetT>
105void
107 const TargetT& current_estimate,
108 const TargetT& input) const
110 error("GeneralisedPrior:\n"
111 "accumulate_Hessian_times_input implementation is not overloaded by your prior.");
112}
113
114template <typename TargetT>
115void
116GeneralisedPrior<TargetT>::check(TargetT const& current_estimate) const
117{
118 if (!_already_set_up)
119 error("The prior should already be set-up, but it's not.");
120}
121
122END_NAMESPACE_STIR
class BasicCoordinate<int num_dimensions, typename coordT> defines num_dimensions -dimensional coordi...
Definition BasicCoordinate.h:57
virtual double compute_gradient_times_input(const DataT &input, const DataT &current_estimate)
compute the dot product of the gradient of the log of the prior function at the current_estimate with...
Definition GeneralisedPrior.inl:71
virtual void compute_Hessian(DataT &prior_Hessian_for_single_densel, const BasicCoordinate< 3, int > &coords, const DataT &current_image_estimate) const
This computes a single row of the Hessian.
Definition GeneralisedPrior.inl:79
void set_penalisation_factor(float new_penalisation_factor)
Definition GeneralisedPrior.inl:41
virtual void add_multiplication_with_approximate_Hessian(DataT &output, const DataT &input) const
This should compute the multiplication of the Hessian with a vector and add it to output.
Definition GeneralisedPrior.inl:98
virtual Succeeded set_up(shared_ptr< const DataT > const &target_sptr)
Has to be called before using this object.
Definition GeneralisedPrior.inl:63
virtual void compute_Hessian_diagonal(DataT &Hessian_diagonal, const DataT &current_estimate) const
This computes the diagonal of the Hessian of the log of the prior function at the current_estimate an...
Definition GeneralisedPrior.inl:91
virtual void check(DataT const &current_estimate) const
Check that the prior is ready to be used.
Definition GeneralisedPrior.inl:116
void initialise_keymap() override
sets key for penalisation factor
Definition GeneralisedPrior.inl:48
virtual void accumulate_Hessian_times_input(DataT &output, const DataT &current_estimate, const DataT &input) const
This should compute the multiplication of the Hessian with a vector and add it to output.
Definition GeneralisedPrior.inl:106
void set_defaults() override
sets value for penalisation factor
Definition GeneralisedPrior.inl:55
virtual bool is_convex() const =0
Indicates if the prior is a smooth convex function.
a class containing an enumeration type that can be used by functions to signal successful operation o...
Definition Succeeded.h:44
void error(const char *const s,...)
Print error with format string a la printf and throw exception.
Definition error.cxx:42