Skip to content

Commit 971a928

Browse files
authored
Fix WrappedMap constructor for vectors (#239)
1 parent 354312d commit 971a928

File tree

5 files changed

+15
-21
lines changed

5 files changed

+15
-21
lines changed

Project.toml

+1-1
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.3"
3+
version = "3.12.1"
44

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

src/wrappedmap.jl

+4-10
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,30 @@ struct WrappedMap{T, A<:MapOrVecOrMat} <: LinearMap{T}
44
_ishermitian::Bool
55
_isposdef::Bool
66
end
7-
function WrappedMap{T}(lmap::MapOrMatrix;
7+
function WrappedMap{T}(lmap::MapOrVecOrMat;
88
issymmetric::Bool = _issymmetric(lmap),
99
ishermitian::Bool = _ishermitian(lmap),
1010
isposdef::Bool = _isposdef(lmap)) where {T}
1111
WrappedMap{T, typeof(lmap)}(lmap, issymmetric, ishermitian, isposdef)
1212
end
13-
function WrappedMap{T}(lmap::AbstractVector;
14-
issym::Bool = false,
15-
isherm::Bool = false,
16-
ispd::Bool = false) where {T}
17-
WrappedMap{T, typeof(lmap)}(lmap,
18-
length(lmap) == 1 && issymmetric(first(lmap)),
19-
length(lmap) == 1 && ishermitian(first(lmap)),
20-
length(lmap) == 1 && isposdef(first(lmap)))
21-
end
2213
WrappedMap(lmap::MapOrVecOrMat{T}; kwargs...) where {T} = WrappedMap{T}(lmap; kwargs...)
2314

2415
# cheap property checks (usually by type)
16+
_issymmetric(A::AbstractVector) = length(A) == 1 && issymmetric(first(A))
2517
_issymmetric(A::AbstractMatrix) = false
2618
_issymmetric(A::AbstractQ) = false
2719
_issymmetric(A::LinearMap) = issymmetric(A)
2820
_issymmetric(A::LinearAlgebra.RealHermSymComplexSym) = issymmetric(A)
2921
_issymmetric(A::Union{Bidiagonal,Diagonal,SymTridiagonal,Tridiagonal}) = issymmetric(A)
3022

23+
_ishermitian(A::AbstractVector) = length(A) == 1 && ishermitian(first(A))
3124
_ishermitian(A::AbstractMatrix) = false
3225
_ishermitian(A::AbstractQ) = false
3326
_ishermitian(A::LinearMap) = ishermitian(A)
3427
_ishermitian(A::LinearAlgebra.RealHermSymComplexHerm) = ishermitian(A)
3528
_ishermitian(A::Union{Bidiagonal,Diagonal,SymTridiagonal,Tridiagonal}) = ishermitian(A)
3629

30+
_isposdef(A::AbstractVector) = length(A) == 1 && isposdef(first(A))
3731
_isposdef(A::AbstractMatrix) = false
3832
_isposdef(A::AbstractQ) = false
3933
_isposdef(A::LinearMap) = isposdef(A)

test/Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1515

1616
[compat]
1717
Aqua = "0.8"
18-
BlockArrays = "0.16"
18+
BlockArrays = "1"
1919
ChainRulesCore = "1"
2020
ChainRulesTestUtils = "1.9"
2121
Documenter = "1"

test/nontradaxes.jl

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ using Test, LinearMaps, LinearAlgebra, BlockArrays
33
@testset "Non-traditional axes" begin
44

55
A = rand(ComplexF64,2,4)
6-
B = PseudoBlockMatrix{ComplexF64}(undef, [2,3], [3,4])
6+
B = BlockMatrix{ComplexF64}(undef, [2,3], [3,4])
77

88
ax1 = axes(B)[1]
99
ax2 = axes(B)[2]
@@ -19,7 +19,7 @@ using Test, LinearMaps, LinearAlgebra, BlockArrays
1919
@test eltype(N) == eltype(B)
2020

2121
u = similar(Array{ComplexF64}, ax2)
22-
v = PseudoBlockVector{ComplexF64}(undef, [3,5])
22+
v = BlockVector{ComplexF64}(undef, [3,5])
2323
w = similar(Array{ComplexF64}, ax1)
2424

2525
for i in eachindex(u) u[i] = rand(ComplexF64) end
@@ -54,7 +54,7 @@ using Test, LinearMaps, LinearAlgebra, BlockArrays
5454
@test blocklengths(axes(C)[1]) == blocklengths(ax1)
5555

5656
A = rand(ComplexF64,2,2)
57-
B = PseudoBlockMatrix{ComplexF64}(undef, [2,2], [2,2])
57+
B = BlockMatrix{ComplexF64}(undef, [2,2], [2,2])
5858
ax1 = axes(B)[1]
5959
ax2 = axes(B)[2]
6060
fill!(B,0)
@@ -75,12 +75,12 @@ using Test, LinearMaps, LinearAlgebra, BlockArrays
7575
D2 = rand(5,3)
7676
D3 = rand(3,6)
7777
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])
78+
A1 = BlockMatrix(D1, [1,3], [2,3])
79+
A2 = BlockMatrix(D2, [2,3], [2,1])
80+
A3 = BlockMatrix(D3, [2,1], [3,2,1])
81+
A4 = BlockMatrix(D4, [3,2,1], [3,2,1])
8282
u = rand(6)
83-
x = PseudoBlockVector(u, [3,2,1])
83+
x = BlockVector(u, [3,2,1])
8484
L = LinearMap(A1) * LinearMap(A2) * LinearMap(A3) * LinearMap(A4)
8585
y = L * x
8686
v = Vector(y)

test/wrappedmap.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Test, LinearMaps, LinearAlgebra
1+
using Test, LinearMaps, LinearAlgebra, SparseArrays
22

33
@testset "wrapped maps" begin
44
A = rand(10, 20)

0 commit comments

Comments
 (0)