Go to the documentation of this file.00001
00002 #include "rrel_estimation_problem.h"
00003
00004 #include <rrel/rrel_wls_obj.h>
00005
00006 #include <vcl_vector.h>
00007 #include <vcl_cassert.h>
00008
00009 rrel_estimation_problem::rrel_estimation_problem( unsigned int dof,
00010 unsigned int num_samples_for_fit )
00011 : dof_( dof ),
00012 num_samples_for_fit_( num_samples_for_fit ),
00013 scale_type_( NONE ),
00014 single_scale_( 0 ),
00015 multiple_scales_( 0 )
00016 {
00017 }
00018
00019 rrel_estimation_problem::rrel_estimation_problem( )
00020 : scale_type_( NONE ),
00021 single_scale_( 0 ),
00022 multiple_scales_( 0 )
00023 {
00024 }
00025
00026 rrel_estimation_problem::~rrel_estimation_problem( )
00027 {
00028 delete multiple_scales_;
00029 }
00030
00031
00032 void
00033 rrel_estimation_problem::compute_weights( const vcl_vector<double>& residuals,
00034 const rrel_wls_obj* obj,
00035 double scale,
00036 vcl_vector<double>& weights ) const
00037 {
00038 if ( residuals.size() != weights.size())
00039 weights.resize( residuals.size() );
00040
00041 switch ( scale_type_ ) {
00042 case NONE:
00043 obj->wgt( residuals.begin(), residuals.end(), scale, weights.begin() );
00044 break;
00045 case SINGLE:
00046 obj->wgt( residuals.begin(), residuals.end(), single_scale_, weights.begin() );
00047 break;
00048 case MULTIPLE:
00049 obj->wgt( residuals.begin(), residuals.end(), multiple_scales_->begin(), weights.begin() );
00050 break;
00051 default:
00052 assert(!"Invalid scale_type");
00053 break;
00054 }
00055 }
00056
00057
00058 const vcl_vector<double>&
00059 rrel_estimation_problem::prior_multiple_scales() const
00060 {
00061 assert( scale_type_ == MULTIPLE );
00062 return *multiple_scales_;
00063 }
00064
00065 double
00066 rrel_estimation_problem::prior_scale() const
00067 {
00068 assert( scale_type_ == SINGLE );
00069 return single_scale_;
00070 }
00071
00072 void
00073 rrel_estimation_problem::set_prior_multiple_scales( const vcl_vector<double>& scales )
00074 {
00075 if ( ! multiple_scales_ ) {
00076 multiple_scales_ = new vcl_vector<double>;
00077 }
00078 *multiple_scales_ = scales;
00079 scale_type_ = MULTIPLE;
00080 }
00081
00082 void
00083 rrel_estimation_problem::set_prior_scale( double scale )
00084 {
00085 single_scale_ = scale;
00086 scale_type_ = SINGLE;
00087 }
00088
00089 void
00090 rrel_estimation_problem::set_no_prior_scale( )
00091 {
00092 scale_type_ = NONE;
00093 }