CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
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 $
3#include "CLHEP/GenericFunctions/FunctionDirectProduct.hh"
4#include <assert.h>
5#include <iostream>
6
7namespace Genfun {
8FUNCTION_OBJECT_IMP(FunctionDirectProduct)
9
11_arg1(arg1->clone()),
12_arg2(arg2->clone()),
13_m(arg1->dimensionality()),
14_n(arg2->dimensionality())
15{
16}
17
19AbsFunction(right),
20_arg1(right._arg1->clone()),
21_arg2(right._arg2->clone()),
22_m(right._m),
23_n(right._n)
24{
25}
26
27
29{
30 delete _arg1;
31 delete _arg2;
32}
33
34
36 unsigned int P = a.dimension();
37 Argument x1(_m);
38 Argument x2(_n);
39 if (_m+_n != P) {
40 std::cerr
41 << "Warning: Direct product function/argument dimension mismatch"
42 << std::endl;
43 assert(0);
44 return 0;
45 }
46 for (unsigned int i = 0; i<_m;i++) {
47 x1[i]=a[i];
48 }
49 for (unsigned int j = 0;j<_n;j++) {
50 x2[j]=a[j+_m];
51 }
52 return (*_arg1)(x1) * (*_arg2)(x2);
53}
54
56 return _m+_n;
57}
58
60{
61 std::cerr
62 << "Warning. direct product called with scalar argument"
63 << std::endl;
64 assert(0);
65 return 0;
66}
67
68
69
70Derivative FunctionDirectProduct::partial(unsigned int index) const {
71 assert (index<(_m+_n));
72 if (index<_m) {
73 const AbsFunction & fPrime = (_arg1->partial(index))%(*_arg2);
74 return Derivative(&fPrime);
75 }
76 else {
77 const AbsFunction & fPrime = (*_arg1)%(_arg2->partial(index-_m));
78 return Derivative(&fPrime);
79 }
80}
81
82
83} // namespace Genfun
#define FUNCTION_OBJECT_IMP(classname)
Definition: AbsFunction.hh:149
virtual Derivative partial(unsigned int) const
Definition: AbsFunction.cc:40
unsigned int dimension() const
Definition: Argument.hh:61
Derivative partial(unsigned int) const override
virtual double operator()(double argument) const override
FunctionDirectProduct(const AbsFunction *arg1, const AbsFunction *arg2)
virtual unsigned int dimensionality() const override
Definition: Abs.hh:14
FunctionNoop Derivative
Definition: AbsFunction.hh:42