@@ -83,6 +83,7 @@ function rational_curve_parametrization(
8383 i = 1
8484 free_ind = collect (1 : DEG+ 2 )
8585 used_ind = zeros (Bool, DEG+ 2 )
86+ lc = nothing
8687 while length (free_ind) > 0
8788 if i > 2 * (DEG+ 2 )
8889 error (" Too many bad specializations: permute variables or use_lfs=true" )
@@ -99,8 +100,14 @@ function rational_curve_parametrization(
99100 for j in 1 : length (free_ind)
100101 # Specialization checks: same vars order, generic degree
101102 if Lr[j]. vars == [symbols (R)[1 : N- 2 ]; symbols (R)[N]] && degree (Lr[j]. elim) == DEG
102- lc = leading_coefficient (Lr[j]. elim)
103- rr = [ p/ lc for p in vcat (Lr[j]. elim, Lr[j]. denom, Lr[j]. param) ]
103+ if isnothing (lc)
104+ lc = leading_coefficient (Lr[j]. elim)
105+ rr = [ p for p in vcat (Lr[j]. elim, Lr[j]. denom, Lr[j]. param) ]
106+ else
107+ # Adjust when the rat_param is multiplied by some constant factor
108+ fact = lc / leading_coefficient (Lr[j]. elim)
109+ rr = [ p* fact for p in vcat (Lr[j]. elim, Lr[j]. denom, Lr[j]. param) ]
110+ end
104111 PARAM[j] = rr
105112 _values[j] = QQ (i+ j- 1 )
106113 used_ind[j] = true
@@ -123,7 +130,10 @@ function rational_curve_parametrization(
123130 COEFFS = Vector {QQPolyRingElem} (undef, DEG+ 1 )
124131 for deg in 0 : DEG
125132 _evals = [coeff (PARAM[i][count], deg) for i in 1 : length (PARAM)]
126- COEFFS[deg+ 1 ] = interpolate (A, _values, _evals)
133+ # Remove denominators for faster interpolation
134+ den = lcm (denominator .(_evals))
135+ _evals *= den
136+ COEFFS[deg+ 1 ] = interpolate (A, _values, _evals) / (lc* den)
127137 end
128138 ctx = MPolyBuildCtx (T)
129139 for (i, c) in enumerate (COEFFS)
0 commit comments