File tree Expand file tree Collapse file tree 4 files changed +31
-0
lines changed
ext/NDTensorsMappedArraysExt Expand file tree Collapse file tree 4 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ ITensors = "9136182c-28ba-11e9-034c-db9fb085ebd5"
1010JLD2 = " 033835bb-8acc-5ee8-8aae-3f567f8a3819"
1111KrylovKit = " 0b1a1467-8014-51b9-945f-bf0ae24f4b77"
1212LinearAlgebra = " 37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
13+ MappedArrays = " dbb5928d-eab1-5f90-85c2-b9b0edb7c900"
1314NDTensors = " 23ae76d9-e61a-49c4-8f12-3f1a16adf9cf"
1415OptimKit = " 77e91f04-9b3b-57a6-a776-40b61faaebe0"
1516PackageCompiler = " 9b87118b-4619-50d2-8e1e-99f35a4d4d9d"
Original file line number Diff line number Diff line change 1+ [deps ]
2+ ITensors = " 9136182c-28ba-11e9-034c-db9fb085ebd5"
3+ LinearAlgebra = " 37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
4+ MappedArrays = " dbb5928d-eab1-5f90-85c2-b9b0edb7c900"
5+ Test = " 8dfed614-e22c-5e08-85e1-65c5234f0b40"
Original file line number Diff line number Diff line change 1+ @eval module $ (gensym ())
2+ using ITensors: Index, itensor
3+ using LinearAlgebra: qr, svd
4+ using MappedArrays: mappedarray
5+ using Test: @test , @testset
6+ f (i:: Int... ) = float (sum (iⱼ -> iⱼ^ 2 , i))
7+ f (i:: CartesianIndex ) = f (Tuple (i)... )
8+ @testset " NDTensorsMappedArraysExt" begin
9+ a = mappedarray (f, CartesianIndices ((2 , 2 )))
10+ b = copy (a)
11+ i, j = Index .((2 , 2 ))
12+ ta = itensor (a, i, j)
13+ tb = itensor (b, i, j)
14+ @test ta ≈ tb
15+ @test ta[i => 1 , j => 2 ] ≈ tb[i => 1 , j => 2 ]
16+ @test 2 * ta ≈ 2 * tb
17+ @test ta + ta ≈ tb + tb
18+ @test ta * ta ≈ tb * tb
19+ ua, sa, va = svd (ta, i)
20+ @test ua * sa * va ≈ ta
21+ qa, ra = qr (ta, i)
22+ @test qa * ra ≈ ta
23+ end
24+ end
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ ITensors.disable_threaded_blocksparse()
2222 " ext/ITensorsChainRulesCoreExt" ,
2323 " ext/ITensorsPackageCompilerExt" ,
2424 " ext/ITensorsVectorInterfaceExt" ,
25+ " ext/NDTensorsMappedArraysExt" ,
2526 ]
2627 @time for dir in dirs
2728 println (" \n Test $(@__DIR__ ) /$(dir) " )
You can’t perform that action at this time.
0 commit comments