Skip to content

Commit 94c5014

Browse files
committed
Add MatrixAlgebraKit factorizations
1 parent a04776b commit 94c5014

File tree

7 files changed

+319
-258
lines changed

7 files changed

+319
-258
lines changed

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527"
1515
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1616
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
1717
MapBroadcast = "ebd9b9da-f48d-417c-9660-449667d60261"
18+
MatrixAlgebraKit = "6c742aac-3347-4629-af66-fc926824e5e4"
1819
SparseArraysBase = "0d5efcca-f356-4864-8770-e1ed8d78f208"
1920
SplitApplyCombine = "03a91e81-4c3e-53e1-a0a4-9c0c8f19dd66"
2021
TypeParameterAccessors = "7e5a90cf-f82e-492e-a09b-e3e26432c138"
@@ -38,6 +39,7 @@ GPUArraysCore = "0.1.0, 0.2"
3839
LinearAlgebra = "1.10"
3940
MacroTools = "0.5.13"
4041
MapBroadcast = "0.1.5"
42+
MatrixAlgebraKit = "0.1.2"
4143
SparseArraysBase = "0.5"
4244
SplitApplyCombine = "1.2.3"
4345
TensorAlgebra = "0.3.2"

src/BlockSparseArrays.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ export BlockSparseArray,
88
eachstoredblock,
99
sparsemortar
1010

11-
# factorizations
12-
include("factorizations/svd.jl")
1311

1412
# possible upstream contributions
1513
include("BlockArraysExtensions/blockedunitrange.jl")
@@ -45,4 +43,7 @@ include("blocksparsearray/blockdiagonalarray.jl")
4543

4644
include("BlockArraysSparseArraysBaseExt/BlockArraysSparseArraysBaseExt.jl")
4745

46+
# factorizations
47+
include("factorizations/svd.jl")
48+
4849
end

src/blocksparsearrayinterface/getunstoredblock.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,18 @@ end
2323
) where {N}
2424
return f(a, Tuple(I)...)
2525
end
26+
27+
# TODO: this is a hack and is also type-unstable
28+
function (f::GetUnstoredBlock)(
29+
a::AbstractMatrix{LinearAlgebra.Diagonal{T,V}}, I::Vararg{Int,2}
30+
) where {T,V}
31+
b_size = ntuple(ndims(a)) do d
32+
return length(f.axes[d][Block(I[d])])
33+
end
34+
if I[1] == I[2]
35+
diag = similar(V, b_size[1])
36+
return LinearAlgebra.Diagonal{T,V}(diag)
37+
else
38+
return zeros(T, b_size...)
39+
end
40+
end

0 commit comments

Comments
 (0)