MCPcopy Create free account
hub / github.com/Singular/Singular / myCompress

Function myCompress

factory/facFqFactorize.cc:134–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132}
133
134CanonicalForm myCompress (const CanonicalForm& F, CFMap& N)
135{
136 int n= F.level();
137 int * degsf= NEW_ARRAY(int,n + 1);
138 int ** swap= new int* [n + 1];
139 for (int i= 0; i <= n; i++)
140 {
141 degsf[i]= 0;
142 swap [i]= new int [3];
143 swap [i] [0]= 0;
144 swap [i] [1]= 0;
145 swap [i] [2]= 0;
146 }
147 int i= 1;
148 n= 1;
149 degsf= degrees (F, degsf);
150
151 CanonicalForm result= F;
152 while ( i <= F.level() )
153 {
154 while( degsf[i] == 0 ) i++;
155 swap[n][0]= i;
156 swap[n][1]= size (LC (F,i));
157 swap[n][2]= degsf [i];
158 if (i != n)
159 result= swapvar (result, Variable (n), Variable(i));
160 n++; i++;
161 }
162
163 int buf1, buf2, buf3;
164 n--;
165
166 for (i= 1; i < n; i++)
167 {
168 for (int j= 1; j < n - i + 1; j++)
169 {
170 if (swap[j][1] > swap[j + 1][1])
171 {
172 buf1= swap [j + 1] [0];
173 buf2= swap [j + 1] [1];
174 buf3= swap [j + 1] [2];
175 swap[j + 1] [0]= swap[j] [0];
176 swap[j + 1] [1]= swap[j] [1];
177 swap[j + 1] [2]= swap[j] [2];
178 swap[j][0]= buf1;
179 swap[j][1]= buf2;
180 swap[j][2]= buf3;
181 result= swapvar (result, Variable (j + 1), Variable (j));
182 }
183 else if (swap[j][1] == swap[j + 1][1] && swap[j][2] < swap[j + 1][2])
184 {
185 buf1= swap [j + 1] [0];
186 buf2= swap [j + 1] [1];
187 buf3= swap [j + 1] [2];
188 swap[j + 1] [0]= swap[j] [0];
189 swap[j + 1] [1]= swap[j] [1];
190 swap[j + 1] [2]= swap[j] [2];
191 swap[j][0]= buf1;

Callers 1

multiFactorizeFunction · 0.70

Calls 7

degreesFunction · 0.85
sizeFunction · 0.85
LCFunction · 0.85
VariableFunction · 0.85
newpairMethod · 0.80
swapvarFunction · 0.70
levelMethod · 0.45

Tested by

no test coverage detected