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 _arg1(right._arg1->clone()),
19 _arg2(right._arg2->clone()),
20 _m(right._m),
21 _n(right._n)
22 {
23 }
24 
25 
27 {
28  delete _arg1;
29  delete _arg2;
30 }
31 
32 
34  unsigned int P = a.dimension();
35  Argument x1(_m);
36  Argument x2(_n);
37  if (_m+_n != P) {
38  std::cerr
39  << "Warning: Direct product function/argument dimension mismatch"
40  << std::endl;
41  assert(0);
42  return 0;
43  }
44  for (unsigned int i = 0; i<_m;i++) {
45  x1[i]=a[i];
46  }
47  for (unsigned int j = 0;j<_n;j++) {
48  x2[j]=a[j+_m];
49  }
50  return (*_arg1)(x1) * (*_arg2)(x2);
51 }
52 
54  return _m+_n;
55 }
56 
57 double FunctionDirectProduct::operator ()(double x) const
58 {
59  std::cerr
60  << "Warning. direct product called with scalar argument"
61  << std::endl;
62  assert(0);
63  return 0;
64 }
65 
66 
67 
68 Derivative FunctionDirectProduct::partial(unsigned int index) const {
69  assert (index<(_m+_n));
70  if (index<_m) {
71  const AbsFunction & fPrime = (_arg1->partial(index))%(*_arg2);
72  return Derivative(&fPrime);
73  }
74  else {
75  const AbsFunction & fPrime = (*_arg1)%(_arg2->partial(index-_m));
76  return Derivative(&fPrime);
77  }
78 }
79 
80 
81 } // namespace Genfun