Skip to content

Commit 7168ba4

Browse files
committed
overload base.kron
1 parent b177aec commit 7168ba4

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/tensor.jl

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,18 @@ where `M = size(B, 2)`, and `N = size(A, 2)`
6969
"""
7070
(ops::Union{AbstractMatrix,AbstractSciMLOperator}...) = TensorProductOperator(ops...)
7171

72-
# TODO - overload Base.kron for tensor product operators
73-
#Base.kron(ops::Union{AbstractMatrix,AbstractSciMLOperator}...) = TensorProductOperator(ops...)
72+
"""
73+
$SIGNATURES
74+
75+
Construct a lazy representation of the Kronecker product `A ⊗ B`. One of the
76+
two factors can be an `AbstractMatrix`, which is then promoted to a
77+
`MatrixOperator` automatically. To avoid fallback to the generic
78+
[`Base.kron`](@ref), at least one of `A` and `B` must be an
79+
`AbstractSciMLOperator`.
80+
"""
81+
Base.kron(A::AbstractSciMLOperator, B::AbstractSciMLOperator) = TensorProductOperator(A, B)
82+
Base.kron(A::AbstractMatrix, B::AbstractSciMLOperator) = TensorProductOperator(A, B)
83+
Base.kron(A::AbstractSciMLOperator, B::AbstractMatrix) = TensorProductOperator(A, B)
7484

7585
# convert to matrix
7686
Base.kron(ops::AbstractSciMLOperator...) = kron(convert.(AbstractMatrix, ops)...)

0 commit comments

Comments
 (0)