Skip to content

Commit 59e1181

Browse files
committed
Add broadcasting for dampened type
1 parent 4bbc0d2 commit 59e1181

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

test/lsmr.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ using Base.Test
33

44
import Base: size, A_mul_B!, Ac_mul_B!, eltype, similar, scale!, copy!, fill!, length
55
import Base.LinAlg: norm
6+
import Base.Broadcast.broadcast!
67

78
# Type used in Dampenedtest
89
# solve (A'A + diag(v).^2 ) x = b
@@ -15,6 +16,12 @@ end
1516
eltype(a::DampenedVector) = promote_type(eltype(a.y), eltype(a.x))
1617
norm(a::DampenedVector) = sqrt(norm(a.y)^2 + norm(a.x)^2)
1718

19+
function Base.Broadcast.broadcast!(f::Tf, to::DampenedVector, from::DampenedVector, args...) where {Tf}
20+
to.x .= f.(from.x, args...)
21+
to.y .= f.(from.y, args...)
22+
to
23+
end
24+
1825
function copy!(a::DampenedVector{Ty, Tx}, b::DampenedVector{Ty, Tx}) where {Ty, Tx}
1926
copy!(a.y, b.y)
2027
copy!(a.x, b.x)

0 commit comments

Comments
 (0)