python: python3.2 cvxopt: 1.1.5 numpy: 1.6.1
I read http://abel.ee.ucla.edu/cvxopt/examples/tutorial/numpy.html
import cvxopt
import numpy as np
cvxopt.matrix(np.array([[7, 8, 9], [10, 11, 12]]))
I got
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: non-numeric element in list
By np.array(cvxopt.matrix([[7, 8, 9], [10, 11, 12]])), I got
array([[b'\x07', b'\n'],
   [b'\x08', b'\x0b'],
   [b'\t', b'\x0c']], 
  dtype='|S8')
                As of cvxopt == 1.2.6 and numpy == 1.21.2:
import cvxopt
import numpy as np
matrix = cvxopt.matrix(np.array([[7, 8, 9], [10, 11, 12]]))
print(matrix)
produces the output:
[  7   8   9]
[ 10  11  12]
and print(repr(matrix)) says:
<2x3 matrix, tc='i'>
and print(type(matrix)) says:
<class 'cvxopt.base.matrix'>
The resulting matrix has integer type (the 'i') because the starting numpy array contained integers. Starting with double results in a 'd' type.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With