Skip to content

Commit 0fa85ab

Browse files
committed
work on simplify Mul
1 parent 451a2b9 commit 0fa85ab

File tree

3 files changed

+33
-14
lines changed

3 files changed

+33
-14
lines changed

src/QuasiArrays/adjtrans.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,13 @@ pinv(v::TransposeAbsVec, tol::Real = 0) = pinv(conj(v.parent)).parent
208208
/(u::TransposeAbsVec, A::AbstractQuasiMatrix) = transpose(transpose(A) \ u.parent)
209209
/(u::AdjointAbsVec, A::Transpose{<:Any,<:AbstractQuasiMatrix}) = adjoint(conj(A.parent) \ u.parent) # technically should be adjoint(copy(adjoint(copy(A))) \ u.parent)
210210
/(u::TransposeAbsVec, A::Adjoint{<:Any,<:AbstractQuasiMatrix}) = transpose(conj(A.parent) \ u.parent) # technically should be transpose(copy(transpose(copy(A))) \ u.parent)
211+
212+
213+
function materialize(M::Mul2{<:Any,<:Any,<:Adjoint,<:Adjoint})
214+
Ac,Bc = M.factors
215+
materialize(Mul(parent(Bc),parent(Ac)))'
216+
end
217+
218+
function adjoint(M::Mul)
219+
Mul(reverse(adjoint.(M.factors))...)
220+
end

src/QuasiArrays/matmul.jl

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,6 @@ QuasiMatMulQuasiMat{styleA, styleB, T, V} = QuasiArrayMulQuasiArray{styleA, styl
2727
*(A::AbstractQuasiArray, B::AbstractArray) = materialize(Mul(A,B))
2828
*(A::AbstractArray, B::AbstractQuasiArray) = materialize(Mul(A,B))
2929
inv(A::AbstractQuasiArray) = materialize(Inv(A))
30-
*(A::Inv{<:Any,<:AbstractQuasiArray}, B::AbstractQuasiArray) = materialize(Mul(A,B))
3130

32-
33-
_Mul(A::Mul, B::Mul) = Mul(A.factors..., B.factors...)
34-
_Mul(A::Mul, B) = Mul(A.factors..., B)
35-
_Mul(A, B::Mul) = Mul(A, B.factors...)
36-
_Mul(A, B) = Mul(A, B)
37-
_lsimplify2(A, B...) = _Mul(A, _lsimplify(B...))
38-
_lsimplify2(A::Mul, B...) = _lsimplify2(A.factors..., B...)
39-
_lsimplify(A) = materialize(A)
40-
_lsimplify(A, B) = materialize(Mul(A,B))
41-
_lsimplify(A, B, C, D...) = _lsimplify2(materialize(Mul(A,B)), C, D...)
42-
lsimplify(M::Mul) = _lsimplify(M.factors...)
43-
44-
*(A::AbstractQuasiArray, B::Mul) = lsimplify(_Mul(A, B))
31+
*(A::AbstractQuasiArray, B::Mul) = materialize(Mul(A, B.factors...))
32+
*(A::Mul, B::AbstractQuasiArray) = materialize(Mul(A.factors..., B))

test/runtests.jl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,24 @@ end
7979
@test fp[1.1] 1
8080
@test fp[2.2] 2
8181
end
82+
83+
84+
85+
86+
L = LinearSpline([1,2,3])
87+
f = L*[1,2,4]
88+
D = Derivative(axes(L,1))
89+
90+
H = HeavisideSpline([1,2,3])
91+
92+
D*L
93+
M = (L'D')*(D*L)
94+
95+
96+
*(M.factors...)
97+
98+
99+
100+
LazyArrays.MemoryLayout(Diagonal(randn(5)))
101+
102+
M.factors[2] * M.factors[3]

0 commit comments

Comments
 (0)