3 // This SWIG interface shows how to reuse classes wrapped by the
4 // mds_utils.ublas.ublas.py module.
6 // Copyright (c) 2014 - Michele De Stefano (micdestefano@users.sourceforge.net)
8 // Distributed under the MIT License (See accompanying file LICENSE)
11 * Usage example for the mds_utils.ublas Python module.
13 * Instructions for generating and building the extension:
15 * 1. swig -c++ -Wall -python -I../../../../include -I../../../../python -o ublas_pkg_usage_wrap.cpp ublas_pkg_usage.i
17 * 2. python setup.py build
19 * Instructions for using the generated example:
21 * Before using the generated python module, ensure that your
22 * PYTHONPATH environment variable contains the path to reach the
23 * mds_utils Python package. For example, if the mds_utils package has
24 * been built but not installed yet, it is typically found into the
25 * mds-utils/python/build/lib.linux-<arch>-<Python version> directory
26 * (for a Linux build) and you have to add this path to your PYTHONPATH
27 * variable. After that, you can import the ublas_pkg_usage module and
28 * try it. The use from the command line is shown into the
29 * ublas_pkg_usage.pycmd file.
33 %module ublas_pkg_usage
35 // Make all necessary inclusions before importing the ublas module
36 %include <mds_utils/python/common.i>
38 // Import the ublas module: this will share the wrapped objects in ublas
39 %import "mds_utils/ublas/ublas.i"
41 // Start wrapping code for the ublas_pkg_usage module
44 #include <boost/numeric/ublas/vector.hpp>
45 #include <boost/numeric/ublas/matrix_sparse.hpp>
50 boost::numeric::ublas::vector<double> create_vector() {
52 using namespace boost::numeric::ublas;
56 v[0] = 1.1; v[1] = 2.2; v[2] = 3.3;
61 boost::numeric::ublas::compressed_matrix<double>
62 create_compressed_matrix() {
64 using namespace boost::numeric::ublas;
66 compressed_matrix<double>
69 m(1,0) = 1.1; m(0,2) = 2.2; m(3,1) = 3.3;
75 class my_vec : public boost::numeric::ublas::vector<double> {