Skip to content

Commit a49ddac

Browse files
committed
Change verbose to have levels
Now, verbose is configurable, with a level from 0 to 10 that we can use to debug stuff in the future.
1 parent 75c4f5f commit a49ddac

File tree

5 files changed

+110
-90
lines changed

5 files changed

+110
-90
lines changed

src/CharPolyFrob.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ INPUTS:
88
divisibility of the roots.
99
* "relative_precision" -- list, list of relative precisions, can be computed by "calculate_relative_precision"
1010
"""
11-
function prec_vec(polygon, relative_precision)
11+
function prec_vec(polygon, relative_precision, verbose=0)
1212
vals = Int.(polygon.values)
1313
hodge_numbers = polygon.slopelengths
14-
println(hodge_numbers)
15-
println(relative_precision)
14+
(0 < verbose) && println(hodge_numbers)
15+
(0 < verbose) && println(relative_precision)
1616
prec_vec = reverse(vals)
1717
i = 1
1818
num_term = 1
@@ -177,32 +177,32 @@ divisibility of the roots.
177177
Frobenius matrix computed over the integers
178178
179179
"""
180-
function compute_Lpolynomial(n, p, polygon, relative_precision, cp_coeffs)
180+
function compute_Lpolynomial(n, p, polygon, relative_precision, cp_coeffs, verbose=0)
181181
p = ZZ(p)
182182
dimension = n - 1 # dimension of the projective space
183183
Lpoly_coeffs = [ZZ(x) for x in cp_coeffs]
184-
println("initial coefficients = $Lpoly_coeffs")
184+
(9 < verbose) && println("initial coefficients = $Lpoly_coeffs")
185185
prec_vec = DeRham.prec_vec(polygon, relative_precision)
186-
println("prec_vec = $prec_vec")
186+
(9 < verbose) && println("prec_vec = $prec_vec")
187187
d = length(cp_coeffs) - 1 # degree of characteristic polynomial
188188
modulus = [ZZ(0) for i in 1:d+1]
189189
for i in 1:d+1
190190
modulus[i] = p^prec_vec[i]
191191
Lpoly_coeffs[i] = mod(Lpoly_coeffs[i], modulus[i])
192192
end
193193
#println("modulus=$modulus")
194-
println("coefficients after moding by prec = $Lpoly_coeffs")
194+
(9 < verbose) && println("coefficients after moding by prec = $Lpoly_coeffs")
195195

196196
Lpoly_coeffs[d+1] = 1 # set leading coefficient to 1
197197
sign = sign_fe(n, d, p, prec_vec, Lpoly_coeffs) # determine the sign of the functional equation
198-
println("sign of functional equation = $sign")
198+
(9 < verbose) && println("sign of functional equation = $sign")
199199
Lpoly_coeffs[1] = sign * p^(div(d*dimension, 2))
200-
println(Lpoly_coeffs[1])
200+
#println(Lpoly_coeffs[1])
201201
Lpoly_coeffs = DeRham.apply_symmetry(n,d,p,prec_vec,Lpoly_coeffs,modulus,sign)
202-
println("coefficients after apply symmetry = $Lpoly_coeffs")
202+
(9 < verbose) && println("coefficients after apply symmetry = $Lpoly_coeffs")
203203
#println("modulus=$modulus")
204204
Lpoly_coeffs = DeRham.apply_newton_identity(n,d,p,prec_vec,Lpoly_coeffs,modulus)
205-
println("coeffficients after applying Newton's identity = $Lpoly_coeffs")
205+
(9 < verbose) && println("coeffficients after applying Newton's identity = $Lpoly_coeffs")
206206

207207
return Lpoly_coeffs
208208
end

src/ControlledReduction.jl

