Skip to content

Commit c1f35a4

Browse files
abelsiqueiradpo
authored andcommitted
Fix opEye bug
1 parent b28e3b5 commit c1f35a4

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/LinearOperators.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ check_positive_definite(M :: AbstractMatrix) = check_positive_definite(LinearOpe
477477
Identity operator of order `n` and of data type `T` (defaults to `Float64`).
478478
"""
479479
function opEye(T :: DataType, n :: Int)
480-
prod = @closure v -> v
480+
prod = @closure v -> copy(v)
481481
F = typeof(prod)
482482
LinearOperator{T,F,F,F}(n, n, true, true, prod, prod, prod)
483483
end

test/test_linop.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ function test_linop()
143143
@test(abs(norm(opI' * v - v)) <= ϵ * norm(v));
144144
@test(norm(Matrix(opI) - Matrix(1.0I, nrow, nrow)) <= ϵ * norm(Matrix(1.0I, nrow, nrow)));
145145

146+
w = opI * v
147+
w[1] = -1.0
148+
@test v[1] != w[1]
149+
146150
opI = opEye(nrow, ncol)
147151
v = rand(ncol) + rand(ncol) * im
148152
v0 = [v ; zeros(nrow - ncol)]

0 commit comments

Comments
 (0)