MCPcopy Create free account
hub / github.com/casadi/casadi / Fun

Class Fun

test/python/function.py:1263–1290  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1261 g = Function("g", [x,y],[sin(x+3*y)])
1262
1263 class Fun(Callback):
1264 # sin(x+3*y)
1265
1266 def __init__(self):
1267 Callback.__init__(self)
1268 self.construct("Fun", {})
1269 def get_n_in(self): return 2
1270 def get_n_out(self): return 1
1271
1272 def eval(self,arg):
1273 x = arg[0]
1274 y = arg[1]
1275 z0 = 3*y
1276 z1 = x+z0
1277 z2 = sin(z1)
1278 return [z2]
1279
1280 def has_forward(self,nfwd): return False
1281 def has_reverse(self,nadj): return False
1282
1283 def has_jacobian(self): return True
1284
1285 def get_jacobian(self, name, inames, onames, opts):
1286 x = SX.sym("x")
1287 y = SX.sym("y")
1288 out_g = SX.sym('out_g', Sparsity(1,1))
1289 J = Function(name, [x,y, out_g], [cos(x+3*y), 3*cos(x+3*y)], inames, onames, opts)
1290 return J
1291
1292 f = Fun()
1293

Callers 5

test_Callback_errorsMethod · 0.85
getPMethod · 0.85

Calls

no outgoing calls

Tested by 4

test_Callback_errorsMethod · 0.68