|
45 | 45 | @inline eltype(M::Rdiv) = promote_type(eltype(M.A), Base.promote_op(inv, eltype(M.B))) |
46 | 46 |
|
47 | 47 | # Lazy getindex |
48 | | -getindex(L::Ldiv{<:Any,<:Any,<:AbstractMatrix,<:AbstractVector}, k::Integer) = copyto!(similar(L), L)[k] |
49 | | -getindex(L::Ldiv{<:Any,<:Any,<:AbstractMatrix,<:AbstractMatrix}, k::Integer,j::Integer) = Ldiv(L.A, L.B[:,j])[k] |
| 48 | + |
| 49 | +getindex(L::Ldiv, k...) = _getindex(indextype(L), L, k) |
| 50 | +concretize(L::AbstractArray) = convert(Array,L) |
| 51 | +concretize(L::Ldiv) = ldiv(concretize(L.A), concretize(L.B)) |
| 52 | +_getindex(::Type{Tuple{I}}, L::Ldiv, (k,)::Tuple{I}) where I = concretize(L)[k] |
| 53 | +_getindex(::Type{Tuple{I,J}}, L::Ldiv, (k,j)::Tuple{I,J}) where {I,J} = Ldiv(L.A, L.B[:,j])[k] |
50 | 54 |
|
51 | 55 | check_ldiv_axes(A, B) = |
52 | 56 | axes(A,1) == axes(B,1) || throw(DimensionMismatch("First axis of A, $(axes(A,1)), and first axis of B, $(axes(B,1)) must match")) |
@@ -105,10 +109,25 @@ const BlasMatLdivMat{styleA, styleB, T<:BlasFloat} = MatLdivMat{styleA, styleB, |
105 | 109 | const MatRdivMat{styleA, styleB, T, V} = Rdiv{styleA, styleB, <:AbstractMatrix{T}, <:AbstractMatrix{V}} |
106 | 110 | const BlasMatRdivMat{styleA, styleB, T<:BlasFloat} = MatRdivMat{styleA, styleB, T, T} |
107 | 111 |
|
108 | | -# function materialize!(L::BlasMatLdivVec{<:AbstractColumnMajor,<:AbstractColumnMajor}) |
109 | | - |
110 | | -# end |
| 112 | +materialize!(M::Ldiv{ScalarLayout}) = Base.invoke(LinearAlgebra.ldiv!, Tuple{Number,AbstractArray}, M.A, M.B) |
| 113 | +materialize!(M::Rdiv{<:Any,ScalarLayout}) = Base.invoke(LinearAlgebra.rdiv!, Tuple{AbstractArray,Number}, M.A, M.B) |
111 | 114 |
|
| 115 | +function materialize!(M::Ldiv{ScalarLayout,<:SymmetricLayout}) |
| 116 | + ldiv!(M.A, symmetricdata(M.B)) |
| 117 | + M.B |
| 118 | +end |
| 119 | +function materialize!(M::Ldiv{ScalarLayout,<:HermitianLayout}) |
| 120 | + ldiv!(M.A, hermitiandata(M.B)) |
| 121 | + M.B |
| 122 | +end |
| 123 | +function materialize!(M::Rdiv{<:SymmetricLayout,ScalarLayout}) |
| 124 | + rdiv!(symmetricdata(M.A), M.B) |
| 125 | + M.A |
| 126 | +end |
| 127 | +function materialize!(M::Rdiv{<:HermitianLayout,ScalarLayout}) |
| 128 | + rdiv!(hermitiandata(M.A), M.B) |
| 129 | + M.A |
| 130 | +end |
112 | 131 |
|
113 | 132 | macro _layoutldiv(Typ) |
114 | 133 | ret = quote |
|
0 commit comments