![]() |
Reference Documentation |
00001 /********************************************************************** 00002 * * 00003 * Copyright (c) 2002 Jakub MOSCICKI, CERN/IT * 00004 * <Jakub.MOSCICKI@cern.ch> * 00005 * * 00006 * This library is free software; you can redistribute it and/or * 00007 * modify it under the terms of the GNU Lesser General Public * 00008 * License as published by the Free Software Foundation; either * 00009 * version 2.1 of the License, or (at your option) 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 GNU * 00014 * Lesser General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU Lesser General Public * 00017 * License along with this library (see file COPYING); if not, write * 00018 * to the Free Software Foundation, Inc., 59 Temple Place, Suite * 00019 * 330, Boston, MA 02111-1307 USA, or contact the author at * 00020 * <Jakub.MOSCICKI@cern.ch> * 00021 **********************************************************************/ 00022 00023 // Implementation file for class Function 00024 // 00025 // Created by: Jakub MOSCICKI at Tue Jan 15 13:05:27 2002 00026 // 00027 // Last update: Tue Jan 15 13:05:27 2002 00028 // 00029 00030 #include "Function.h" 00031 00032 # include <algorithm> 00033 00034 #if ( ((defined __sun) && (__SUNPRO_CC > 0x0500)) ) 00035 # include <assert.h> 00036 #endif 00037 00038 using std::vector; 00039 using std::string; 00040 00041 Function_plain_wrapper::Function_plain_wrapper(string label, Anaphe::IModelFunction *modelFun) : m_label(label), m_modelFun(modelFun)//, m_owner(true) 00042 { 00043 assert(m_modelFun); 00044 // assert(m_modelFun.get()); 00045 _init(); 00046 m_version = std::string(AIDA_VERSION); 00047 } 00048 00049 /* 00050 Function_plain_wrapper::Function_plain_wrapper(string label, Anaphe::IModelFunction* modelFun, bool owner) : m_label(label), m_modelFun(modelFun), m_owner(owner) 00051 { 00052 assert(m_modelFun.get()); 00053 _init(); 00054 } 00055 */ 00056 00057 void Function_plain_wrapper::_init() 00058 { 00059 for(int i=0; i<m_modelFun->numberOfParameters(); ++i) 00060 m_parNames.push_back(m_modelFun->nameOfParameter(i)); 00061 00062 m_parVals = m_modelFun->parameters(); 00063 } 00064 00065 Function_plain_wrapper::~Function_plain_wrapper() 00066 { 00067 // if(!m_owner) 00068 // m_modelFun.release(); 00069 } 00070 00071 Function_plain_wrapper::Function_plain_wrapper(const Function_plain_wrapper &) 00072 { 00073 } 00074 00075 Function_plain_wrapper & Function_plain_wrapper::operator = (const Function_plain_wrapper &rhs) 00076 { 00077 if (this == &rhs) return *this; // time saving self-test 00078 00079 return *this; 00080 } 00081 00082 const std::string & Function_plain_wrapper::label ( ) const 00083 { 00084 return m_label; 00085 } 00086 00087 double Function_plain_wrapper::value ( const std::vector< double > & point ) const 00088 { 00089 return m_modelFun->value(point); 00090 } 00091 00092 int Function_plain_wrapper::dimension ( ) const 00093 { 00094 return m_modelFun->dimension(); 00095 } 00096 00097 const std::vector< std::string > & Function_plain_wrapper::parameterNames ( ) const 00098 { 00099 return m_parNames; 00100 } 00101 00102 const std::vector< double > & Function_plain_wrapper::parameterValues ( ) const 00103 { 00104 return m_parVals; 00105 } 00106 00107 const string & Function_plain_wrapper::version ( ) const 00108 { 00109 return m_version; 00110 } 00111 00112 bool Function_plain_wrapper::setParameterValue ( const std::string & name, double value ) 00113 { 00114 vector<string>::iterator pos = std::find(m_parNames.begin(),m_parNames.end(),name); 00115 00116 if(pos!=m_parNames.end()) 00117 { 00118 assert(pos-m_parNames.begin()<m_parVals.size()); 00119 m_parVals[pos-m_parNames.begin()] = value; 00120 m_modelFun->setParameters(m_parVals); 00121 return true; 00122 } 00123 00124 return false; 00125 } 00126 00127 bool Function_plain_wrapper::setParameterValues(vector<double> vals) 00128 { 00129 if(vals.size()!=m_parVals.size()) return false; 00130 00131 m_parVals = vals; 00132 m_modelFun->setParameters(m_parVals); 00133 00134 return true; 00135 } 00136 00137 Function_impl_owner::Function_impl_owner(string label, std::auto_ptr<Anaphe::IModelFunction> modelFun) : m_modelFun(modelFun), m_wrapper(label, modelFun.get()) 00138 {} 00139 00140 00141 00142 00143
Anaphe documentation generated by Doxygen (www.doxygen.org) |