Lines changed: 47 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ if the reduction hits the end, returns u as the "true" value, otherwise returns
329329
"""
330330
function reducechain_costachunks(u,g,m,S,f,pseudoInverseMat,p,Ruvs,explookup,A,B,temp,g_temp,params)
331331
#p = Int64(characteristic(parent(f)))
332+
verbose = params.verbose
332333
n = nvars(parent(f)) - 1
333334
d = total_degree(f)
334335
PR = parent(f)
@@ -342,13 +343,13 @@ function reducechain_costachunks(u,g,m,S,f,pseudoInverseMat,p,Ruvs,explookup,A,B
342343
if params.vars_reversed == false
343344
reverse!(I) # parity issue due to Costa's code being reverse from ours
344345
end
345-
#println("Expanded I: $I")
346+
(4 < verbose) && println("Expanded I: $I")
346347

347348
gMat = g
348349
#println(gMat)
349350
#chain = 0
350351
#I_edgar = [x//7 for x in I]
351-
#verbose && println("This is I: $I_edgar")
352+
(4 < verbose) && println("This is I: $I_edgar")
352353
J = copy(I)
353354

354355
#TODO?
@@ -357,8 +358,7 @@ function reducechain_costachunks(u,g,m,S,f,pseudoInverseMat,p,Ruvs,explookup,A,B
357358
else
358359
V = chooseV(Array{Int}(divexact.(I,p)),d)
359360
end
360-
#println("V: $V")
361-
# verbose && println("LOOK! I=$I, V = $V")
361+
(4 < verbose) && println("LOOK! I=$I, V = $V")
362362

363363

364364
if params.vars_reversed == true
@@ -392,8 +392,8 @@ function reducechain_costachunks(u,g,m,S,f,pseudoInverseMat,p,Ruvs,explookup,A,B
392392
i = 1
393393

394394

395-
#verbose && println("Before reduction chunk: $(convert.(Int,gMat))")
396-
#verbose && println("Before reduction chunk, I is $I")
395+
#(9 < verbose) && println("Before reduction chunk: $(convert.(Int,gMat))")
396+
(4 < verbose) && println("Before reduction chunk, I is $I")
397397
if params.fastevaluation && 1 nend-(d*n-n)
398398
gMat = finitediff_prodeval_linear!(B,A,0,nend-(d*n-n)-1,gMat,temp,ui)
399399
i = nend-(d*n-n) + 1
@@ -405,7 +405,7 @@ function reducechain_costachunks(u,g,m,S,f,pseudoInverseMat,p,Ruvs,explookup,A,B
405405

406406
#gMat = (A+B*(nend-(d*n-n)-i))*gMat
407407

408-
#verbose && println("After step $i: $(convert.(Int,gMat))")
408+
#(9 < verbose) && println("After step $i: $(convert.(Int,gMat))")
409409

410410
i = i+1
411411
#println(gMat)
@@ -417,17 +417,16 @@ function reducechain_costachunks(u,g,m,S,f,pseudoInverseMat,p,Ruvs,explookup,A,B
417417
# UPDATE: I think the problem with fastevaluation is fixed... right?
418418
@. I = I - (nend-(d*n-n))*V
419419
end
420-
#verbose && println("After steps 1-$i, I is $I")
420+
(4 < verbose) && println("After steps 1-$i, I is $I")
421421
i = i-1
422422
while i <= nend-1
423423
if params.vars_reversed == true
424424
y = rev_tweak(J - i*V,d*n-n) .- rev_tweak(J - (i+1)*V,d*n-n)
425425
else
426426
y = tweak(J - i*V,d*n-n) .- tweak(J - (i+1)*V,d*n-n)
427427
end
428-
#println("V: $y")
429-
#verbose &&
430-
#println("Getting y direction reduction matrix for V = $(y)")
428+
(4 < verbose) && println("Getting y direction reduction matrix for V = $(y)")
429+
431430
# there's some sort of parity issue between our code and Costa's
432431
#A,B = computeRPoly_LAOneVar(y,rev_tweak(J - (i+1)*V,d*n-n) - y,S,n,d,f,pseudoInverseMat,R,PR,termorder)
433432

@@ -446,13 +445,12 @@ function reducechain_costachunks(u,g,m,S,f,pseudoInverseMat,p,Ruvs,explookup,A,B
446445

447446
#gMat = (A+B)*gMat
448447

449-
#verbose &&
450-
#println("After step $(i+1): $(gMat))")
448+
(4 < verbose) && println("After step $(i+1): $(gMat))")
449+
451450

452451
i = i+1
453452
@. I = I - y
454-
#verbose &&
455-
#println("After step $(i+1), I is $I")
453+
(4 < verbose) && println("After step $(i+1), I is $I")
456454
end
457455

458456
#U = I - V
@@ -476,7 +474,6 @@ function reducechain_costachunks(u,g,m,S,f,pseudoInverseMat,p,Ruvs,explookup,A,B
476474
end
477475
=#
478476

479-
#verbose && println("Getting reduction matrix for V = $V")
480477

481478
#A,B = computeRPoly_LAOneVar(V,I - Int64((nend-(d*n-n)))*V,S,n,d,f,pseudoInverseMat,R,PR,termorder)
482479
#=
@@ -662,7 +659,7 @@ only be used at the beginning of reduction
662659
"""
663660
function costadata_of_initial_term!(term,g,n,d,p,termorder)
664661

