Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cvxMat = matrix(pdObj.as_matrix())
- pdObj[:]=np.array(cvxMat)
- (matrix(pdObj.as_matrix()).T*cvxMat)[0]
- >>> m1 = cvxopt.matrix([[1, 2, 3], [2, 3, 4]])
- >>> m2 = pd.DataFrame(np.array(m1)).T
- >>> m1
- <3x2 matrix, tc='i'>
- >>> m2.shape
- (2, 3)
- >>> np.dot(m1,m2)
- array([[ 5, 8, 11],
- [ 8, 13, 18],
- [11, 18, 25]])
- >>> m1 * m2
- 0 1 2
- 0 1 4 9
- 1 4 9 16
- [2 rows x 3 columns]
- In [90]: m1 = cvxopt.matrix([[1, 2, 3], [2, 3, 4]])
- In [91]: m2 = np.matrix([[1, 2, 3], [2, 3, 4]])
- In [92]: m1
- Out[92]: <3x2 matrix, tc='i'>
- In [94]: m2.shape
- Out[94]: (2, 3)
- In [95]: m1 * m2
- Out[95]:
- matrix([[ 5, 8, 11],
- [ 8, 13, 18],
- [11, 18, 25]])
- def dot( A, B ):
- """ np.dot .value or .values if they exist """
- for val in "value values" .split():
- A = getattr( A, val, A ) # A.val or A
- B = getattr( B, val, B )
- A = np.asanyarray( A )
- B = np.asanyarray( B )
- try:
- np.dot( A, B )
- except ValueError:
- print >>sys.stderr, "error: can't dot shapes %s x %s" % (A.shape, B.shape)
- raise
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement