Skip to content

Commit 6c92d7c

Browse files
authored
Add MatrixAlgebraKit svd (#111)
1 parent a04776b commit 6c92d7c

File tree

9 files changed

+323
-262
lines changed

9 files changed

+323
-262
lines changed

Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "BlockSparseArrays"
22
uuid = "2c9a651f-6452-4ace-a6ac-809f4280fbb4"
33
authors = ["ITensor developers <[email protected]> and contributors"]
4-
version = "0.4.6"
4+
version = "0.5.0"
55

66
[deps]
77
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
@@ -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"

docs/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
66

77
[compat]
88
BlockArrays = "1"
9-
BlockSparseArrays = "0.4"
9+
BlockSparseArrays = "0.5"
1010
Documenter = "1"
1111
Literate = "2"

examples/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
55

66
[compat]
77
BlockArrays = "1"
8-
BlockSparseArrays = "0.4"
8+
BlockSparseArrays = "0.5"
99
Test = "1"

src/BlockSparseArrays.jl

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

11-
# factorizations
12-
include("factorizations/svd.jl")
13-
1411
# possible upstream contributions
1512
include("BlockArraysExtensions/blockedunitrange.jl")
1613
include("BlockArraysExtensions/BlockArraysExtensions.jl")
@@ -45,4 +42,7 @@ include("blocksparsearray/blockdiagonalarray.jl")
4542

4643
include("BlockArraysSparseArraysBaseExt/BlockArraysSparseArraysBaseExt.jl")
4744

45+
# factorizations
46+
include("factorizations/svd.jl")
47+
4848
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 = zero!(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)