diff --git a/test/Project.toml b/test/Project.toml index 509e3a49f0..9974c37a38 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -10,6 +10,7 @@ ITensors = "9136182c-28ba-11e9-034c-db9fb085ebd5" JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819" KrylovKit = "0b1a1467-8014-51b9-945f-bf0ae24f4b77" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +MappedArrays = "dbb5928d-eab1-5f90-85c2-b9b0edb7c900" NDTensors = "23ae76d9-e61a-49c4-8f12-3f1a16adf9cf" OptimKit = "77e91f04-9b3b-57a6-a776-40b61faaebe0" PackageCompiler = "9b87118b-4619-50d2-8e1e-99f35a4d4d9d" diff --git a/test/ext/NDTensorsMappedArraysExt/Project.toml b/test/ext/NDTensorsMappedArraysExt/Project.toml new file mode 100644 index 0000000000..2236ea0414 --- /dev/null +++ b/test/ext/NDTensorsMappedArraysExt/Project.toml @@ -0,0 +1,5 @@ +[deps] +ITensors = "9136182c-28ba-11e9-034c-db9fb085ebd5" +LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +MappedArrays = "dbb5928d-eab1-5f90-85c2-b9b0edb7c900" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/test/ext/NDTensorsMappedArraysExt/runtests.jl b/test/ext/NDTensorsMappedArraysExt/runtests.jl new file mode 100644 index 0000000000..6c38ed96fa --- /dev/null +++ b/test/ext/NDTensorsMappedArraysExt/runtests.jl @@ -0,0 +1,24 @@ +@eval module $(gensym()) +using ITensors: Index, itensor +using LinearAlgebra: qr, svd +using MappedArrays: mappedarray +using Test: @test, @testset +f(i::Int...) = float(sum(iⱼ -> iⱼ^2, i)) +f(i::CartesianIndex) = f(Tuple(i)...) +@testset "NDTensorsMappedArraysExt" begin + a = mappedarray(f, CartesianIndices((2, 2))) + b = copy(a) + i, j = Index.((2, 2)) + ta = itensor(a, i, j) + tb = itensor(b, i, j) + @test ta ≈ tb + @test ta[i => 1, j => 2] ≈ tb[i => 1, j => 2] + @test 2 * ta ≈ 2 * tb + @test ta + ta ≈ tb + tb + @test ta * ta ≈ tb * tb + ua, sa, va = svd(ta, i) + @test ua * sa * va ≈ ta + qa, ra = qr(ta, i) + @test qa * ra ≈ ta +end +end diff --git a/test/runtests.jl b/test/runtests.jl index 88af73a005..a0c92a13a1 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -22,6 +22,7 @@ ITensors.disable_threaded_blocksparse() "ext/ITensorsChainRulesCoreExt", "ext/ITensorsPackageCompilerExt", "ext/ITensorsVectorInterfaceExt", + "ext/NDTensorsMappedArraysExt", ] @time for dir in dirs println("\nTest $(@__DIR__)/$(dir)")