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

scaled_real_parameter.cc

Go to the documentation of this file.
00001 // scaled_real_parameter.cc
00002 // SuperMix version 1.0  C++ source file
00003 //
00004 // Copyright (c) 1999 California Institute of Technology.
00005 // All rights reserved.
00006 //
00007 // Redistribution and use in source and binary forms for noncommercial
00008 // purposes are permitted provided that the above copyright notice and
00009 // this paragraph are duplicated in all such forms and that any
00010 // documentation and other materials related to such distribution and
00011 // use acknowledge that the software was developed by California
00012 // Institute of Technology. Redistribution and/or use in source or
00013 // binary forms is not permitted for any commercial purpose. Use of
00014 // this software does not include a permitted use of the Institute's
00015 // name or trademark for any purpose.
00016 //
00017 // DISCLAIMER:
00018 // THIS SOFTWARE AND/OR RELATED MATERIALS ARE PROVIDED "AS-IS" WITHOUT
00019 // WARRANTY OF ANY KIND INCLUDING ANY WARRANTIES OF PERFORMANCE OR
00020 // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE OR PURPOSE (AS SET
00021 // FORTH IN UCC 23212-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
00022 // LICENSED PRODUCT, HOWEVER USED.  IN NO EVENT SHALL CALTECH/JPL BE
00023 // LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING BUT NOT LIMITED TO
00024 // INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, INCLUDING ECONOMIC
00025 // DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, REGARDLESS OF
00026 // WHETHER CALTECH/JPL SHALL BE ADVISED, HAVE REASON TO KNOW, OR IN
00027 // FACT SHALL KNOW OF THE POSSIBILITY.  THE USER BEARS ALL RISK
00028 // RELATING TO QUALITY AND PERFORMANCE OF THE SOFTWARE AND/OR RELATED
00029 // MATERIALS.
00030 
00031 #include "parameter/scaled_real_parameter.h"
00032 #include "global.h"
00033 #include "error.h"
00034 
00035 
00036 // default constructor
00037 scaled_real_parameter::scaled_real_parameter() :
00038   shadowed(0),
00039   scale(0.),
00040   get_flag(0)
00041 { }
00042 
00043 scaled_real_parameter::scaled_real_parameter(const double s, abstract_real_parameter & p) :
00044   shadowed(&p),
00045   scale(s),
00046   get_flag(0)
00047 { }
00048 
00049 double scaled_real_parameter::get() const
00050 {
00051   if(shadowed==0)
00052   {
00053     error::warning(
00054       "Accessing an uninitialized scaled_real_parameter, returning zero.");
00055     return 0.0;
00056   }
00057 
00058   if(get_flag)     // is flag on already !!?
00059   {
00060     get_flag = 0;  // reset it for next time
00061     error::warning(
00062        "Terminating infinite real_parameter shadowing loop, returning zero.");
00063     return 0.;
00064   }
00065 
00066   get_flag = 1;
00067 
00068   double v = scale * shadowed->get();
00069 
00070   get_flag = 0;
00071 
00072   return v;
00073 }
00074 
00075 void scaled_real_parameter::set(const double s, abstract_real_parameter & p)
00076 {
00077   shadowed = &p;
00078   scale = s;
00079 }

Please direct comments and corrections to supermix@submm.caltech.edu
Go to the supermix home page
Generated by doxygen1.2.7