Skip to content

Minor clean-up #170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
name = "LinearMaps"
uuid = "7a12625a-238d-50fd-b39a-03d52299707e"
version = "3.5.1"
version = "3.5.2"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[compat]
julia = "1.6"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Quaternions = "94ee1d12-ae83-5a48-8b1c-48b8ff168ae0"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Aqua", "BenchmarkTools", "BlockArrays", "InteractiveUtils", "LinearAlgebra", "Quaternions", "SparseArrays", "Test"]
2 changes: 1 addition & 1 deletion src/blockmap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ end
function _blockscaling!(y, A::BlockDiagonalMap, x, α, β)
maps, yinds, xinds = A.maps, A.rowranges, A.colranges
# TODO: think about multi-threading here
@views for i in eachindex(yinds, maps, xinds)
@inbounds for i in eachindex(yinds, maps, xinds)
_unsafe_mul!(selectdim(y, 1, yinds[i]), maps[i], selectdim(x, 1, xinds[i]), α, β)
end
return y
Expand Down
4 changes: 2 additions & 2 deletions src/composition.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function Base.:(*)(α::Number, A::CompositeMap)
end
end
# needed for disambiguation
function Base.:(*)(α::RealOrComplex, A::CompositeMap)
function Base.:(*)(α::RealOrComplex, A::CompositeMap{<:RealOrComplex})
T = Base.promote_op(*, typeof(α), eltype(A))
return ScaledMap{T}(α, A)
end
Expand All @@ -83,7 +83,7 @@ function Base.:(*)(A::CompositeMap, α::Number)
end
end
# needed for disambiguation
function Base.:(*)(A::CompositeMap, α::RealOrComplex)
function Base.:(*)(A::CompositeMap{<:RealOrComplex}, α::RealOrComplex)
T = Base.promote_op(*, typeof(α), eltype(A))
return ScaledMap{T}(α, A)
end
Expand Down
16 changes: 16 additions & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[deps]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Quaternions = "94ee1d12-ae83-5a48-8b1c-48b8ff168ae0"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
Aqua = "0.5"
BenchmarkTools = "1"
BlockArrays = "0.16"
Quaternions = "0.5"
julia = "1.6"
9 changes: 3 additions & 6 deletions test/numbertypes.jl
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
using Test, LinearMaps, LinearAlgebra, Quaternions

# type piracy because Quaternions.jl doesn't have it right
Base.:(*)(z::Complex, q::Quaternion) = quat(z) * q
Base.:(*)(q::Quaternion, z::Complex) = q * quat(z)
Base.:(+)(q::Quaternion, z::Complex) = q + quat(z)

@testset "noncommutative number type" begin
x = Quaternion.(rand(10), rand(10), rand(10), rand(10))
v = rand(10)
A = Quaternion.(rand(10,10), rand(10,10), rand(10,10), rand(10,10))
B = rand(ComplexF64, 10, 10)
C = similar(A)
γ = Quaternion.(rand(4)...) # "Number"
γ = Quaternion(rand(4)...) # "Number"
α = UniformScaling(γ)
β = UniformScaling(Quaternion.(rand(4)...))
λ = rand(ComplexF64)
Expand Down Expand Up @@ -46,6 +41,8 @@ Base.:(+)(q::Quaternion, z::Complex) = q + quat(z)
@test λ*L isa LinearMaps.CompositeMap
@test γ * (λ * LinearMap(B)) isa LinearMaps.CompositeMap
@test (λ * LinearMap(B)) * γ isa LinearMaps.CompositeMap
@test ((L*L)*λ) isa LinearMaps.CompositeMap
@test (λ*(L*L)) isa LinearMaps.CompositeMap
@test λ*L * x ≈ λ*A * x
@test λ*L' * x ≈ λ*A' * x
@test α * (3L * x) ≈ γ * (3A * x)
Expand Down