Skip to content
This repository has been archived by the owner on Dec 18, 2021. It is now read-only.

Commit

Permalink
fix 1.6 warning on kron! (#47)
Browse files Browse the repository at this point in the history
* fix 1.6 warning

* use static
  • Loading branch information
Roger-luo authored Nov 9, 2021
1 parent 3f3cb5b commit eaa9509
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions src/utils/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export batch_normalize,
hilbertkron,
batched_kron!,
batched_kron,
kron!,
# norms
trnorm,
nucnorm,
Expand Down Expand Up @@ -135,22 +134,25 @@ function batched_kron!(
return C
end

# NOTE: JuliaLang/julia/pull/31069 includes this function
function kron!(
C::AbstractMatrix{T},
A::AbstractMatrix{T1},
B::AbstractMatrix{T2},
) where {T,T1,T2}
@assert !Base.has_offset_axes(A, B)
m = 1
@inbounds for j = 1:size(A, 2), l = 1:size(B, 2), i = 1:size(A, 1)
aij = A[i, j]
for k = 1:size(B, 1)
C[m] = aij * B[k, l]
m += 1
@static if !@isdefined(kron!)
export kron!
# NOTE: JuliaLang/julia/pull/31069 includes this function
function kron!(
C::AbstractMatrix{T},
A::AbstractMatrix{T1},
B::AbstractMatrix{T2},
) where {T,T1,T2}
@assert !Base.has_offset_axes(A, B)
m = 1
@inbounds for j = 1:size(A, 2), l = 1:size(B, 2), i = 1:size(A, 1)
aij = A[i, j]
for k = 1:size(B, 1)
C[m] = aij * B[k, l]
m += 1
end
end
return C
end
return C
end


Expand Down

0 comments on commit eaa9509

Please sign in to comment.