Skip to content

Commit

Permalink
test normalize_eachmatrix
Browse files Browse the repository at this point in the history
  • Loading branch information
stecrotti committed May 27, 2024
1 parent 18ffe03 commit eff4741
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/periodic_tensor_train.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,21 @@
end
end


@testset "Normalize eachmatrix" begin
rng = MersenneTwister(0)
qs = (2, 4)
L = 4
A = rand_periodic_tt( [1; rand(rng, 10:15, L-1); 1], qs... )
A.z = -100 * rand(rng)
x, p = sample(rng, A)
e = evaluate(A, x)
z = normalization(A)
normalize_eachmatrix!(A)
@test evaluate(A, x) e
@test float(normalization(A)) float(z)
end

@testset "Flat" begin
L = 5
bondsizes = rand(1:4, L)
Expand Down
14 changes: 14 additions & 0 deletions test/tensor_train.jl
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,20 @@ end
end
end

@testset "Normalize eachmatrix" begin
rng = MersenneTwister(0)
qs = (2, 4)
L = 4
A = rand_tt( [1; rand(rng, 10:15, L-1); 1], qs... )
A.z = -100 * rand(rng)
x, p = sample(rng, A)
e = evaluate(A, x)
z = normalization(A)
normalize_eachmatrix!(A)
@test evaluate(A, x) e
@test float(normalization(A)) float(z)
end

@testset "Sum of TTs" begin
for N in 1:3
for q in 1:3
Expand Down

0 comments on commit eff4741

Please sign in to comment.