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