Skip to content

Commit

Permalink
Fixed bug with gradient rotation.
Browse files Browse the repository at this point in the history
  • Loading branch information
cncastillo committed Oct 21, 2021
1 parent 20a1b40 commit c370897
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/Grad.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ end
#Gradient operations
*(x::Grad::Real) = Grad*x.A,x.T)
*::Real,x::Grad) = Grad*x.A,x.T)
*(A::Matrix{Float64},GR::Matrix{Grad}) = begin
N, M = size(GR)
[sum(A[i,1:N] .* GR[:,j]) for i=1:N, j=1:M]
end
import Base.zero
zero(::Grad) = Grad(0,0)
/(x::Grad::Real) = Grad(x.A/α,x.T)
Expand Down
3 changes: 2 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ end
θ = π*t
R = MRIsim.rotz(θ)
s2 = R*s
@test s2.GR.A [A1*cos(θ)-A2*sin(θ); A1*sin(θ)+A2*cos(θ)]
GR2 = R*s.GR.A
@test s2.GR.A GR2
# Rotation 3D case
T, t1, t2, t3 = rand(4)
N = 100
Expand Down

2 comments on commit c370897

@cncastillo
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/47216

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.4 -m "<description of version>" c370897729e033a4f96b3cf3e124314f4380bd30
git push origin v0.3.4

Please sign in to comment.