You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've run into an issue where the instructions on creating transposes for custom linear maps are insufficient for the custom map to fully work. A MWE using the documented example of MyFillMap:
using LinearMaps, LinearAlgebra
struct MyFillMap{T} <:LinearMaps.LinearMap{T}
λ::T
size::Dims{2}functionMyFillMap(λ::T, dims::Dims{2}) where {T}
all(≥(0), dims) ||throw(ArgumentError("dims of MyFillMap must be non-negative"))
promote_type(T, typeof(λ)) == T ||throw(InexactError())
returnnew{T}(λ, dims)
endend
Base.size(A::MyFillMap) = A.size
function LinearAlgebra.mul!(y::AbstractVecOrMat, A::MyFillMap, x::AbstractVector)
LinearMaps.check_dim_mul(y, A, x)
returnfill!(y, iszero(A.λ) ?zero(eltype(y)) : A.λ*sum(x))
endfunction LinearAlgebra.mul!(
y::AbstractVecOrMat,
transA::LinearMaps.TransposeMap{<:Any,<:MyFillMap},
x::AbstractVector
)
LinearMaps.check_dim_mul(y, transA, x)
λ = transA.lmap.λ
returnfill!(y, iszero(λ) ?zero(eltype(y)) :transpose(λ)*sum(x))
end
I've run into an issue where the instructions on creating transposes for custom linear maps are insufficient for the custom map to fully work. A MWE using the documented example of
MyFillMap
:Then,
Adding this:
Makes the example work.
The text was updated successfully, but these errors were encountered: