Skip to content

Instantly share code, notes, and snippets.

@tomascsantos
Created May 7, 2020 20:09
Show Gist options
  • Save tomascsantos/2b198db8cc30a29fa256972e6e84aa22 to your computer and use it in GitHub Desktop.
Save tomascsantos/2b198db8cc30a29fa256972e6e84aa22 to your computer and use it in GitHub Desktop.
Matrix Multiplication
C = np.array([
[0,1],
[0,-1],
[1,0],
[-1,0]
])
lam2 = opti.variable(C.shape[0], self.H+1) #dual variables for obstacle opt
Rot = lambda theta : np.array([
[casadi.cos(theta), -casadi.sin(theta)],
[casadi.sin(theta), casadi.cos(theta)],
])
print("C type: ", type(C))
>>>C type: <class 'numpy.ndarray'>
print("R type: ", type(Rot(theta[k])))
>>>R type: <class 'numpy.ndarray'>
print("lam type: ", type(lam2[:,k]))
>>>lam type: <class 'casadi.casadi.MX'>
test = C.T @ lam2[:,k]
print("test type: ", type(test))
>>>test type: <class 'casadi.casadi.MX'>
test2 = Rot(theta[k]).T @ lam2[:,k]
>>>
File "/home/tomas/Documents/ee106b/final_proj/mpc.py", line 169, in MPC
test2 = Rot(theta[k]).T @ lam2[:,k]
File "/home/tomas/anaconda3/envs/proj3_env/lib/python3.6/site-packages/casadi/casadi.py", line 6105, in __rmatmul__
def __rmatmul__(x, y): return _casadi.mtimes(y, x)
NotImplementedError: Wrong number or type of arguments for overloaded function 'mtimes'.
Possible prototypes are:
mtimes([Sparsity])
mtimes([DM])
mtimes([SX])
mtimes([MX])
mtimes(Sparsity,Sparsity)
mtimes(DM,DM)
mtimes(SX,SX)
mtimes(MX,MX)
You have: '(np.array(MX),MX)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment