Skip to content

Commit

Permalink
Fix some method signatures related AbstractQ's (#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkarrasch authored Oct 3, 2023
1 parent bdbfe00 commit e29a810
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 19 deletions.
9 changes: 3 additions & 6 deletions src/blockmap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ julia> L * ones(Int, 6)
6
```
"""
function Base.hcat(As::Union{LinearMap, UniformScaling, AbstractVecOrMatOrQ}...)
function Base.hcat(As::Union{LinearMap, UniformScaling, AbstractArray, AbstractQ}...)
T = promote_type(map(eltype, As)...)
nbc = length(As)

Expand Down Expand Up @@ -119,7 +119,7 @@ julia> L * ones(Int, 3)
3
```
"""
function Base.vcat(As::Union{LinearMap,UniformScaling,AbstractVecOrMatOrQ}...)
function Base.vcat(As::Union{LinearMap, UniformScaling, AbstractArray, AbstractQ}...)
T = promote_type(map(eltype, As)...)
nbr = length(As)

Expand Down Expand Up @@ -162,10 +162,7 @@ julia> L * ones(Int, 6)
6
```
"""
Base.hvcat

function Base.hvcat(rows::Tuple{Vararg{Int}},
As::Union{LinearMap, UniformScaling, AbstractVecOrMatOrQ}...)
function Base.hvcat(rows::Tuple{Vararg{Int}}, As::Union{LinearMap, UniformScaling, AbstractArray, AbstractQ}...)
nr = length(rows)
T = promote_type(map(eltype, As)...)
sum(rows) == length(As) ||
Expand Down
2 changes: 1 addition & 1 deletion src/fillmap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ FillMap(λ, m::Int, n::Int) = FillMap(λ, (m, n))

# properties
Base.size(A::FillMap) = A.size
MulStyle(A::FillMap) = FiveArg()
MulStyle(::FillMap) = FiveArg()
LinearAlgebra.issymmetric(A::FillMap) = A.size[1] == A.size[2]
LinearAlgebra.ishermitian(A::FillMap) = isreal(A.λ) && A.size[1] == A.size[2]
LinearAlgebra.isposdef(A::FillMap) = (size(A, 1) == size(A, 2) == 1 && isposdef(A.λ))
Expand Down
2 changes: 1 addition & 1 deletion src/getindex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ _getindex(A::LinearMap, I::Indexer, J::Indexer) =
error("partial two-dimensional slicing of LinearMaps is not supported, consider using A[:,J][I] or A[I,:][J] instead")

