A high-performance general-purpose compute library

- Main Page
- Tutorials
- 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#include <af/half.h>
18
19 namespace af {
20
21 template<typename T> struct dtype_traits;
22
23 template<>
24 struct dtype_traits<float> {
25 enum {
26 af_type = f32,
27 ctype = f32
28 };
29 typedef float base_type;
30 static const char* getName() { return "float"; }
31};
32
33 template<>
34 struct dtype_traits<af::cfloat> {
35 enum {
36 af_type = c32 ,
37 ctype = c32
38 };
39 typedef float base_type;
40 static const char* getName() { return "std::complex<float>"; }
41};
42
43 template<>
44 struct dtype_traits<std::complex<float> > {
45 enum {
46 af_type = c32 ,
47 ctype = c32
48 };
49 typedef float base_type;
50 static const char* getName() { return "std::complex<float>"; }
51};
52
53 template<>
54 struct dtype_traits<double> {
55 enum {
56 af_type = f64 ,
57 ctype = f32
58 };
59 typedef double base_type;
60 static const char* getName() { return "double"; }
61};
62
63 template<>
64 struct dtype_traits<af::cdouble> {
65 enum {
66 af_type = c64 ,
67 ctype = c64
68 };
69 typedef double base_type;
70 static const char* getName() { return "std::complex<double>"; }
71};
72
73 template<>
74 struct dtype_traits<std::complex<double> > {
75 enum {
76 af_type = c64 ,
77 ctype = c64
78 };
79 typedef double base_type;
80 static const char* getName() { return "std::complex<double>"; }
81};
82
83 template<>
84 struct dtype_traits<char> {
85 enum {
86 af_type = b8 ,
87 ctype = f32
88 };
89 typedef char base_type;
90 static const char* getName() { return "char"; }
91};
92
93 template<>
94 struct dtype_traits<int> {
95 enum {
96 af_type = s32 ,
97 ctype = f32
98 };
99 typedef int base_type;
100 static const char* getName() { return "int"; }
101};
102
103 template<>
104 struct dtype_traits<unsigned> {
105 enum {
106 af_type = u32 ,
107 ctype = f32
108 };
109 typedef unsigned base_type;
110 static const char* getName() { return "uint"; }
111};
112
113 template<>
114 struct dtype_traits<unsigned char> {
115 enum {
116 af_type = u8 ,
117 ctype = f32
118 };
119 typedef unsigned char base_type;
120 static const char* getName() { return "uchar"; }
121};
122
123 template<>
124 struct dtype_traits<long long> {
125 enum {
126 af_type = s64 ,
127 ctype = s64
128 };
129 typedef long long base_type;
130 static const char* getName() { return "long"; }
131};
132
133 template<>
134 struct dtype_traits<unsigned long long> {
135 enum {
136 af_type = u64 ,
137 ctype = u64
138 };
139 typedef unsigned long long base_type;
140 static const char* getName() { return "ulong"; }
141};
142
143#if AF_API_VERSION >= 32
144 template<>
145 struct dtype_traits<short> {
146 enum {
147 af_type = s16 ,
148 ctype = s16
149 };
150 typedef short base_type;
151 static const char* getName() { return "short"; }
152};
153#endif
154
155#if AF_API_VERSION >= 32
156 template<>
157 struct dtype_traits<unsigned short> {
158 enum {
159 af_type = u16 ,
160 ctype = u16
161 };
162 typedef unsigned short base_type;
163 static const char* getName() { return "ushort"; }
164};
165#endif
166
167#if AF_API_VERSION >= 37
168 template<>
169 struct dtype_traits<half> {
170 enum {
171 af_type = f16 ,
172 ctype = f16
173 };
174 typedef half base_type;
175 static const char* getName() { return "half"; }
176};
177#endif
178}
179
180#endif
complex.h
defines.h
u32
@ u32
32-bit unsigned integral values
Definition defines.h:217
u64
@ u64
64-bit unsigned integral values
Definition defines.h:220
s32
@ s32
32-bit signed integral values
Definition defines.h:216
s64
@ s64
64-bit signed integral values
Definition defines.h:219
b8
@ b8
8-bit boolean values
Definition defines.h:215
c64
@ c64
64-bit complex floating point values
Definition defines.h:214
f32
@ f32
32-bit floating point values
Definition defines.h:211
s16
@ s16
16-bit signed integral values
Definition defines.h:222
c32
@ c32
32-bit complex floating point values
Definition defines.h:212
f64
@ f64
64-bit floating point values
Definition defines.h:213
u16
@ u16
16-bit unsigned integral values
Definition defines.h:225
f16
@ f16
16-bit floating point value
Definition defines.h:228
u8
@ u8
8-bit unsigned integral values
Definition defines.h:218
af::complex
array complex(const array &in)
C++ Interface to create a complex array from a single real array.
half.h
af
Definition algorithm.h:15
af::af_cdouble
Definition complex.h:32
af::af_cfloat
Definition complex.h:24
af::dtype_traits< af::cdouble >::getName
static const char * getName()
Definition traits.hpp:70
af::dtype_traits< af::cdouble >::base_type
double base_type
Definition traits.hpp:69
af::dtype_traits< af::cfloat >::getName
static const char * getName()
Definition traits.hpp:40
af::dtype_traits< af::cfloat >::base_type
float base_type
Definition traits.hpp:39
af::dtype_traits< char >::getName
static const char * getName()
Definition traits.hpp:90
af::dtype_traits< char >::base_type
char base_type
Definition traits.hpp:89
af::dtype_traits< double >::getName
static const char * getName()
Definition traits.hpp:60
af::dtype_traits< double >::base_type
double base_type
Definition traits.hpp:59
af::dtype_traits< float >::getName
static const char * getName()
Definition traits.hpp:30
af::dtype_traits< float >::base_type
float base_type
Definition traits.hpp:29
af::dtype_traits< half >::getName
static const char * getName()
Definition traits.hpp:175
af::dtype_traits< half >::base_type
half base_type
Definition traits.hpp:174
af::dtype_traits< int >::base_type
int base_type
Definition traits.hpp:99
af::dtype_traits< int >::getName
static const char * getName()
Definition traits.hpp:100
af::dtype_traits< long long >::getName
static const char * getName()
Definition traits.hpp:130
af::dtype_traits< long long >::base_type
long long base_type
Definition traits.hpp:129
af::dtype_traits< short >::getName
static const char * getName()
Definition traits.hpp:151
af::dtype_traits< short >::base_type
short base_type
Definition traits.hpp:150
af::dtype_traits< std::complex< double > >::getName
static const char * getName()
Definition traits.hpp:80
af::dtype_traits< std::complex< double > >::base_type
double base_type
Definition traits.hpp:79
af::dtype_traits< std::complex< float > >::getName
static const char * getName()
Definition traits.hpp:50
af::dtype_traits< std::complex< float > >::base_type
float base_type
Definition traits.hpp:49
af::dtype_traits< unsigned >::base_type
unsigned base_type
Definition traits.hpp:109
af::dtype_traits< unsigned >::getName
static const char * getName()
Definition traits.hpp:110
af::dtype_traits< unsigned char >::getName
static const char * getName()
Definition traits.hpp:120
af::dtype_traits< unsigned char >::base_type
unsigned char base_type
Definition traits.hpp:119
af::dtype_traits< unsigned long long >::base_type
unsigned long long base_type
Definition traits.hpp:139
af::dtype_traits< unsigned long long >::getName
static const char * getName()
Definition traits.hpp:140
af::dtype_traits< unsigned short >::base_type
unsigned short base_type
Definition traits.hpp:162
af::dtype_traits< unsigned short >::getName
static const char * getName()
Definition traits.hpp:163
af::dtype_traits
Definition traits.hpp:21
af_half
Definition half.h:12