Macaulay2 Engine
Loading...
Searching...
No Matches

◆ spairs_sort()

void gbA::spairs_sort ( int len,
spair *& list )
private

Definition at line 1226 of file gb-default.cpp.

1227{
1228 if (ps == nullptr || ps->next == nullptr) return;
1229 if (len <= 1) return;
1230 spairs a; // array of spair's
1231 spairs b; // these are the ones which are uncomputed, but whose lead_of_spoly
1232 // is 0.
1233 a.reserve(len);
1234 for (spair *p = ps; p != nullptr; p = p->next)
1235 {
1236 if ((p->type > SPAIR::SPAIR_SKEW) || p->lead_of_spoly)
1237 a.push_back(p);
1238 else
1239 b.push_back(p);
1240 }
1241
1242 SPolySorter SP(R, _F);
1243 // QuickSorter<SPolySorter>::sort(&SP,&a[0],a.size());
1244 std::stable_sort(a.begin(), a.end(), SP);
1245 int asize = INTSIZE(a);
1246 int bsize = INTSIZE(b);
1247
1248 if (asize > 0)
1249 {
1250 ps = a[0];
1251 for (int i = 1; i < asize; i++) a[i - 1]->next = a[i];
1252 }
1253 else if (bsize > 0)
1254 {
1255 ps = b[0];
1256 // debugging// fprintf(stderr, "bsize is %d\n",bsize);
1257 }
1258 else
1259 {
1260 ps = nullptr;
1261 return;
1262 }
1263
1264 if (asize > 0) a[asize - 1]->next = (bsize > 0 ? b[0] : nullptr);
1265 if (bsize > 0)
1266 {
1267 for (int i = 1; i < bsize; i++) b[i - 1]->next = b[i];
1268 b[bsize - 1]->next = nullptr;
1269 }
1270}
GBRing * R
const FreeModule * _F
@ SPAIR_SKEW
int p
#define INTSIZE(a)
Definition style.hpp:37

References _F, INTSIZE, gbA::spair::next, p, R, and SPAIR_SKEW.

Referenced by spair_set_prepare_next_degree().