@@ -685,10 +685,10 @@ LM_distributable_computation_template(const shared_ptr<ProjMatrixByBin> PM_sptr,
685
685
686
686
PM_sptr->get_proj_matrix_elems_for_one_bin (local_row[thread_num], measured_bin);
687
687
call_back (*local_output_image_sptrs[thread_num],
688
- measured_bin,
689
- *input_image_ptr,
690
688
local_row[thread_num],
691
- has_add ? record.my_corr : 0 );
689
+ has_add ? record.my_corr : 0 .F ,
690
+ measured_bin,
691
+ *input_image_ptr);
692
692
}
693
693
}
694
694
#ifdef STIR_OPENMP
@@ -710,56 +710,54 @@ LM_distributable_computation_template(const shared_ptr<ProjMatrixByBin> PM_sptr,
710
710
711
711
constexpr float max_quotient = 10000 .F;
712
712
713
+ /* gradient without the sensitivity term
714
+
715
+ \sum_e A_e^t (y_e/(A_e lambda+ c))
716
+ */
713
717
inline void
714
718
LM_gradient (DiscretisedDensity<3 , float >& output_image,
715
- const Bin& measured_bin,
716
- const DiscretisedDensity<3 , float >& input_image,
717
719
const ProjMatrixElemsForOneBin& row,
718
- const float add_term)
720
+ const float add_term,
721
+ const Bin& measured_bin,
722
+ const DiscretisedDensity<3 , float >& input_image)
719
723
{
720
724
Bin fwd_bin = measured_bin;
721
725
fwd_bin.set_bin_value (0 .0f );
722
726
row.forward_project (fwd_bin, input_image);
727
+ const auto fwd = fwd_bin.get_bin_value () + add_term;
723
728
724
- if (add_term)
725
- fwd_bin.set_bin_value (fwd_bin.get_bin_value () + add_term);
726
-
727
- float measured_div_fwd = 0 .F ;
728
- if (measured_bin.get_bin_value () <= max_quotient * fwd_bin.get_bin_value ())
729
- measured_div_fwd = measured_bin.get_bin_value () / fwd_bin.get_bin_value ();
730
- else
731
- return ;
729
+ if (measured_bin.get_bin_value () > max_quotient * fwd)
730
+ return ; // cancel singularity
731
+ const auto measured_div_fwd = measured_bin.get_bin_value () / fwd;
732
732
733
733
fwd_bin.set_bin_value (measured_div_fwd);
734
734
row.back_project (output_image, fwd_bin);
735
735
}
736
736
737
737
/* Hessian
738
738
739
- \sum_e A_e^t (y_e/(A_e lambda+ c)^2 A_e x )
739
+ \sum_e A_e^t (y_e/(A_e lambda+ c)^2 A_e rhs )
740
740
*/
741
741
inline void
742
742
LM_Hessian (DiscretisedDensity<3 , float >& output_image,
743
+ const ProjMatrixElemsForOneBin& row,
744
+ const float add_term,
743
745
const Bin& measured_bin,
744
746
const DiscretisedDensity<3 , float >& input_image,
745
- const DiscretisedDensity<3 , float >& rhs,
746
- const ProjMatrixElemsForOneBin& row,
747
- const float add_term)
747
+ const DiscretisedDensity<3 , float >& rhs)
748
748
{
749
749
Bin fwd_bin = measured_bin;
750
750
fwd_bin.set_bin_value (0 .0f );
751
751
row.forward_project (fwd_bin, input_image);
752
+ const auto fwd = fwd_bin.get_bin_value () + add_term;
752
753
753
- if (add_term)
754
- fwd_bin.set_bin_value (fwd_bin.get_bin_value () + add_term);
755
-
756
- if (measured_bin.get_bin_value () > max_quotient * fwd_bin.get_bin_value ())
757
- return ;
758
- float measured_div_fwd2 = measured_bin.get_bin_value () / square (fwd_bin.get_bin_value ());
754
+ if (measured_bin.get_bin_value () > max_quotient * fwd)
755
+ return ; // cancel singularity
756
+ const auto measured_div_fwd2 = measured_bin.get_bin_value () / square (fwd);
759
757
758
+ // forward project rhs
760
759
fwd_bin.set_bin_value (0 .0f );
761
760
row.forward_project (fwd_bin, rhs);
762
-
763
761
if (fwd_bin.get_bin_value () == 0 )
764
762
return ;
765
763
0 commit comments