MINT2
ComplexProduct.cpp
Go to the documentation of this file.
1 // author: Jonas Rademacker (Jonas.Rademacker@bristol.ac.uk)
2 // status: Mon 9 Feb 2009 19:17:55 GMT
3 #include "Mint/ComplexProduct.h"
4 #include <iostream>
5 using namespace std;
6 using namespace MINT;
7 
8 ComplexProduct::ComplexProduct(IFitParRegister* daddy)
9  : FitParDependent(daddy), _facVec(), _fixedDoubleVec(), _fixedComplexVec()
10 {
11 }
13  : FitParDependent(daddy), _facVec(), _fixedDoubleVec(), _fixedComplexVec()
14 {
15  addTerm(initVal);
16 }
17 
18 ComplexProduct::ComplexProduct(const std::complex<double>& z, IFitParRegister* daddy)
19  : FitParDependent(daddy), _facVec(), _fixedDoubleVec(), _fixedComplexVec()
20 {
21  addTerm(z);
22 }
23 
25  : FitParDependent(other, newDaddy)
26  , _facVec(other._facVec)
27  , _fixedDoubleVec(other._fixedDoubleVec)
28  , _fixedComplexVec(other._fixedComplexVec)
29 {
30 }
31 
33  _facVec.clear();
34  _fixedDoubleVec.clear();
35  _fixedComplexVec.clear();
37 }
38 
39 
40 void ComplexProduct::multiply(const ComplexProduct& multiplyWith)
41 {
42  registerFitParDependence(multiplyWith);
43  for(unsigned int i=0; i< multiplyWith._facVec.size(); i++){
44  addTerm(multiplyWith._facVec[i]);
45  }
46  for(unsigned int i=0; i< multiplyWith._fixedDoubleVec.size(); i++){
47  addTerm(multiplyWith._fixedDoubleVec[i]);
48  }
49  for(unsigned int i=0; i< multiplyWith._fixedComplexVec.size(); i++){
50  addTerm(multiplyWith._fixedComplexVec[i]);
51  }
52 }
53 
54 
55 void ComplexProduct::addTerm(double val){
56  _fixedDoubleVec.push_back(val);
57 }
58 
59 void ComplexProduct::addTerm(const std::complex<double>& z){
60  // counted_ptr<IReturnComplex> bz(new BasicComplex(z));
61  // addTerm(bz);
62  _fixedComplexVec.push_back(z);
63 }
64 
66  bool dbThis=false;
68  _facVec.push_back(irc);
69  if(dbThis){
70  cout << "ComplexProduct::addTerm as pointer"
71  << " just got: " << irc->ComplexVal()
72  << " taking me to prod = " << ComplexVal()
73  << endl;
74  }
75 }
77  bool dbThis=false;
78  _facVec.push_back(irc);
79  if(dbThis){
80  cout << "ComplexProduct::addTerm as pointer"
81  << " just got: " << irc->ComplexVal()
82  << " taking me to prod = " << ComplexVal()
83  << endl;
84  }
85 }
86 
88  addTerm(val);
89  return *this;
90 }
91 ComplexProduct& ComplexProduct::operator*=(const std::complex<double>& z){
92  addTerm(z);
93  return *this;
94 }
96  irc){
97  addTerm(irc);
98  return *this;
99 }
100 
102  multiply(cp);
103  return *this;
104 }
105 
106 /* now inlined:
107 std::complex<double> ComplexProduct::ComplexVal(){
108  std::complex<double> prod(1,0);
109 
110  for(unsigned i = 0; i < _facVec.size(); i++){
111  prod *= (_facVec[i])->ComplexVal();
112  }
113 
114  return prod;
115 }
116 */
117 //
ComplexProduct(IFitParRegister *daddy=0)
virtual std::complex< double > ComplexVal()=0
std::complex< double > ComplexVal()
std::vector< double > _fixedDoubleVec
ComplexProduct & operator *=(double val)
void multiply(const ComplexProduct &multiplyWith)
virtual bool registerFitParDependence(const IFitParDependent &fpd)
void addTerm(double val)
std::vector< counted_ptr< IReturnComplex > > _facVec
std::vector< std::complex< double > > _fixedComplexVec