Skip to content

Commit 4dfcbf5

Browse files
authored
Merge pull request #16 from tensor4all/compathelper/new_version/2025-09-10-00-57-22-980-01784345259
CompatHelper: bump compat for QuanticsGrids to 0.6, (keep existing compat)
2 parents d5df837 + b48bd22 commit 4dfcbf5

File tree

3 files changed

+32
-11
lines changed

3 files changed

+32
-11
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ TensorCrossInterpolation = "b261b2ec-6378-4871-b32e-9173bb050604"
1111

1212
[compat]
1313
BitIntegers = "0.3.5"
14-
QuanticsGrids = "0.3"
14+
QuanticsGrids = "0.3, 0.6"
1515
TensorCrossInterpolation = "0.9.16"
1616
julia = "1.6"
1717

src/tciinterface.jl

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,7 @@ function quanticscrossinterpolate(
7575
nrandominitpivot=5,
7676
kwargs...
7777
) where {ValueType,n}
78-
R = grid.R
79-
80-
qlocaldimensions = if grid.unfoldingscheme === :interleaved
81-
fill(2, n * R)
82-
else
83-
fill(2^n, R)
84-
end
78+
qlocaldimensions = QG.localdimensions(grid)
8579

8680
qf_ = (n == 1
8781
? q -> f(only(QG.quantics_to_origcoord(grid, q)))

test/test_fouriertransform.jl

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,52 @@ import TensorCrossInterpolation as TCI
33
import QuanticsGrids as QG
44
import Random
55

6+
"""
7+
function index_to_quantics!(digitlist, index::Integer; base::Integer=2)
8+
9+
* `digitlist` base-b representation (1d vector)
10+
* `base` base for quantics (default: 2)
11+
"""
12+
function index_to_quantics!(digitlist, index::Integer; base::Integer=2)
13+
numdigits = length(digitlist)
14+
for i = 1:numdigits
15+
digitlist[i] = mod(index - 1, base^(numdigits - i + 1)) ÷ base^(numdigits - i) + 1
16+
end
17+
return digitlist
18+
end
19+
20+
"""
21+
index_to_quantics(index::Integer; numdigits=8, base::Integer=2)
22+
23+
Does the same as [`index_to_quantics!`](@ref) but returns a new vector.
24+
"""
25+
function index_to_quantics(index::Integer; numdigits=8, base::Integer=2)
26+
digitlist = Vector{Int}(undef, numdigits)
27+
return index_to_quantics!(digitlist, index; base=base)
28+
end
29+
30+
#@testset "Quantics Fourier Transform, R=$R" for R in [4, 16, 62]
631
@testset "Quantics Fourier Transform, R=$R" for R in [4, 16, 62]
732
Random.seed!(23593243)
833

34+
grid = QG.DiscretizedGrid{1}(R, 0, 1)
35+
936
r = 12
1037
coeffs = randn(ComplexF64, r)
1138
fm(x) = sum(coeffs .* cispi.(2 * (0:r-1) * x))
12-
fq(q) = fm((QG.quantics_to_index_fused(q)[1] - 1) / 2^big(R))
39+
fq(q) = fm(QG.quantics_to_origcoord(grid, q)[1])
1340

1441
qtci, = TCI.crossinterpolate2(ComplexF64, fq, fill(2, R); tolerance=1e-14)
1542
fouriertt = QTCI.quanticsfouriermpo(R; normalize=false) / 2^big(R)
1643
qtcif = TCI.contract(fouriertt, qtci)
1744

1845
for i in 1:min(r, 2^big(R))
19-
q = QG.index_to_quantics(i, numdigits=R)
46+
q = index_to_quantics(i, numdigits=R)
2047
@test qtcif(reverse(q)) coeffs[i]
2148
end
2249

2350
for i in Int.(round.(range(r+2, 2^big(R); length=100)))
24-
q = QG.index_to_quantics(i, numdigits=R)
51+
q = index_to_quantics(i, numdigits=R)
2552
@test abs(qtcif(reverse(q))) < 1e-12
2653
end
2754
end

0 commit comments

Comments
 (0)