-
Notifications
You must be signed in to change notification settings - Fork 298
/
trans_tag.hpp
89 lines (72 loc) · 2.55 KB
/
trans_tag.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//
// Copyright (c) 2009 Rutger ter Borg
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_NUMERIC_BINDINGS_TRANS_TAG_HPP
#define BOOST_NUMERIC_BINDINGS_TRANS_TAG_HPP
#include <Core/Utils/numeric/bindings/data_order.hpp>
#include <Core/Utils/numeric/bindings/tag.hpp>
#include <Core/Utils/numeric/bindings/detail/property_map.hpp>
namespace boost {
namespace numeric {
namespace bindings {
namespace detail {
template< typename LibraryOrder, typename DataOrder, typename ValueTransform >
struct trans_tag_impl {
// If your program complains about this part, this probably
// means that you are trying to use row_major matrices where you
// should use column_major matrices. E.g., for ublas, use
// matrix< double, column_major > instead of matrix< double >
// to fix this.
};
template<>
struct trans_tag_impl< tag::column_major, tag::column_major, mpl::void_ > {
typedef tag::no_transpose type;
};
template<>
struct trans_tag_impl< tag::column_major, tag::row_major, mpl::void_ > {
typedef tag::transpose type;
};
template<>
struct trans_tag_impl< tag::column_major, tag::row_major, tag::conjugate > {
typedef tag::conjugate type;
};
template<>
struct trans_tag_impl< tag::row_major, tag::row_major, mpl::void_ > {
typedef tag::no_transpose type;
};
template<>
struct trans_tag_impl< tag::row_major, tag::column_major, mpl::void_ > {
typedef tag::transpose type;
};
template<>
struct trans_tag_impl< tag::row_major, tag::column_major, tag::conjugate > {
typedef tag::conjugate type;
};
} // namespace detail
namespace result_of {
template< typename T, typename Order >
struct trans_tag {
typedef typename detail::trans_tag_impl< Order,
typename result_of::data_order<T>::type,
typename detail::property_at< T, tag::value_transform >::type >::type type;
};
} // namespace result_of
//
// trans_tag will output tags that are compatible with BLAS and LAPACK, either one
// of tag::transpose, tag::no_transpose, or tag::conjugate.
// It needs an library-orientation (Order) before it can make a decision about whether
// a tranpose is in order. Consult the various cases above to see what kind of
// tag is being generated in what kind of situation.
//
template< typename T, typename Order >
typename result_of::trans_tag< T, Order >::type trans_tag( const T& t, Order ) {
return result_of::trans_tag< T, Order >::type();
}
} // namespace bindings
} // namespace numeric
} // namespace boost
#endif