promote_type.hpp
Go to the documentation of this file.
1 // Copyright (C) 2009-2011 NICTA (www.nicta.com.au)
2 // Copyright (C) 2009-2011 Conrad Sanderson
3 //
4 // This file is part of the Armadillo C++ library.
5 // It is provided without any warranty of fitness
6 // for any purpose. You can redistribute this file
7 // and/or modify it under the terms of the GNU
8 // Lesser General Public License (LGPL) as published
9 // by the Free Software Foundation, either version 3
10 // of the License or (at your option) any later version.
11 // (see http://www.opensource.org/licenses for more info)
12 
13 
16 
17 
18 template<typename T1, typename T2>
20  {
21  static const bool value = false;
22  typedef T1 result;
23  };
24 
25 
27  {
28  static const bool value = true;
29  };
30 
31 
32 template<typename T> struct is_promotable<T, T> : public is_promotable_ok { typedef T result; };
33 template<typename T> struct is_promotable<std::complex<T>, T> : public is_promotable_ok { typedef std::complex<T> result; };
34 
35 template<> struct is_promotable<std::complex<double>, std::complex<float> > : public is_promotable_ok { typedef std::complex<double> result; };
36 template<> struct is_promotable<std::complex<double>, float> : public is_promotable_ok { typedef std::complex<double> result; };
37 template<> struct is_promotable<std::complex<float>, double> : public is_promotable_ok { typedef std::complex<double> result; };
38 
39 #if defined(ARMA_64BIT_WORD)
40 template<typename t> struct is_promotable<std::complex<t>, u64> : public is_promotable_ok { typedef std::complex<t> result; };
41 template<typename t> struct is_promotable<std::complex<t>, s64> : public is_promotable_ok { typedef std::complex<t> result; };
42 #endif
43 template<typename T> struct is_promotable<std::complex<T>, s32> : public is_promotable_ok { typedef std::complex<T> result; };
44 template<typename T> struct is_promotable<std::complex<T>, u32> : public is_promotable_ok { typedef std::complex<T> result; };
45 template<typename T> struct is_promotable<std::complex<T>, s16> : public is_promotable_ok { typedef std::complex<T> result; };
46 template<typename T> struct is_promotable<std::complex<T>, u16> : public is_promotable_ok { typedef std::complex<T> result; };
47 template<typename T> struct is_promotable<std::complex<T>, s8> : public is_promotable_ok { typedef std::complex<T> result; };
48 template<typename T> struct is_promotable<std::complex<T>, u8> : public is_promotable_ok { typedef std::complex<T> result; };
49 
50 
51 template<> struct is_promotable<double, float> : public is_promotable_ok { typedef double result; };
52 #if defined(ARMA_64BIT_WORD)
53 template<> struct is_promotable<double, s64 > : public is_promotable_ok { typedef double result; };
54 template<> struct is_promotable<double, u64 > : public is_promotable_ok { typedef double result; };
55 #endif
56 template<> struct is_promotable<double, s32 > : public is_promotable_ok { typedef double result; };
57 template<> struct is_promotable<double, u32 > : public is_promotable_ok { typedef double result; };
58 template<> struct is_promotable<double, s16 > : public is_promotable_ok { typedef double result; };
59 template<> struct is_promotable<double, u16 > : public is_promotable_ok { typedef double result; };
60 template<> struct is_promotable<double, s8 > : public is_promotable_ok { typedef double result; };
61 template<> struct is_promotable<double, u8 > : public is_promotable_ok { typedef double result; };
62 
63 #if defined(ARMA_64BIT_WORD)
64 template<> struct is_promotable<float, s64> : public is_promotable_ok { typedef float result; };
65 template<> struct is_promotable<float, u64> : public is_promotable_ok { typedef float result; };
66 #endif
67 template<> struct is_promotable<float, s32> : public is_promotable_ok { typedef float result; };
68 template<> struct is_promotable<float, u32> : public is_promotable_ok { typedef float result; };
69 template<> struct is_promotable<float, s16> : public is_promotable_ok { typedef float result; };
70 template<> struct is_promotable<float, u16> : public is_promotable_ok { typedef float result; };
71 template<> struct is_promotable<float, s8 > : public is_promotable_ok { typedef float result; };
72 template<> struct is_promotable<float, u8 > : public is_promotable_ok { typedef float result; };
73 
74 #if defined(ARMA_64BIT_WORD)
75 template<> struct is_promotable<u64, u32> : public is_promotable_ok { typedef u64 result; };
76 template<> struct is_promotable<u64, u16> : public is_promotable_ok { typedef u64 result; };
77 template<> struct is_promotable<u64, u8 > : public is_promotable_ok { typedef u64 result; };
78 #endif
79 
80 #if defined(ARMA_64BIT_WORD)
81 template<> struct is_promotable<s64, u64> : public is_promotable_ok { typedef s64 result; }; // float ?
82 template<> struct is_promotable<s64, u32> : public is_promotable_ok { typedef s64 result; };
83 template<> struct is_promotable<s64, s32> : public is_promotable_ok { typedef s64 result; };
84 template<> struct is_promotable<s64, s16> : public is_promotable_ok { typedef s64 result; };
85 template<> struct is_promotable<s64, u16> : public is_promotable_ok { typedef s64 result; };
86 template<> struct is_promotable<s64, s8 > : public is_promotable_ok { typedef s64 result; };
87 template<> struct is_promotable<s64, u8 > : public is_promotable_ok { typedef s64 result; };
88 #endif
89 
90 template<> struct is_promotable<s32, u32> : public is_promotable_ok { typedef s32 result; }; // float ?
91 template<> struct is_promotable<s32, s16> : public is_promotable_ok { typedef s32 result; };
92 template<> struct is_promotable<s32, u16> : public is_promotable_ok { typedef s32 result; };
93 template<> struct is_promotable<s32, s8 > : public is_promotable_ok { typedef s32 result; };
94 template<> struct is_promotable<s32, u8 > : public is_promotable_ok { typedef s32 result; };
95 
96 template<> struct is_promotable<u32, s16> : public is_promotable_ok { typedef s32 result; }; // float ?
97 template<> struct is_promotable<u32, u16> : public is_promotable_ok { typedef u32 result; };
98 template<> struct is_promotable<u32, s8 > : public is_promotable_ok { typedef s32 result; }; // float ?
99 template<> struct is_promotable<u32, u8 > : public is_promotable_ok { typedef u32 result; };
100 
101 template<> struct is_promotable<s16, u16> : public is_promotable_ok { typedef s16 result; }; // s32 ?
102 template<> struct is_promotable<s16, s8 > : public is_promotable_ok { typedef s16 result; };
103 template<> struct is_promotable<s16, u8 > : public is_promotable_ok { typedef s16 result; };
104 
105 template<> struct is_promotable<u16, s8> : public is_promotable_ok { typedef s16 result; }; // s32 ?
106 template<> struct is_promotable<u16, u8> : public is_promotable_ok { typedef u16 result; };
107 
108 template<> struct is_promotable<s8, u8> : public is_promotable_ok { typedef s8 result; }; // s16 ?
109 
110 
111 
112 
113 //
114 // mirrored versions
115 
116 template<typename T> struct is_promotable<T, std::complex<T> > : public is_promotable_ok { typedef std::complex<T> result; };
117 
118 template<> struct is_promotable<std::complex<float>, std::complex<double> > : public is_promotable_ok { typedef std::complex<double> result; };
119 template<> struct is_promotable<float, std::complex<double> > : public is_promotable_ok { typedef std::complex<double> result; };
120 template<> struct is_promotable<double, std::complex<float> > : public is_promotable_ok { typedef std::complex<double> result; };
121 
122 #if defined(ARMA_64BIT_WORD)
123 template<typename T> struct is_promotable<s64, std::complex<T> > : public is_promotable_ok { typedef std::complex<T> result; };
124 template<typename T> struct is_promotable<u64, std::complex<T> > : public is_promotable_ok { typedef std::complex<T> result; };
125 #endif
126 template<typename T> struct is_promotable<s32, std::complex<T> > : public is_promotable_ok { typedef std::complex<T> result; };
127 template<typename T> struct is_promotable<u32, std::complex<T> > : public is_promotable_ok { typedef std::complex<T> result; };
128 template<typename T> struct is_promotable<s16, std::complex<T> > : public is_promotable_ok { typedef std::complex<T> result; };
129 template<typename T> struct is_promotable<u16, std::complex<T> > : public is_promotable_ok { typedef std::complex<T> result; };
130 template<typename T> struct is_promotable<s8, std::complex<T> > : public is_promotable_ok { typedef std::complex<T> result; };
131 template<typename T> struct is_promotable<u8, std::complex<T> > : public is_promotable_ok { typedef std::complex<T> result; };
132 
133 
134 template<> struct is_promotable<float, double> : public is_promotable_ok { typedef double result; };
135 #if defined(ARMA_64BIT_WORD)
136 template<> struct is_promotable<s64 , double> : public is_promotable_ok { typedef double result; };
137 template<> struct is_promotable<u64 , double> : public is_promotable_ok { typedef double result; };
138 #endif
139 template<> struct is_promotable<s32 , double> : public is_promotable_ok { typedef double result; };
140 template<> struct is_promotable<u32 , double> : public is_promotable_ok { typedef double result; };
141 template<> struct is_promotable<s16 , double> : public is_promotable_ok { typedef double result; };
142 template<> struct is_promotable<u16 , double> : public is_promotable_ok { typedef double result; };
143 template<> struct is_promotable<s8 , double> : public is_promotable_ok { typedef double result; };
144 template<> struct is_promotable<u8 , double> : public is_promotable_ok { typedef double result; };
145 
146 #if defined(ARMA_64BIT_WORD)
147 template<> struct is_promotable<s64, float> : public is_promotable_ok { typedef float result; };
148 template<> struct is_promotable<u64, float> : public is_promotable_ok { typedef float result; };
149 #endif
150 template<> struct is_promotable<s32, float> : public is_promotable_ok { typedef float result; };
151 template<> struct is_promotable<u32, float> : public is_promotable_ok { typedef float result; };
152 template<> struct is_promotable<s16, float> : public is_promotable_ok { typedef float result; };
153 template<> struct is_promotable<u16, float> : public is_promotable_ok { typedef float result; };
154 template<> struct is_promotable<s8 , float> : public is_promotable_ok { typedef float result; };
155 template<> struct is_promotable<u8 , float> : public is_promotable_ok { typedef float result; };
156 
157 #if defined(ARMA_64BIT_WORD)
158 template<> struct is_promotable<u32, u64> : public is_promotable_ok { typedef u64 result; };
159 template<> struct is_promotable<u16, u64> : public is_promotable_ok { typedef u64 result; };
160 template<> struct is_promotable<u8, u64> : public is_promotable_ok { typedef u64 result; };
161 #endif
162 
163 #if defined(ARMA_64BIT_WORD)
164 template<> struct is_promotable<u64, s64> : public is_promotable_ok { typedef s64 result; }; // float ?
165 template<> struct is_promotable<u32, s64> : public is_promotable_ok { typedef s64 result; };
166 template<> struct is_promotable<s16, s64> : public is_promotable_ok { typedef s64 result; };
167 template<> struct is_promotable<u16, s64> : public is_promotable_ok { typedef s64 result; };
168 template<> struct is_promotable<s8 , s64> : public is_promotable_ok { typedef s64 result; };
169 template<> struct is_promotable<u8 , s64> : public is_promotable_ok { typedef s64 result; };
170 #endif
171 
172 template<> struct is_promotable<u32, s32> : public is_promotable_ok { typedef s32 result; }; // float ?
173 template<> struct is_promotable<s16, s32> : public is_promotable_ok { typedef s32 result; };
174 template<> struct is_promotable<u16, s32> : public is_promotable_ok { typedef s32 result; };
175 template<> struct is_promotable<s8 , s32> : public is_promotable_ok { typedef s32 result; };
176 template<> struct is_promotable<u8 , s32> : public is_promotable_ok { typedef s32 result; };
177 
178 template<> struct is_promotable<s16, u32> : public is_promotable_ok { typedef s32 result; }; // float ?
179 template<> struct is_promotable<u16, u32> : public is_promotable_ok { typedef u32 result; };
180 template<> struct is_promotable<s8 , u32> : public is_promotable_ok { typedef s32 result; }; // float ?
181 template<> struct is_promotable<u8 , u32> : public is_promotable_ok { typedef u32 result; };
182 
183 template<> struct is_promotable<u16, s16> : public is_promotable_ok { typedef s16 result; }; // s32 ?
184 template<> struct is_promotable<s8 , s16> : public is_promotable_ok { typedef s16 result; };
185 template<> struct is_promotable<u8 , s16> : public is_promotable_ok { typedef s16 result; };
186 
187 template<> struct is_promotable<s8, u16> : public is_promotable_ok { typedef s16 result; }; // s32 ?
188 template<> struct is_promotable<u8, u16> : public is_promotable_ok { typedef u16 result; };
189 
190 template<> struct is_promotable<u8, s8> : public is_promotable_ok { typedef s8 result; }; // s16 ?
191 
192 
193 
194 
195 
196 template<typename T1, typename T2>
198  {
199  inline static void check()
200  {
202  }
203 
205  };
206 
207 
208 
209 template<typename T1, typename T2>
211  {
213  };
214 
215 
216 
is_promotable< T1, T2 >::result result
static void check()
#define arma_type_check(condition)
promote_type< typename T1::elem_type, typename T2::elem_type >::result eT
static const bool value


armadillo_matrix
Author(s):
autogenerated on Fri Apr 16 2021 02:31:58