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

Further simplify StaticArrays usage #29

Merged
merged 1 commit into from
Mar 21, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/ellipsoid.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,7 @@ function boundpts(b::Ellipsoid{N}) where {N}
# n is (n .* r2) / sqrt(r2' * n.^2). Below is the broadcasted version of this over a
# matrix n, whose each column is a direction normal. Once calculated, we need to
# change the coordinates back to the original coordinates.
#
# This operation can be written M = b.p' * ((ndir .* r2) ./ sqrt.(r2' * ndir.^2)), but
# the resulting M is not an SMatrix. (The calculation involves broadcasted division by
# a row vector, which leads to a non-SMatrix.) Therefore, we first calculate M'
# (which remains SMatrix) and recover M.
M = (((ndir .* r2)' ./ sqrt.(ndir'.^2 * r2)) * b.p)'
M = b.p' * ((ndir .* r2) ./ sqrt.(r2' * ndir.^2))
Copy link
Owner

Choose a reason for hiding this comment

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

Isn't r2 a real scalar, and hence doesn't need the '? Also use .* to fuse that multiply with the other dot ops.

Copy link
Collaborator Author

@wsshin wsshin Mar 21, 2018

Choose a reason for hiding this comment

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

No, in this case r2 is a vector of the squared radii of the ellipsoid, and ndir is a matrix, so I think the operations are used correctly.

Copy link
Owner

Choose a reason for hiding this comment

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

Ah, I see.


return M
end
Expand Down