 |
My Project
debian-1:4.1.2-p1+ds-2
|
#include "debug.h"
#include "config.h"
#include "canonicalform.h"
#include "facMul.h"
#include "cf_util.h"
#include "templates/ftmpl_functions.h"
#include <NTL/lzz_pEX.h>
#include "NTLconvert.h"
#include "FLINTconvert.h"
Go to the source code of this file.
|
void | kronSubQa (fmpz_poly_t result, const CanonicalForm &A, int d) |
|
CanonicalForm | reverseSubstQa (const fmpz_poly_t F, int d, const Variable &x, const Variable &alpha, const CanonicalForm &den) |
|
CanonicalForm | mulFLINTQa (const CanonicalForm &F, const CanonicalForm &G, const Variable &alpha) |
|
CanonicalForm | mulFLINTQ (const CanonicalForm &F, const CanonicalForm &G) |
|
CanonicalForm | divFLINTQ (const CanonicalForm &F, const CanonicalForm &G) |
|
CanonicalForm | modFLINTQ (const CanonicalForm &F, const CanonicalForm &G) |
|
CanonicalForm | mulFLINTQaTrunc (const CanonicalForm &F, const CanonicalForm &G, const Variable &alpha, int m) |
|
CanonicalForm | mulFLINTQTrunc (const CanonicalForm &F, const CanonicalForm &G, int m) |
|
CanonicalForm | uniReverse (const CanonicalForm &F, int d, const Variable &x) |
|
CanonicalForm | newtonInverse (const CanonicalForm &F, const int n, const Variable &x) |
|
void | newtonDivrem (const CanonicalForm &F, const CanonicalForm &G, CanonicalForm &Q, CanonicalForm &R) |
| division with remainder of univariate polynomials over Q and Q(a) using Newton inversion, satisfying F=G*Q+R, deg(R) < deg(G) More...
|
|
void | newtonDiv (const CanonicalForm &F, const CanonicalForm &G, CanonicalForm &Q) |
|
CanonicalForm | mulNTL (const CanonicalForm &F, const CanonicalForm &G, const modpk &b) |
| multiplication of univariate polys using FLINT/NTL over F_p, F_q, Z/p^k, Z/p^k[t]/(f), Z, Q, Q(a), if we are in GF factory's default multiplication is used. If b!= 0 and getCharacteristic() == 0 the input will be considered as elements over Z/p^k or Z/p^k[t]/(f). More...
|
|
CanonicalForm | modNTL (const CanonicalForm &F, const CanonicalForm &G, const modpk &b) |
| mod of univariate polys using FLINT/NTL over F_p, F_q, Z/p^k, Z/p^k[t]/(f), Z, Q, Q(a), if we are in GF factory's default multiplication is used. If b!= 0 and getCharacteristic() == 0 the input will be considered as elements over Z/p^k or Z/p^k[t]/(f); in this case invertiblity of Lc(G) is not checked More...
|
|
CanonicalForm | divNTL (const CanonicalForm &F, const CanonicalForm &G, const modpk &b) |
| division of univariate polys using FLINT/NTL over F_p, F_q, Z/p^k, Z/p^k[t]/(f), Z, Q, Q(a), if we are in GF factory's default multiplication is used. If b!= 0 and getCharacteristic() == 0 the input will be considered as elements over Z/p^k or Z/p^k[t]/(f); in this case invertiblity of Lc(G) is not checked More...
|
|
void | kronSubFp (nmod_poly_t result, const CanonicalForm &A, int d) |
|
void | kronSubFq (fq_nmod_poly_t result, const CanonicalForm &A, int d, const fq_nmod_ctx_t fq_con) |
|
void | kronSubQa (fmpz_poly_t result, const CanonicalForm &A, int d1, int d2) |
|
void | kronSubReciproFp (nmod_poly_t subA1, nmod_poly_t subA2, const CanonicalForm &A, int d) |
|
void | kronSubReciproFq (fq_nmod_poly_t subA1, fq_nmod_poly_t subA2, const CanonicalForm &A, int d, const fq_nmod_ctx_t fq_con) |
|
void | kronSubReciproQ (fmpz_poly_t subA1, fmpz_poly_t subA2, const CanonicalForm &A, int d) |
|
CanonicalForm | reverseSubstQ (const fmpz_poly_t F, int d) |
|
CanonicalForm | reverseSubstQa (const fmpz_poly_t F, int d1, int d2, const Variable &alpha, const fmpq_poly_t mipo) |
|
CanonicalForm | reverseSubstReciproFp (const nmod_poly_t F, const nmod_poly_t G, int d, int k) |
|
CanonicalForm | reverseSubstReciproFq (const fq_nmod_poly_t F, const fq_nmod_poly_t G, int d, int k, const Variable &alpha, const fq_nmod_ctx_t fq_con) |
|
CanonicalForm | reverseSubstReciproQ (const fmpz_poly_t F, const fmpz_poly_t G, int d, int k) |
|
CanonicalForm | reverseSubstFq (const fq_nmod_poly_t F, int d, const Variable &alpha, const fq_nmod_ctx_t fq_con) |
|
CanonicalForm | reverseSubstFp (const nmod_poly_t F, int d) |
|
CanonicalForm | mulMod2FLINTFpReci (const CanonicalForm &F, const CanonicalForm &G, const CanonicalForm &M) |
|
CanonicalForm | mulMod2FLINTFp (const CanonicalForm &F, const CanonicalForm &G, const CanonicalForm &M) |
|
CanonicalForm | mulMod2FLINTFqReci (const CanonicalForm &F, const CanonicalForm &G, const CanonicalForm &M, const Variable &alpha, const fq_nmod_ctx_t fq_con) |
|
CanonicalForm | mulMod2FLINTFq (const CanonicalForm &F, const CanonicalForm &G, const CanonicalForm &M, const Variable &alpha, const fq_nmod_ctx_t fq_con) |
|
CanonicalForm | mulMod2FLINTQReci (const CanonicalForm &F, const CanonicalForm &G, const CanonicalForm &M) |
|
CanonicalForm | mulMod2FLINTQ (const CanonicalForm &F, const CanonicalForm &G, const CanonicalForm &M) |
|
CanonicalForm | mulMod2FLINTQa (const CanonicalForm &F, const CanonicalForm &G, const CanonicalForm &M) |
|
CanonicalForm | mulMod2NTLFq (const CanonicalForm &F, const CanonicalForm &G, const CanonicalForm &M) |
|
CanonicalForm | mulMod2 (const CanonicalForm &A, const CanonicalForm &B, const CanonicalForm &M) |
| Karatsuba style modular multiplication for bivariate polynomials. More...
|
|
CanonicalForm | mod (const CanonicalForm &F, const CFList &M) |
| reduce F modulo elements in M. More...
|
|
CanonicalForm | mulMod (const CanonicalForm &A, const CanonicalForm &B, const CFList &MOD) |
| Karatsuba style modular multiplication for multivariate polynomials. More...
|
|
CanonicalForm | prodMod (const CFList &L, const CanonicalForm &M) |
| product of all elements in L modulo M via divide-and-conquer. More...
|
|
CanonicalForm | prodMod (const CFList &L, const CFList &M) |
| product of all elements in L modulo M via divide-and-conquer. More...
|
|
CanonicalForm | reverse (const CanonicalForm &F, int d) |
|
CanonicalForm | newtonInverse (const CanonicalForm &F, const int n, const CanonicalForm &M) |
|
CanonicalForm | newtonDiv (const CanonicalForm &F, const CanonicalForm &G, const CanonicalForm &M) |
| division of F by G wrt Variable (1) modulo M using Newton inversion More...
|
|
void | newtonDivrem (const CanonicalForm &F, const CanonicalForm &G, CanonicalForm &Q, CanonicalForm &R, const CanonicalForm &M) |
| division with remainder of F by G wrt Variable (1) modulo M using Newton inversion More...
|
|
static CFList | split (const CanonicalForm &F, const int m, const Variable &x) |
|
static void | divrem32 (const CanonicalForm &F, const CanonicalForm &G, CanonicalForm &Q, CanonicalForm &R, const CFList &M) |
|
static void | divrem21 (const CanonicalForm &F, const CanonicalForm &G, CanonicalForm &Q, CanonicalForm &R, const CFList &M) |
|
void | divrem2 (const CanonicalForm &F, const CanonicalForm &G, CanonicalForm &Q, CanonicalForm &R, const CanonicalForm &M) |
| division with remainder of F by G wrt Variable (1) modulo M. Uses an algorithm based on Burnikel, Ziegler "Fast recursive division". More...
|
|
void | divrem (const CanonicalForm &F, const CanonicalForm &G, CanonicalForm &Q, CanonicalForm &R, const CFList &MOD) |
| division with remainder of F by G wrt Variable (1) modulo MOD. Uses an algorithm based on Burnikel, Ziegler "Fast recursive division". More...
|
|
bool | uniFdivides (const CanonicalForm &A, const CanonicalForm &B) |
| divisibility test for univariate polys More...
|
|
This file implements functions for fast multiplication and division with remainder.
Nomenclature rules: kronSub* -> plain Kronecker substitution reverseSubst* -> reverse Kronecker substitution kronSubRecipro* -> reciprocal Kronecker substitution as described in D. Harvey "Faster polynomial multiplication via multipoint Kronecker substitution"
- Author
- Martin Lee
Definition in file facMul.cc.
◆ divFLINTQ()
Definition at line 170 of file facMul.cc.
175 fmpq_poly_t FLINTA,FLINTB;
179 fmpq_poly_div (FLINTA, FLINTA, FLINTB);
182 fmpq_poly_clear (FLINTA);
183 fmpq_poly_clear (FLINTB);
◆ divNTL()
division of univariate polys using FLINT/NTL over F_p, F_q, Z/p^k, Z/p^k[t]/(f), Z, Q, Q(a), if we are in GF factory's default multiplication is used. If b!= 0 and getCharacteristic() == 0 the input will be considered as elements over Z/p^k or Z/p^k[t]/(f); in this case invertiblity of Lc(G) is not checked
- Returns
- divNTL returns F/G
- Parameters
-
[in] | F | a univariate poly |
[in] | G | a univariate poly |
[in] | b | coeff bound |
Definition at line 850 of file facMul.cc.
867 #if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
869 fmpz_mod_poly_t FLINTmipo;
878 fq_ctx_init_modulus (
fq_con, FLINTmipo,
"Z");
883 fq_inv (FLINTG, FLINTG,
fq_con);
884 fq_mul (FLINTF, FLINTF, FLINTG,
fq_con);
889 fmpz_mod_poly_clear (FLINTmipo);
890 fq_clear (FLINTF,
fq_con);
891 fq_clear (FLINTG,
fq_con);
897 ZZ_pE::init (NTLmipo);
901 div (
result, to_ZZ_pE (NTLf), to_ZZ_pE (NTLg));
913 if (!
G.inBaseDomain())
917 #if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
919 fmpz_mod_poly_t FLINTmipo;
929 fq_ctx_init_modulus (
fq_con, FLINTmipo,
"Z");
934 fq_inv (FLINTG, FLINTG,
fq_con);
935 fq_poly_scalar_mul_fq (FLINTF, FLINTF, FLINTG,
fq_con);
941 fmpz_mod_poly_clear (FLINTmipo);
942 fq_poly_clear (FLINTF,
fq_con);
943 fq_clear (FLINTG,
fq_con);
949 ZZ_pE::init (NTLmipo);
952 div (NTLf, NTLf, to_ZZ_pE (NTLg));
973 fmpz_mod_poly_t FLINTF, FLINTG;
976 fmpz_mod_poly_divrem (FLINTF, FLINTG, FLINTF, FLINTG);
978 fmpz_mod_poly_clear (FLINTG);
979 fmpz_mod_poly_clear (FLINTF);
980 fmpz_clear (FLINTpk);
990 ZZ_pX NTLf= to_ZZ_pX (ZZf);
991 ZZ_pX NTLg= to_ZZ_pX (ZZg);
992 div (NTLf, NTLf, NTLg);
1002 #if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
1004 fmpz_mod_poly_t FLINTmipo;
1006 fq_poly_t FLINTF, FLINTG;
1013 fq_ctx_init_modulus (
fq_con, FLINTmipo,
"Z");
1018 fq_poly_divrem (FLINTF, FLINTG, FLINTF, FLINTG,
fq_con);
1023 fmpz_clear (FLINTp);
1024 fmpz_mod_poly_clear (FLINTmipo);
1026 fq_poly_clear (FLINTF,
fq_con);
1027 fq_poly_clear (FLINTG,
fq_con);
1032 ZZ_pE::init (NTLmipo);
1035 div (NTLf, NTLf, NTLg);
1050 ASSERT (F.
level() ==
G.level(),
"expected polys of same level");
1060 #if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
1061 nmod_poly_t FLINTmipo;
1069 fq_nmod_poly_t FLINTF, FLINTG;
1073 fq_nmod_poly_divrem (FLINTF, FLINTG, FLINTF, FLINTG,
fq_con);
1083 zz_pE::init (NTLMipo);
1086 div (NTLF, NTLF, NTLG);
1093 nmod_poly_t FLINTF, FLINTG;
1096 nmod_poly_div (FLINTF, FLINTF, FLINTG);
1103 div (NTLF, NTLF, NTLG);
◆ divrem()
division with remainder of F by G wrt Variable (1) modulo MOD. Uses an algorithm based on Burnikel, Ziegler "Fast recursive division".
- See also
- divrem2()
- Parameters
-
[in] | F | multivariate, compressed polynomial |
[in] | G | multivariate, compressed polynomial |
[in,out] | Q | dividend |
[in,out] | R | remainder, degree (R, 1) < degree (G, 1) |
[in] | MOD | only contains powers of Variables of level higher than 1 |
Definition at line 3583 of file facMul.cc.
3610 H=
i.getItem()*xToDegB;
3618 H=
R*xToDegB +
i.getItem();
◆ divrem2()
division with remainder of F by G wrt Variable (1) modulo M. Uses an algorithm based on Burnikel, Ziegler "Fast recursive division".
- Returns
- Q returns the dividend, R returns the remainder.
- See also
- divrem()
- Parameters
-
[in] | F | bivariate, compressed polynomial |
[in] | G | bivariate, compressed polynomial |
[in,out] | Q | dividend |
[in,out] | R | remainder, degree (R, 1) < degree (G, 1) |
[in] | M | power of Variable (2) |
Definition at line 3516 of file facMul.cc.
3566 H=
i.getItem()*xToDegB;
3576 H=
R*xToDegB +
i.getItem();
◆ divrem21()
Definition at line 3376 of file facMul.cc.
3397 int m= (int)
ceil ((
double) (degB + 1)/2.0) + 1;
3398 ASSERT (4*
m >= degA,
"expected degree (F, 1) < 2*degree (G, 1)");
3400 if (splitA.
length() == 3)
3402 if (splitA.
length() == 2)
3407 if (splitA.
length() == 1)
3429 if (splitR.
length() == 1)
◆ divrem32()
Definition at line 3447 of file facMul.cc.
3468 int m= (int)
ceil ((
double) (degB + 1)/ 2.0);
3469 ASSERT (3*
m > degA,
"expected degree (F, 1) < 3*degree (G, 1)");
3473 if (splitA.
length() == 2)
3477 if (splitA.
length() == 1)
3507 Q +=
LC (
R,
x)*xToM;
◆ kronSubFp()
Definition at line 1115 of file facMul.cc.
1119 result->length= d*(degAy + 1);
1120 flint_mpn_zero (
result->coeffs, d*(degAy+1));
1129 flint_mpn_copyi (
result->coeffs+
k,
buf->coeffs, nmod_poly_length(
buf));
1133 _nmod_poly_normalise (
result);
◆ kronSubFq()
Definition at line 1138 of file facMul.cc.
1143 _fq_nmod_poly_set_length (
result, d*(degAy + 1),
fq_con);
1144 _fq_nmod_vec_zero (
result->coeffs, d*(degAy + 1),
fq_con);
1146 fq_nmod_poly_t
buf1;
1154 if (
i.coeff().inCoeffDomain())
◆ kronSubQa() [1/2]
Definition at line 42 of file facMul.cc.
45 fmpz_poly_init2 (
result, d*(degAy + 1));
46 _fmpz_poly_set_length (
result, d*(degAy + 1));
50 if (
i.coeff().inBaseDomain())
53 for (
j=
i.coeff();
j.hasTerms();
j++)
57 _fmpz_poly_normalise(
result);
◆ kronSubQa() [2/2]
Definition at line 1220 of file facMul.cc.
1223 fmpz_poly_init2 (
result, d1*(degAy + 1));
1224 _fmpz_poly_set_length (
result, d1*(degAy + 1));
1232 if (
i.coeff().inCoeffDomain())
1236 _fmpz_vec_set (
result->coeffs +
k,
buf->coeffs,
buf->length);
1237 fmpz_poly_clear (
buf);
1241 for (
j=
i.coeff();
j.hasTerms();
j++)
1246 _fmpz_vec_set (
result->coeffs +
k,
buf->coeffs,
buf->length);
1247 fmpz_poly_clear (
buf);
1251 _fmpz_poly_normalise (
result);
◆ kronSubReciproFp()
void kronSubReciproFp |
( |
nmod_poly_t |
subA1, |
|
|
nmod_poly_t |
subA2, |
|
|
const CanonicalForm & |
A, |
|
|
int |
d |
|
) |
| |
Definition at line 1255 of file facMul.cc.
1265 int k, kk,
j, bufRepLength;
1271 kk= (degAy -
i.exp())*d;
1272 bufRepLength= (int) nmod_poly_length (
buf);
1273 for (
j= 0;
j < bufRepLength;
j++)
1275 nmod_poly_set_coeff_ui (subA1,
j +
k,
1276 n_addmod (nmod_poly_get_coeff_ui (subA1,
j+
k),
1277 nmod_poly_get_coeff_ui (
buf,
j),
1281 nmod_poly_set_coeff_ui (subA2,
j + kk,
1282 n_addmod (nmod_poly_get_coeff_ui (subA2,
j + kk),
1283 nmod_poly_get_coeff_ui (
buf,
j),
1290 _nmod_poly_normalise (subA1);
1291 _nmod_poly_normalise (subA2);
◆ kronSubReciproFq()
void kronSubReciproFq |
( |
fq_nmod_poly_t |
subA1, |
|
|
fq_nmod_poly_t |
subA2, |
|
|
const CanonicalForm & |
A, |
|
|
int |
d, |
|
|
const fq_nmod_ctx_t |
fq_con |
|
) |
| |
Definition at line 1296 of file facMul.cc.
1300 fq_nmod_poly_init2 (subA1, d*(degAy + 2),
fq_con);
1301 fq_nmod_poly_init2 (subA2, d*(degAy + 2),
fq_con);
1303 _fq_nmod_poly_set_length (subA1, d*(degAy + 2),
fq_con);
1304 _fq_nmod_vec_zero (subA1->coeffs, d*(degAy + 2),
fq_con);
1306 _fq_nmod_poly_set_length (subA2, d*(degAy + 2),
fq_con);
1307 _fq_nmod_vec_zero (subA2->coeffs, d*(degAy + 2),
fq_con);
1309 fq_nmod_poly_t
buf1;
1316 if (
i.coeff().inCoeffDomain())
1327 kk= (degAy -
i.exp())*d;
1328 _fq_nmod_vec_add (subA1->coeffs+
k, subA1->coeffs+
k,
buf1->coeffs,
1330 _fq_nmod_vec_add (subA2->coeffs+kk, subA2->coeffs+kk,
buf1->coeffs,
1335 _fq_nmod_poly_normalise (subA1,
fq_con);
1336 _fq_nmod_poly_normalise (subA2,
fq_con);
◆ kronSubReciproQ()
void kronSubReciproQ |
( |
fmpz_poly_t |
subA1, |
|
|
fmpz_poly_t |
subA2, |
|
|
const CanonicalForm & |
A, |
|
|
int |
d |
|
) |
| |
Definition at line 1341 of file facMul.cc.
1345 fmpz_poly_init2 (subA1, d*(degAy + 2));
1346 fmpz_poly_init2 (subA2, d*(degAy + 2));
1356 kk= (degAy -
i.exp())*d;
1357 _fmpz_vec_add (subA1->coeffs+
k, subA1->coeffs +
k,
buf->coeffs,
buf->length);
1358 _fmpz_vec_add (subA2->coeffs+kk, subA2->coeffs + kk,
buf->coeffs,
buf->length);
1359 fmpz_poly_clear (
buf);
1362 _fmpz_poly_normalise (subA1);
1363 _fmpz_poly_normalise (subA2);
◆ mod()
reduce F modulo elements in M.
- Returns
- mod returns F modulo M
- Parameters
-
[in] | F | compressed polynomial |
[in] | M | list containing only univariate polynomials |
Definition at line 2939 of file facMul.cc.
◆ modFLINTQ()
Definition at line 188 of file facMul.cc.
193 fmpq_poly_t FLINTA,FLINTB;
197 fmpq_poly_rem (FLINTA, FLINTA, FLINTB);
200 fmpq_poly_clear (FLINTA);
201 fmpq_poly_clear (FLINTB);
◆ modNTL()
mod of univariate polys using FLINT/NTL over F_p, F_q, Z/p^k, Z/p^k[t]/(f), Z, Q, Q(a), if we are in GF factory's default multiplication is used. If b!= 0 and getCharacteristic() == 0 the input will be considered as elements over Z/p^k or Z/p^k[t]/(f); in this case invertiblity of Lc(G) is not checked
- Returns
- modNTL returns F mod G
- Parameters
-
[in] | F | a univariate poly |
[in] | G | a univariate poly |
[in] | b | coeff bound |
Definition at line 676 of file facMul.cc.
710 fmpz_mod_poly_t FLINTF, FLINTG;
713 fmpz_mod_poly_divrem (FLINTG, FLINTF, FLINTF, FLINTG);
715 fmpz_mod_poly_clear (FLINTG);
716 fmpz_mod_poly_clear (FLINTF);
717 fmpz_clear (FLINTpk);
727 ZZ_pX NTLf= to_ZZ_pX (ZZf);
728 ZZ_pX NTLg= to_ZZ_pX (ZZg);
729 rem (NTLf, NTLf, NTLg);
739 #if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
741 fmpz_mod_poly_t FLINTmipo;
743 fq_poly_t FLINTF, FLINTG;
751 fq_ctx_init_modulus (
fq_con, FLINTmipo,
"Z");
756 fq_poly_rem (FLINTF, FLINTF, FLINTG,
fq_con);
762 fmpz_mod_poly_clear (FLINTmipo);
763 fq_poly_clear (FLINTF,
fq_con);
764 fq_poly_clear (FLINTG,
fq_con);
771 ZZ_pE::init (NTLmipo);
774 rem (NTLf, NTLf, NTLg);
789 ASSERT (F.
level() ==
G.level(),
"expected polys of same level");
799 #if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
800 nmod_poly_t FLINTmipo;
808 fq_nmod_poly_t FLINTF, FLINTG;
812 fq_nmod_poly_rem (FLINTF, FLINTF, FLINTG,
fq_con);
822 zz_pE::init (NTLMipo);
825 rem (NTLF, NTLF, NTLG);
832 nmod_poly_t FLINTF, FLINTG;
835 nmod_poly_divrem (FLINTG, FLINTF, FLINTF, FLINTG);
842 rem (NTLF, NTLF, NTLG);
◆ mulFLINTQ()
Definition at line 129 of file facMul.cc.
139 fmpz_poly_t FLINTA,FLINTB;
142 fmpz_poly_mul (FLINTA, FLINTA, FLINTB);
146 fmpz_poly_clear (FLINTA);
147 fmpz_poly_clear (FLINTB);
◆ mulFLINTQa()
Definition at line 99 of file facMul.cc.
112 int d= degAa + 1 + degBa;
114 fmpz_poly_t FLINTA,FLINTB;
118 fmpz_poly_mul (FLINTA, FLINTA, FLINTB);
123 fmpz_poly_clear (FLINTA);
124 fmpz_poly_clear (FLINTB);
◆ mulFLINTQaTrunc()
Definition at line 206 of file facMul.cc.
220 int d= degAa + 1 + degBa;
222 fmpz_poly_t FLINTA,FLINTB;
227 fmpz_poly_mullow (FLINTA, FLINTA, FLINTB,
k);
231 fmpz_poly_clear (FLINTA);
232 fmpz_poly_clear (FLINTB);
◆ mulFLINTQTrunc()
Definition at line 237 of file facMul.cc.
243 if (
G.inCoeffDomain())
257 fmpz_poly_t FLINTA,FLINTB;
260 fmpz_poly_mullow (FLINTA, FLINTA, FLINTB,
m);
264 fmpz_poly_clear (FLINTA);
265 fmpz_poly_clear (FLINTB);
◆ mulMod()
Karatsuba style modular multiplication for multivariate polynomials.
- Returns
- mulMod2 returns A * B mod MOD.
- Parameters
-
[in] | A | multivariate, compressed polynomial |
[in] | B | multivariate, compressed polynomial |
[in] | MOD | only contains powers of Variables of level higher than 1 |
Definition at line 2947 of file facMul.cc.
2961 if (
G.inCoeffDomain())
2964 int sizeF=
size (F);
2965 int sizeG=
size (
G);
2967 if (sizeF / MOD.
length() < 100 || sizeG / MOD.
length() < 100)
2970 return mod (
G*F, MOD);
2972 return mod (F*
G, MOD);
2979 if ((degF <= 1 && F.
level() <=
M.level()) &&
2980 (degG <= 1 &&
G.level() <=
M.level()))
2984 if (degF == 1 && degG == 1)
2995 return H11*
y*
y + (H01 - H00 - H11)*
y + H00;
3007 else if (degF == 1 && degG == 0)
3009 else if (degF == 0 && degG == 1)
3015 if (degF >=
m || degG >=
m)
3029 return F0G0 + MLo*(F0G1 + F1G0);
3033 m= (
tmax(degF, degG)+1)/2;
3042 return H11*yToM*yToM + (H01 - H11 - H00)*yToM + H00;
3044 DEBOUTLN (cerr,
"fatal end in mulMod");
◆ mulMod2()
Karatsuba style modular multiplication for bivariate polynomials.
- Returns
- mulMod2 returns A * B mod M.
- Parameters
-
[in] | A | bivariate, compressed polynomial |
[in] | B | bivariate, compressed polynomial |
[in] | M | power of Variable (2) |
Definition at line 2853 of file facMul.cc.
2859 ASSERT (
M.isUnivariate(),
"M must be univariate");
2863 if (F.inCoeffDomain())
2865 if (
G.inCoeffDomain())
2872 if ((degF < 1 && degG < 1) && (F.isUnivariate() &&
G.isUnivariate()) &&
2873 (F.level() ==
G.level()))
2878 else if (degF <= 1 && degG <= 1)
2884 int sizeF=
size (F);
2885 int sizeG=
size (
G);
2887 int fallBackToNaive= 50;
2888 if (sizeF < fallBackToNaive || sizeG < fallBackToNaive)
2891 return mod (
G*F,
M);
2893 return mod (F*
G,
M);
2902 (((degF-degG) < 50 && degF > degG) || ((degG-degF) < 50 && degF <= degG)))
2906 if (degF >=
m || degG >=
m)
2917 return F0G0 + MLo*(F0G1 + F1G0);
2930 return H11*yToM*yToM + (H01 - H11 - H00)*yToM + H00;
2932 DEBOUTLN (cerr,
"fatal end in mulMod2");
◆ mulMod2FLINTFp()
Definition at line 1995 of file facMul.cc.
2005 int d1= degAx + 1 + degBx;
2006 int d2=
tmax (degAy, degBy);
2008 if (d1 > 128 && d2 > 160 && (degAy == degBy) && (2*degAy >
degree (
M)))
2011 nmod_poly_t FLINTA, FLINTB;
2016 nmod_poly_mullow (FLINTA, FLINTA, FLINTB, (
long)
k);
◆ mulMod2FLINTFpReci()
Definition at line 1957 of file facMul.cc.
1971 nmod_poly_mullow (F1, F1, G1, (
long)
k);
1978 int b= nmod_poly_degree (F2) + nmod_poly_degree (G2) -
k - degtailF - degtailG
1979 + d1*(2+taildegF + taildegG);
1980 nmod_poly_mulhigh (F2, F2, G2,
b);
1981 nmod_poly_shift_right (F2, F2,
b);
1982 int d2=
tmax (nmod_poly_degree (F2)/d1, nmod_poly_degree (F1)/d1);
◆ mulMod2FLINTFq()
Definition at line 2069 of file facMul.cc.
2080 int d1= degAx + 1 + degBx;
2081 int d2=
tmax (degAy, degBy);
2083 if (d1 > 128 && d2 > 160 && (degAy == degBy) && (2*degAy >
degree (
M)))
2086 fq_nmod_poly_t FLINTA, FLINTB;
2091 fq_nmod_poly_mullow (FLINTA, FLINTA, FLINTB, (
long)
k,
fq_con);
◆ mulMod2FLINTFqReci()
Definition at line 2027 of file facMul.cc.
2035 fq_nmod_poly_t F1, F2;
2038 fq_nmod_poly_t G1, G2;
2042 fq_nmod_poly_mullow (F1, F1, G1, (
long)
k,
fq_con);
2049 int b=
k + degtailF + degtailG - d1*(2+taildegF + taildegG);
2051 fq_nmod_poly_reverse (F2, F2, fq_nmod_poly_length (F2,
fq_con),
fq_con);
2052 fq_nmod_poly_reverse (G2, G2, fq_nmod_poly_length (G2,
fq_con),
fq_con);
2053 fq_nmod_poly_mullow (F2, F2, G2,
b+1,
fq_con);
2054 fq_nmod_poly_reverse (F2, F2,
b+1,
fq_con);
2056 int d2=
tmax (fq_nmod_poly_degree (F2,
fq_con)/d1,
2057 fq_nmod_poly_degree (F1,
fq_con)/d1);
◆ mulMod2FLINTQ()
Definition at line 2139 of file facMul.cc.
2147 int d1= degAx + 1 + degBx;
2154 fmpz_poly_t FLINTA, FLINTB;
2159 fmpz_poly_mullow (FLINTA, FLINTA, FLINTB, (
long)
k);
2161 fmpz_poly_clear (FLINTA);
2162 fmpz_poly_clear (FLINTB);
◆ mulMod2FLINTQa()
Definition at line 2199 of file facMul.cc.
2207 int degFx=
degree (F, 1);
2208 int degFa=
degree (F, a);
2212 int d2= degFa+degGa+1;
2213 int d1= degFx + 1 + degGx;
2221 fmpz_poly_t FLINTF, FLINTG;
2225 fmpz_poly_mullow (FLINTF, FLINTF, FLINTG, d1*
degree (
M));
2230 fmpz_poly_clear (FLINTF);
2231 fmpz_poly_clear (FLINTG);
◆ mulMod2FLINTQReci()
Definition at line 2102 of file facMul.cc.
2116 fmpz_poly_mullow (F1, F1, G1, (
long)
k);
2123 int b= fmpz_poly_degree (F2) + fmpz_poly_degree (G2) -
k - degtailF - degtailG
2124 + d1*(2+taildegF + taildegG);
2125 fmpz_poly_mulhigh_n (F2, F2, G2,
b);
2126 fmpz_poly_shift_right (F2, F2,
b);
2127 int d2=
tmax (fmpz_poly_degree (F2)/d1, fmpz_poly_degree (F1)/d1);
2131 fmpz_poly_clear (F1);
2132 fmpz_poly_clear (F2);
2133 fmpz_poly_clear (G1);
2134 fmpz_poly_clear (G2);
◆ mulMod2NTLFq()
Definition at line 2793 of file facMul.cc.
2802 #if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
2803 nmod_poly_t FLINTmipo;
2817 int d1= degAx + degBx + 1;
2818 int d2=
tmax (degAy, degBy);
2825 zz_pE::init (NTLMipo);
2828 if ((d1 > 128/degMipo) && (d2 > 160/degMipo) && (degAy == degBy) &&
2830 return mulMod2NTLFqReci (
A,
B,
M,
alpha);
2837 MulTrunc (NTLA, NTLA, NTLB, (
long)
k);
2847 A= mulMod2NTLFp (
A,
B,
M);
◆ mulNTL()
multiplication of univariate polys using FLINT/NTL over F_p, F_q, Z/p^k, Z/p^k[t]/(f), Z, Q, Q(a), if we are in GF factory's default multiplication is used. If b!= 0 and getCharacteristic() == 0 the input will be considered as elements over Z/p^k or Z/p^k[t]/(f).
- Returns
- mulNTL returns F*G
- Parameters
-
[in] | F | a univariate poly |
[in] | G | a univariate poly |
[in] | b | coeff bound |
Definition at line 407 of file facMul.cc.
426 #if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
428 fmpz_mod_poly_t FLINTmipo;
430 fq_poly_t FLINTF, FLINTG;
438 fq_ctx_init_modulus (
fq_con, FLINTmipo,
"Z");
443 fq_poly_mul (FLINTF, FLINTF, FLINTG,
fq_con);
449 fmpz_mod_poly_clear (FLINTmipo);
450 fq_poly_clear (FLINTF,
fq_con);
451 fq_poly_clear (FLINTG,
fq_con);
457 ZZ_pE::init (NTLmipo);
460 mul (NTLf, NTLf, NTLg);
480 fmpz_mod_poly_t FLINTF, FLINTG;
483 fmpz_mod_poly_mul (FLINTF, FLINTF, FLINTG);
485 fmpz_mod_poly_clear (FLINTG);
486 fmpz_mod_poly_clear (FLINTF);
487 fmpz_clear (FLINTpk);
497 ZZ_pX NTLf= to_ZZ_pX (ZZf);
498 ZZ_pX NTLg= to_ZZ_pX (ZZg);
499 mul (NTLf, NTLf, NTLg);
511 #if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
513 fmpz_mod_poly_t FLINTmipo;
521 fq_ctx_init_modulus (
fq_con, FLINTmipo,
"Z");
532 fq_poly_scalar_mul_fq (FLINTG, FLINTG, FLINTF,
fq_con);
535 fmpz_poly_clear (FLINTF);
536 fq_poly_clear (FLINTG,
fq_con);
546 fq_poly_scalar_mul_fq (FLINTF, FLINTF, FLINTG,
fq_con);
549 fmpz_poly_clear (FLINTG);
550 fq_poly_clear (FLINTF,
fq_con);
559 fq_mul (FLINTF, FLINTF, FLINTG,
fq_con);
562 fq_clear (FLINTF,
fq_con);
563 fq_clear (FLINTG,
fq_con);
567 fmpz_mod_poly_clear (FLINTmipo);
574 ZZ_pE::init (NTLmipo);
580 mul (NTLg, to_ZZ_pE (NTLf), NTLg);
587 mul (NTLf, NTLf, to_ZZ_pE (NTLg));
595 mul (
result, to_ZZ_pE (NTLg), to_ZZ_pE (NTLf));
608 ASSERT (F.
level() ==
G.level(),
"expected polys of same level");
625 #if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
626 nmod_poly_t FLINTmipo;
634 fq_nmod_poly_t FLINTF, FLINTG;
638 fq_nmod_poly_mul (FLINTF, FLINTF, FLINTG,
fq_con);
648 zz_pE::init (NTLMipo);
651 mul (NTLF, NTLF, NTLG);
658 nmod_poly_t FLINTF, FLINTG;
661 nmod_poly_mul (FLINTF, FLINTF, FLINTG);
668 mul (NTLF, NTLF, NTLG);
◆ newtonDiv() [1/2]
◆ newtonDiv() [2/2]
division of F by G wrt Variable (1) modulo M using Newton inversion
- Returns
- newtonDiv returns the dividend
- See also
- divrem2(), newtonDivrem()
- Parameters
-
[in] | F | bivariate, compressed polynomial |
[in] | G | bivariate, compressed polynomial which is monic in Variable (1) |
[in] | M | power of Variable (2) |
Definition at line 3180 of file facMul.cc.
3216 #if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
3217 nmod_poly_t FLINTmipo;
3226 fq_nmod_poly_t FLINTA, FLINTB;
3230 fq_nmod_poly_divrem (FLINTA, FLINTB, FLINTA, FLINTB,
fq_con);
3239 bool zz_pEbak= zz_pE::initialized();
3247 div (NTLA, NTLA, NTLB);
◆ newtonDivrem() [1/2]
division with remainder of univariate polynomials over Q and Q(a) using Newton inversion, satisfying F=G*Q+R, deg(R) < deg(G)
- Parameters
-
[in] | F | univariate poly |
[in] | G | univariate poly |
[in,out] | Q | quotient |
[in,out] | R | remainder |
Definition at line 342 of file facMul.cc.
345 ASSERT (F.
level() ==
G.level(),
"F and G have different level");
◆ newtonDivrem() [2/2]
division with remainder of F by G wrt Variable (1) modulo M using Newton inversion
- Returns
- Q returns the dividend, R returns the remainder.
- See also
- divrem2(), newtonDiv()
- Parameters
-
[in] | F | bivariate, compressed polynomial |
[in] | G | bivariate, compressed polynomial which is monic in Variable (1) |
[in,out] | Q | dividend |
[in,out] | R | remainder, degree (R, 1) < degree (G, 1) |
[in] | M | power of Variable (2) |
Definition at line 3259 of file facMul.cc.
3299 #if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
3300 nmod_poly_t FLINTmipo;
3308 fq_nmod_poly_t FLINTA, FLINTB;
3312 fq_nmod_poly_divrem (FLINTA, FLINTB, FLINTA, FLINTB,
fq_con);
3327 DivRem (NTLQ, NTLR, NTLA, NTLB);
◆ newtonInverse() [1/2]
Definition at line 3125 of file facMul.cc.
3131 ASSERT (!
g.isZero(),
"expected a unit");
3147 for (
int i= 1;
i <=
l;
i++)
◆ newtonInverse() [2/2]
Definition at line 287 of file facMul.cc.
298 ASSERT (F.
mvar() ==
x,
"main variable of F and x differ");
299 ASSERT (!
g.isZero(),
"expected a unit");
312 for (
int i= 1;
i <=
l;
i++)
◆ prodMod() [1/2]
product of all elements in L modulo M via divide-and-conquer.
- Returns
- prodMod returns product of all elements in L modulo M.
- Parameters
-
[in] | L | contains only bivariate, compressed polynomials |
[in] | M | power of Variable (2) |
Definition at line 3047 of file facMul.cc.
3064 for (
int j= 1;
j <=
l;
j++,
i++)
◆ prodMod() [2/2]
product of all elements in L modulo M via divide-and-conquer.
- Returns
- prodMod returns product of all elements in L modulo M.
- Parameters
-
[in] | L | contains multivariate, compressed polynomials |
[in] | M | contains only powers of Variables |
Definition at line 3074 of file facMul.cc.
3078 else if (L.
length() == 1)
3080 else if (L.
length() == 2)
3088 for (
int j= 1;
j <=
l;
j++,
i++)
◆ reverse()
Definition at line 3101 of file facMul.cc.
3113 while (d -
i.exp() < 0)
3116 for (;
i.hasTerms() && (d -
i.exp() >= 0);
i++)
◆ reverseSubstFp()
Definition at line 1921 of file facMul.cc.
1931 int degf= nmod_poly_degree(F);
1933 int degfSubK, repLength,
j;
1940 repLength= degfSubK + 1;
1943 for (
j= 0;
j < repLength;
j++)
1944 nmod_poly_set_coeff_ui (
buf,
j, nmod_poly_get_coeff_ui (F,
j +
k));
1945 _nmod_poly_normalise (
buf);
◆ reverseSubstFq()
Definition at line 1886 of file facMul.cc.
1895 int degf= fq_nmod_poly_degree(F,
fq_con);
1897 int degfSubK, repLength;
1904 repLength= degfSubK + 1;
1906 fq_nmod_poly_init2 (
buf, repLength,
fq_con);
1907 _fq_nmod_poly_set_length (
buf, repLength,
fq_con);
1908 _fq_nmod_vec_set (
buf->coeffs, F->coeffs+
k, repLength,
fq_con);
◆ reverseSubstQ()
Definition at line 1366 of file facMul.cc.
1374 int degf= fmpz_poly_degree(F);
1376 int degfSubK, repLength;
1383 repLength= degfSubK + 1;
1385 fmpz_poly_init2 (
buf, repLength);
1386 _fmpz_poly_set_length (
buf, repLength);
1387 _fmpz_vec_set (
buf->coeffs, F->coeffs+
k, repLength);
1388 _fmpz_poly_normalise (
buf);
1393 fmpz_poly_clear (
buf);
◆ reverseSubstQa() [1/2]
Definition at line 62 of file facMul.cc.
67 int degf= fmpz_poly_degree (F);
80 repLength= degfSubK + 1;
82 fmpq_poly_init2 (
buf, repLength);
83 _fmpq_poly_set_length (
buf, repLength);
84 _fmpz_vec_set (
buf->coeffs, F->coeffs +
k, repLength);
85 _fmpq_poly_normalise (
buf);
89 fmpq_poly_clear (
buf);
93 fmpq_poly_clear (
mipo);
◆ reverseSubstQa() [2/2]
Definition at line 1472 of file facMul.cc.
1481 int degf= fmpz_poly_degree(F);
1491 repLength= degfSubK + 1;
1495 while (
j*d2 < repLength)
1497 fmpq_poly_init2 (
buf, d2);
1498 _fmpq_poly_set_length (
buf, d2);
1499 _fmpz_vec_set (
buf->coeffs, F->coeffs +
k +
j*d2, d2);
1500 _fmpq_poly_normalise (
buf);
1504 fmpq_poly_clear (
buf);
1506 if (repLength -
j*d2 != 0 &&
j*d2 - repLength < d2)
1510 fmpq_poly_init2 (
buf, repLength);
1511 _fmpq_poly_set_length (
buf, repLength);
1513 _fmpz_vec_set (
buf->coeffs, F->coeffs +
k +
j*d2, repLength);
1514 _fmpq_poly_normalise (
buf);
1517 fmpq_poly_clear (
buf);
◆ reverseSubstReciproFp()
Definition at line 1529 of file facMul.cc.
1538 nmod_poly_set (
f, F);
1539 nmod_poly_set (
g,
G);
1540 int degf= nmod_poly_degree(
f);
1541 int degg= nmod_poly_degree(
g);
1546 if (nmod_poly_length (
f) < (
long) d*(
k+1))
1547 nmod_poly_fit_length (
f,(
long)d*(
k+1));
1553 int degfSubLf= degf;
1554 int deggSubLg=
degg-lg;
1555 int repLengthBuf2, repLengthBuf1, ind, tmp;
1556 while (degf >= lf || lg >= 0)
1560 else if (degfSubLf < 0)
1563 repLengthBuf1= degfSubLf + 1;
1566 for (ind= 0; ind < repLengthBuf1; ind++)
1567 nmod_poly_set_coeff_ui (
buf1, ind, nmod_poly_get_coeff_ui (
f, ind+lf));
1568 _nmod_poly_normalise (
buf1);
1570 repLengthBuf1= nmod_poly_length (
buf1);
1572 if (deggSubLg >= d - 1)
1573 repLengthBuf2= d - 1;
1574 else if (deggSubLg < 0)
1577 repLengthBuf2= deggSubLg + 1;
1580 for (ind= 0; ind < repLengthBuf2; ind++)
1581 nmod_poly_set_coeff_ui (
buf2, ind, nmod_poly_get_coeff_ui (
g, ind + lg));
1583 _nmod_poly_normalise (
buf2);
1584 repLengthBuf2= nmod_poly_length (
buf2);
1587 for (ind= 0; ind < repLengthBuf1; ind++)
1588 nmod_poly_set_coeff_ui (buf3, ind, nmod_poly_get_coeff_ui (
buf1, ind));
1589 for (ind= repLengthBuf1; ind < d; ind++)
1590 nmod_poly_set_coeff_ui (buf3, ind, 0);
1591 for (ind= 0; ind < repLengthBuf2; ind++)
1592 nmod_poly_set_coeff_ui (buf3, ind+d, nmod_poly_get_coeff_ui (
buf2, ind));
1593 _nmod_poly_normalise (buf3);
1600 degfSubLf= degf - lf;
1603 deggSubLg=
degg - lg;
1605 if (lg >= 0 && deggSubLg > 0)
1607 if (repLengthBuf2 > degfSubLf + 1)
1608 degfSubLf= repLengthBuf2 - 1;
1609 tmp=
tmin (repLengthBuf1, deggSubLg + 1);
1610 for (ind= 0; ind < tmp; ind++)
1611 nmod_poly_set_coeff_ui (
g, ind + lg,
1612 n_submod (nmod_poly_get_coeff_ui (
g, ind + lg),
1613 nmod_poly_get_coeff_ui (
buf1, ind),
1627 for (ind= 0; ind < repLengthBuf2; ind++)
1628 nmod_poly_set_coeff_ui (
f, ind + lf,
1629 n_submod (nmod_poly_get_coeff_ui (
f, ind + lf),
1630 nmod_poly_get_coeff_ui (
buf2, ind),
◆ reverseSubstReciproFq()
Definition at line 1648 of file facMul.cc.
1654 fq_nmod_poly_t
f,
g;
1655 int degf= fq_nmod_poly_degree(F,
fq_con);
1662 fq_nmod_poly_set (
f, F,
fq_con);
1664 if (fq_nmod_poly_length (
f,
fq_con) < (
long) d*(
k + 1))
1665 fq_nmod_poly_fit_length (
f, (
long) d*(
k + 1),
fq_con);
1671 int degfSubLf= degf;
1672 int deggSubLg=
degg-lg;
1673 int repLengthBuf2, repLengthBuf1, tmp;
1674 while (degf >= lf || lg >= 0)
1678 else if (degfSubLf < 0)
1681 repLengthBuf1= degfSubLf + 1;
1682 fq_nmod_poly_init2 (
buf1, repLengthBuf1,
fq_con);
1683 _fq_nmod_poly_set_length (
buf1, repLengthBuf1,
fq_con);
1685 _fq_nmod_vec_set (
buf1->coeffs,
f->coeffs + lf, repLengthBuf1,
fq_con);
1688 repLengthBuf1= fq_nmod_poly_length (
buf1,
fq_con);
1690 if (deggSubLg >= d - 1)
1691 repLengthBuf2= d - 1;
1692 else if (deggSubLg < 0)
1695 repLengthBuf2= deggSubLg + 1;
1697 fq_nmod_poly_init2 (
buf2, repLengthBuf2,
fq_con);
1698 _fq_nmod_poly_set_length (
buf2, repLengthBuf2,
fq_con);
1699 _fq_nmod_vec_set (
buf2->coeffs,
g->coeffs + lg, repLengthBuf2,
fq_con);
1702 repLengthBuf2= fq_nmod_poly_length (
buf2,
fq_con);
1704 fq_nmod_poly_init2 (buf3, repLengthBuf2 + d,
fq_con);
1705 _fq_nmod_poly_set_length (buf3, repLengthBuf2 + d,
fq_con);
1706 _fq_nmod_vec_set (buf3->coeffs,
buf1->coeffs, repLengthBuf1,
fq_con);
1707 _fq_nmod_vec_set (buf3->coeffs + d,
buf2->coeffs, repLengthBuf2,
fq_con);
1709 _fq_nmod_poly_normalise (buf3,
fq_con);
1716 degfSubLf= degf - lf;
1719 deggSubLg=
degg - lg;
1721 if (lg >= 0 && deggSubLg > 0)
1723 if (repLengthBuf2 > degfSubLf + 1)
1724 degfSubLf= repLengthBuf2 - 1;
1725 tmp=
tmin (repLengthBuf1, deggSubLg + 1);
1726 _fq_nmod_vec_sub (
g->coeffs + lg,
g->coeffs + lg,
buf1->
coeffs,
1737 _fq_nmod_vec_sub (
f->coeffs + lf,
f->coeffs + lf,
buf2->coeffs,
◆ reverseSubstReciproQ()
Definition at line 1752 of file facMul.cc.
1760 fmpz_poly_set (
f, F);
1761 fmpz_poly_set (
g,
G);
1762 int degf= fmpz_poly_degree(
f);
1763 int degg= fmpz_poly_degree(
g);
1767 if (fmpz_poly_length (
f) < (
long) d*(
k+1))
1768 fmpz_poly_fit_length (
f,(
long)d*(
k+1));
1774 int degfSubLf= degf;
1775 int deggSubLg=
degg-lg;
1776 int repLengthBuf2, repLengthBuf1, ind, tmp;
1778 while (degf >= lf || lg >= 0)
1782 else if (degfSubLf < 0)
1785 repLengthBuf1= degfSubLf + 1;
1787 fmpz_poly_init2 (
buf1, repLengthBuf1);
1789 for (ind= 0; ind < repLengthBuf1; ind++)
1791 fmpz_poly_get_coeff_fmpz (
tmp1,
f, ind + lf);
1792 fmpz_poly_set_coeff_fmpz (
buf1, ind,
tmp1);
1794 _fmpz_poly_normalise (
buf1);
1796 repLengthBuf1= fmpz_poly_length (
buf1);
1798 if (deggSubLg >= d - 1)
1799 repLengthBuf2= d - 1;
1800 else if (deggSubLg < 0)
1803 repLengthBuf2= deggSubLg + 1;
1805 fmpz_poly_init2 (
buf2, repLengthBuf2);
1807 for (ind= 0; ind < repLengthBuf2; ind++)
1809 fmpz_poly_get_coeff_fmpz (
tmp1,
g, ind + lg);
1810 fmpz_poly_set_coeff_fmpz (
buf2, ind,
tmp1);
1813 _fmpz_poly_normalise (
buf2);
1814 repLengthBuf2= fmpz_poly_length (
buf2);
1816 fmpz_poly_init2 (buf3, repLengthBuf2 + d);
1817 for (ind= 0; ind < repLengthBuf1; ind++)
1819 fmpz_poly_get_coeff_fmpz (
tmp1,
buf1, ind);
1820 fmpz_poly_set_coeff_fmpz (buf3, ind,
tmp1);
1822 for (ind= repLengthBuf1; ind < d; ind++)
1823 fmpz_poly_set_coeff_ui (buf3, ind, 0);
1824 for (ind= 0; ind < repLengthBuf2; ind++)
1826 fmpz_poly_get_coeff_fmpz (
tmp1,
buf2, ind);
1827 fmpz_poly_set_coeff_fmpz (buf3, ind + d,
tmp1);
1829 _fmpz_poly_normalise (buf3);
1836 degfSubLf= degf - lf;
1839 deggSubLg=
degg - lg;
1841 if (lg >= 0 && deggSubLg > 0)
1843 if (repLengthBuf2 > degfSubLf + 1)
1844 degfSubLf= repLengthBuf2 - 1;
1845 tmp=
tmin (repLengthBuf1, deggSubLg + 1);
1846 for (ind= 0; ind < tmp; ind++)
1848 fmpz_poly_get_coeff_fmpz (
tmp1,
g, ind + lg);
1849 fmpz_poly_get_coeff_fmpz (
tmp2,
buf1, ind);
1851 fmpz_poly_set_coeff_fmpz (
g, ind + lg,
tmp1);
1856 fmpz_poly_clear (
buf1);
1857 fmpz_poly_clear (
buf2);
1858 fmpz_poly_clear (buf3);
1863 for (ind= 0; ind < repLengthBuf2; ind++)
1865 fmpz_poly_get_coeff_fmpz (
tmp1,
f, ind + lf);
1866 fmpz_poly_get_coeff_fmpz (
tmp2,
buf2, ind);
1868 fmpz_poly_set_coeff_fmpz (
f, ind + lf,
tmp1);
1871 fmpz_poly_clear (
buf1);
1872 fmpz_poly_clear (
buf2);
1873 fmpz_poly_clear (buf3);
1876 fmpz_poly_clear (
f);
1877 fmpz_poly_clear (
g);
◆ split()
Definition at line 3336 of file facMul.cc.
3343 else if (
x.
level() !=
A.level())
3354 while (
i.hasTerms() &&
i.exp() -
j*
m >= 0)
◆ uniFdivides()
divisibility test for univariate polys
- Returns
- uniFdivides returns true if A divides B
- Parameters
-
[in] | A | univariate poly |
[in] | B | univariate poly |
Definition at line 3626 of file facMul.cc.
3637 if (
A.inCoeffDomain())
3652 #if (HAVE_FLINT && __FLINT_RELEASE >= 20400)
3653 nmod_poly_t FLINTmipo;
3661 fq_nmod_poly_t FLINTA, FLINTB;
3664 int result= fq_nmod_poly_divides (FLINTA, FLINTB, FLINTA,
fq_con);
3672 zz_pE::init (NTLMipo);
3675 return divide (NTLB, NTLA);
3679 nmod_poly_t FLINTA, FLINTB;
3682 nmod_poly_divrem (FLINTB, FLINTA, FLINTB, FLINTA);
3683 bool result= nmod_poly_is_zero (FLINTA);
3690 return divide (NTLB, NTLA);
3700 fmpq_poly_t FLINTA,FLINTB;
3703 fmpq_poly_rem (FLINTA, FLINTB, FLINTA);
3704 bool result= fmpq_poly_is_zero (FLINTA);
3705 fmpq_poly_clear (FLINTA);
3706 fmpq_poly_clear (FLINTB);
◆ uniReverse()
Definition at line 270 of file facMul.cc.
278 while (d -
i.exp() < 0)
281 for (;
i.hasTerms() && (d -
i.exp() >= 0);
i++)
CanonicalForm prodMod(const CFList &L, const CanonicalForm &M)
product of all elements in L modulo M via divide-and-conquer.
CanonicalForm mulMod2FLINTFqReci(const CanonicalForm &F, const CanonicalForm &G, const CanonicalForm &M, const Variable &alpha, const fq_nmod_ctx_t fq_con)
CanonicalForm reverseSubstQa(const fmpz_poly_t F, int d, const Variable &x, const Variable &alpha, const CanonicalForm &den)
fq_nmod_poly_init(prod, fq_con)
CanonicalForm convertnmod_poly_t2FacCF(const nmod_poly_t poly, const Variable &x)
conversion of a FLINT poly over Z/p to CanonicalForm
static const int SW_RATIONAL
set to 1 for computations over Q
zz_pX convertFacCF2NTLzzpX(const CanonicalForm &f)
CanonicalForm reverseSubstReciproFq(const fq_nmod_poly_t F, const fq_nmod_poly_t G, int d, int k, const Variable &alpha, const fq_nmod_ctx_t fq_con)
class to iterate through CanonicalForm's
#define DEBOUTLN(stream, objects)
const CanonicalForm int const CFList const Variable & y
ZZ_pEX convertFacCF2NTLZZ_pEX(const CanonicalForm &f, const ZZ_pX &mipo)
CanonicalForm in Z_p(a)[X] to NTL ZZ_pEX.
void kronSubFp(nmod_poly_t result, const CanonicalForm &A, int d)
nmod_poly_clear(FLINTmipo)
void convertCF2Fmpz(fmpz_t result, const CanonicalForm &f)
conversion of a factory integer to fmpz_t
CanonicalForm convertNTLZZ_pEX2CF(const ZZ_pEX &f, const Variable &x, const Variable &alpha)
void kronSubFq(fq_nmod_poly_t result, const CanonicalForm &A, int d, const fq_nmod_ctx_t fq_con)
void convertFacCF2Fq_t(fq_t result, const CanonicalForm &f, const fq_ctx_t ctx)
conversion of a factory element of F_q (for non-word size p) to a FLINT fq_t
void divrem(const CanonicalForm &F, const CanonicalForm &G, CanonicalForm &Q, CanonicalForm &R, const CFList &MOD)
division with remainder of F by G wrt Variable (1) modulo MOD. Uses an algorithm based on Burnikel,...
CanonicalForm mulMod2FLINTFpReci(const CanonicalForm &F, const CanonicalForm &G, const CanonicalForm &M)
const signed long floor(const ampf< Precision > &x)
CanonicalForm reverseSubstFp(const nmod_poly_t F, int d)
CanonicalForm convertNTLZZpX2CF(const ZZ_pX &poly, const Variable &x)
NAME: convertNTLZZpX2CF.
CanonicalForm mulMod2FLINTFp(const CanonicalForm &F, const CanonicalForm &G, const CanonicalForm &M)
CanonicalForm mulFLINTQ(const CanonicalForm &F, const CanonicalForm &G)
const signed long ceil(const ampf< Precision > &x)
void kronSubReciproFp(nmod_poly_t subA1, nmod_poly_t subA2, const CanonicalForm &A, int d)
CanonicalForm modFLINTQ(const CanonicalForm &F, const CanonicalForm &G)
CanonicalForm reverseSubstQ(const fmpz_poly_t F, int d)
void convertFacCF2Fq_nmod_poly_t(fq_nmod_poly_t result, const CanonicalForm &f, const fq_nmod_ctx_t ctx)
conversion of a factory univariate poly over F_q to a FLINT fq_nmod_poly_t
#define GaloisFieldDomain
CanonicalForm convertFq_nmod_poly_t2FacCF(const fq_nmod_poly_t p, const Variable &x, const Variable &alpha, const fq_nmod_ctx_t ctx)
conversion of a FLINT poly over Fq to a CanonicalForm with alg. variable alpha and polynomial variabl...
static void divrem32(const CanonicalForm &F, const CanonicalForm &G, CanonicalForm &Q, CanonicalForm &R, const CFList &M)
convertFacCF2nmod_poly_t(FLINTmipo, M)
CanonicalForm getMipo(const Variable &alpha, const Variable &x)
zz_pEX convertFacCF2NTLzz_pEX(const CanonicalForm &f, const zz_pX &mipo)
CanonicalForm mulNTL(const CanonicalForm &F, const CanonicalForm &G, const modpk &b)
multiplication of univariate polys using FLINT/NTL over F_p, F_q, Z/p^k, Z/p^k[t]/(f),...
CanonicalForm reverseSubstReciproFp(const nmod_poly_t F, const nmod_poly_t G, int d, int k)
#define ASSERT(expression, message)
fq_nmod_ctx_clear(fq_con)
template List< Variable > Difference(const List< Variable > &, const List< Variable > &)
int status int void * buf
void kronSubQa(fmpz_poly_t result, const CanonicalForm &A, int d)
nmod_poly_init(FLINTmipo, getCharacteristic())
CanonicalForm convertNTLzz_pEX2CF(const zz_pEX &f, const Variable &x, const Variable &alpha)
template CanonicalForm tmin(const CanonicalForm &, const CanonicalForm &)
CanonicalForm mulFLINTQaTrunc(const CanonicalForm &F, const CanonicalForm &G, const Variable &alpha, int m)
CanonicalForm mulMod2FLINTQa(const CanonicalForm &F, const CanonicalForm &G, const CanonicalForm &M)
CanonicalForm mulFLINTQTrunc(const CanonicalForm &F, const CanonicalForm &G, int m)
ZZ_pX convertFacCF2NTLZZpX(const CanonicalForm &f)
NAME: convertFacCF2NTLZZpX.
ZZX convertFacCF2NTLZZX(const CanonicalForm &f)
CanonicalForm mulMod2(const CanonicalForm &A, const CanonicalForm &B, const CanonicalForm &M)
Karatsuba style modular multiplication for bivariate polynomials.
CanonicalForm reverseSubstFq(const fq_nmod_poly_t F, int d, const Variable &alpha, const fq_nmod_ctx_t fq_con)
bool fdivides(const CanonicalForm &f, const CanonicalForm &g)
bool fdivides ( const CanonicalForm & f, const CanonicalForm & g )
void newtonDivrem(const CanonicalForm &F, const CanonicalForm &G, CanonicalForm &Q, CanonicalForm &R)
division with remainder of univariate polynomials over Q and Q(a) using Newton inversion,...
CanonicalForm mulFLINTQa(const CanonicalForm &F, const CanonicalForm &G, const Variable &alpha)
fq_nmod_ctx_init_modulus(fq_con, FLINTmipo, "Z")
CanonicalForm mulMod2FLINTFq(const CanonicalForm &F, const CanonicalForm &G, const CanonicalForm &M, const Variable &alpha, const fq_nmod_ctx_t fq_con)
void divrem2(const CanonicalForm &F, const CanonicalForm &G, CanonicalForm &Q, CanonicalForm &R, const CanonicalForm &M)
division with remainder of F by G wrt Variable (1) modulo M. Uses an algorithm based on Burnikel,...
gmp_float exp(const gmp_float &a)
template CanonicalForm tmax(const CanonicalForm &, const CanonicalForm &)
void convertFacCF2Fmpq_poly_t(fmpq_poly_t result, const CanonicalForm &f)
conversion of a factory univariate polynomials over Q to fmpq_poly_t
static CFList split(const CanonicalForm &F, const int m, const Variable &x)
CanonicalForm convertFmpz_poly_t2FacCF(const fmpz_poly_t poly, const Variable &x)
conversion of a FLINT poly over Z to CanonicalForm
void convertFacCF2Fmpz_mod_poly_t(fmpz_mod_poly_t result, const CanonicalForm &f, const fmpz_t p)
conversion of a factory univariate poly over Z to a FLINT poly over Z/p (for non word size p)
CanonicalForm mulMod(const CanonicalForm &A, const CanonicalForm &B, const CFList &MOD)
Karatsuba style modular multiplication for multivariate polynomials.
void newtonDiv(const CanonicalForm &F, const CanonicalForm &G, CanonicalForm &Q)
CanonicalForm bCommonDen(const CanonicalForm &f)
CanonicalForm bCommonDen ( const CanonicalForm & f )
CanonicalForm divide(const CanonicalForm &ff, const CanonicalForm &f, const CFList &as)
factory's class for variables
CanonicalForm mulMod2NTLFq(const CanonicalForm &F, const CanonicalForm &G, const CanonicalForm &M)
CanonicalForm convertFmpq_poly_t2FacCF(const fmpq_poly_t p, const Variable &x)
conversion of a FLINT poly over Q to CanonicalForm
CanonicalForm divFLINTQ(const CanonicalForm &F, const CanonicalForm &G)
CanonicalForm mod(const CanonicalForm &F, const CFList &M)
reduce F modulo elements in M.
CanonicalForm reverseSubstReciproQ(const fmpz_poly_t F, const fmpz_poly_t G, int d, int k)
static void divrem21(const CanonicalForm &F, const CanonicalForm &G, CanonicalForm &Q, CanonicalForm &R, const CFList &M)
CanonicalForm reverse(const CanonicalForm &F, int d)
CanonicalForm convertFq_poly_t2FacCF(const fq_poly_t p, const Variable &x, const Variable &alpha, const fq_ctx_t ctx)
conversion of a FLINT poly over Fq (for non-word size p) to a CanonicalForm with alg....
void kronSubReciproQ(fmpz_poly_t subA1, fmpz_poly_t subA2, const CanonicalForm &A, int d)
CanonicalForm mulMod2FLINTQ(const CanonicalForm &F, const CanonicalForm &G, const CanonicalForm &M)
CanonicalForm convertNTLZZX2CF(const ZZX &polynom, const Variable &x)
const Variable & v
< [in] a sqrfree bivariate poly
void kronSubReciproFq(fq_nmod_poly_t subA1, fq_nmod_poly_t subA2, const CanonicalForm &A, int d, const fq_nmod_ctx_t fq_con)
CanonicalForm uniReverse(const CanonicalForm &F, int d, const Variable &x)
CanonicalForm convertFq_t2FacCF(const fq_t poly, const Variable &alpha)
conversion of a FLINT element of F_q with non-word size p to a CanonicalForm with alg....
CanonicalForm newtonInverse(const CanonicalForm &F, const int n, const Variable &x)
void convertFacCF2Fq_poly_t(fq_poly_t result, const CanonicalForm &f, const fq_ctx_t ctx)
conversion of a factory univariate poly over F_q (for non-word size p) to a FLINT fq_poly_t
fq_nmod_poly_clear(prod, fq_con)
bool getReduce(const Variable &alpha)
void convertFacCF2Fmpz_poly_t(fmpz_poly_t result, const CanonicalForm &f)
conversion of a factory univariate polynomial over Z to a fmpz_poly_t
ZZ convertFacCF2NTLZZ(const CanonicalForm &f)
NAME: convertFacCF2NTLZZX.
void rem(unsigned long *a, unsigned long *q, unsigned long p, int °a, int degq)
CanonicalForm convertNTLzzpX2CF(const zz_pX &poly, const Variable &x)
CanonicalForm convertFmpz_mod_poly_t2FacCF(const fmpz_mod_poly_t poly, const Variable &x, const modpk &b)
conversion of a FLINT poly over Z/p (for non word size p) to a CanonicalForm over Z