Skip to content

Commit 3a8f8bc

Browse files
kshyattlkdvos
andcommitted
Update src/linalg/factorizations.jl
Co-authored-by: Lukas Devos <ldevos98@gmail.com>
1 parent 9ba6e72 commit 3a8f8bc

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

‎src/linalg/factorizations.jl‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
11
using MatrixAlgebraKit
2-
using MatrixAlgebraKit: AbstractAlgorithm, YALAPACK.BlasMat, Algorithm, diagview
2+
using MatrixAlgebraKit: AbstractAlgorithm, YALAPACK.BlasMat, Algorithm, diagview, zero!, one!
33
import MatrixAlgebraKit as MAK
44

55
# Type piracy for defining the MAK rules on BlockArrays!
66
# -----------------------------------------------------
77

88
const BlockBlasMat{T <: MAK.BlasFloat} = BlockMatrix{T}
99

10+
function MatrixAlgebraKit.zero!(A::BlockBlasMat)
11+
for bi in 1:blocksize(A, 1), bj in 1:blocksize(A, 2)
12+
zero!(A[Block(bi), Block(bj)])
13+
end
14+
return A
15+
end
16+
1017
function MatrixAlgebraKit.one!(A::BlockBlasMat)
11-
_one, _zero = one(eltype(A)), zero(eltype(A))
12-
A .= _zero
13-
n_blocks = blocksize(A)[1]
14-
# awful workaround to BlockArrays indexing interface
15-
for bi in 1:n_blocks
16-
A[Block(bi), Block(bi)] .= diagm(fill(_one, blocksizes(A)[bi, bi][1]))
18+
A .= zero(eltype(A))
19+
for bi in 1:blocksize(A, 1), bj in 1:blocksize(A, 2)
20+
if bi == bj
21+
one!(A[Block(bi), Block(bj)])
22+
#else
23+
# zero!(A[Block(bi), Block(bj)])
24+
end
1725
end
1826
return A
1927
end

0 commit comments

Comments
 (0)