diff --git a/Project.toml b/Project.toml index e55a43f..1e463f6 100644 --- a/Project.toml +++ b/Project.toml @@ -4,20 +4,22 @@ authors = ["Ritter.Marc , Hiroshi Shinaoka < version = "0.7.0" [deps] +BitIntegers = "c3b6d118-76ef-56ca-8cc7-ebb389d030a1" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" QuanticsGrids = "634c7f73-3e90-4749-a1bd-001b8efc642d" TensorCrossInterpolation = "b261b2ec-6378-4871-b32e-9173bb050604" [compat] +BitIntegers = "0.3.5" QuanticsGrids = "0.3" -TensorCrossInterpolation = "0.9" +TensorCrossInterpolation = "0.9.16" julia = "1.6" [extras] Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" +Glob = "c27321d9-0574-5035-807b-f59d2c89b15c" JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" -Glob = "c27321d9-0574-5035-807b-f59d2c89b15c" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] diff --git a/src/QuanticsTCI.jl b/src/QuanticsTCI.jl index 0edc347..7fa09a2 100644 --- a/src/QuanticsTCI.jl +++ b/src/QuanticsTCI.jl @@ -10,6 +10,11 @@ import Base: sum export quanticscrossinterpolate, evaluate, sum, integral export cachedata, quanticsfouriermpo +import BitIntegers +import BitIntegers: UInt256, UInt512, UInt1024 + +BitIntegers.@define_integers 2048 MyInt2048 MyUInt2048 + include("tciinterface.jl") include("fouriertransform.jl") diff --git a/src/tciinterface.jl b/src/tciinterface.jl index f029b0b..edb7dec 100644 --- a/src/tciinterface.jl +++ b/src/tciinterface.jl @@ -87,7 +87,22 @@ function quanticscrossinterpolate( ? q -> f(only(QG.quantics_to_origcoord(grid, q))) : q -> f(QG.quantics_to_origcoord(grid, q)...)) - qf = TCI.CachedFunction{ValueType}(qf_, qlocaldimensions) + maxlinearindex = prod(BigInt.(qlocaldimensions)) + if maxlinearindex < typemax(UInt256) + keytype = UInt256 + elseif maxlinearindex < typemax(UInt512) + keytype = UInt512 + elseif maxlinearindex < typemax(UInt1024) + keytype = UInt1024 + elseif maxlinearindex < typemax(MyUInt2048) + keytype = MyUInt2048 + else + keytype = BigInt + end + if keytype === BigInt + @warn "Using BigInt as key type. This will lead to significant memory usage and performance degradation." + end + qf = TCI.CachedFunction{ValueType, keytype}(qf_, qlocaldimensions) qinitialpivots = (initialpivots === nothing ? [ones(Int, length(qlocaldimensions))]