Skip to content

Commit 4b48f63

Browse files
committed
Implement fill
1 parent fe59c72 commit 4b48f63

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/kroneckerarray.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,29 @@ function Base.reshape(
415415
return reshape(a, kroneckerfactors.(ax, 1)) reshape(b, kroneckerfactors.(ax, 2))
416416
end
417417

418+
function Base.fill!(ab::AbstractKroneckerArray, v)
419+
a, b = kroneckerfactors(ab)
420+
fill!(a, v)
421+
fill!(b, v)
422+
return ab
423+
end
424+
function Base.fill!(ab::AbstractKroneckerMatrix, v)
425+
a, b = kroneckerfactors(ab)
426+
(!isactive(a) && isone(a)) && (fill!(b, v); return ab)
427+
(!isactive(b) && isone(b)) && (fill!(a, v); return ab)
428+
fill!(a, v)
429+
fill!(b, v)
430+
return ab
431+
end
432+
function Base.fill!(ab::AbstractKroneckerVector, v)
433+
a, b = kroneckerfactors(ab)
434+
(!isactive(a) && all(isone, a)) && (fill!(b, v); return ab)
435+
(!isactive(b) && all(isone, b)) && (fill!(a, v); return ab)
436+
fill!(a, v)
437+
fill!(b, v)
438+
return ab
439+
end
440+
418441
using Base.Broadcast: Broadcast, AbstractArrayStyle, BroadcastStyle, Broadcasted
419442

420443
struct KroneckerStyle{N, A, B} <: BC.AbstractArrayStyle{N} end

0 commit comments

Comments
 (0)