CLHEP VERSION Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

FunctionDirectProduct.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 // $Id: FunctionDirectProduct.cc,v 1.3 2003/09/06 14:04:14 boudreau Exp $
4 #include <assert.h>
5 
6 namespace Genfun {
7 FUNCTION_OBJECT_IMP(FunctionDirectProduct)
8 
10 _arg1(arg1->clone()),
11 _arg2(arg2->clone()),
12 _m(arg1->dimensionality()),
13 _n(arg2->dimensionality())
14 {
15 }
16 
18 AbsFunction(right),
19 _arg1(right._arg1->clone()),
20 _arg2(right._arg2->clone()),
21 _m(right._m),
22 _n(right._n)
23 {
24 }
25 
26 
28 {
29  delete _arg1;
30  delete _arg2;
31 }
32 
33 
35  unsigned int P = a.dimension();
36  Argument x1(_m);
37  Argument x2(_n);
38  if (_m+_n != P) {
39  std::cerr
40  << "Warning: Direct product function/argument dimension mismatch"
41  << std::endl;
42  assert(0);
43  return 0;
44  }
45  for (unsigned int i = 0; i<_m;i++) {
46  x1[i]=a[i];
47  }
48  for (unsigned int j = 0;j<_n;j++) {
49  x2[j]=a[j+_m];
50  }
51  return (*_arg1)(x1) * (*_arg2)(x2);
52 }
53 
55  return _m+_n;
56 }
57 
59 {
60  std::cerr
61  << "Warning. direct product called with scalar argument"
62  << std::endl;
63  assert(0);
64  return 0;
65 }
66 
67 
68 
69 Derivative FunctionDirectProduct::partial(unsigned int index) const {
70  assert (index<(_m+_n));
71  if (index<_m) {
72  const AbsFunction & fPrime = (_arg1->partial(index))%(*_arg2);
73  return Derivative(&fPrime);
74  }
75  else {
76  const AbsFunction & fPrime = (*_arg1)%(_arg2->partial(index-_m));
77  return Derivative(&fPrime);
78  }
79 }
80 
81 
82 } // namespace Genfun
Genfun::FunctionDirectProduct::FunctionDirectProduct
FunctionDirectProduct(const AbsFunction *arg1, const AbsFunction *arg2)
Definition: FunctionDirectProduct.cc:9
Genfun::FunctionDirectProduct::operator()
virtual double operator()(double argument) const
Definition: FunctionDirectProduct.cc:58
a
@ a
Definition: testCategories.cc:125
Genfun::Derivative
FunctionNoop Derivative
Definition: CLHEP/GenericFunctions/AbsFunction.hh:40
Genfun::AbsFunction
Definition: CLHEP/GenericFunctions/AbsFunction.hh:48
Genfun::FunctionDirectProduct::~FunctionDirectProduct
virtual ~FunctionDirectProduct()
Definition: FunctionDirectProduct.cc:27
FunctionDirectProduct.hh
Genfun::Argument
Definition: CLHEP/GenericFunctions/Argument.hh:17
Genfun::FunctionNoop
Definition: CLHEP/GenericFunctions/FunctionNoop.hh:19
j
long j
Definition: JamesRandomSeeding.txt:28
Genfun::AbsFunction::partial
virtual Derivative partial(unsigned int) const
Definition: AbsFunction.cc:40
i
long i
Definition: JamesRandomSeeding.txt:27
Genfun::FunctionDirectProduct::dimensionality
virtual unsigned int dimensionality() const
Definition: FunctionDirectProduct.cc:54
FUNCTION_OBJECT_IMP
#define FUNCTION_OBJECT_IMP(classname)
Definition: CLHEP/GenericFunctions/AbsFunction.hh:156
Genfun::FunctionDirectProduct::partial
Derivative partial(unsigned int) const
Definition: FunctionDirectProduct.cc:69
Genfun
Definition: CLHEP/GenericFunctions/Abs.hh:14
Genfun::FunctionDirectProduct
Definition: CLHEP/GenericFunctions/FunctionDirectProduct.hh:23