diff --git a/src/nonlocal.jl b/src/nonlocal.jl index a4baa19..843bd8e 100644 --- a/src/nonlocal.jl +++ b/src/nonlocal.jl @@ -70,7 +70,7 @@ end function _local_bound_correlation_core(chunk, ins::NTuple{N,Int}, squareG::Array{T,2}; marg::Bool = true) where {T,N} ia = ins[1] score = typemin(T) - ind = Vector{Int8}(undef, sum(ins[2:N]) - N + 1) + ind = Vector{Int8}(undef, sum(ins[2:N]) - marg*(N-1)) digits!(ind, chunk[1] - 1; base = 2) sumsizes = [1; cumsum(collect(ins[2:N]) .- marg) .+ 1] prodsizes = ones(Int, N - 1) diff --git a/test/nonlocal.jl b/test/nonlocal.jl index 8f515b8..3165369 100644 --- a/test/nonlocal.jl +++ b/test/nonlocal.jl @@ -21,6 +21,9 @@ @test local_bound(fp1) ≈ local_bound(fp2) @test local_bound(fc1) ≈ local_bound(fc2) @test local_bound(fc1) ≈ local_bound(fp1) + bigfc1 = zeros(T, 5, 6) + @views bigfc1[2:5, 2:6] .= fc1 + @test local_bound(fc1; marg = false) ≈ local_bound(bigfc1; marg = true) fp1 = rand(T, 2, 2, 2, 3, 4, 5) fp2 = permutedims(fp1, (3, 2, 1, 6, 5, 4)) fc1 = tensor_correlation(fp1) @@ -28,6 +31,9 @@ @test local_bound(fp1) ≈ local_bound(fp2) @test local_bound(fc1) ≈ local_bound(fc2) @test local_bound(fc1) ≈ local_bound(fp1) + bigfc1 = zeros(T, 5, 6, 7) + @views bigfc1[2:5, 2:6, 2:7] .= fc1 + @test local_bound(fc1; marg = false) ≈ local_bound(bigfc1; marg = true) end Random.seed!(1337)