665-
#verbose && println("p: $p")
662+
#(9 < verbose) && println("p: $p")
666663

667664
R = base_ring(parent(term[1]))
668665
i = term
@@ -686,7 +683,7 @@ function costadata_of_initial_term!(term,g,n,d,p,termorder)
686683
end
687684

688685

689-
#verbose && println("creation: u is type $(typeof(II))")
686+
#(9 < verbose) && println("creation: u is type $(typeof(II))")
690687
return (II,g)
691688
end
692689

@@ -719,7 +716,7 @@ function incorporate_initial_term!(costadata_arr,costadata)
719716

720717
# otherwise, push on a new term
721718
if !ind_already
722-
#verbose && println("incorporation: u has type $(typeof(costadata[1]))")
719+
#(9 < verbose) && println("incorporation: u has type $(typeof(costadata[1]))")
723720
push!(costadata_arr,costadata)
724721
end
725722
end
@@ -822,7 +819,7 @@ function reducepoly_costachunks(pol,S,f,pseudoInverseMat,p,Ruvs,explookup,A,B,te
822819
d = total_degree(f)
823820
PR = parent(f)
824821
R = coefficient_ring(parent(f))
825-
#verbose && println(pol)
822+
#(9 < verbose) && println(pol)
826823
g_length = binomial(d*n,d*n-n)
827824

828825
i = pol
@@ -833,28 +830,28 @@ function reducepoly_costachunks(pol,S,f,pseudoInverseMat,p,Ruvs,explookup,A,B,te
833830

834831
poleorder = highpoleorder
835832
while n < poleorder
836-
params.verbose && println("pole order is $poleorder")
833+
(9 < params.verbose) && println("pole order is $poleorder")
837834
# this is an array of polynomials
838835
ωₑ = termsoforder(pol,poleorder)
839836

840-
#verbose && println("ωₑ: $ωₑ")
837+
#(9 < verbose) && println("ωₑ: $ωₑ")
841838

842839

843840

844841
for term in ωₑ
845-
#verbose && println("term: $term")
842+
#(9 < verbose) && println("term: $term")
846843
g = zeros(UInt,g_length)
847844
term_costadata = costadata_of_initial_term!(term,g,n,d,p,params.termorder)
848-
#verbose && println("term, in Costa's format: $term_costadata")
845+
#(9 < verbose) && println("term, in Costa's format: $term_costadata")
849846
#ω = ω + ωₑ
850847
incorporate_initial_term!(ω,term_costadata)
851848
end
852849

853-
#verbose && println("ω: $ω")
850+
#(9 < verbose) && println("ω: $ω")
854851
#ω = reducepoly_LA(ω,n,d,p,S,f,pseudoInverseMat,R,PR)
855852
for i in eachindex(ω)
856853
#ω[i] = reducechain...
857-
#verbose && println("u is type $(typeof(ω[i][1]))")
854+
#(9 < verbose) && println("u is type $(typeof(ω[i][1]))")
858855
g_temp = similar(ω[i][2])
859856
ω[i] = reducechain_costachunks(ω[i]...,poleorder,S,f,pseudoInverseMat,p,Ruvs,explookup,A,B,temp,g_temp,params)
860857
end
@@ -863,7 +860,7 @@ function reducepoly_costachunks(pol,S,f,pseudoInverseMat,p,Ruvs,explookup,A,B,te
863860
end
864861

865862
#println("ω: $ω")
866-
#verbose && println(poly_of_end_costadatas(ω,PR,p,d,n,S,termorder))
863+
#(9 < verbose) && println(poly_of_end_costadatas(ω,PR,p,d,n,S,termorder))
867864

868865
#println(gen_exp_vec(n,n*d-n-1,termorder))
869866

@@ -921,12 +918,17 @@ function reducetransform_costachunks(FT,N_m,S,f,pseudoInverseMat,p,params)
921918
result = []
922919
i = 1
923920
for pol in FT
924-
println("Reducing vector $i")
921+
(0 < params.verbose) && println("Reducing vector $i")
925922
i += 1
926-
@time reduction = reducepoly_costachunks(pol,S,f,pseudoInverseMat,p,Ruvs,explookup,A,B,temp,params)
923+
if (0 < params.verbose)
924+
@time reduction = reducepoly_costachunks(pol,S,f,pseudoInverseMat,p,Ruvs,explookup,A,B,temp,params)
925+
else
926+
reduction = reducepoly_costachunks(pol,S,f,pseudoInverseMat,p,Ruvs,explookup,A,B,temp,params)
927+
end
928+
927929
push!(result, reduction)
928930
end
929-
println(result)
931+
930932
return result
931933
end
932934

@@ -944,7 +946,13 @@ function reducetransform_naive(FT,N_m,S,f,pseudoInverseMat,p,params)
944946
for i in 1:length(ev1)
945947
get!(explookup,ev1[i],i)
946948
end
947-
@time precomputeRuvs(S,f,pseudoInverseMat,Ruvs,explookup,params)
949+
950+
if (0 < params.verbose)
951+
@time precomputeRuvs(S,f,pseudoInverseMat,Ruvs,explookup,params)
952+
else
953+
precomputeRuvs(S,f,pseudoInverseMat,Ruvs,explookup,params)
954+
end
955+
948956

949957
contexts = OscarReductionContext[]
950958

@@ -965,12 +973,16 @@ function reducetransform_naive(FT,N_m,S,f,pseudoInverseMat,p,params)
965973
Threads.@threads for i in 1:length(FT) #pol in FT
966974
context = contexts[i]
967975
pol = FT[i]
968-
println("Reducing vector $i")
969-
@time reduction = reducepoly_naive(pol,S,f,pseudoInverseMat,p,context,explookup,params)
976+
(0 < params.verbose) && println("Reducing vector $i")
977+
if (0 < params.verbose)
978+
@time reduction = reducepoly_naive(pol,S,f,pseudoInverseMat,p,context,explookup,params)
979+
else
980+
reduction = reducepoly_naive(pol,S,f,pseudoInverseMat,p,context,explookup,params)
981+
end
970982
result[i] = reduction
971983
#push!(result, reduction)
972984
end
973-
println(result)
985+
974986
return result
975987
end
976988

@@ -1032,7 +1044,7 @@ function computeRuv(V,S,f,pseudoInverseMat,Ruvs,explookup,params)
10321044
if haskey(Ruvs, V)
10331045
return get(Ruvs, V, 0)
10341046
else
1035-
println("New key: $V")
1047+
(4 < params.verbose) && println("New key: $V")
10361048
end
10371049
ev1 = gen_exp_vec(n+1,n*d-n,params.termorder)
10381050
ev2 = gen_exp_vec(n+1,n*d-n+d-length(S),params.termorder)

src/DeRham.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ using LinearAlgebra
66
using Combinatorics
77
using Memoize
88

9-
verbose = true
10-
119
#include("NemoAdditions.jl")
1210

1311
include("Utils.jl")

src/Frobenius.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ function applyFrobeniusToMon(n, d, f, N, p, beta, m, R, PR, termorder,vars_rever
5555
if vars_reversed == false
5656
beta = reverse(beta)
5757
end
58-
verbose && println("N=$N, m=$m")
59-
verbose && println("Scaling by factorial of: ", p * (N + m - 1) - 1)
58+
(9 < verbose) && println("N=$N, m=$m")
59+
(9 < verbose) && println("Scaling by factorial of: ", p * (N + m - 1) - 1)
6060
Factorial = factorial(ZZ(p * (N + m - 1) - 1))
61-
#verbose && println("Factorial: $Factorial")
62-
#verbose && println("p: $p")
61+
#(9 < verbose) && println("Factorial: $Factorial")
62+
#(9 < verbose) && println("p: $p")
6363
o = ones(Int64, n+1)
6464
B = MPolyBuildCtx(PR)
6565
push_term!(B, R(1), o)
@@ -69,7 +69,7 @@ function applyFrobeniusToMon(n, d, f, N, p, beta, m, R, PR, termorder,vars_rever
6969
for j in 0:(N-1)
7070
e = j + m
7171
factorial_e = R(ZZ(Factorial//factorial(ZZ(p * e - 1))))
72-
#verbose && println("e=$e,factorial_e=$factorial_e")
72+
#(9 < verbose) && println("e=$e,factorial_e=$factorial_e")
7373
ev = gen_exp_vec(n+1,d*j,termorder)
7474
fj = f^j
7575
sum = 0
@@ -80,12 +80,12 @@ function applyFrobeniusToMon(n, d, f, N, p, beta, m, R, PR, termorder,vars_rever
8080
#coefficient = R(factorial_e * (D[j+1] * (coeff(fj,alpha)^p)))
8181
coefficient = R(factorial_e * (D[j+1] * (coeff(fj,alpha)))) # not sure whether there should be a power of p here
8282
sum = sum + coefficient * monomial
83-
if verbose && coefficient != 0
83+
if (9 < verbose) && coefficient != 0
8484
Djm = D[j+1]
8585
C_jalpha = coeff(fj,alpha)
86-
#println("Djm=$Djm, C_jalpha=$C_jalpha")
86+
println("Djm=$Djm, C_jalpha=$C_jalpha")
8787
end
88-
#verbose && coefficient != 0 && println("coefficient=$coefficient, monomial=$monomial")
88+
#(9 < verbose) && coefficient != 0 && println("coefficient=$coefficient, monomial=$monomial")
8989
#println(typeof((D[j+1]*(coeff(map_coefficients(lift,fj),alpha)^p))*monomial))
9090
end
9191
push!(result, [sum, p*(m+j)])
@@ -130,7 +130,7 @@ function applyFrobeniusToBasis(Basis,f,N_m,p,params)
130130
result = []
131131
for b in Basis
132132
Fmon = applyFrobeniusToMon(n,d,f,N_m[b[2]],p,exponent_vector(b[1],1),b[2],R,PR,termorder,vars_reversed,verbose=verbose)
133-
verbose && println(Fmon)
133+
(9 < verbose) && println(Fmon)
134134
push!(result, Fmon)
135135
end
136136
return result

0 commit comments

Comments
 (0)