STIR  6.2.0
Public Member Functions | Static Public Attributes | Protected Attributes | List of all members

CUDA implementation of the Relative Difference prior. More...

#include "stir/recon_buildblock/CUDA/CudaRelativeDifferencePrior.h"

Inheritance diagram for stir::CudaRelativeDifferencePrior< elemT >:
Inheritance graph
[legend]

Public Member Functions

void set_defaults () override
 Set defaults before parsing.
 
double compute_value (const DiscretisedDensity< 3, elemT > &current_image_estimate) override
 compute the value of the function More...
 
void compute_gradient (DiscretisedDensity< 3, elemT > &prior_gradient, const DiscretisedDensity< 3, elemT > &current_image_estimate) override
 This should compute the gradient of the log of the prior function at the current_estimate. More...
 
Succeeded set_up (shared_ptr< const DiscretisedDensity< 3, elemT >> const &target_sptr) override
 Has to be called before using this object.
 
- Public Member Functions inherited from stir::RegisteredParsingObject< CudaRelativeDifferencePrior< elemT >, GeneralisedPrior< DiscretisedDensity< 3, elemT > >, RelativeDifferencePrior< elemT > >
std::string get_registered_name () const override
 Returns Derived::registered_name.
 
std::string parameter_info () override
 Returns a string with all parameters and their values, in a form suitable for parsing again.
 
- Public Member Functions inherited from stir::RelativeDifferencePrior< elemT >
 RelativeDifferencePrior ()
 Default constructor.
 
 RelativeDifferencePrior (const bool only_2D, float penalization_factor, float gamma, float epsilon)
 Constructs it explicitly.
 
double compute_value (const DiscretisedDensity< 3, elemT > &current_image_estimate) override
 compute the value of the function
 
void compute_gradient (DiscretisedDensity< 3, elemT > &prior_gradient, const DiscretisedDensity< 3, elemT > &current_image_estimate) override
 compute gradient
 
void compute_Hessian (DiscretisedDensity< 3, elemT > &prior_Hessian_for_single_densel, const BasicCoordinate< 3, int > &coords, const DiscretisedDensity< 3, elemT > &current_image_estimate) const override
 
void add_multiplication_with_approximate_Hessian (DiscretisedDensity< 3, elemT > &output, const DiscretisedDensity< 3, elemT > &input) const override
 
void accumulate_Hessian_times_input (DiscretisedDensity< 3, elemT > &output, const DiscretisedDensity< 3, elemT > &current_estimate, const DiscretisedDensity< 3, elemT > &input) const override
 Compute the multiplication of the hessian of the prior multiplied by the input.
 
float get_gamma () const
 get the gamma value used in RDP
 
void set_gamma (float e)
 set the gamma value used in the RDP
 
float get_epsilon () const
 get the epsilon value used in RDP
 
void set_epsilon (float e)
 set the epsilon value used in the RDP
 
Array< 3, float > get_weights () const
 get penalty weights for the neigbourhood More...
 
void set_weights (const Array< 3, float > &)
 set penalty weights for the neigbourhood More...
 
shared_ptr< DiscretisedDensity< 3, elemT > > get_kappa_sptr () const
 get current kappa image More...
 
void set_kappa_sptr (const shared_ptr< DiscretisedDensity< 3, elemT >> &)
 set kappa image
 
bool is_convex () const override
 Indicates if the prior is a smooth convex function. More...
 
template<>
const char *const registered_name
 
- Public Member Functions inherited from stir::GeneralisedPrior< DiscretisedDensity< 3, elemT > >
virtual void compute_Hessian (DiscretisedDensity< 3, elemT > &prior_Hessian_for_single_densel, const BasicCoordinate< 3, int > &coords, const DiscretisedDensity< 3, elemT > &current_image_estimate) const
 This computes a single row of the Hessian. More...
 
virtual void add_multiplication_with_approximate_Hessian (DiscretisedDensity< 3, elemT > &output, const DiscretisedDensity< 3, elemT > &input) const
 This should compute the multiplication of the Hessian with a vector and add it to output. More...
 
virtual void accumulate_Hessian_times_input (DiscretisedDensity< 3, elemT > &output, const DiscretisedDensity< 3, elemT > &current_estimate, const DiscretisedDensity< 3, elemT > &input) const
 This should compute the multiplication of the Hessian with a vector and add it to output. More...
 
float get_penalisation_factor () const
 
void set_penalisation_factor (float new_penalisation_factor)
 
virtual Succeeded set_up (shared_ptr< const DiscretisedDensity< 3, elemT > > const &target_sptr)
 Has to be called before using this object.
 
- Public Member Functions inherited from stir::ParsingObject
 ParsingObject (const ParsingObject &)
 
ParsingObjectoperator= (const ParsingObject &)
 
void ask_parameters ()
 
bool parse (std::istream &f)
 
bool parse (const char *const filename)
 

Static Public Attributes

static const char *const registered_name = "Cuda Relative Difference Prior"
 
- Static Public Attributes inherited from stir::RelativeDifferencePrior< elemT >
static const char *const registered_name
 Name which will be used when parsing a GeneralisedPrior object.
 

Protected Attributes

int z_dim
 
int y_dim
 
int x_dim
 
cppdim3 block_dim
 
cppdim3 grid_dim
 
float * d_weights_data = 0
 Device copy of weights.
 
float * d_kappa_data = 0
 Device copy of kappa.
 
- Protected Attributes inherited from stir::RelativeDifferencePrior< elemT >
float gamma
 Create variable gamma for Relative Difference Penalty.
 
