18 mpz_init_set_ui(coef[0],0);
28 for (
int i=0;
i<=n;
i++)
30 mpz_init_set(coef[
i], a[i]);
61 for (
int i=0;
i<=b.
deg;
i++)
68 mpz_init_set(coef[
i],a.
coef[i]);
73 while(mpz_sgn(coef[i])==0 && i>=0)
77 else {poly_add(b,a); }
85 this->poly_add(*
this,g);
96 mpz_add(coef[0],coef[0],a);
98 if (deg==0 && mpz_sgn(coef[0])==0)
109 this->poly_add_const(*
this,a);
117 if (i<=deg && is_zero()==0)
119 mpz_add(coef[i],coef[i],a);
121 if (deg==i && mpz_sgn(coef[i])==0)
124 else if (is_zero()==1)
127 for(
int j=0;
j<=
i;
j++)
129 mpz_init_set_ui(coef[
j],0);
131 mpz_add(coef[i],coef[i],a);
136 for(
int j=i;
j>deg;
j--)
138 mpz_init_set_ui(coef[
j],0);
140 mpz_add(coef[i],coef[i],a);
148 if (i<=deg && is_zero()==0)
150 mpz_add(coef[i],coef[i],a);
152 else if (is_zero()==1)
155 for(
int j=0;
j<=
i;
j++)
157 mpz_init_set_ui(coef[
j],0);
159 mpz_add(coef[i],coef[i],a);
164 for(
int j=i;
j>deg;
j--)
166 mpz_init_set_ui(coef[
j],0);
168 mpz_add(coef[i],coef[i],a);
173 while(mpz_sgn(coef[k])==0 && k>=0)
190 while(mpz_sgn(coef[i])==0 && i>=0)
200 this->poly_sub(*
this,b);
214 mpz_sub(coef[0],coef[0],a);
219 while(mpz_sgn(coef[i])==0 && i>=0)
229 this->poly_sub_const(*
this,a);
238 if (i<=deg && is_zero()!=1)
240 mpz_sub(coef[i],coef[i],a);
242 if (deg==i && mpz_sgn(coef[i])==0)
245 else if (is_zero()==1)
247 for(
int j=0;
j<=
i;
j++)
249 mpz_init_set_ui(coef[
j],0);
251 mpz_sub(coef[i],coef[i],a);
256 for(
int j=i;
j>deg;
j--)
258 mpz_init_set_ui(coef[
j],0);
260 mpz_sub(coef[i],coef[i],a);
269 if (i<=deg && is_zero()!=1)
271 mpz_sub(coef[i],coef[i],a);
273 if (deg==i && mpz_sgn(coef[i])==0)
276 else if (is_zero()==1)
278 for(
int j=0;
j<=
i;
j++)
280 mpz_init_set_ui(coef[
j],0);
282 mpz_sub(coef[i],coef[i],a);
287 for(
int j=i;
j>deg;
j--)
289 mpz_init_set_ui(coef[
j],0);
291 mpz_sub(coef[i],coef[i],a);
309 for (
int i=deg;
i>=n;
i--)
311 mpz_init_set(coef[
i],f.
coef[i-n]);
313 for (
int i=n-1;
i>=0;
i--)
315 mpz_init_set_ui(coef[
i],0);
322 this->poly_mon_mult(*
this,n);
336 mpz_init_set_ui(temp,0);
337 for(
int i=0;
i<=deg;
i++)
339 mpz_mul(temp,n,g.
coef[
i]);
340 mpz_init_set(coef[
i],temp);
355 mpz_init_set_ui(temp,0);
356 for(
int i=0;
i<=deg;
i++)
358 mpz_mul(temp,n,g.
coef[
i]);
359 mpz_init_set(coef[
i],temp);
367 this->poly_scalar_mult(*
this,n);
376 for (
int i=0;
i<=deg;
i++)
378 mpz_neg(coef[
i],coef[i]);
393 mpz_init_set_ui(temp,0);
400 for(
int i=a.
deg+1;
i<=deg;
i++)
402 mpz_init_set_ui(atemp.
coef[
i],0);
404 for(
int i=b.
deg+1;
i<=deg;
i++)
406 mpz_init_set_ui(btemp.
coef[
i],0);
412 for (
int k=0;
k<=deg;
k++)
414 mpz_init_set_ui(coef[
k],0);
415 for (
int i=0;
i<=
k;
i++)
418 mpz_add(coef[k],coef[k],temp);
429 this->poly_mult_n(*
this,g);
448 n =
static_cast<int>(ceil(
log(n)/
log(2)));
449 n =
static_cast<int>(
pow(2,n));
496 mpz_init_set_ui(temp,0);
497 for(
int i=0;
i<=deg;
i++)
499 mpz_divexact(temp,g.
coef[
i],n);
500 mpz_init_set(coef[
i],temp);
507 this->poly_scalar_div(*
this,n);
520 for (
int i=0;
i<=f.
deg-n;
i++)
522 mpz_init_set(coef[
i],f.
coef[n+i]);
537 for (
int i=0;
i<=n-1;
i++)
539 mpz_init_set(coef[
i],f.
coef[i]);
557 mpz_init_set_ui(a,0);
581 this->poly_div( Q, R,*
this,B);
617 this->poly_pseudodiv_rem(*
this,B);
638 for (
int i=0;
i<=
k;
i++)
640 mpz_init_set_ui(Q.
coef[
i],0);
662 mpz_init_set_ui(dummy,0);
666 if (mpz_cmp_ui(Q.
coef[
i],0)!=0)
668 mpz_pow_ui(dummy,B.
coef[B.
deg],delta);
685 this->poly_pseudodiv(Q, R,*
this,B);
724 mpz_init_set_ui(cont,0);
730 mpz_init_set(temp,coef[0]);
731 while (mpz_cmp_ui(temp,1)!=0 && i<=deg)
733 mpz_gcd(temp,temp,coef[i]);
736 mpz_init_set(cont,temp);
751 if (mpz_cmp_ui(cont,1)==0)
756 for (
int i=0;
i<=deg;
i++)
758 mpz_init_set_ui(coef[
i],0);
759 mpz_divexact(coef[i],f.
coef[i],cont);
770 mpz_init_set(erg,coef[deg]);
771 for (
int i=deg;
i>=1;
i--)
774 mpz_add(erg,erg,coef[
i-1]);
783 for (
int i=A.
deg;
i>=1;
i--)
786 poly_add_const_to(A.
coef[
i-1]);
799 for(
int i=0;
i<=deg;
i++)
801 mpz_init_set(coef[
i],b.
coef[i]);
810 mpz_init_set(coef[0],b);
829 for (
int i=deg;
i>=0;
i--)
831 if (mpz_cmp(coef[
i],g.
coef[i])!=0)
852 if (mpz_cmpabs_ui(coef[0],1)==0) {
return 1; }
860 if (mpz_cmpabs_ui(coef[deg],1)==0)
919 mpz_init_set_ui(a,0);
921 mpz_init_set_ui(b,0);
923 mpz_init_set_ui(d,0);
949 mpz_init_set(coef[0],d);
954 poly_scalar_mult_to(d);
963 this->poly_ppgcd(*
this,B);
986 mpz_init_set_ui(a,0);
988 mpz_init_set_ui(b,0);
990 mpz_init_set_ui(d,0);
992 mpz_init_set_ui(h,1);
994 mpz_init_set_ui(g,1);
996 mpz_init_set_ui(temp1,0);
998 mpz_init_set_ui(temp2,0);
1020 mpz_pow_ui(temp1,h,delta);
1021 mpz_mul(temp2,temp1,g);
1027 mpz_pow_ui(temp1,h,1-delta);
1028 mpz_pow_ui(temp2,g,delta);
1029 mpz_mul(h,temp1,temp2);
1041 mpz_init_set(coef[0],d);
1047 poly_scalar_mult_to(d);
1048 poly_scalar_div_to(temp1);
1057 this->poly_subgcd(*
this,B);
1066 poly_extsubgcd(t,r,g,B,A);
1073 mpz_init_set_ui(temp,1);
1089 mpz_init_set_ui(temp,1);
1090 mpz_init_set_ui(base,1);
1091 mpz_init_set_ui(base2,1);
1092 mpz_init_set_ui(base3,1);
1093 mpz_init_set_ui(psi,1);
1129 mpz_set_si(temp,-1);
1132 mpz_init_set_ui(temp2,0);
1133 mpz_pow_ui(temp2,f2.
coef[f2.
deg],alpha);
1138 mpz_pow_ui(base,temp,alpha);
1143 mpz_pow_ui(base2,f2.
coef[f2.
deg],alpha);
1147 mpz_pow_ui(base,temp,delta);
1175 mpz_pow_ui(temp2,f2.
coef[f2.
deg],alpha);
1180 mpz_pow_ui(base,psi,delta);
1181 mpz_pow_ui(base2,f1.
coef[f1.
deg],delta);
1184 mpz_mul(base2,base2,psi);
1185 mpz_divexact(psi,base2,base);
1189 mpz_pow_ui(base,temp,alpha);
1190 mpz_pow_ui(base2,psi,delta2);
1191 mpz_mul(base2,base2,f1.
coef[f1.
deg]);
1198 mpz_pow_ui(base3,f2.
coef[f2.
deg],alpha);
1248 cout <<
"Bitte geben Sie ein int_polynom ein! Zunächst den Grad: " << endl;
1252 for (
int i=0;
i<=deg;
i++)
1254 mpz_init_set_ui(coef[
i],0);
1255 printf(
"Geben Sie nun f[%i] ein:",i);
1256 mpz_inp_str(coef[i],stdin, 10);
1267 cout <<
"0" <<
"\n" <<endl;
1270 for (
int i=deg;
i>=1;
i--)
1272 mpz_out_str(stdout,10, coef[
i]);
1275 mpz_out_str(stdout,10, coef[0]);
void poly_scalar_div(const int_poly, const mpz_t)
void poly_mon_mult_to(const int)
void poly_pseudodiv_to(int_poly &, int_poly &, int_poly)
void poly_gcd(int_poly, int_poly)
void poly_mon_mult(const int_poly, const int)
void poly_multsub_to(const int_poly, const int_poly)
void poly_add_mon_to(mpz_t, int)
void poly_sub_const_to(const mpz_t)
void poly_sub_to(const int_poly)
void poly_pseudodiv_rem_to(const int_poly)
void poly_subgcd(int_poly, int_poly)
void poly_sub(const int_poly, const int_poly)
void poly_scalar_mult_to(const mpz_t)
void poly_subgcd_to(int_poly)
gmp_float log(const gmp_float &a)
void poly_add(const int_poly, const int_poly)
void poly_mult_n(int_poly, int_poly)
void poly_pseudodiv_rem(int_poly, int_poly)
void poly_ppgcd_to(int_poly)
void poly_sub_mon(const int_poly, mpz_t, int)
bool delta(X x, Y y, D d)
void poly_multadd_to(const int_poly, const int_poly)
void poly_ppgcd(int_poly, int_poly)
void poly_add_const_to(const mpz_t)
int is_equal(const int_poly) const
void poly_set(const int_poly)
void poly_horner(mpz_t, const mpz_t)
void poly_div_to(int_poly &, int_poly &, const int_poly)
void poly_mon_div_rem(const int_poly, const int)
void poly_mult_n_to(const int_poly)
void poly_add_mon(const int_poly, mpz_t, int)
void poly_sub_mon_to(mpz_t, int)
void poly_add_const(int_poly, const mpz_t)
void poly_pseudodiv(int_poly &, int_poly &, int_poly, int_poly)
void poly_scalar_div_to(const mpz_t)
void poly_sub_const(int_poly, const mpz_t)
void poly_scalar_mult(const mpz_t, const int_poly)
void poly_extsubgcd(int_poly &, int_poly &, int_poly &, int_poly, int_poly)
void poly_div(int_poly &, int_poly &, int_poly, int_poly)
void poly_mon_div(const int_poly, const int)
void poly_mult_ka(int_poly, int_poly)
Rational pow(const Rational &a, int e)
void poly_horner_int_poly(int_poly, const int_poly)
void poly_add_to(const int_poly)