@@ -397,6 +397,7 @@ function (R::GenericCycloRing)(f::Dict{UPolyFrac,UPoly}; simplify::Bool=true) #
397
397
398
398
# congruence preparation
399
399
substitutes = get_substitutes! (R)
400
+ power = R. power
400
401
401
402
# reduce numerators modulo denominators
402
403
L = NTuple{4 ,UPoly}[]
@@ -412,7 +413,17 @@ function (R::GenericCycloRing)(f::Dict{UPolyFrac,UPoly}; simplify::Bool=true) #
412
413
# example be `(q+1)//2` and `q` congruent to `1`
413
414
# modulo `2`. Then `substitutes[1]` is `2*q+1`
414
415
# and `gp=(2*q+2)//2=q+1` which simplifies to `0`.
415
- gp = evaluate (g, [1 ], [substitutes[1 ]])
416
+ #
417
+ # `power` is used in cases where the first parameter
418
+ # represents a root of order `power`. In this case the
419
+ # polynomials need to be deflated before the evaluation
420
+ # and the inflated back again.
421
+ if isone (power)
422
+ gp = evaluate (g, [1 ], [substitutes[1 ]])
423
+ else
424
+ gd = deflate (numerator (g), [power])// deflate (denominator (g), [power])
425
+ gp = evaluate (gd, [1 ], [substitutes[1 ]])
426
+ end
416
427
end
417
428
a, r = divrem (numerator (gp), denominator (gp))
418
429
push! (L, (c, denominator (gp), r, a))
@@ -447,6 +458,9 @@ function (R::GenericCycloRing)(f::Dict{UPolyFrac,UPoly}; simplify::Bool=true) #
447
458
gp = g
448
459
else
449
460
gp = evaluate (g, [1 ], [substitutes[2 ]])
461
+ if ! isone (power)
462
+ gp = inflate (numerator (gp), [power])// inflate (denominator (gp), [power])
463
+ end
450
464
end
451
465
if haskey (fp, gp)
452
466
fp[gp] += cp * c
@@ -480,9 +494,10 @@ function generic_cyclotomic_ring(
480
494
R:: UPolyRing ,
481
495
symbol:: Symbol = :E ;
482
496
congruence:: Union{Tuple{ZZRingElem,ZZRingElem},Nothing} = nothing ,
497
+ power:: Int64 = 1 ,
483
498
cached:: Bool = true ,
484
499
)
485
- S = GenericCycloRing (R, symbol, congruence)
500
+ S = GenericCycloRing (R, symbol, congruence, power )
486
501
E = GenericCycloRingGen (S)
487
502
length (gens (R)) < 1 && error (" At least one free variable is needed" )
488
503
return (S, E)
0 commit comments