float epsilon
 Create variable epsilon for Relative Difference Penalty.
 
bool only_2D
 can be set during parsing to restrict the weights to the 2D case
 
std::string gradient_filename_prefix
 filename prefix for outputing the gradient whenever compute_gradient() is called. More...
 
Array< 3, float > weights
 penalty weights More...
 
std::string kappa_filename
 Filename for the $\kappa$ image that will be read by post_processing()
 
shared_ptr< DiscretisedDensity< 3, elemT > > kappa_ptr
 
- Protected Attributes inherited from stir::GeneralisedPrior< DiscretisedDensity< 3, elemT > >
float penalisation_factor
 
bool _already_set_up
 
- Protected Attributes inherited from stir::ParsingObject
KeyParser parser
 

Additional Inherited Members

- Static Public Member Functions inherited from stir::RegisteredParsingObject< CudaRelativeDifferencePrior< elemT >, GeneralisedPrior< DiscretisedDensity< 3, elemT > >, RelativeDifferencePrior< elemT > >
static GeneralisedPrior< DiscretisedDensity< 3, elemT > > * read_from_stream (std::istream *)
 Construct a new object (of type Derived) by parsing the istream. More...
 
- Static Public Member Functions inherited from stir::RegisteredParsingObject< RelativeDifferencePrior< elemT >, GeneralisedPrior< DiscretisedDensity< 3, elemT > >, GeneralisedPrior< DiscretisedDensity< 3, elemT > > >
static GeneralisedPrior< DiscretisedDensity< 3, elemT > > * read_from_stream (std::istream *)
 Construct a new object (of type Derived) by parsing the istream. More...
 
- Static Public Member Functions inherited from stir::RegisteredObject< GeneralisedPrior< DiscretisedDensity< 3, elemT > > >
static GeneralisedPrior< DiscretisedDensity< 3, elemT > > * read_registered_object (std::istream *in, const std::string &registered_name)
 Construct a new object (of a type derived from Root, its actual type determined by the registered_name parameter) by parsing the istream. More...
 
static GeneralisedPrior< DiscretisedDensity< 3, elemT > > * ask_type_and_parameters ()
 ask the user for the type, and then calls read_registered_object(0, type) More...
 
static void list_registered_names (std::ostream &stream)
 List all possible registered names to the stream. More...
 
- Protected Types inherited from stir::RegisteredObject< GeneralisedPrior< DiscretisedDensity< 3, elemT > > >
typedef GeneralisedPrior< DiscretisedDensity< 3, elemT > > *(* RootFactory) (std::istream *)
 The type of a root factory is a function, taking an istream* as argument, and returning a Root*.
 
typedef FactoryRegistry< std::string, RootFactory, interfile_lessRegistryType
 The type of the registry.
 
- Protected Member Functions inherited from stir::RelativeDifferencePrior< elemT >
void check (DiscretisedDensity< 3, elemT > const &current_image_estimate) const override
 Check that the prior is ready to be used.
 
void set_defaults () override
 Set defaults before parsing.
 
void initialise_keymap () override
 Initialise all keywords.
 
bool post_processing () override
 This will be called at the end of the parsing. More...
 
double value (const elemT x_j, const elemT x_k) const
 The value and partial derivatives of the Relative Difference Prior. More...
 
elemT derivative_10 (const elemT x, const elemT y) const
 
elemT derivative_20 (const elemT x_j, const elemT x_k) const
 
elemT derivative_11 (const elemT x_j, const elemT x_k) const
 
- Protected Member Functions inherited from stir::GeneralisedPrior< DiscretisedDensity< 3, elemT > >
void set_defaults () override
 sets value for penalisation factor More...
 
void initialise_keymap () override
 sets key for penalisation factor More...
 
virtual void check (DiscretisedDensity< 3, elemT > const &current_estimate) const
 Check that the prior is ready to be used.
 
- Protected Member Functions inherited from stir::ParsingObject
virtual void set_key_values ()
 This will be called before parsing or parameter_info is called. More...
 
- Static Protected Member Functions inherited from stir::RegisteredObject< GeneralisedPrior< DiscretisedDensity< 3, elemT > > >
static RegistryTyperegistry ()
 Static function returning the registry. More...
 

Detailed Description

template<typename elemT>
class stir::CudaRelativeDifferencePrior< elemT >

CUDA implementation of the Relative Difference prior.

See also
RelativeDifferencePrior. Results should be identical.
Todo:
Limitation: currently only weights of size 3x3x3 are supported. Therefore, single slice images will lead to an error being thrown.

Member Function Documentation

◆ compute_value()

template<typename elemT >
double stir::CudaRelativeDifferencePrior< elemT >::compute_value ( const DiscretisedDensity< 3, elemT > &  current_estimate)
overridevirtual

compute the value of the function

For derived classes where this doesn't make sense, it's recommended to return 0.

Implements stir::GeneralisedPrior< DiscretisedDensity< 3, elemT > >.

◆ compute_gradient()

template<typename elemT >
void stir::CudaRelativeDifferencePrior< elemT >::compute_gradient ( DiscretisedDensity< 3, elemT > &  prior_gradient,
const DiscretisedDensity< 3, elemT > &  current_estimate 
)
overridevirtual

This should compute the gradient of the log of the prior function at the current_estimate.

The gradient is already multiplied with the penalisation_factor.

Warning
The derived class should overwrite any data in prior_gradient.

Implements stir::GeneralisedPrior< DiscretisedDensity< 3, elemT > >.


The documentation for this class was generated from the following file: