1 // mds_utils/python/ublas/numpy_array.i
3 // Copyright (c) 2014 - Michele De Stefano (micdestefano@users.sourceforge.net)
5 // Distributed under the MIT License (See accompanying file LICENSE)
7 %include "mds_utils/python/common.i"
8 %include "mds_utils/python/obj.i"
9 %include "std_complex.i"
13 #include <mds_utils/python/ublas/numpy_array.hpp>
15 namespace ublas_convert = boost::numeric::ublas;
18 %define NUMPY_ARRAY_IN_TYPEMAPS_GEN(type)
20 %typemap(in) ublas_convert::NumPy1DArray< type > = mds_utils::python::Obj;
21 %typemap(in) ublas_convert::NumPy1DArray< type >& (ublas_convert::NumPy1DArray< type > tmp) {
25 } catch (std::exception& e) {
26 PyErr_SetString(PyExc_RuntimeError,e.what());
30 %typemap(in) ublas_convert::NumPy1DArray< type >* = ublas_convert::NumPy1DArray< type >&;
32 %typecheck(SWIG_TYPECHECK_POINTER) ublas_convert::NumPy1DArray< type > {
33 $1 = PyArray_Check($input);
39 NUMPY_ARRAY_IN_TYPEMAPS_GEN(char)
40 NUMPY_ARRAY_IN_TYPEMAPS_GEN(unsigned char)
41 NUMPY_ARRAY_IN_TYPEMAPS_GEN(short)
42 NUMPY_ARRAY_IN_TYPEMAPS_GEN(unsigned short)
43 NUMPY_ARRAY_IN_TYPEMAPS_GEN(int)
44 NUMPY_ARRAY_IN_TYPEMAPS_GEN(unsigned int)
45 NUMPY_ARRAY_IN_TYPEMAPS_GEN(long)
46 NUMPY_ARRAY_IN_TYPEMAPS_GEN(unsigned long)
47 NUMPY_ARRAY_IN_TYPEMAPS_GEN(long long)
48 NUMPY_ARRAY_IN_TYPEMAPS_GEN(unsigned long long)
49 NUMPY_ARRAY_IN_TYPEMAPS_GEN(size_t)
50 NUMPY_ARRAY_IN_TYPEMAPS_GEN(float)
51 NUMPY_ARRAY_IN_TYPEMAPS_GEN(double)
52 NUMPY_ARRAY_IN_TYPEMAPS_GEN(long double)
53 NUMPY_ARRAY_IN_TYPEMAPS_GEN(std::complex<float>)
54 NUMPY_ARRAY_IN_TYPEMAPS_GEN(std::complex<double>)
55 NUMPY_ARRAY_IN_TYPEMAPS_GEN(std::complex<long double>)
58 %define NUMPY_ARRAY_OUT_TYPEMAPS_GEN(type)
60 %typemap(out) ublas_convert::NumPy1DArray< type > = mds_utils::python::Obj;
64 NUMPY_ARRAY_OUT_TYPEMAPS_GEN(char)
65 NUMPY_ARRAY_OUT_TYPEMAPS_GEN(unsigned char)
66 NUMPY_ARRAY_OUT_TYPEMAPS_GEN(short)
67 NUMPY_ARRAY_OUT_TYPEMAPS_GEN(unsigned short)
68 NUMPY_ARRAY_OUT_TYPEMAPS_GEN(int)
69 NUMPY_ARRAY_OUT_TYPEMAPS_GEN(unsigned int)
70 NUMPY_ARRAY_OUT_TYPEMAPS_GEN(long)
71 NUMPY_ARRAY_OUT_TYPEMAPS_GEN(unsigned long)
72 NUMPY_ARRAY_OUT_TYPEMAPS_GEN(long long)
73 NUMPY_ARRAY_OUT_TYPEMAPS_GEN(unsigned long long)
74 NUMPY_ARRAY_OUT_TYPEMAPS_GEN(size_t)
75 NUMPY_ARRAY_OUT_TYPEMAPS_GEN(float)
76 NUMPY_ARRAY_OUT_TYPEMAPS_GEN(double)
77 NUMPY_ARRAY_OUT_TYPEMAPS_GEN(long double)
78 NUMPY_ARRAY_OUT_TYPEMAPS_GEN(std::complex<float>)
79 NUMPY_ARRAY_OUT_TYPEMAPS_GEN(std::complex<double>)
80 NUMPY_ARRAY_OUT_TYPEMAPS_GEN(std::complex<long double>)