Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect lengths of Jacobians #231

Closed
lzxnl opened this issue Jan 29, 2020 · 2 comments · Fixed by #233
Closed

Incorrect lengths of Jacobians #231

lzxnl opened this issue Jan 29, 2020 · 2 comments · Fixed by #233

Comments

@lzxnl
Copy link

lzxnl commented Jan 29, 2020

Define the function

function grad(f,vars) #vars is an array of variables
if length(f) > 1
f1 = ModelingToolkit.jacobian(f,vars)
else
f1 = ModelingToolkit.gradient(f,vars)
end
f2,f2! = ModelingToolkit.build_function(f1,vars,ModelingToolkit.simplified_expr,Val{false})
return f2
end

Now, try grad([x,y,z],[x,y,z]) after declaring x, y, z to be variables. The result is not a constant identity matrix function, even though it should be. Rather, it's a vector with 9 entries, a flattened form of what the answer should be. Is there a bug somewhere?

@wupeifan
Copy link
Contributor

I think currently they flatten all the matrices. You can reshape it yourself. Just a column priority...

@ChrisRackauckas
Copy link
Member

fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants