3 // Copyright (c) 2014 - Michele De Stefano (micdestefano@users.sourceforge.net)
5 // Distributed under the MIT License (See accompanying file LICENSE)
9 * \example matrix_usage.pycmd
11 * Shows the usage of the matrix_usage extension from the Python prompt.
14 matrix.hpp functionalities usage example from the Python prompt:
16 >>> import matrix_usage as mu
17 >>> M = mu.create_npy_array()
29 >>> A = mu.create_npy_array_cplx()
31 array([[ 1.1+1.1j, 2.2+2.2j],
32 [ 3.3+3.3j, 4.4+4.4j],
33 [ 5.5+5.5j, 6.6+6.6j]])
34 >>> B = mu.create_npy_array_row()
46 >>> S = mu.create_npy_array_short()
50 [ 5, -6]], dtype=int16)
53 [3,2]((1.1,2.2),(3.3,4.4),(5.5,6.6))
56 [3,2]((1.1,2.2),(3.3,4.4),(5.5,6.6))
59 [3,2]((1.1,4.4),(2.2,5.5),(3.3,6.6))
61 matrix_usage.py:105: ComplexWarning: Casting complex values to real discards the imaginary part
62 return _matrix_usage.get_matrix(*args)
64 [3,2]((1.1,2.2),(3.3,4.4),(5.5,6.6))
67 [3,2](((1.1,0),(2.2,0)),((3.3,0),(4.4,0)),((5.5,0),(6.6,0)))
69 array([[ 1.1+0.j, 2.2+0.j],
72 >>> A = mu.create_npy_array_cplx()
74 array([[ 1.1+1.1j, 2.2+2.2j],
75 [ 3.3+3.3j, 4.4+4.4j],
76 [ 5.5+5.5j, 6.6+6.6j]])
79 [3,2](((1.1,1.1),(2.2,2.2)),((3.3,3.3),(4.4,4.4)),((5.5,5.5),(6.6,6.6)))
83 // The previous command tested the get function, with type cast to char
84 >>> C = mu.create_ublas_matrix_column_major()
86 <Swig Object of type 'boost::numeric::ublas::matrix< double,boost::numeric::ublas::column_major > *' at 0x28e2180>
87 >>> mu.get_matrix_no_conversion(C)
89 [3,2]((1.1,4.4),(2.2,5.5),(3.3,6.6))
90 >>> mu.destroy_ublas_matrix_column_major(C)