4545# matrix factorizations assume copy
4646# maybe: copy=false kwarg
4747
48- function matricize (a:: AbstractArray , biperm:: AbstractBlockPermutation{2} )
48+ function matricize (a:: AbstractArray , biperm:: AbstractBlockPermutation{2} ; copy = false )
4949 ndims (a) == length (biperm) || throw (ArgumentError (" Invalid bipermutation" ))
50- return matricize (FusionStyle (a), a, biperm)
50+ return matricize (FusionStyle (a), a, biperm; copy )
5151end
5252
5353function matricize (
54- style:: FusionStyle , a:: AbstractArray , biperm:: AbstractBlockPermutation{2}
54+ style:: FusionStyle , a:: AbstractArray , biperm:: AbstractBlockPermutation{2} ; copy = false
5555)
56+ if istrivialperm (Tuple (biperm)) && ! copy
57+ return matricize (style, a, trivialperm (biperm))
58+ end
5659 a_perm = permuteblockeddims (a, biperm)
5760 return matricize (style, a_perm, trivialperm (biperm))
5861end
5962
6063function matricize (
61- style:: FusionStyle , a:: AbstractArray , biperm:: BlockedTrivialPermutation{2}
64+ style:: FusionStyle , a:: AbstractArray , biperm:: BlockedTrivialPermutation{2} ; copy = false
6265)
6366 return throw (MethodError (matricize, Tuple{typeof (style),typeof (a),typeof (biperm)}))
6467end
@@ -69,8 +72,8 @@ function matricize(::ReshapeFusion, a::AbstractArray, biperm::BlockedTrivialPerm
6972 return reshape (a, new_axes... )
7073end
7174
72- function matricize (a:: AbstractArray , permblock1:: Tuple , permblock2:: Tuple )
73- return matricize (a, blockedpermvcat (permblock1, permblock2; length= Val (ndims (a))))
75+ function matricize (a:: AbstractArray , permblock1:: Tuple , permblock2:: Tuple ; copy = false )
76+ return matricize (a, blockedpermvcat (permblock1, permblock2; length= Val (ndims (a))); copy )
7477end
7578
7679# ==================================== unmatricize =======================================
0 commit comments