Skip to content

Commit e392cc8

Browse files
committed
More factorizations
1 parent aa15737 commit e392cc8

File tree

5 files changed

+238
-355
lines changed

5 files changed

+238
-355
lines changed

src/fillarrays/kroneckerarray.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,23 @@ const SquareEyeSquareEye{T,A<:SquareEye{T},B<:SquareEye{T}} = KroneckerMatrix{T,
1111
# Like `adapt` but preserves `Eye`.
1212
_adapt(to, a::Eye) = a
1313

14+
# Like `similar` but preserves `Eye`.
15+
function _similar(a::AbstractArray, elt::Type, ax::Tuple)
16+
return similar(a, elt, ax)
17+
end
18+
function _similar(A::Type{<:AbstractArray}, ax::Tuple)
19+
return similar(A, ax)
20+
end
21+
function _similar(a::AbstractArray, ax::Tuple)
22+
return _similar(a, eltype(a), ax)
23+
end
24+
function _similar(a::AbstractArray, elt::Type)
25+
return _similar(a, elt, axes(a))
26+
end
27+
function _similar(a::AbstractArray)
28+
return _similar(a, eltype(a), axes(a))
29+
end
30+
1431
# Like `similar` but preserves `Eye`.
1532
function _similar(a::Eye, elt::Type, axs::NTuple{2,AbstractUnitRange})
1633
return Eye{elt}(axs)

src/fillarrays/linearalgebra.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ end
77

88
function _mul(a::Eye, b::Eye)
99
check_mul_axes(a, b)
10+
(size(a, 1) > size(a, 2)) &&
11+
(size(b, 1) < size(b, 2)) &&
12+
error("This multiplication leads to a projector.")
1013
T = promote_type(eltype(a), eltype(b))
1114
return Eye{T}((axes(a, 1), axes(b, 2)))
1215
end

0 commit comments

Comments
 (0)