1 // mds_utils/python/ublas/vector.i
3 // Copyright (c) 2014 - Michele De Stefano (micdestefano@users.sourceforge.net)
5 // Distributed under the MIT License (See accompanying file LICENSE)
9 #include <mds_utils/python/ublas/vector.hpp>
11 namespace ublas_convert = boost::numeric::ublas;
14 %define VECTOR_IN_TYPEMAPS_GEN(type)
16 %typemap(in) (ublas_convert::vector< type >) {
18 $1 = mds_utils::python::ublas::get< boost::numeric::ublas::vector< type > >($input);
19 } catch (std::exception& e) {
20 PyErr_SetString(PyExc_RuntimeError,e.what());
25 %typecheck(SWIG_TYPECHECK_POINTER) ublas_convert::vector< type > {
26 $1 = PyArray_Check($input);
32 VECTOR_IN_TYPEMAPS_GEN(char)
33 VECTOR_IN_TYPEMAPS_GEN(unsigned char)
34 VECTOR_IN_TYPEMAPS_GEN(short)
35 VECTOR_IN_TYPEMAPS_GEN(unsigned short)
36 VECTOR_IN_TYPEMAPS_GEN(int)
37 VECTOR_IN_TYPEMAPS_GEN(unsigned int)
38 VECTOR_IN_TYPEMAPS_GEN(long)
39 VECTOR_IN_TYPEMAPS_GEN(unsigned long)
40 VECTOR_IN_TYPEMAPS_GEN(long long)
41 VECTOR_IN_TYPEMAPS_GEN(unsigned long long)
42 VECTOR_IN_TYPEMAPS_GEN(size_t)
43 VECTOR_IN_TYPEMAPS_GEN(float)
44 VECTOR_IN_TYPEMAPS_GEN(double)
45 VECTOR_IN_TYPEMAPS_GEN(long double)
46 VECTOR_IN_TYPEMAPS_GEN(std::complex<float>)
47 VECTOR_IN_TYPEMAPS_GEN(std::complex<double>)
48 VECTOR_IN_TYPEMAPS_GEN(std::complex<long double>)
50 %typemap(out) ublas_convert::vector<double> {
51 $result = mds_utils::python::ublas::to_python($1);
56 %define VECTOR_OUT_TYPEMAPS_GEN(type)
58 %typemap(out) ublas_convert::vector< type > = ublas_convert::vector<double>;
62 VECTOR_OUT_TYPEMAPS_GEN(char)
63 VECTOR_OUT_TYPEMAPS_GEN(unsigned char)
64 VECTOR_OUT_TYPEMAPS_GEN(short)
65 VECTOR_OUT_TYPEMAPS_GEN(unsigned short)
66 VECTOR_OUT_TYPEMAPS_GEN(int)
67 VECTOR_OUT_TYPEMAPS_GEN(unsigned int)
68 VECTOR_OUT_TYPEMAPS_GEN(long)
69 VECTOR_OUT_TYPEMAPS_GEN(unsigned long)
70 VECTOR_OUT_TYPEMAPS_GEN(long long)
71 VECTOR_OUT_TYPEMAPS_GEN(unsigned long long)
72 VECTOR_OUT_TYPEMAPS_GEN(size_t)
73 VECTOR_OUT_TYPEMAPS_GEN(float)
74 VECTOR_OUT_TYPEMAPS_GEN(long double)
75 VECTOR_OUT_TYPEMAPS_GEN(std::complex<float>)
76 VECTOR_OUT_TYPEMAPS_GEN(std::complex<double>)
77 VECTOR_OUT_TYPEMAPS_GEN(std::complex<long double>)