Skip to content

Commit

Permalink
kron for rectangular Eye
Browse files Browse the repository at this point in the history
  • Loading branch information
jishnub committed Jun 30, 2023
1 parent 8a13ebd commit 14a0423
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/FillArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ Base.replace_in_print_matrix(A::RectDiagonal, i::Integer, j::Integer, s::Abstrac


const RectOrDiagonal{T,V,Axes} = Union{RectDiagonal{T,V,Axes}, Diagonal{T,V}}
const RectDiagonalEye{T} = RectDiagonal{T,<:Ones{T,1}}
const SquareEye{T,Axes} = Diagonal{T,Ones{T,1,Tuple{Axes}}}
const Eye{T,Axes} = RectOrDiagonal{T,Ones{T,1,Tuple{Axes}}}

Expand Down
1 change: 1 addition & 0 deletions src/fillalgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -453,3 +453,4 @@ function kron(f::AbstractFillVecOrMat, g::AbstractFillVecOrMat)
sz = _kronsize(f, g)
_kron(f, g, sz)
end
kron(E1::RectDiagonalEye, E2::RectDiagonalEye) = kron(sparse(E1), sparse(E2))
9 changes: 8 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1519,7 +1519,14 @@ end
if VERSION >= v"1.9"
@test K isa typeof(E)
end
@test K == kron(collect(E), collect(E))
C = collect(E)
@test K == kron(C, C)

E = Eye(2,3)
K = kron(E, E)
C = collect(E)
@test K == kron(C, C)
@test issparse(kron(E,E))
end

@testset "dot products" begin
Expand Down

0 comments on commit 14a0423

Please sign in to comment.