Skip to content

Commit

Permalink
Broadcast over constants in multiply!() and add!()
Browse files Browse the repository at this point in the history
Permit the arguments to multiply! and add! (and by extension,
divide! and the copying versions) to be arrays, and broadcast
over them.  This allows for example

    julia> multiply!(s, s[:depmax])

to normalise the traces in `s` by their maximum positive amplitude.
  • Loading branch information
anowacki committed Mar 31, 2017
1 parent abef7d6 commit 5876c10
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/SAC.jl
Expand Up @@ -889,7 +889,7 @@ envelope!(s::SACtr) = envelope!([s])
Multiply the values in a SAC trace by `value`
""" ->
function multiply!(a::Array{SACtr}, val)
for s in a s.t[:] = s.t[:]*val end
for s in a s.t[:] = s.t[:].*val end
update_headers!(a)
end
multiply!(s::SACtr, val) = multiply!([s], val)
Expand All @@ -901,7 +901,7 @@ mul! = multiply!
Add a constant value to a SAC trace
""" ->
function add!(a::Array{SACtr}, val)
for s in a s.t[:] = s.t[:] + val end
for s in a s.t[:] = s.t[:] .+ val end
update_headers!(a)
end
add!(s::SACtr, val) = add!([s], val)
Expand Down

0 comments on commit 5876c10

Please sign in to comment.