Skip to content

Commit

Permalink
Add method for multiplication of a Matrix by an Array{Grad}
Browse files Browse the repository at this point in the history
  • Loading branch information
pvillacorta committed Jan 30, 2025
1 parent 9f18312 commit 36ab6c6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions KomaMRIBase/src/datatypes/sequence/Grad.jl
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,13 @@ Base.zero(::Type{Grad}) = Grad(0.0, 0.0)
# Rotation
Base.zero(::Grad) = Grad(0.0, 0.0)
*::Real, x::Grad) = Grad* x.A, x.T, x.rise, x.fall, x.delay)
*::Matrix, x::Array{Grad}) = begin
y = deepcopy(x)
for (i, g) in enumerate(y)
g.A =*x.A)[i]
end
return y
end
+(x::Grad, y::Grad) = Grad(x.A .+ y.A, max(x.T, y.T), max(x.rise, y.rise), max(x.fall, y.fall), max(x.delay, y.delay)) #TODO: solve this in a better way (by "stacking" gradients) issue #487
# Others
*(x::Grad, α::Real) = Grad* x.A, x.T, x.rise, x.fall, x.delay)
Expand Down

0 comments on commit 36ab6c6

Please sign in to comment.