00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00027 #include <bound_delta.h>
00028
00029 bool bound_delta::apply(work_node& _x, undelta_base*& _u) const
00030 {
00031 double _gain(1.);
00032 std::vector<interval>::const_iterator _i;
00033 if(indices.empty())
00034 {
00035 std::vector<interval>::const_iterator _e(new_f_bounds.end()),
00036 _xo(_x.node_ranges.begin());
00037 _u = (undelta_base *) new bound_undelta(indices, _x.node_ranges,
00038 _x.gain_factor, _x.log_vol);
00039 _x.node_ranges = new_f_bounds;
00040 for(_i = new_f_bounds.begin(); _i != _e; ++_i, ++_xo)
00041 _gain *= gainfactor(*_xo, *_i);
00042 }
00043 else
00044 {
00045 std::vector<unsigned int>::const_iterator _c,_e;
00046
00047 _e = indices.end();
00048 _u = (undelta_base *) new bound_undelta(indices, _x.gain_factor,
00049 _x.log_vol);
00050 ((bound_undelta*)_u)->old_f_bounds.reserve(indices.size());
00051 _i = new_f_bounds.begin();
00052 for(_c = indices.begin(); _c != _e; ++_c)
00053 {
00054 const interval& __ix(_x.node_ranges[*_c]);
00055 _gain *= gainfactor(__ix, *_i);
00056 ((bound_undelta*)_u)->old_f_bounds.push_back(__ix);
00057 _x.node_ranges[*_c] = *_i;
00058 ++_i;
00059 }
00060 }
00061 _x.log_vol = _x.compute_log_volume(_x.node_ranges);
00062 _x.gain_factor *= _gain;
00063 return true;
00064 }
00065
00066 bool bound_undelta::unapply(work_node& _x) const
00067 {
00068 if(indices.empty())
00069 _x.node_ranges = old_f_bounds;
00070 else
00071 {
00072 std::vector<unsigned int>::const_iterator _c,_e;
00073 std::vector<interval>::const_iterator _i;
00074
00075 _e = indices.end();
00076 _i = old_f_bounds.begin();
00077 for(_c = indices.begin(); _c != _e; ++_c)
00078 _x.node_ranges[*_c] = *_i++;
00079 }
00080 _x.gain_factor = old_gain;
00081 _x.log_vol = old_log_vol;
00082 return true;
00083 }
00084