Skip to content

Commit 2b43953

Browse files
krcoolsdkarrasch
andauthored
Always use similar as fallback when resize throws in applying composite maps (#221)
Co-authored-by: Daniel Karrasch <[email protected]>
1 parent 4c95579 commit 2b43953

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "LinearMaps"
22
uuid = "7a12625a-238d-50fd-b39a-03d52299707e"
3-
version = "3.11.1"
3+
version = "3.11.2"
44

55
[deps]
66
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"

src/composition.jl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,7 @@ function _resize(dest::AbstractVector, sz::Tuple{<:Integer})
239239
try
240240
resize!(dest, sz[1])
241241
catch err
242-
if err == ErrorException("cannot resize array with shared data")
243-
dest = similar(dest, sz)
244-
else
245-
rethrow(err)
246-
end
242+
dest = similar(dest, sz)
247243
end
248244
dest
249245
end

test/nontradaxes.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,19 @@ using Test, LinearMaps, LinearAlgebra, BlockArrays
7070
B2u = B2*u; L2u = L2*u
7171
@test axes(B2u)[1] == axes(L2u)[1] == axes(B2)[1] == axes(L2)[1]
7272
@test blocklengths(axes(B2u)[1]) == blocklengths(axes(L2u)[1]) == [2,2]
73+
74+
D1 = rand(4,5)
75+
D2 = rand(5,3)
76+
D3 = rand(3,6)
77+
D4 = rand(6,6)
78+
A1 = PseudoBlockMatrix(D1, [1,3], [2,3])
79+
A2 = PseudoBlockMatrix(D2, [2,3], [2,1])
80+
A3 = PseudoBlockMatrix(D3, [2,1], [3,2,1])
81+
A4 = PseudoBlockMatrix(D4, [3,2,1], [3,2,1])
82+
u = rand(6)
83+
x = PseudoBlockVector(u, [3,2,1])
84+
L = LinearMap(A1) * LinearMap(A2) * LinearMap(A3) * LinearMap(A4)
85+
y = L * x
86+
v = Vector(y)
87+
@test v D1*(D2*(D3*(D4*u)))
7388
end

0 commit comments

Comments
 (0)