blitz
Version 1.0.2
Loading...
Searching...
No Matches
numtrait.h
Go to the documentation of this file.
1
// -*- C++ -*-
2
/***************************************************************************
3
* blitz/numtrait.h Declaration of the NumericTypeTraits class
4
*
5
* $Id$
6
*
7
* Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org>
8
*
9
* This file is a part of Blitz.
10
*
11
* Blitz is free software: you can redistribute it and/or modify
12
* it under the terms of the GNU Lesser General Public License
13
* as published by the Free Software Foundation, either version 3
14
* of the License, or (at your option) any later version.
15
*
16
* Blitz is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU Lesser General Public License for more details.
20
*
21
* You should have received a copy of the GNU Lesser General Public
22
* License along with Blitz. If not, see <http://www.gnu.org/licenses/>.
23
*
24
* Suggestions: blitz-devel@lists.sourceforge.net
25
* Bugs: blitz-support@lists.sourceforge.net
26
*
27
* For more information, please see the Blitz++ Home Page:
28
* https://sourceforge.net/projects/blitz/
29
*
30
***************************************************************************/
31
32
#ifndef BZ_NUMTRAIT_H
33
#define BZ_NUMTRAIT_H
34
35
#ifndef BZ_BLITZ_H
36
#include <
blitz/blitz.h
>
37
#endif
38
39
namespace
blitz
{
40
41
#ifndef BZ_USE_NUMTRAIT
42
#define BZ_SUMTYPE(X) X
43
#define BZ_DIFFTYPE(X) X
44
#define BZ_FLOATTYPE(X) X
45
#define BZ_SIGNEDTYPE(X) X
46
#else
47
48
#define BZ_SUMTYPE(X) _bz_typename NumericTypeTraits<X>::T_sumtype
49
#define BZ_DIFFTYPE(X) _bz_typename NumericTypeTraits<X>::T_difftype
50
#define BZ_FLOATTYPE(X) _bz_typename NumericTypeTraits<X>::T_floattype
51
#define BZ_SIGNEDTYPE(X) _bz_typename NumericTypeTraits<X>::T_signedtype
52
53
template
<
typename
P_numtype>
54
class
NumericTypeTraits {
55
public
:
56
typedef
P_numtype T_sumtype;
// Type to be used for summing
57
typedef
P_numtype T_difftype;
// Type to be used for difference
58
typedef
P_numtype T_floattype;
// Type to be used for floating-point
59
// calculations
60
typedef
P_numtype T_signedtype;
// Type to be used for signed calculations
61
enum
{ hasTrivialCtor = 0 };
// Assume the worst
62
};
63
64
#define BZDECLNUMTRAIT(X,Y,Z,W,U) \
65
template<> \
66
class NumericTypeTraits<X> { \
67
public: \
68
typedef Y T_sumtype; \
69
typedef Z T_difftype; \
70
typedef W T_floattype; \
71
typedef U T_signedtype; \
72
enum { hasTrivialCtor = 1 }; \
73
}
74
75
#ifdef BZ_HAVE_BOOL
76
BZDECLNUMTRAIT(
bool
,
unsigned
,
int
,
float
,
int
);
77
#endif
78
79
BZDECLNUMTRAIT(
char
,
int
,
int
,
float
,
char
);
80
BZDECLNUMTRAIT(
unsigned
char
,
unsigned
,
int
,
float
,
int
);
81
BZDECLNUMTRAIT(
short
int
,
int
,
int
,
float
,
short
int
);
82
BZDECLNUMTRAIT(
short
unsigned
int
,
unsigned
int
,
int
,
float
,
int
);
83
BZDECLNUMTRAIT(
int
,
long
,
int
,
float
,
int
);
84
BZDECLNUMTRAIT(
unsigned
int
,
unsigned
long
,
int
,
float
,
long
);
85
BZDECLNUMTRAIT(
long
,
long
,
long
,
double
,
long
);
86
BZDECLNUMTRAIT(
unsigned
long
,
unsigned
long
,
long
,
double
,
long
);
87
BZDECLNUMTRAIT(
float
,
double
,
float
,
float
,
float
);
88
BZDECLNUMTRAIT(
double
,
double
,
double
,
double
,
double
);
89
90
#ifdef BZ_HAVE_COMPLEX
91
// BZDECLNUMTRAIT(complex<float>, complex<double>, complex<float>, complex<float>);
92
// BZDECLNUMTRAIT(complex<double>, complex<long double>, complex<double>, complex<double>);
93
#endif
// BZ_HAVE_COMPLEX
94
95
#endif
// BZ_USE_NUMTRAIT
96
97
}
98
99
#endif
// BZ_NUMTRAIT_H
blitz.h
blitz
Definition:
array-impl.h:66
blitz
numtrait.h
Generated by
1.9.6