@@ -74,22 +74,16 @@ for f in [
7474 MAK.$ f! (t, out, MAK. select_algorithm (MAK.$ f!, t, nothing ; alg. kwargs... ))
7575end
7676
77- # specializations until fixes in base package
78- function MAK. is_left_isometric (A:: BlockMatrix ; atol:: Real = 0 , rtol:: Real = MAK. defaulttol (A), norm = LinearAlgebra. norm)
79- P = A' * A
80- nP = norm (P) # isapprox would use `rtol * max(norm(P), norm(I))`
81- for I in MAK. diagind (P)
82- P[I] -= 1
83- end
84- return norm (P) <= max (atol, rtol * nP) # assume that the norm of I is `sqrt(n)`
85- end
86- function MAK. is_right_isometric (A:: BlockMatrix ; atol:: Real = 0 , rtol:: Real = MAK. defaulttol (A), norm = LinearAlgebra. norm)
87- P = A * A'
88- nP = norm (P) # isapprox would use `rtol * max(norm(P), norm(I))`
89- for I in MAK. diagind (P)
90- P[I] -= 1
91- end
92- return norm (P) <= max (atol, rtol * nP) # assume that the norm of I is `sqrt(n)`
77+ # specializations until fixes in base packages:
78+ # - `similar(::MulAdd{<:AbstractBlockLayout,...})` hardcodes `Array` blocks, so `A' * A` on
79+ # non-CPU blocks mixes host and device storage (JuliaArrays/BlockArrays.jl#215).
80+ # - `MAK.diagview` silently does not alias into a `BlockMatrix`, so subtracting the identity there is a no-op.
81+ # Densifying sidesteps both, and preserves the storage type of the blocks.
82+ function MAK. is_left_isometric (A:: BlockMatrix ; kwargs... )
83+ return MAK. is_left_isometric (copy_dense! (similar_dense (A), A); kwargs... )
84+ end
85+ function MAK. is_right_isometric (A:: BlockMatrix ; kwargs... )
86+ return MAK. is_right_isometric (copy_dense! (similar_dense (A), A); kwargs... )
9387end
9488
9589# Make sure sparse blocktensormaps have dense outputs
0 commit comments