Morpheus 1.0.0
Dynamic matrix type and algorithms for sparse matrices
Loading...
Searching...
No Matches
Morpheus_FormatTraits.hpp
1
23#ifndef MORPHEUS_FORMAT_TRAITS_HPP
24#define MORPHEUS_FORMAT_TRAITS_HPP
25
26// #include <Morpheus_FormatTags.hpp>
27#include <Morpheus_TypeTraits.hpp>
28#include <Morpheus_SpaceTraits.hpp>
29
30#include <impl/Morpheus_MatrixTags.hpp>
31#include <impl/Morpheus_VectorTags.hpp>
32
33#include <type_traits>
34
35namespace Morpheus {
51template <class T>
53 typedef char yes[1];
54 typedef char no[2];
55
56 template <class U>
57 static yes& test(
58 U*,
59 typename std::enable_if<Impl::has_matrix_tag<U>::value>::type* = nullptr);
60
61 template <class U>
62 static no& test(...);
63
64 public:
65 static const bool value = sizeof(test<T>(nullptr)) == sizeof(yes);
66};
67
73template <typename T>
75
84template <class T>
86 typedef char yes[1];
87 typedef char no[2];
88
89 template <class U>
90 static yes& test(
91 U*, typename std::enable_if<Impl::has_sparse_matrix_tag_v<U>>::type* =
92 nullptr);
93
94 template <class U>
95 static no& test(...);
96
97 public:
98 static const bool value = sizeof(test<T>(nullptr)) == sizeof(yes);
99};
100
106template <typename T>
107inline constexpr bool is_sparse_matrix_container_v =
109
116template <class T>
118 typedef char yes[1];
119 typedef char no[2];
120
121 template <class U>
122 static yes& test(
123 U*, typename std::enable_if<Impl::has_dense_matrix_tag_v<U>>::type* =
124 nullptr);
125
126 template <class U>
127 static no& test(...);
128
129 public:
130 static const bool value = sizeof(test<T>(nullptr)) == sizeof(yes);
131};
132
138template <typename T>
139inline constexpr bool is_dense_matrix_container_v =
141
149template <class T>
151 typedef char yes[1];
152 typedef char no[2];
153
154 template <class U>
155 static yes& test(
156 U*,
157 typename std::enable_if<Impl::has_vector_tag<U>::value>::type* = nullptr);
158
159 template <class U>
160 static no& test(...);
161
162 public:
163 static const bool value = sizeof(test<T>(nullptr)) == sizeof(yes);
164};
165
171template <typename T>
173
181template <class T>
183 typedef char yes[1];
184 typedef char no[2];
185
186 template <class U>
187 static yes& test(
188 U*, typename std::enable_if<is_matrix_container_v<U> ||
189 is_vector_container_v<U>>::type* = nullptr);
190
191 template <class U>
192 static no& test(...);
193
194 public:
195 static const bool value = sizeof(test<T>(nullptr)) == sizeof(yes);
196};
197
203template <typename T>
205
214template <class T>
216 typedef char yes[1];
217 typedef char no[2];
218
219 template <class U>
220 static yes& test(
221 U*,
222 typename std::enable_if<Impl::has_dynamic_matrix_tag<U>::value>::type* =
223 nullptr);
224
225 template <class U>
226 static no& test(...);
227
228 public:
229 static const bool value = sizeof(test<T>(nullptr)) == sizeof(yes);
230};
231
237template <typename T>
238inline constexpr bool is_dynamic_matrix_container_v =
240
248template <class T1, class T2>
250 typedef char yes[1];
251 typedef char no[2];
252
253 template <class U1, class U2>
254 static yes& test(
255 typename U1::tag*, typename U2::tag*,
256 typename std::enable_if<
257 is_container_v<U1> && is_container_v<U2> &&
258 std::is_same<typename U1::tag, typename U2::tag>::value>::type* =
259 nullptr);
260
261 template <class U1, class U2>
262 static no& test(...);
263
264 public:
265 static const bool value =
266 sizeof(test<T1, T2>(nullptr, nullptr)) == sizeof(yes);
267};
268
275template <typename T1, typename T2>
277
285template <class T1, class T2>
287 typedef char yes[1];
288 typedef char no[2];
289
290 template <class U1, class U2>
291 static yes& test(
292 U1*, U2*,
293 typename std::enable_if<has_same_memory_space_v<U1, U2> &&
294 has_same_layout_v<U1, U2> &&
295 has_same_value_type_v<U1, U2> &&
296 has_same_index_type_v<U1, U2>>::type* = nullptr);
297
298 template <class U1, class U2>
299 static no& test(...);
300
301 public:
302 static const bool value =
303 sizeof(test<T1, T2>(nullptr, nullptr)) == sizeof(yes);
304};
305
312template <typename T1, typename T2>
314
322template <class T1, class T2>
324 typedef char yes[1];
325 typedef char no[2];
326
327 template <class U1, class U2>
328 static yes& test(
329 typename U1::tag*, typename U2::tag*,
330 typename std::enable_if<(is_dynamic_matrix_container<U1>::value ||
332 is_compatible_v<U1, U2>>::type* = nullptr);
333
334 template <class U1, class U2>
335 static no& test(...);
336
337 public:
338 static const bool value =
339 sizeof(test<T1, T2>(nullptr, nullptr)) == sizeof(yes);
340};
341
348template <typename T1, typename T2>
349inline constexpr bool is_dynamically_compatible_v =
351
359template <typename T1, typename T2>
361 : std::integral_constant<bool, has_same_format_v<T1, T2> &&
362 is_compatible_v<T1, T2>> {};
363
370template <typename T1, typename T2>
371inline constexpr bool is_format_compatible_v =
373
382template <class T1, class T2>
384 typedef char yes[1];
385 typedef char no[2];
386
387 template <class U1, class U2>
388 static yes& test(
389 U1*, U2*,
390 typename std::enable_if<
391 !has_same_memory_space_v<U1, U2> && has_same_format_v<U1, U2> &&
392 has_same_layout_v<U1, U2> && has_same_value_type_v<U1, U2> &&
393 has_same_index_type_v<U1, U2>>::type* = nullptr);
394
395 template <class U1, class U2>
396 static no& test(...);
397
398 public:
399 static const bool value =
400 sizeof(test<T1, T2>(nullptr, nullptr)) == sizeof(yes);
401};
402
405} // namespace Morpheus
406
407#endif // MORPHEUS_FORMAT_TRAITS_HPP
Checks if the given type T has a valid Dynamic Matrix Tag i.e has a tag member trait that is a derive...
Definition: Morpheus_MatrixTags.hpp:277
Checks if the given type T has a tag trait of type MatrixTag.
Definition: Morpheus_MatrixTags.hpp:89
Checks if the given type T has a valid Vector Tag i.e has a tag member trait that is a derived class ...
Definition: Morpheus_VectorTags.hpp:86
Checks if the two types have the same format i.e both are valid containers and have the same tag memb...
Definition: Morpheus_FormatTraits.hpp:249
Checks if the two types are compatible containers i.e are in the same memory space and have the same ...
Definition: Morpheus_FormatTraits.hpp:286
Checks if the given type T is a valid Morpheus Container i.e is either a valid matrix or a vector con...
Definition: Morpheus_FormatTraits.hpp:182
A valid Dense Matrix container is the one that has a valid Dense Matrix tag i.e satisfies the has_den...
Definition: Morpheus_FormatTraits.hpp:117
A valid Dynamic Matrix container is the one that has a valid Dynamic Matrix tag i....
Definition: Morpheus_FormatTraits.hpp:215
Checks if the two types are dynamically compatible containers i.e are compatible containers and at le...
Definition: Morpheus_FormatTraits.hpp:323
Checks if the two types are format compatible containers but from different memory space i....
Definition: Morpheus_FormatTraits.hpp:383
A valid Matrix container is the one that has a valid Matrix tag i.e satisfies the has_matrix_tag chec...
Definition: Morpheus_FormatTraits.hpp:52
A valid Sparse Matrix container is the one that has a valid Sparse Matrix tag i.e satisfies the has_s...
Definition: Morpheus_FormatTraits.hpp:85
A valid Vector container is the one that has a valid Vector tag i.e satisfies the has_vector_tag chec...
Definition: Morpheus_FormatTraits.hpp:150
Generic Morpheus interfaces.
Definition: dummy.cpp:24
constexpr bool is_container_v
Short-hand to is_container.
Definition: Morpheus_FormatTraits.hpp:204
constexpr bool is_vector_container_v
Short-hand to is_vector_container.
Definition: Morpheus_FormatTraits.hpp:172
constexpr bool is_compatible_v
Short-hand to is_compatible.
Definition: Morpheus_FormatTraits.hpp:313
constexpr bool is_dense_matrix_container_v
Short-hand to is_dense_matrix_container.
Definition: Morpheus_FormatTraits.hpp:139
constexpr bool is_format_compatible_v
Short-hand to is_format_compatible.
Definition: Morpheus_FormatTraits.hpp:371
constexpr bool has_same_format_v
Short-hand to has_same_format.
Definition: Morpheus_FormatTraits.hpp:276
constexpr bool is_matrix_container_v
Short-hand to is_matrix_container.
Definition: Morpheus_FormatTraits.hpp:74
constexpr bool is_dynamically_compatible_v
Short-hand to is_dynamically_compatible.
Definition: Morpheus_FormatTraits.hpp:349
constexpr bool is_dynamic_matrix_container_v
Short-hand to is_dynamic_matrix_container.
Definition: Morpheus_FormatTraits.hpp:238
constexpr bool is_sparse_matrix_container_v
Short-hand to is_sparse_matrix_container.
Definition: Morpheus_FormatTraits.hpp:107
Checks if the two types are format compatible containers i.e are compatible containers and have the s...
Definition: Morpheus_FormatTraits.hpp:362