Anaphe Home Page Reference Documentation

Main Page     Namespaces     Classes     Source Code    

H_Bin_Helper.cpp

Go to the documentation of this file.
00001 #include "HTL/H_Bin_Helper.h"
00002 
00003 
00004 #define CLASS___ H_Bin_Helper
00005 
00006 
00007 
00008 double CLASS___::in_range_error( const I_Histo &a_histo
00009         , const H_F1d & an_operation )
00010         // For each in-range bin, apply `operation' on the `error' and
00011         // add all of the obtained errors.
00012         // * By default (i.e., in case of H_Identity() ), is returned:
00013         //      SUM[ error() ] 
00014         // * Otherwise:
00015         //      SUM[ operation(error()) ]
00016         //   e.g. When `operation' is H_Sqr, is computed:
00017         //      SUM[ sqr(error()) ]
00018 {
00019         H_F1d &operation = (H_F1d &) an_operation;
00020         I_Histo &h = (I_Histo &) a_histo;
00021         double result = operation( h.i_bin(0).error() );
00022         for( Index i=1; i<h.bin_count(); i++ ) {
00023                 result += operation( h.i_bin(i).error() );
00024         }
00025         return result;
00026 }
00027 
00028 double CLASS___::in_range_value( const I_Histo &a_histo
00029         , const H_F1d & an_operation )
00030         // For each in-range bin, apply `operation' on the `value' and
00031         // add all of the obtained values.
00032         // * By default (i.e., in case of H_Identity() ), is returned:
00033         //      SUM[ value() ] 
00034         // * Otherwise:
00035         //      SUM[ operation(value()) ]
00036         //   e.g. When `operation' is H_Sqr, is computed:
00037         //      SUM[ sqr(value()) ]
00038 {
00039         H_F1d &operation = (H_F1d &) an_operation;
00040         I_Histo &h = (I_Histo &) a_histo;
00041         double result = operation( h.i_bin(0).value() );
00042         for( Index i=1; i<h.bin_count(); i++ ) {
00043                 result += operation( h.i_bin(i).value() );
00044         }
00045         return result;
00046 }
00047 
00048 double CLASS___::in_range_min_value( const I_Histo &a_histo )
00049         // Min value of in-range bins of histo `a_histo'.
00050 {
00051         I_Histo &h = (I_Histo &) a_histo;
00052         double result = h.i_bin(0).value();
00053         double v = 0.0;
00054         for( Index i=1; i<h.bin_count(); i++ ) {
00055                 v = h.i_bin(i).value();
00056                 if( v<result ) result = v;
00057         }
00058         return result;
00059 }
00060 
00061 double CLASS___::in_range_max_value( const I_Histo &a_histo )
00062         // Max value of in-range bins of histo `a_histo'.
00063 {
00064         I_Histo &h = (I_Histo &) a_histo;
00065         double result = h.i_bin(0).value();
00066         double v = 0.0;
00067         for( Index i=1; i<h.bin_count(); i++ ) {
00068                 v = h.i_bin(i).value();
00069                 if( v>result ) result = v;
00070         }
00071         return result;
00072 }
00073 
00074 double CLASS___::bin_center( const I_Histo &a_histo, Index p,
00075         I_Histo::I_Bin_Location &l )
00076         // Center of the bin indexed/located by `l' on axis `p' 
00077         // of the histo `a_histo'.
00078 {
00079   I_Histo &h = (I_Histo &) a_histo;
00080   if (h.dim() >= p && l.size() >= (unsigned long)p) {
00081     if( (h.i_bin(l).count() != 0) && (h.i_bin(l).offset(p) == 0 )) {
00082       // Absolute gravity center stored in the bin:
00083       return h.i_bin(l).center(p);
00084     } else {
00085       // Relative gravity center stored in the bin:
00086       return h.i_partition(p).i_lower_point( l[p] ) +
00087         h.i_partition(p).i_bin_width( l[p] ) * 0.5;
00088     }
00089   } else {
00090     HTL_ERR("Incompatible index or dimension in bin_center(). Center is zero");
00091     return 0;
00092   }
00093 }
00094 
00095 
00096 #undef CLASS___
00097 


Anaphe documentation generated by Doxygen (www.doxygen.org)