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

Don't create a reshaped array when compute a Jacobian of a StaticVector #113

Merged
merged 1 commit into from
Jul 29, 2020

Conversation

andreasnoack
Copy link
Member

@andreasnoack andreasnoack commented Jul 29, 2020

valued function of size one. It causes very inefficient fallbacks

julia> reshape(SMatrix{1,1}(1.0), 1, 1)
1×1 reshape(::SArray{Tuple{1,1},Float64,2,1}, 1, 1) with eltype Float64:
 1.0

julia> reshape(SMatrix{1,1}(1.0), 1, 1)*1.0
1×1 Array{Float64,2}:
 1.0

Fixes #104

src/jacobians.jl Outdated
if maximum(colorvec) == 1
J = reshape(J, 1, 1)
end
J = reshape(J, (axes(J, 1), axes(J, 1)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like this assumes square?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Bummer. StaticArrays are hard. I'll try to come up with a solution.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fixed now

@andreasnoack andreasnoack merged commit 80b76d4 into master Jul 29, 2020
@andreasnoack andreasnoack deleted the an/noreshape branch July 29, 2020 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Non-allocating Jacobians with StaticArrays
2 participants