1 | #ifndef QPOLY |
---|
2 | #define QPOLY |
---|
3 | |
---|
4 | |
---|
5 | #include <gmp.h> |
---|
6 | #include <omalloc/omalloc.h> |
---|
7 | |
---|
8 | |
---|
9 | class Q_poly // Klasse von Q_polynomen mit Typ (Grad, Koeffizienten ganzzahlig) |
---|
10 | { |
---|
11 | |
---|
12 | public: |
---|
13 | // Charakteristika der Q_polynome (TO DO??: Dynamisches Array) |
---|
14 | |
---|
15 | int deg; // Grad des Q_polynoms |
---|
16 | mpz_t denom; // Hauptnenner der Koeffizienten |
---|
17 | mpz_t coef[100]; // Feld der Koeffizienten |
---|
18 | //mpz_t coef = reinterpret_cast<mpz_t*> (omAlloc(100*sizeof(mpz_t))); |
---|
19 | |
---|
20 | |
---|
21 | // Konstruktoren und Destruktoren |
---|
22 | Q_poly(); |
---|
23 | Q_poly( int ,mpz_t, mpz_t*); |
---|
24 | //Q_poly(int_poly,int); |
---|
25 | //~Q_poly(); |
---|
26 | |
---|
27 | //Reduktion modulo p |
---|
28 | Q_poly Q_poly_reduce(); |
---|
29 | Q_poly Q_poly_extend(mpz_t); |
---|
30 | |
---|
31 | // Arithmetische Operationen |
---|
32 | |
---|
33 | |
---|
34 | // Additionen |
---|
35 | |
---|
36 | Q_poly Q_poly_add(const Q_poly , const Q_poly ); |
---|
37 | Q_poly Q_poly_add_to(const Q_poly); |
---|
38 | Q_poly Q_poly_add_mon(const Q_poly,mpz_t, int); //addiert Monome zu Q_polynom |
---|
39 | Q_poly Q_poly_add_mon_to(mpz_t,int); |
---|
40 | Q_poly Q_poly_add_const( Q_poly, const mpz_t); |
---|
41 | Q_poly Q_poly_add_const_to(const mpz_t); |
---|
42 | |
---|
43 | // Subtraktion |
---|
44 | |
---|
45 | Q_poly Q_poly_sub(const Q_poly , const Q_poly ); |
---|
46 | Q_poly Q_poly_sub_to(const Q_poly); |
---|
47 | Q_poly Q_poly_sub_mon(const Q_poly,mpz_t,int); |
---|
48 | Q_poly Q_poly_sub_mon_to(mpz_t,int); |
---|
49 | Q_poly Q_poly_sub_const( Q_poly, const mpz_t); |
---|
50 | Q_poly Q_poly_sub_const_to(const mpz_t); |
---|
51 | |
---|
52 | //Multiplikationen |
---|
53 | |
---|
54 | Q_poly Q_poly_mult_n(Q_poly,Q_poly); |
---|
55 | Q_poly Q_poly_mult_n_to(const Q_poly); |
---|
56 | Q_poly Q_poly_mult_ka(const Q_poly, const Q_poly); |
---|
57 | Q_poly Q_poly_scalar_mult(const mpz_t ,const Q_poly); |
---|
58 | Q_poly Q_poly_scalar_mult(const Q_poly, const mpz_t); |
---|
59 | Q_poly Q_poly_scalar_mult_to(const mpz_t); |
---|
60 | Q_poly Q_poly_neg(); |
---|
61 | Q_poly Q_poly_mon_mult(const Q_poly, const int); |
---|
62 | Q_poly Q_poly_mon_mult_to(const int); |
---|
63 | |
---|
64 | //Divisionen |
---|
65 | Q_poly Q_poly_div(Q_poly&, Q_poly&,const Q_poly, const Q_poly); // exakte Division |
---|
66 | Q_poly Q_poly_div_to(Q_poly&, Q_poly&,const Q_poly); // To Variante exakte Division |
---|
67 | Q_poly Q_poly_scalar_div(const Q_poly, const mpz_t); // Dividiert Polynom durch ganze Zahl |
---|
68 | Q_poly Q_poly_scalar_div_to(const mpz_t); |
---|
69 | Q_poly Q_poly_div_rem(const Q_poly, const Q_poly); //Division mit Rest |
---|
70 | Q_poly Q_poly_div_rem_to(const Q_poly); |
---|
71 | Q_poly Q_poly_mon_div(const Q_poly, const int); //Division durch Monom |
---|
72 | Q_poly Q_poly_mon_div_rem(const Q_poly, const int); |
---|
73 | |
---|
74 | //Kombinationen |
---|
75 | |
---|
76 | Q_poly Q_poly_multadd_to(const Q_poly, const Q_poly); //a=a*b+c |
---|
77 | Q_poly Q_poly_multsub_to(const Q_poly,const Q_poly); //a=a*b-c |
---|
78 | //Q_poly Q_poly_addmult_to(const Q_poly, const Q_poly); |
---|
79 | |
---|
80 | |
---|
81 | |
---|
82 | |
---|
83 | // Sonstige Operationen |
---|
84 | Q_poly Q_poly_set(const Q_poly); |
---|
85 | Q_poly Q_poly_set(const mpz_t); // Setzt Q_polynom auf Konstante aus Z |
---|
86 | Q_poly Q_poly_set(const mpz_t, const mpz_t); // Setzt Q_polynom auf Konstante aus Q |
---|
87 | Q_poly Q_poly_set_zero(); // Setzt Q_polynom auf 0 |
---|
88 | void Q_poly_horner(mpz_t, const mpz_t); // Wertet Q_polynom mittels Horner-Schema an einer Stelle aus |
---|
89 | void Q_poly_horner_Q_poly(Q_poly, const Q_poly); //Setzt Q_polynom in Q_polynom mittels Horner Schema ein |
---|
90 | Q_poly Q_poly_gcd(Q_poly,Q_poly); //Standard GGT |
---|
91 | Q_poly Q_poly_extgcd(Q_poly &,Q_poly &,Q_poly &, Q_poly, Q_poly); //Erweiterter Standard GGT |
---|
92 | int is_equal(Q_poly &); // Test auf Gleichheit |
---|
93 | int is_zero(); // Test auf Gleichheit mit 0 |
---|
94 | int is_one(); // Test auf Gleichheit mit 1 |
---|
95 | int is_monic(); // testet, ob das Q_polynom normiert ist |
---|
96 | |
---|
97 | // Ein und Ausgabe |
---|
98 | void Q_poly_insert(); // Eingabe von Q_polynom |
---|
99 | void Q_poly_print(); //Ausgabe von Q_polynom |
---|
100 | |
---|
101 | |
---|
102 | }; |
---|
103 | |
---|
104 | #endif |
---|
105 | |
---|
106 | |
---|