Skip to content

Commit 7104fbe

Browse files
authored
some suggestion (#224)
1 parent 66f7e53 commit 7104fbe

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

src/pullbacks/eig.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@ function check_and_prepare_eig_cotangents(
1010
if !iszerotangent(ΔV)
1111
n == size(ΔV, 1) || throw(DimensionMismatch())
1212
length(indV) == size(ΔV, 2) || throw(DimensionMismatch())
13-
ΔV₁ = zero(V)
14-
ΔV₁[:, indV] = ΔV
13+
if indV == 1:p
14+
ΔV₁ = copy(ΔV)
15+
else
16+
ΔV₁ = zero(V)
17+
ΔV₁[:, indV] = ΔV
18+
end
1519
VᴴΔV₁ = V' * ΔV₁
1620
if p == n
1721
ΔV₊ = zero!(ΔV₁)

src/pullbacks/eigh.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@ function check_and_prepare_eigh_cotangents(
1010
if !iszerotangent(ΔV)
1111
n == size(ΔV, 1) || throw(DimensionMismatch())
1212
length(indV) == size(ΔV, 2) || throw(DimensionMismatch())
13-
ΔV₁ = zero(V)
14-
ΔV₁[:, indV] = ΔV
13+
if indV == 1:p
14+
ΔV₁ = copy(ΔV)
15+
else
16+
ΔV₁ = zero(V)
17+
ΔV₁[:, indV] = ΔV
18+
end
1519
VᴴΔV₁ = V' * ΔV₁
1620
if p == n
1721
ΔV₊ = zero!(ΔV₁)

0 commit comments

Comments
 (0)