source: XMLIO_V2/external/include/blitz/numtrait.h @ 73

Last change on this file since 73 was 73, checked in by ymipsl, 14 years ago
  • Property svn:eol-style set to native
File size: 3.6 KB
Line 
1// -*- C++ -*-
2/***************************************************************************
3 * blitz/numtrait.h      Declaration of the NumericTypeTraits class
4 *
5 * $Id: numtrait.h,v 1.6 2005/05/07 04:17:56 julianc Exp $
6 *
7 * Copyright (C) 1997-2001 Todd Veldhuizen <tveldhui@oonumerics.org>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * Suggestions:          blitz-dev@oonumerics.org
20 * Bugs:                 blitz-bugs@oonumerics.org
21 *
22 * For more information, please see the Blitz++ Home Page:
23 *    http://oonumerics.org/blitz/
24 *
25 ***************************************************************************/
26
27#ifndef BZ_NUMTRAIT_H
28#define BZ_NUMTRAIT_H
29
30#ifndef BZ_BLITZ_H
31 #include <blitz/blitz.h>
32#endif
33
34BZ_NAMESPACE(blitz)
35
36#ifndef BZ_USE_NUMTRAIT
37  #define BZ_SUMTYPE(X)    X
38  #define BZ_DIFFTYPE(X)   X
39  #define BZ_FLOATTYPE(X)  X
40  #define BZ_SIGNEDTYPE(X) X
41#else
42
43#define BZ_SUMTYPE(X)   _bz_typename NumericTypeTraits<X>::T_sumtype
44#define BZ_DIFFTYPE(X)  _bz_typename NumericTypeTraits<X>::T_difftype
45#define BZ_FLOATTYPE(X) _bz_typename NumericTypeTraits<X>::T_floattype
46#define BZ_SIGNEDTYPE(X) _bz_typename NumericTypeTraits<X>::T_signedtype
47
48template<typename P_numtype>
49class NumericTypeTraits {
50public:
51    typedef P_numtype T_sumtype;    // Type to be used for summing
52    typedef P_numtype T_difftype;   // Type to be used for difference
53    typedef P_numtype T_floattype;  // Type to be used for floating-point
54                                    // calculations
55    typedef P_numtype T_signedtype; // Type to be used for signed calculations
56    enum { hasTrivialCtor = 0 };    // Assume the worst
57};
58
59#define BZDECLNUMTRAIT(X,Y,Z,W,U)                                   \
60    template<>                                                      \
61    class NumericTypeTraits<X> {                                    \
62    public:                                                         \
63        typedef Y T_sumtype;                                        \
64        typedef Z T_difftype;                                       \
65        typedef W T_floattype;                                      \
66        typedef U T_signedtype;                                     \
67        enum { hasTrivialCtor = 1 };                                \
68    }                                                               
69
70#ifdef BZ_HAVE_BOOL
71    BZDECLNUMTRAIT(bool,unsigned,int,float,int);
72#endif
73
74BZDECLNUMTRAIT(char,int,int,float,char);
75BZDECLNUMTRAIT(unsigned char, unsigned, int, float,int);
76BZDECLNUMTRAIT(short int, int, int, float, short int);
77BZDECLNUMTRAIT(short unsigned int, unsigned int, int, float, int);
78BZDECLNUMTRAIT(int, long, int, float, int);
79BZDECLNUMTRAIT(unsigned int, unsigned long, int, float, long);
80BZDECLNUMTRAIT(long, long, long, double, long);
81BZDECLNUMTRAIT(unsigned long, unsigned long, long, double, long);
82BZDECLNUMTRAIT(float, double, float, float, float);
83BZDECLNUMTRAIT(double, double, double, double, double);
84
85#ifdef BZ_HAVE_COMPLEX
86// BZDECLNUMTRAIT(complex<float>, complex<double>, complex<float>, complex<float>);
87// BZDECLNUMTRAIT(complex<double>, complex<long double>, complex<double>, complex<double>);
88#endif // BZ_HAVE_COMPLEX
89
90#endif // BZ_USE_NUMTRAIT
91
92BZ_NAMESPACE_END
93
94#endif // BZ_NUMTRAIT_H
Note: See TracBrowser for help on using the repository browser.