@@ -2,10 +2,10 @@ struct CompositeMap{T, As<:Tuple{Vararg{LinearMap}}} <: LinearMap{T}
22 maps:: As # stored in order of application to vector
33 function CompositeMap {T, As} (maps:: As ) where {T, As}
44 N = length (maps)
5- for n = 2 : N
5+ for n in 2 : N
66 size (maps[n], 2 ) == size (maps[n- 1 ], 1 ) || throw (DimensionMismatch (" CompositeMap" ))
77 end
8- for n = 1 : N
8+ for n in 1 : N
99 promote_type (T, eltype (maps[n])) == T || throw (InexactError ())
1010 end
1111 new {T, As} (maps)
4040
4141# scalar multiplication and division
4242function Base.:(* )(α:: Number , A:: LinearMap )
43- T = promote_type (eltype (α), eltype (A))
43+ T = promote_type (typeof (α), eltype (A))
4444 return CompositeMap {T} (tuple (A, UniformScalingMap (α, size (A, 1 ))))
4545end
4646function Base.:(* )(α:: Number , A:: CompositeMap )
47- T = promote_type (eltype (α), eltype (A))
47+ T = promote_type (typeof (α), eltype (A))
4848 Alast = last (A. maps)
4949 if Alast isa UniformScalingMap
5050 return CompositeMap {T} (tuple (Base. front (A. maps)... , UniformScalingMap (α * Alast. λ, size (Alast, 1 ))))
@@ -53,11 +53,11 @@ function Base.:(*)(α::Number, A::CompositeMap)
5353 end
5454end
5555function Base.:(* )(A:: LinearMap , α:: Number )
56- T = promote_type (eltype (α), eltype (A))
56+ T = promote_type (typeof (α), eltype (A))
5757 return CompositeMap {T} (tuple (UniformScalingMap (α, size (A, 2 )), A))
5858end
5959function Base.:(* )(A:: CompositeMap , α:: Number )
60- T = promote_type (eltype (α), eltype (A))
60+ T = promote_type (typeof (α), eltype (A))
6161 Afirst = first (A. maps)
6262 if Afirst isa UniformScalingMap
6363 return CompositeMap {T} (tuple (UniformScalingMap (Afirst. λ * α, size (Afirst, 1 )), Base. tail (A. maps)... ))
@@ -70,28 +70,28 @@ Base.:(/)(A::LinearMap, α::Number) = A * inv(α)
7070Base.:(- )(A:: LinearMap ) = - 1 * A
7171
7272# composition of linear maps
73- function Base.:(* )(A1 :: CompositeMap , A2 :: CompositeMap )
74- size (A1 , 2 ) == size (A2 , 1 ) || throw (DimensionMismatch (" *" ))
75- T = promote_type (eltype (A1 ), eltype (A2 ))
76- return CompositeMap {T} (tuple (A2 . maps... , A1 . maps... ))
73+ function Base.:(* )(A₁ :: CompositeMap , A₂ :: CompositeMap )
74+ size (A₁ , 2 ) == size (A₂ , 1 ) || throw (DimensionMismatch (" *" ))
75+ T = promote_type (eltype (A₁ ), eltype (A₂ ))
76+ return CompositeMap {T} (tuple (A₂ . maps... , A₁ . maps... ))
7777end
78- function Base.:(* )(A1 :: LinearMap , A2 :: CompositeMap )
79- size (A1 , 2 ) == size (A2 , 1 ) || throw (DimensionMismatch (" *" ))
80- T = promote_type (eltype (A1 ), eltype (A2 ))
81- return CompositeMap {T} (tuple (A2 . maps... , A1 ))
78+ function Base.:(* )(A₁ :: LinearMap , A₂ :: CompositeMap )
79+ size (A₁ , 2 ) == size (A₂ , 1 ) || throw (DimensionMismatch (" *" ))
80+ T = promote_type (eltype (A₁ ), eltype (A₂ ))
81+ return CompositeMap {T} (tuple (A₂ . maps... , A₁ ))
8282end
83- function Base.:(* )(A1 :: CompositeMap , A2 :: LinearMap )
84- size (A1 , 2 ) == size (A2 , 1 ) || throw (DimensionMismatch (" *" ))
85- T = promote_type (eltype (A1 ), eltype (A2 ))
86- return CompositeMap {T} (tuple (A2, A1 . maps... ))
83+ function Base.:(* )(A₁ :: CompositeMap , A₂ :: LinearMap )
84+ size (A₁ , 2 ) == size (A₂ , 1 ) || throw (DimensionMismatch (" *" ))
85+ T = promote_type (eltype (A₁ ), eltype (A₂ ))
86+ return CompositeMap {T} (tuple (A₂, A₁ . maps... ))
8787end
88- function Base.:(* )(A1 :: LinearMap , A2 :: LinearMap )
89- size (A1 , 2 ) == size (A2 , 1 ) || throw (DimensionMismatch (" *" ))
90- T = promote_type (eltype (A1), eltype (A2 ))
91- return CompositeMap {T} (tuple (A2, A1 ))
88+ function Base.:(* )(A₁ :: LinearMap , A₂ :: LinearMap )
89+ size (A₁ , 2 ) == size (A₂ , 1 ) || throw (DimensionMismatch (" *" ))
90+ T = promote_type (eltype (A₁), eltype (A₂ ))
91+ return CompositeMap {T} (tuple (A₂, A₁ ))
9292end
93- Base.:(* )(A1 :: LinearMap , A2 :: UniformScaling{T} ) where {T} = A1 * A2[ 1 , 1 ]
94- Base.:(* )(A1 :: UniformScaling{T} , A2 :: LinearMap ) where {T} = A1[ 1 , 1 ] * A2
93+ Base.:(* )(A₁ :: LinearMap , A₂ :: UniformScaling ) = A₁ * A₂ . λ
94+ Base.:(* )(A₁ :: UniformScaling , A₂ :: LinearMap ) = A₁ . λ * A₂
9595
9696# special transposition behavior
9797LinearAlgebra. transpose (A:: CompositeMap{T} ) where {T} = CompositeMap {T} (map (transpose, reverse (A. maps)))
@@ -114,7 +114,7 @@ function A_mul_B!(y::AbstractVector, A::CompositeMap, x::AbstractVector)
114114 if N> 2
115115 dest = Array {T} (undef, size (A. maps[2 ], 1 ))
116116 end
117- for n= 2 : N- 1
117+ for n in 2 : N- 1
118118 try
119119 resize! (dest, size (A. maps[n], 1 ))
120120 catch err
0 commit comments