Last active
August 29, 2015 14:20
-
-
Save adbuerger/89ef1e4f47661ae7c1a4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import casadi as ca | |
import pylab as pl | |
# [...] | |
# A is of type SX, column vector, shape (788, 1), dense | |
# B is of type sx, column vector, shape (984, 1), dense | |
# V is of type struct_symSX, shape (1594, 1), dense | |
# W is a numpy array, matrix with shape (788, 788), almost diagonal | |
fA = ca.SXFunction(ca.nlpIn(x = V), ca.nlpOut(f = A)) | |
fA.init() | |
fB = ca.SXFunction(ca.nlpIn(x = V), ca.nlpOut(f = B)) | |
fB.init() | |
J1 = ca.mul(W, fA.jac("x", "f")) | |
J2 = fB.jac("x", "f") | |
h1 = ca.horzcat((ca.mul([J1.T, W, J1]), J2.T)) | |
h2 = ca.horzcat((J2, pl.zeros((B.size, B.size)))) | |
Jp = ca.mul([ \ | |
ca.horzcat((pl.eye(V.size), pl.zeros((V.size, B.size)))), \ | |
ca.solve(ca.vertcat((h1, h2)), pl.eye(V.size, + B.size)), \ | |
ca.vertcat((J1.T, pl.zeros((B.size, A.size)))) \ | |
]) | |
fcov = ca.SXFunction(ca.nlpIn(x = V), ca.nlpOut(f = ca.mul(Jp, Jp.T))) | |
fcov.init() | |
# [...] followed by an evaluation of fcov |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment