@@ -19,19 +19,19 @@ struct DiffEqOperatorCombination{T,O<:Tuple{Vararg{AbstractDiffEqLinearOperator{
1919 new {T,typeof(ops),typeof(cache)} (ops, cache)
2020 end
2121end
22- + (ops:: AbstractDiffEqLinearOperator... ) = DiffEqOperatorCombination (ops)
23- + (op:: AbstractDiffEqLinearOperator , A:: AbstractMatrix ) = op + DiffEqArrayOperator (A)
24- + (op:: AbstractDiffEqLinearOperator{T} , α:: UniformScaling ) where T = op + UniformScaling (T (α. λ))(size (op,1 ))
25- + (A:: AbstractMatrix , op:: AbstractDiffEqLinearOperator ) = op + A
26- + (α:: UniformScaling , op:: AbstractDiffEqLinearOperator ) = op + α
27- + (L1:: DiffEqOperatorCombination , L2:: AbstractDiffEqLinearOperator ) = DiffEqOperatorCombination ((L1. ops... , L2))
28- + (L1:: AbstractDiffEqLinearOperator , L2:: DiffEqOperatorCombination ) = DiffEqOperatorCombination ((L1, L2. ops... ))
29- + (L1:: DiffEqOperatorCombination , L2:: DiffEqOperatorCombination ) = DiffEqOperatorCombination ((L1. ops... , L2. ops... ))
30- - (L1:: AbstractDiffEqLinearOperator , L2:: AbstractDiffEqLinearOperator ) = L1 + (- L2)
31- - (L:: AbstractDiffEqLinearOperator , A:: AbstractMatrix ) = L + (- A)
32- - (A:: AbstractMatrix , L:: AbstractDiffEqLinearOperator ) = A + (- L)
33- - (L:: AbstractDiffEqLinearOperator , α:: UniformScaling ) = L + (- α)
34- - (α:: UniformScaling , L:: AbstractDiffEqLinearOperator ) = α + (- L)
22+ Base.: + (ops:: AbstractDiffEqLinearOperator... ) = DiffEqOperatorCombination (ops)
23+ Base.: + (op:: AbstractDiffEqLinearOperator , A:: AbstractMatrix ) = op + DiffEqArrayOperator (A)
24+ Base.: + (op:: AbstractDiffEqLinearOperator{T} , α:: UniformScaling ) where T = op + UniformScaling (T (α. λ))(size (op,1 ))
25+ Base.: + (A:: AbstractMatrix , op:: AbstractDiffEqLinearOperator ) = op + A
26+ Base.: + (α:: UniformScaling , op:: AbstractDiffEqLinearOperator ) = op + α
27+ Base.: + (L1:: DiffEqOperatorCombination , L2:: AbstractDiffEqLinearOperator ) = DiffEqOperatorCombination ((L1. ops... , L2))
28+ Base.: + (L1:: AbstractDiffEqLinearOperator , L2:: DiffEqOperatorCombination ) = DiffEqOperatorCombination ((L1, L2. ops... ))
29+ Base.: + (L1:: DiffEqOperatorCombination , L2:: DiffEqOperatorCombination ) = DiffEqOperatorCombination ((L1. ops... , L2. ops... ))
30+ Base.: - (L1:: AbstractDiffEqLinearOperator , L2:: AbstractDiffEqLinearOperator ) = L1 + (- L2)
31+ Base.: - (L:: AbstractDiffEqLinearOperator , A:: AbstractMatrix ) = L + (- A)
32+ Base.: - (A:: AbstractMatrix , L:: AbstractDiffEqLinearOperator ) = A + (- L)
33+ Base.: - (L:: AbstractDiffEqLinearOperator , α:: UniformScaling ) = L + (- α)
34+ Base.: - (α:: UniformScaling , L:: AbstractDiffEqLinearOperator ) = α + (- L)
3535getops (L:: DiffEqOperatorCombination ) = L. ops
3636Matrix (L:: DiffEqOperatorCombination ) = sum (Matrix, L. ops)
3737convert (:: Type{AbstractMatrix} , L:: DiffEqOperatorCombination ) =
@@ -40,8 +40,8 @@ convert(::Type{AbstractMatrix}, L::DiffEqOperatorCombination) =
4040size (L:: DiffEqOperatorCombination , args... ) = size (L. ops[1 ], args... )
4141getindex (L:: DiffEqOperatorCombination , i:: Int ) = sum (op -> op[i], L. ops)
4242getindex (L:: DiffEqOperatorCombination , I:: Vararg{Int, N} ) where {N} = sum (op -> op[I... ], L. ops)
43- * (L:: DiffEqOperatorCombination , x:: AbstractArray ) = sum (op -> op * x, L. ops)
44- * (x:: AbstractArray , L:: DiffEqOperatorCombination ) = sum (op -> x * op, L. ops)
43+ Base.: * (L:: DiffEqOperatorCombination , x:: AbstractArray ) = sum (op -> op * x, L. ops)
44+ Base.: * (x:: AbstractArray , L:: DiffEqOperatorCombination ) = sum (op -> x * op, L. ops)
4545/ (L:: DiffEqOperatorCombination , x:: AbstractArray ) = sum (op -> op / x, L. ops)
4646\ (x:: AbstractArray , L:: DiffEqOperatorCombination ) = sum (op -> x \ op, L. ops)
4747function mul! (y:: AbstractVector , L:: DiffEqOperatorCombination , b:: AbstractVector )
@@ -77,13 +77,20 @@ struct DiffEqOperatorComposition{T,O<:Tuple{Vararg{AbstractDiffEqLinearOperator{
7777 new {T,typeof(ops),typeof(caches)} (ops, caches)
7878 end
7979end
80- * (ops:: AbstractDiffEqLinearOperator... ) = DiffEqOperatorComposition (reverse (ops))
80+ # this is needed to not break dispatch in MethodOfLines
81+ function Base.:* (ops:: AbstractDiffEqLinearOperator... )
82+ try
83+ return DiffEqOperatorComposition (reverse (ops))
84+ catch e
85+ return 1
86+ end
87+ end
8188∘ (L1:: AbstractDiffEqLinearOperator , L2:: AbstractDiffEqLinearOperator ) = DiffEqOperatorComposition ((L2, L1))
82- * (L1:: DiffEqOperatorComposition , L2:: AbstractDiffEqLinearOperator ) = DiffEqOperatorComposition ((L2, L1. ops... ))
89+ Base.: * (L1:: DiffEqOperatorComposition , L2:: AbstractDiffEqLinearOperator ) = DiffEqOperatorComposition ((L2, L1. ops... ))
8390∘ (L1:: DiffEqOperatorComposition , L2:: AbstractDiffEqLinearOperator ) = DiffEqOperatorComposition ((L2, L1. ops... ))
84- * (L1:: AbstractDiffEqLinearOperator , L2:: DiffEqOperatorComposition ) = DiffEqOperatorComposition ((L2. ops... , L1))
91+ Base.: * (L1:: AbstractDiffEqLinearOperator , L2:: DiffEqOperatorComposition ) = DiffEqOperatorComposition ((L2. ops... , L1))
8592∘ (L1:: AbstractDiffEqLinearOperator , L2:: DiffEqOperatorComposition ) = DiffEqOperatorComposition ((L2. ops... , L1))
86- * (L1:: DiffEqOperatorComposition , L2:: DiffEqOperatorComposition ) = DiffEqOperatorComposition ((L2. ops... , L1. ops... ))
93+ Base.: * (L1:: DiffEqOperatorComposition , L2:: DiffEqOperatorComposition ) = DiffEqOperatorComposition ((L2. ops... , L1. ops... ))
8794∘ (L1:: DiffEqOperatorComposition , L2:: DiffEqOperatorComposition ) = DiffEqOperatorComposition ((L2. ops... , L1. ops... ))
8895getops (L:: DiffEqOperatorComposition ) = L. ops
8996Matrix (L:: DiffEqOperatorComposition ) = prod (Matrix, reverse (L. ops))
@@ -93,8 +100,8 @@ convert(::Type{AbstractMatrix}, L::DiffEqOperatorComposition) =
93100size (L:: DiffEqOperatorComposition ) = (size (L. ops[end ], 1 ), size (L. ops[1 ], 2 ))
94101size (L:: DiffEqOperatorComposition , m:: Integer ) = size (L)[m]
95102opnorm (L:: DiffEqOperatorComposition ) = prod (opnorm, L. ops)
96- * (L:: DiffEqOperatorComposition , x:: AbstractArray ) = foldl ((acc, op) -> op* acc, L. ops; init= x)
97- * (x:: AbstractArray , L:: DiffEqOperatorComposition ) = foldl ((acc, op) -> acc* op, reverse (L. ops); init= x)
103+ Base.: * (L:: DiffEqOperatorComposition , x:: AbstractArray ) = foldl ((acc, op) -> op* acc, L. ops; init= x)
104+ Base.: * (x:: AbstractArray , L:: DiffEqOperatorComposition ) = foldl ((acc, op) -> acc* op, reverse (L. ops); init= x)
98105/ (L:: DiffEqOperatorComposition , x:: AbstractArray ) = foldl ((acc, op) -> op/ acc, L. ops; init= x)
99106/ (x:: AbstractArray , L:: DiffEqOperatorComposition ) = foldl ((acc, op) -> acc/ op, L. ops; init= x)
100107\ (L:: DiffEqOperatorComposition , x:: AbstractArray ) = foldl ((acc, op) -> op\ acc, reverse (L. ops); init= x)
0 commit comments