compressing two polynomials F and G, M is used for compressing, N to reverse the compression
| 90 | /// compressing two polynomials F and G, M is used for compressing, |
| 91 | /// N to reverse the compression |
| 92 | int myCompress (const CanonicalForm& F, const CanonicalForm& G, CFMap & M, |
| 93 | CFMap & N, bool topLevel) |
| 94 | { |
| 95 | int n= tmax (F.level(), G.level()); |
| 96 | int * degsf= NEW_ARRAY(int,n + 1); |
| 97 | int * degsg= NEW_ARRAY(int,n + 1); |
| 98 | |
| 99 | for (int i = n; i >= 0; i--) |
| 100 | degsf[i]= degsg[i]= 0; |
| 101 | |
| 102 | degsf= degrees (F, degsf); |
| 103 | degsg= degrees (G, degsg); |
| 104 | |
| 105 | int both_non_zero= 0; |
| 106 | int f_zero= 0; |
| 107 | int g_zero= 0; |
| 108 | int both_zero= 0; |
| 109 | |
| 110 | if (topLevel) |
| 111 | { |
| 112 | for (int i= 1; i <= n; i++) |
| 113 | { |
| 114 | if (degsf[i] != 0 && degsg[i] != 0) |
| 115 | { |
| 116 | both_non_zero++; |
| 117 | continue; |
| 118 | } |
| 119 | if (degsf[i] == 0 && degsg[i] != 0 && i <= G.level()) |
| 120 | { |
| 121 | f_zero++; |
| 122 | continue; |
| 123 | } |
| 124 | if (degsg[i] == 0 && degsf[i] && i <= F.level()) |
| 125 | { |
| 126 | g_zero++; |
| 127 | continue; |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | if (both_non_zero == 0) |
| 132 | { |
| 133 | DELETE_ARRAY(degsf); |
| 134 | DELETE_ARRAY(degsg); |
| 135 | return 0; |
| 136 | } |
| 137 | |
| 138 | // map Variables which do not occur in both polynomials to higher levels |
| 139 | int k= 1; |
| 140 | int l= 1; |
| 141 | for (int i= 1; i <= n; i++) |
| 142 | { |
| 143 | if (degsf[i] != 0 && degsg[i] == 0 && i <= F.level()) |
| 144 | { |
| 145 | if (k + both_non_zero != i) |
| 146 | { |
| 147 | M.newpair (Variable (i), Variable (k + both_non_zero)); |
| 148 | N.newpair (Variable (k + both_non_zero), Variable (i)); |
| 149 | } |
no test coverage detected