GeoModel - GeoModelCore
Sigma.cpp
1 //==========================================================================//
2 // Imported from the QAT library (qat.pitt.edu) by the copyright holder //
3 // Joe Boudreau. Software licensed under the terms and conditions of the //
4 // GNU Lesser Public License v3. //
5 //==========================================================================//
6 #include "GeoGenericFunctions/Sigma.h"
7 #include <stdexcept>
8 
9 namespace GeoGenfun {
10 FUNCTION_OBJECT_IMP(Sigma)
11 
12 void Sigma::accumulate( const AbsFunction & fcn) {
13  _fcn.push_back(fcn.clone());
14 }
15 
16 Sigma::Sigma()
17 {
18 }
19 
20 Sigma::Sigma(const Sigma & right) : AbsFunction(right)
21 {
22  for (size_t i=0; i<right._fcn.size();i++) {
23  _fcn.push_back(right._fcn[i]->clone());
24  }
25 }
26 
27 unsigned int Sigma::dimensionality() const {
28  if (_fcn.size()==0) throw std::runtime_error("Cannot determine dimensionality from empty sum");
29  return _fcn[0]->dimensionality();
30 }
31 
32 Sigma::~Sigma()
33 {
34  for (size_t i=0; i<_fcn.size();i++) {
35  delete _fcn[i];
36  }
37 }
38 
39 double Sigma::operator ()(double x) const
40 {
41  double retVal=0.0;
42  for (size_t i=0;i<_fcn.size();i++) retVal += (*_fcn[i])(x);
43  return retVal;
44 }
45 
46 
47 double Sigma::operator ()(const Argument & x) const
48 {
49  double retVal=0.0;
50  for (size_t i=0;i<_fcn.size();i++) retVal += (*_fcn[i])(x);
51  return retVal;
52 }
53 
54 
55 
56 Derivative Sigma::partial(unsigned int index) const {
57  Sigma fPrime;
58  for (size_t i=0;i<_fcn.size();i++) {
59  fPrime.accumulate(_fcn[i]->partial(index));
60  }
61  return Derivative(&fPrime);
62 }
63 
64 
65 
66 } // namespace GeoGenfun
Definition: Abs.h:15