_getindex(A::LinearMap, ::Base.Slice, j::Integer) = A*unitvec(A, 2, j)
function _getindex(A::LinearMap, i::Integer, J::Base.Slice)
function _getindex(A::LinearMap, i::Integer, ::Base.Slice)
try
# requires adjoint action to be defined
return vec(unitvec(A, 1, i)'A)
Expand Down
2 changes: 1 addition & 1 deletion src/left.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ julia> mul!(C, A, B, 1, 1)
5.0 7.0
```
"""
function mul!(X::AbstractMatrix, Y::AbstractMatrix, A::LinearMap, α, β)
function mul!(X::AbstractMatrix, Y::AbstractMatrix, A::LinearMap, α::Number, β::Number)
check_dim_mul(X, Y, A)
_unsafe_mul!(X, Y, A, α, β)
end
Expand Down
4 changes: 2 additions & 2 deletions src/uniformscalingmap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ Base.:(*)(J::UniformScalingMap, α::RealOrComplex) = UniformScalingMap(J.λ * α
Base.:(*)(J::UniformScalingMap, x::AbstractVector) =
length(x) == J.M ? J.λ * x : throw(DimensionMismatch("*"))
# multiplication with matrix
Base.:(*)(J::UniformScalingMap, B::AbstractMatrix) =
Base.:(*)(J::UniformScalingMap, B::Union{AbstractMatrix,AbstractQ}) =
size(B, 1) == J.M ? J.λ * LinearMap(B) : throw(DimensionMismatch("*"))
Base.:(*)(A::AbstractMatrix, J::UniformScalingMap) =
Base.:(*)(A::Union{AbstractMatrix,AbstractQ}, J::UniformScalingMap) =
size(A, 2) == J.M ? LinearMap(A) * J.λ : throw(DimensionMismatch("*"))
# disambiguation
Base.:(*)(xc::LinearAlgebra.AdjointAbsVec, J::UniformScalingMap) = xc * J.λ
Expand Down
16 changes: 8 additions & 8 deletions src/wrappedmap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ _unsafe_mul!(Y, A::VecOrMatMap, s::Number) = _unsafe_mul!(Y, A.lmap, s)
_unsafe_mul!(Y, A::VecOrMatMap, s::Number, α, β) = _unsafe_mul!(Y, A.lmap, s, α, β)

# combine LinearMap and Matrix objects: linear combinations and map composition
Base.:(+)(A₁::LinearMap, A₂::AbstractMatrix) = +(A₁, WrappedMap(A₂))
Base.:(+)(A₁::AbstractMatrix, A₂::LinearMap) = +(WrappedMap(A₁), A₂)
Base.:(-)(A₁::LinearMap, A₂::AbstractMatrix) = -(A₁, WrappedMap(A₂))
Base.:(-)(A₁::AbstractMatrix, A₂::LinearMap) = -(WrappedMap(A₁), A₂)
Base.:(+)(A₁::LinearMap, A₂::Union{AbstractMatrix,AbstractQ}) = +(A₁, WrappedMap(A₂))
Base.:(+)(A₁::Union{AbstractMatrix,AbstractQ}, A₂::LinearMap) = +(WrappedMap(A₁), A₂)
Base.:(-)(A₁::LinearMap, A₂::Union{AbstractMatrix,AbstractQ}) = -(A₁, WrappedMap(A₂))
Base.:(-)(A₁::Union{AbstractMatrix,AbstractQ}, A₂::LinearMap) = -(WrappedMap(A₁), A₂)

"""
*(A::LinearMap, X::AbstractMatrix)::CompositeMap
*(A::LinearMap, X::Union{AbstractMatrix,AbstractQ})::CompositeMap
Return the `CompositeMap` `A*LinearMap(X)`, interpreting the matrix `X` as a linear
operator, rather than a collection of column vectors. To compute the action of `A` on each
Expand All @@ -129,10 +129,10 @@ julia> A*X isa LinearMaps.CompositeMap
true
```
"""
Base.:(*)(A₁::LinearMap, A₂::AbstractMatrix) = *(A₁, WrappedMap(A₂))
Base.:(*)(A₁::LinearMap, A₂::Union{AbstractMatrix,AbstractQ}) = *(A₁, WrappedMap(A₂))

"""
*(X::AbstractMatrix, A::LinearMap)::CompositeMap
*(X::Union{AbstractMatrix,AbstractQ}, A::LinearMap)::CompositeMap
Return the `CompositeMap` `LinearMap(X)*A`, interpreting the matrix `X` as a linear
operator. To compute the right-action of `A` on each row of `X`, call `Matrix(X*A)`
Expand All @@ -146,4 +146,4 @@ julia> X*A isa LinearMaps.CompositeMap
true
```
"""
Base.:(*)(A₁::AbstractMatrix, A₂::LinearMap) = *(WrappedMap(A₁), A₂)
Base.:(*)(A₁::Union{AbstractMatrix,AbstractQ}, A₂::LinearMap) = *(WrappedMap(A₁), A₂)

2 comments on commit e29a810

@dkarrasch
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/92932

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v3.11.1 -m "<description of version>" e29a810f29c2458f0450f8100e81e6a898f60e74
git push origin v3.11.1

Please sign in to comment.