Michele De Stefano's C++ Utilities
common.hpp
1 // mds_utils/python/ublas/detail/common.hpp
2 //
3 // Copyright (c) 2014 - Michele De Stefano (micdestefano@users.sourceforge.net)
4 //
5 // Distributed under the MIT License (See accompanying file LICENSE)
6 
7 #ifndef MDS_UTILS_PYTHON_UBLAS_DETAIL_MATRIX_HPP_INCLUDED
8 #define MDS_UTILS_PYTHON_UBLAS_DETAIL_MATRIX_HPP_INCLUDED
9 
10 
12 #include <type_traits>
13 #include <algorithm>
14 #include <boost/type_traits/is_complex.hpp>
15 #include <boost/numeric/conversion/cast.hpp>
16 #include <boost/numeric/ublas/fwd.hpp>
17 
18 
19 
21 namespace mds_utils { namespace python { namespace ublas { namespace detail {
22 
23 template<class ublas_orientation>
24 struct ublas_to_npy_storage;
25 
26 template<>
27 struct ublas_to_npy_storage<boost::numeric::ublas::row_major_tag> {
28 
30 };
31 
32 template<>
33 struct ublas_to_npy_storage<boost::numeric::ublas::row_major> {
34 
36 };
37 
38 template<>
39 struct ublas_to_npy_storage<boost::numeric::ublas::column_major_tag> {
40 
42 };
43 
44 template<>
45 struct ublas_to_npy_storage<boost::numeric::ublas::column_major> {
46 
48 };
49 
50 
51 template<class orientation_category>
52 int numpy_flags();
53 
54 template<>
55 inline int numpy_flags<boost::numeric::ublas::row_major_tag>() {
56  return 0;
57 }
58 
59 template<>
60 inline int numpy_flags<boost::numeric::ublas::column_major_tag>() {
61  return 1;
62 }
63 
65 
66 //template<class py_T,class M>
67 //inline typename std::enable_if<
68 // !boost::is_complex<typename M::value_type>::value
69 // >::type
70 // copy_arr(const PyArrayObject *po,size_t nel,M& m) {
71 //
72 // py_T *data(reinterpret_cast<py_T*>(PyArray_DATA(const_cast<PyArrayObject*>(po))));
73 // std::transform(data,data+nel,m.data().begin(),
74 // [](py_T x) {
75 // return boost::numeric_cast<typename M::value_type>(x);
76 // });
77 //}
78 //
79 //
80 //template<class py_T,class M>
81 //inline typename std::enable_if<
82 // boost::is_complex<typename M::value_type>::value
83 // >::type
84 // copy_arr(const PyArrayObject *po,size_t nel,M& m) {
85 // py_T *data(reinterpret_cast<py_T*>(PyArray_DATA(const_cast<PyArrayObject*>(po))));
86 //
87 // std::transform(data,data+nel,m.data().begin(),
88 // [](py_T x) {
89 // return typename M::value_type(
90 // boost::numeric_cast<typename M::value_type::value_type>(x.real),
91 // boost::numeric_cast<typename M::value_type::value_type>(x.imag));
92 // });
93 //}
94 
95 
96 }}}}
98 
99 #endif
Tag for the C storage ordering.
Contains the wrapper for the NumPy iterator for ndarray objects.
Tag for the FORTRAN storage ordering.
Main namespace of all Michele De Stefano&#39;s C++ utilities.
Definition: endian.hpp:30