My Project
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
18namespace af {
19
20template<typename T> struct dtype_traits;
21
22template<>
24 enum {
25 af_type = f32,
26 ctype = f32
27 };
28 typedef float base_type;
29 static const char* getName() { return "float"; }
30};
31
32template<>
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
42template<>
43struct 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
52template<>
54 enum {
55 af_type = f64 ,
56 ctype = f32
57 };
58 typedef double base_type;
59 static const char* getName() { return "double"; }
60};
61
62template<>
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
72template<>
73struct 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
82template<>
84 enum {
85 af_type = b8 ,
86 ctype = f32
87 };
88 typedef char base_type;
89 static const char* getName() { return "char"; }
90};
91
92template<>
94 enum {
95 af_type = s32 ,
96 ctype = f32
97 };
98 typedef int base_type;
99 static const char* getName() { return "int"; }
100};
101
102template<>
104 enum {
105 af_type = u32 ,
106 ctype = f32
107 };
108 typedef unsigned base_type;
109 static const char* getName() { return "uint"; }
110};
111
112template<>
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
122template<>
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
132template<>
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#if AF_API_VERSION >= 32
143template<>
145 enum {
146 af_type = s16 ,
147 ctype = s16
148 };
149 typedef short base_type;
150 static const char* getName() { return "short"; }
151};
152#endif
153
154#if AF_API_VERSION >= 32
155template<>
157 enum {
158 af_type = u16 ,
159 ctype = u16
160 };
161 typedef unsigned short base_type;
162 static const char* getName() { return "ushort"; }
163};
164#endif
165
166}
167
168#endif
@ u32
32-bit unsigned integral values
Definition defines.h:202
@ u64
64-bit unsigned integral values
Definition defines.h:205
@ s32
32-bit signed integral values
Definition defines.h:201
@ s64
64-bit signed integral values
Definition defines.h:204
@ b8
8-bit boolean values
Definition defines.h:200
@ c64
64-bit complex floating point values
Definition defines.h:199
@ f32
32-bit floating point values
Definition defines.h:196
@ s16
16-bit signed integral values
Definition defines.h:207
@ c32
32-bit complex floating point values
Definition defines.h:197
@ f64
64-bit complex floating point values
Definition defines.h:198
@ u16
16-bit unsigned integral values
Definition defines.h:210
@ u8
8-bit unsigned integral values
Definition defines.h:203
AFAPI array complex(const array &lhs, const array &rhs)
C++ Interface for creating complex array from two inputs.
AFAPI array sum(const array &in, const int dim=-1)
C++ Interface for sum of elements in an array.
Definition algorithm.h:15
Definition complex.h:32
Definition complex.h:24
static const char * getName()
Definition traits.hpp:69
double base_type
Definition traits.hpp:68
static const char * getName()
Definition traits.hpp:39
float base_type
Definition traits.hpp:38
static const char * getName()
Definition traits.hpp:89
char base_type
Definition traits.hpp:88
static const char * getName()
Definition traits.hpp:59
double base_type
Definition traits.hpp:58
static const char * getName()
Definition traits.hpp:29
float base_type
Definition traits.hpp:28
int base_type
Definition traits.hpp:98
static const char * getName()
Definition traits.hpp:99
static const char * getName()
Definition traits.hpp:129
long long base_type
Definition traits.hpp:128
static const char * getName()
Definition traits.hpp:150
short base_type
Definition traits.hpp:149
static const char * getName()
Definition traits.hpp:79
double base_type
Definition traits.hpp:78
static const char * getName()
Definition traits.hpp:49
float base_type
Definition traits.hpp:48
unsigned base_type
Definition traits.hpp:108
static const char * getName()
Definition traits.hpp:109
static const char * getName()
Definition traits.hpp:119
unsigned char base_type
Definition traits.hpp:118
unsigned long long base_type
Definition traits.hpp:138
static const char * getName()
Definition traits.hpp:139
unsigned short base_type
Definition traits.hpp:161
static const char * getName()
Definition traits.hpp:162
Definition traits.hpp:20