00001 // SuperMix version 1.0 C++ source file 00002 // 00003 // Copyright (c) 1999 California Institute of Technology. 00004 // All rights reserved. 00005 // 00006 // Redistribution and use in source and binary forms for noncommercial 00007 // purposes are permitted provided that the above copyright notice and 00008 // this paragraph are duplicated in all such forms and that any 00009 // documentation and other materials related to such distribution and 00010 // use acknowledge that the software was developed by California 00011 // Institute of Technology. Redistribution and/or use in source or 00012 // binary forms is not permitted for any commercial purpose. Use of 00013 // this software does not include a permitted use of the Institute's 00014 // name or trademark for any purpose. 00015 // 00016 // DISCLAIMER: 00017 // THIS SOFTWARE AND/OR RELATED MATERIALS ARE PROVIDED "AS-IS" WITHOUT 00018 // WARRANTY OF ANY KIND INCLUDING ANY WARRANTIES OF PERFORMANCE OR 00019 // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE OR PURPOSE (AS SET 00020 // FORTH IN UCC 23212-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE 00021 // LICENSED PRODUCT, HOWEVER USED. IN NO EVENT SHALL CALTECH/JPL BE 00022 // LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING BUT NOT LIMITED TO 00023 // INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, INCLUDING ECONOMIC 00024 // DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, REGARDLESS OF 00025 // WHETHER CALTECH/JPL SHALL BE ADVISED, HAVE REASON TO KNOW, OR IN 00026 // FACT SHALL KNOW OF THE POSSIBILITY. THE USER BEARS ALL RISK 00027 // RELATING TO QUALITY AND PERFORMANCE OF THE SOFTWARE AND/OR RELATED 00028 // MATERIALS. 00029 00030 // ************************************************************************ 00031 // 00032 // simple_error_func.cc 00033 // 00034 // See simple_error_func.h for more information. 00035 // 00036 // 4/21/99 by John Ward 00037 // 00038 // Based on errfunc.cc written 7/22/98 J.Z. 00039 // 00040 // 9/11/00: Changed class name to error_func_parameters 00041 // 9/8/00: Inlined simple_error_func::vary_parameter::get(), set(). Some 00042 // general rearrangement of functionality. 00043 // 00044 // ************************************************************************ 00045 00046 #include "simple_error_func.h" 00047 #include "error.h" 00048 00049 abstract_real_parameter * error_func_parameters::vary(double min, double init, 00050 double max, double scale) 00051 { 00052 if(min > max) 00053 error::fatal("min > max in error_func_parameters::vary() argument list"); 00054 00055 if(scale <= 0.0) 00056 error::fatal("Units argument <= 0 in error_func_parameters::vary()"); 00057 00058 // scale the min, init, and max values 00059 min *= scale; 00060 init *= scale; 00061 max *= scale; 00062 00063 // increment the count and save the values in their associated vectors 00064 num_parms++; 00065 minimum.push_back(min); 00066 initial.push_back(init); // this value isn't limited by min, max 00067 maximum.push_back(max); 00068 units.push_back(scale); 00069 00070 // create and set the associated variable to a limited initial value 00071 init = limit(min, init, max); 00072 parms.push_back(init); // the actual value is limited by min,max 00073 current.push_back(error_func_parameters::vary_parameter(init)); 00074 00075 // Return an abstract_real_parameter pointer to the variable 00076 // Note that the following funny syntax is needed. 00077 // The * dereferences the STL reverse_iterator rbegin(), which 00078 // "points" to the last element of the list. 00079 // The & produces a pointer to an abstract_real_parameter object. 00080 return(&(*current.rbegin())) ; 00081 } 00082 00083 real_vector error_func_parameters::get_parms_user() 00084 { 00085 real_vector pv(size(), Index_1); 00086 00087 for(int i = 1; i <= size(); i++) 00088 pv[i] = parms[i]/units[i]; 00089 00090 return(pv) ; 00091 } 00092 00093 void error_func_parameters::set_parms(const real_vector & pv) 00094 { 00095 // check if vector length is ok 00096 int imin = pv.minindex() ; 00097 int imax = pv.maxindex() ; 00098 if(size() != imax-imin+1) { 00099 error::warning( 00100 "error_func_parameters::set_parms: length of real_vector != number of parameters") ; 00101 } 00102 00103 // and store away the values (note that we will take incorrect length) 00104 int i = imin ; 00105 int j = 1; // index into minimum, maximum, and parms vectors (Index_1) 00106 std::list<vary_parameter>::iterator ip ; 00107 for(ip=current.begin(); ip!= current.end() && i <= imax; ip++, i++, j++) 00108 { 00109 double v = limit(minimum[j], pv[i], maximum[j]); 00110 parms[j] = v; 00111 ip->set(v); 00112 } 00113 00114 return ; 00115 } 00116
Please direct comments and corrections to
supermix@submm.caltech.edu
Go to the supermix home page
Generated by
1.2.7