|
39 | 39 | # the following for multiplying with transpose and adjoint map are optional:
|
40 | 40 | # subtypes can overwrite nonmutating methods, implement mutating methods or do nothing
|
41 | 41 | function Base.At_mul_B(A::LinearMap, x::AbstractVector)
|
42 |
| - if length(methods(Base.At_mul_B!,Tuple{AbstractVector, typeof(A), AbstractVector})) > 1 |
| 42 | + l = methods(Base.At_mul_B!,Tuple{AbstractVector, typeof(A), AbstractVector}) |
| 43 | + if length(l) > 0 && first(l.ms).sig.parameters[3] != LinearMap |
43 | 44 | Base.At_mul_B!(similar(x, promote_type(eltype(A), eltype(x)), size(A,2)), A, x)
|
44 | 45 | else
|
45 | 46 | throw(MethodError(Base.At_mul_B, (A, x)))
|
46 | 47 | end
|
47 | 48 | end
|
48 | 49 | function Base.At_mul_B!(y::AbstractVector, A::LinearMap, x::AbstractVector)
|
49 | 50 | length(y) == size(A, 2) || throw(DimensionMismatch("At_mul_B!"))
|
50 |
| - if length(methods(Base.At_mul_B,Tuple{typeof(A), AbstractVector})) > 1 |
| 51 | + l = methods(Base.At_mul_B,Tuple{typeof(A), AbstractVector}) |
| 52 | + if length(l) > 0 && first(l.ms).sig.parameters[2] != LinearMap |
51 | 53 | copy!(y, Base.At_mul_B(A, x))
|
52 | 54 | else
|
53 | 55 | throw(MethodError(Base.At_mul_B!, (y, A, x)))
|
54 | 56 | end
|
55 | 57 | end
|
56 | 58 | function Base.Ac_mul_B(A::LinearMap,x::AbstractVector)
|
57 |
| - if length(methods(Base.Ac_mul_B!,Tuple{AbstractVector, typeof(A), AbstractVector})) > 1 |
| 59 | + l = methods(Base.Ac_mul_B!,Tuple{AbstractVector, typeof(A), AbstractVector}) |
| 60 | + if length(l) > 0 && first(l.ms).sig.parameters[3] != LinearMap |
58 | 61 | Base.Ac_mul_B!(similar(x, promote_type(eltype(A), eltype(x)), size(A,2)), A, x)
|
59 | 62 | else
|
60 | 63 | throw(MethodError(Base.Ac_mul_B, (A, x)))
|
|
63 | 66 | function
|
64 | 67 | Base.Ac_mul_B!(y::AbstractVector, A::LinearMap, x::AbstractVector)
|
65 | 68 | length(y)==size(A,2) || throw(DimensionMismatch("At_mul_B!"))
|
66 |
| - if length(methods(Base.Ac_mul_B,Tuple{typeof(A), AbstractVector})) > 1 |
| 69 | + l = methods(Base.Ac_mul_B,Tuple{typeof(A), AbstractVector}) |
| 70 | + if length(l) > 0 && first(l.ms).sig.parameters[2] != LinearMap |
67 | 71 | copy!(y, Base.Ac_mul_B(A, x))
|
68 | 72 | else
|
69 | 73 | throw(MethodError(Base.Ac_mul_B!, (y, A, x)))
|
|
0 commit comments