Jpp
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
software
JMath
JCalculator.hh
Go to the documentation of this file.
1
#ifndef __JMATH__JCALCULATOR__
2
#define __JMATH__JCALCULATOR__
3
4
5
/**
6
* \author mdejong
7
*/
8
9
namespace
JMATH {}
10
namespace
JPP {
using namespace
JMATH; }
11
12
namespace
JMATH {
13
14
/**
15
* Auxiliary class for product evaluation of objects.
16
*/
17
template
<
class
T,
int
N = 0>
18
struct
JCalculator
:
19
public
T
// object
20
{
21
static
JCalculator
calculator
;
// calculator
22
};
23
24
25
/**
26
* Calculator.
27
*/
28
template
<
class
T,
int
N>
29
JCalculator<T,N>
JCalculator<T,N>::calculator
;
30
31
32
/**
33
* Product evaluation of objects.
34
*
35
* \param first first object
36
* \param second second object
37
* \return calculator
38
*/
39
template
<
class
T>
40
inline
const
JCalculator<T, 1>
&
operator*
(
const
T& first,
const
T& second)
41
{
42
JCalculator<T, 1>::calculator
.mul(first, second);
43
44
return
JCalculator<T, 1>::calculator
;
45
}
46
47
48
/**
49
* Recursive product evaluation of objects.
50
*
51
* \param first first object
52
* \param second second object
53
* \return calculator
54
*/
55
template
<
class
T,
int
N>
56
inline
const
JCalculator<T, N+1>
&
operator*
(
const
T& first,
const
JCalculator<T, N>
& second)
57
{
58
JCalculator<T, N+1>::calculator
.mul(first, second);
59
60
return
JCalculator<T, N+1>::calculator
;
61
}
62
63
64
/**
65
* Recursive product evaluation of objects.
66
*
67
* \param first first object
68
* \param second second object
69
* \return calculator
70
*/
71
template
<
class
T,
int
N>
72
inline
const
JCalculator<T, N+1>
&
operator*
(
const
JCalculator<T, N>
& first,
const
T& second)
73
{
74
JCalculator<T, N+1>::calculator
.mul(first, second);
75
76
return
JCalculator<T, N+1>::calculator
;
77
}
78
}
79
80
#endif
JMATH::JCalculator::calculator
static JCalculator calculator
Calculator.
Definition:
JCalculator.hh:21
JMATH::operator*
const JCalculator< T, 1 > & operator*(const T &first, const T &second)
Product evaluation of objects.
Definition:
JCalculator.hh:40
JMATH::JCalculator
Auxiliary class for product evaluation of objects.
Definition:
JCalculator.hh:18
Generated by
1.8.5