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
6namespace Genfun {
7FUNCTION_OBJECT_IMP(FunctionDirectProduct)
8
10_arg1(arg1->clone()),
11_arg2(arg2->clone()),
12_m(arg1->dimensionality()),
13_n(arg2->dimensionality())
14{
15}
16
18AbsFunction(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
69Derivative 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
#define FUNCTION_OBJECT_IMP(classname)
virtual Derivative partial(unsigned int) const
Definition: AbsFunction.cc:40
virtual double operator()(double argument) const
virtual unsigned int dimensionality() const
FunctionDirectProduct(const AbsFunction *arg1, const AbsFunction *arg2)
Derivative partial(unsigned int) const
@ a