Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

bound_delta.cc

Go to the documentation of this file.
00001 // Bound Delta implementation -*- C++ -*-
00002 
00003 // Copyright (C) 2001-2003 Hermann Schichl
00004 //
00005 // This file is part of the COCONUT API.  This library
00006 // is free software; you can redistribute it and/or modify it under the
00007 // terms of the Library GNU General Public License as published by the
00008 // Free Software Foundation; either version 2, or (at your option)
00009 // any later version.
00010 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // Library GNU General Public License for more details.
00015 
00016 // As a special exception, you may use this file as part of a free software
00017 // library without restriction.  Specifically, if other files instantiate
00018 // templates or use macros or inline functions from this file, or you compile
00019 // this file and link it with other files to produce an executable, this
00020 // file does not by itself cause the resulting executable to be covered by
00021 // the Library GNU General Public License.  This exception does not however
00022 // invalidate any other reasons why the executable file might be covered by
00023 // the Library GNU General Public License.
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 

Generated on Tue Nov 4 01:57:56 2003 for COCONUT API by doxygen1.2.18