- Main Page
- Tutorials
- Functions
- Release Notes
- Examples

traits.hpp
Go to the documentation of this file.
1 /*******************************************************
2 * Copyright (c) 2014, ArrayFire
3 * All rights reserved.
4 *
5 * This file is distributed under 3-clause BSD license.
6 * The complete license agreement can be obtained at:
7 * http://arrayfire.com/licenses/BSD-3-Clause
8 ********************************************************/
9
10 #pragma once
11
12 #ifdef __cplusplus
13
14 #include <complex>
15 #include <af/defines.h>
16 #include <af/complex.h>
17
18 namespace af {
19
20 template<typename T> struct dtype_traits;
21
22 template<>
23 struct dtype_traits<float> {
24 enum {
25 af_type = f32,
26 ctype = f32
27 };
28 typedef float base_type;
29 static const char* getName() { return "float"; }
30 };
31
32 template<>
33 struct dtype_traits<af::cfloat> {
34 enum {
35 af_type = c32 ,
36 ctype = c32
37 };
38 typedef float base_type;
39 static const char* getName() { return "std::complex<float>"; }
40 };
41
42 template<>
43 struct dtype_traits<std::complex<float> > {
44 enum {
45 af_type = c32 ,
46 ctype = c32
47 };
48 typedef float base_type;
49 static const char* getName() { return "std::complex<float>"; }
50 };
51
52 template<>
53 struct dtype_traits<double> {
54 enum {
55 af_type = f64 ,
56 ctype = f32
57 };
58 typedef double base_type;
59 static const char* getName() { return "double"; }
60 };
61
62 template<>
63 struct dtype_traits<af::cdouble> {
64 enum {
65 af_type = c64 ,
66 ctype = c64
67 };
68 typedef double base_type;
69 static const char* getName() { return "std::complex<double>"; }
70 };
71
72 template<>
73 struct dtype_traits<std::complex<double> > {
74 enum {
75 af_type = c64 ,
76 ctype = c64
77 };
78 typedef double base_type;
79 static const char* getName() { return "std::complex<double>"; }
80 };
81
82 template<>
83 struct dtype_traits<char> {
84 enum {
85 af_type = b8 ,
86 ctype = f32
87 };
88 typedef char base_type;
89 static const char* getName() { return "char"; }
90 };
91
92 template<>
93 struct dtype_traits<int> {
94 enum {
95 af_type = s32 ,
96 ctype = f32
97 };
98 typedef int base_type;
99 static const char* getName() { return "int"; }
100 };
101
102 template<>
103 struct dtype_traits<unsigned> {
104 enum {
105 af_type = u32 ,
106 ctype = f32
107 };
108 typedef unsigned base_type;
109 static const char* getName() { return "uint"; }
110 };
111
112 template<>
113 struct dtype_traits<unsigned char> {
114 enum {
115 af_type = u8 ,
116 ctype = f32
117 };
118 typedef unsigned char base_type;
119 static const char* getName() { return "uchar"; }
120 };
121
122 template<>
123 struct dtype_traits<long long> {
124 enum {
125 af_type = s64 ,
126 ctype = s64
127 };
128 typedef long long base_type;
129 static const char* getName() { return "long"; }
130 };
131
132 template<>
133 struct dtype_traits<unsigned long long> {
134 enum {
135 af_type = u64 ,
136 ctype = u64
137 };
138 typedef unsigned long long base_type;
139 static const char* getName() { return "ulong"; }
140 };
141
142 }
143
144 #endif
af::dtype_traits< unsigned >::getName
static const char * getName()
Definition: traits.hpp:109
af::dtype_traits< unsigned char >::getName
static const char * getName()
Definition: traits.hpp:119
af::dtype_traits< af::cfloat >::base_type
float base_type
Definition: traits.hpp:38
af::dtype_traits
Definition: traits.hpp:20
complex.h
af
Definition: algorithm.h:14
af::complex
AFAPI array complex(const array &lhs, const array &rhs)
C++ Interface for creating complex array from two inputs.
af::dtype_traits< float >::base_type
float base_type
Definition: traits.hpp:28
af::dtype_traits< char >::getName
static const char * getName()
Definition: traits.hpp:89
af::dtype_traits< std::complex< float > >::base_type
float base_type
Definition: traits.hpp:48
s32
32-bit signed integral values
Definition: defines.h:172
s64
64-bit signed integral values
Definition: defines.h:175
af::dtype_traits< int >::base_type
int base_type
Definition: traits.hpp:98
af::af_cdouble
Definition: complex.h:32
af::dtype_traits< std::complex< double > >::getName
static const char * getName()
Definition: traits.hpp:79
f64
64-bit complex floating point values
Definition: defines.h:169
af::dtype_traits< unsigned char >::base_type
unsigned char base_type
Definition: traits.hpp:118
af::dtype_traits< unsigned long long >::base_type
unsigned long long base_type
Definition: traits.hpp:138
af::dtype_traits< std::complex< double > >::base_type
double base_type
Definition: traits.hpp:78
af::dtype_traits< long long >::base_type
long long base_type
Definition: traits.hpp:128
af::dtype_traits< unsigned >::base_type
unsigned base_type
Definition: traits.hpp:108
af::dtype_traits< unsigned long long >::getName
static const char * getName()
Definition: traits.hpp:139
af::dtype_traits< long long >::getName
static const char * getName()
Definition: traits.hpp:129
u64
64-bit unsigned integral values
Definition: defines.h:176
defines.h
af::dtype_traits< af::cfloat >::getName
static const char * getName()
Definition: traits.hpp:39
c64
64-bit complex floating point values
Definition: defines.h:170
c32
32-bit complex floating point values
Definition: defines.h:168
af::dtype_traits< double >::getName
static const char * getName()
Definition: traits.hpp:59
af::dtype_traits< float >::getName
static const char * getName()
Definition: traits.hpp:29
u8
8-bit unsigned integral values
Definition: defines.h:174
af::af_cfloat
Definition: complex.h:24
af::dtype_traits< af::cdouble >::base_type
double base_type
Definition: traits.hpp:68
af::dtype_traits< int >::getName
static const char * getName()
Definition: traits.hpp:99
u32
32-bit unsigned integral values
Definition: defines.h:173
af::dtype_traits< af::cdouble >::getName
static const char * getName()
Definition: traits.hpp:69
af::dtype_traits< std::complex< float > >::getName
static const char * getName()
Definition: traits.hpp:49
af::dtype_traits< double >::base_type
double base_type
Definition: traits.hpp:58
f32
32-bit floating point values
Definition: defines.h:167
af::dtype_traits< char >::base_type
char base_type
Definition: traits.hpp:88
b8
8-bit boolean values
Definition: defines.h:171