source: git/dyn_modules/syzextra/syzextra.cc @ 7088f18

jengelh-datetimespielwiese
Last change on this file since 7088f18 was 7088f18, checked in by Oleksandr Motsak <motsak@…>, 11 years ago
Old Schreyer Syzygy functions went to a namespace accesed via a class + wrappers & moved internal declarations to syzextra.cc
  • Property mode set to 100644
File size: 18.4 KB
Line 
1// -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2/*****************************************************************************\
3 * Computer Algebra System SINGULAR   
4\*****************************************************************************/
5/** @file syzextra.cc
6 *
7 * Here we implement the Computation of Syzygies
8 *
9 * ABSTRACT: Computation of Syzygies due to Schreyer
10 *
11 * @author Oleksandr Motsak
12 *
13 **/
14/*****************************************************************************/
15
16// include header file
17#include <kernel/mod2.h>
18
19#include "syzextra.h"
20
21#include "DebugPrint.h"
22
23#include <omalloc/omalloc.h>
24
25#include <misc/intvec.h>
26#include <misc/options.h>
27
28#include <coeffs/coeffs.h>
29
30#include <polys/monomials/p_polys.h>
31#include <polys/monomials/ring.h>
32
33#include <kernel/kstd1.h>
34#include <kernel/polys.h>
35#include <kernel/syz.h>
36#include <kernel/ideals.h>
37
38
39
40#include <Singular/tok.h>
41#include <Singular/ipid.h>
42#include <Singular/lists.h>
43#include <Singular/attrib.h>
44
45#include <Singular/ipid.h> 
46#include <Singular/ipshell.h> // For iiAddCproc
47
48#include <stdio.h>
49#include <stdlib.h>
50#include <string.h>
51
52// USING_NAMESPACE_SINGULARXX;
53USING_NAMESPACE( SINGULARXXNAME :: DEBUG )
54
55
56BEGIN_NAMESPACE_SINGULARXX     BEGIN_NAMESPACE(SYZEXTRA)
57
58
59BEGIN_NAMESPACE(SORT_c_ds)
60
61
62#ifdef _GNU_SOURCE
63static int cmp_c_ds(const void *p1, const void *p2, void *R)
64{
65#else
66static int cmp_c_ds(const void *p1, const void *p2)
67{
68  void *R = currRing; 
69#endif
70
71  const int YES = 1;
72  const int NO = -1;
73
74  const ring r =  (const ring) R; // TODO/NOTE: the structure is known: C, lp!!!
75
76  assume( r == currRing );
77
78  const poly a = *(const poly*)p1;
79  const poly b = *(const poly*)p2;
80
81  assume( a != NULL );
82  assume( b != NULL );
83
84  assume( p_LmTest(a, r) );
85  assume( p_LmTest(b, r) );
86
87
88  const signed long iCompDiff = p_GetComp(a, r) - p_GetComp(b, r);
89
90  // TODO: test this!!!!!!!!!!!!!!!!
91
92  //return -( compare (c, qsorts) )
93
94  const int __DEBUG__ = 0;
95
96#ifndef NDEBUG
97  if( __DEBUG__ )
98  {
99    PrintS("cmp_c_ds: a, b: \np1: "); dPrint(a, r, r, 2);
100    PrintS("b: "); dPrint(b, r, r, 2);
101    PrintLn();
102  }
103#endif
104
105
106  if( iCompDiff > 0 )
107    return YES;
108
109  if( iCompDiff < 0 )
110    return  NO;
111
112  assume( iCompDiff == 0 );
113
114  const signed long iDegDiff = p_Totaldegree(a, r) - p_Totaldegree(b, r);
115
116  if( iDegDiff > 0 )
117    return YES;
118
119  if( iDegDiff < 0 )
120    return  NO;
121
122  assume( iDegDiff == 0 );
123
124#ifndef NDEBUG
125  if( __DEBUG__ )
126  {
127    PrintS("cmp_c_ds: a & b have the same comp & deg! "); PrintLn();
128  }
129#endif
130
131  for (int v = rVar(r); v > 0; v--)
132  {
133    assume( v > 0 );
134    assume( v <= rVar(r) );
135
136    const signed int d = p_GetExp(a, v, r) - p_GetExp(b, v, r);
137
138    if( d > 0 )
139      return YES;
140
141    if( d < 0 )
142      return NO;
143
144    assume( d == 0 );
145  }
146
147  return 0; 
148}
149
150END_NAMESPACE
151/* namespace SORT_c_ds */
152
153/// return a new term: leading coeff * leading monomial of p
154/// with 0 leading component!
155poly leadmonom(const poly p, const ring r)
156{
157  poly m = NULL;
158
159  if( p != NULL )
160  {
161    assume( p != NULL );
162    assume( p_LmTest(p, r) );
163
164    m = p_LmInit(p, r);
165    p_SetCoeff0(m, n_Copy(p_GetCoeff(p, r), r), r);
166
167    p_SetComp(m, 0, r);
168    p_Setm(m, r);
169
170    assume( p_GetComp(m, r) == 0 );
171    assume( m != NULL );
172    assume( pNext(m) == NULL );
173    assume( p_LmTest(m, r) );
174  }
175
176  return m;
177}
178
179
180   
181poly p_Tail(const poly p, const ring r)
182{
183  if( p == NULL)
184    return NULL;
185  else
186    return p_Copy( pNext(p), r );
187}
188
189
190ideal id_Tail(const ideal id, const ring r)
191{
192  if( id == NULL)
193    return NULL;
194
195  const ideal newid = idInit(IDELEMS(id),id->rank);
196 
197  for (int i=IDELEMS(id) - 1; i >= 0; i--)
198    newid->m[i] = p_Tail( id->m[i], r );
199
200  newid->rank = id_RankFreeModule(newid, currRing);
201
202  return newid; 
203}
204
205
206
207void Sort_c_ds(const ideal id, const ring r)
208{
209  const int sizeNew = IDELEMS(id);
210
211#ifdef _GNU_SOURCE
212#define qsort_my(m, s, ss, r, cmp) qsort_r(m, s, ss, cmp, r)
213#else
214#define qsort_my(m, s, ss, r, cmp) qsort_r(m, s, ss, cmp)
215#endif
216 
217  if( sizeNew >= 2 )
218    qsort_my(id->m, sizeNew, sizeof(poly), r, SORT_c_ds::cmp_c_ds);
219
220#undef qsort_my
221
222  id->rank = id_RankFreeModule(id, r);
223}
224
225
226BEGIN_NAMESPACE(INTERNAL)
227
228ideal ComputeLeadingSyzygyTerms(const ideal& id, const ring r)
229{
230  // 1. set of components S?
231  // 2. for each component c from S: set of indices of leading terms
232  // with this component?
233  // 3. short exp. vectors for each leading term?
234
235  const int size = IDELEMS(id);
236
237  if( size < 2 )
238  {
239    const ideal newid = idInit(1, 0); newid->m[0] = NULL; // zero ideal...       
240    return newid;
241  }
242
243
244  // TODO/NOTE: input is supposed to be (reverse-) sorted wrt "(c,ds)"!??
245
246  // components should come in groups: count elements in each group
247  // && estimate the real size!!!
248
249
250  // use just a vector instead???
251  const ideal newid = idInit( (size * (size-1))/2, size); // maximal size: ideal case!
252
253  int k = 0;
254
255  for (int j = 0; j < size; j++)
256  {
257    const poly p = id->m[j];
258    assume( p != NULL );
259    const int  c = p_GetComp(p, r);
260
261    for (int i = j - 1; i >= 0; i--)
262    {
263      const poly pp = id->m[i];
264      assume( pp != NULL );
265      const int  cc = p_GetComp(pp, r);
266
267      if( c != cc )
268        continue;
269
270      const poly m = p_Init(r); // p_New???
271
272      // m = LCM(p, pp) / p! // TODO: optimize: knowing the ring structure: (C/lp)!
273      for (int v = rVar(r); v > 0; v--)
274      {
275        assume( v > 0 );
276        assume( v <= rVar(r) );
277
278        const short e1 = p_GetExp(p , v, r);
279        const short e2 = p_GetExp(pp, v, r);
280
281        if( e1 >= e2 )
282          p_SetExp(m, v, 0, r);
283        else
284          p_SetExp(m, v, e2 - e1, r);
285
286      }
287
288      assume( (j > i) && (i >= 0) );
289
290      p_SetComp(m, j + 1, r);
291      pNext(m) = NULL;
292      p_SetCoeff0(m, n_Init(1, r->cf), r); // for later...
293
294      p_Setm(m, r); // should not do anything!!!
295
296      newid->m[k++] = m;
297    }
298  }
299
300//   if( __DEBUG__ && FALSE )
301//   {
302//     PrintS("ComputeLeadingSyzygyTerms::Temp0: \n");
303//     dPrint(newid, r, r, 1);
304//   }
305
306  // the rest of newid is assumed to be zeroes...
307
308  // simplify(newid, 2 + 32)??
309  // sort(newid, "C,ds")[1]???
310  id_DelDiv(newid, r); // #define SIMPL_LMDIV 32
311
312//   if( __DEBUG__ && FALSE )
313//   {
314//     PrintS("ComputeLeadingSyzygyTerms::Temp1: \n");
315//     dPrint(newid, r, r, 1);
316//   }
317
318  idSkipZeroes(newid); // #define SIMPL_NULL 2
319
320//   if( __DEBUG__ )
321//   {
322//     PrintS("ComputeLeadingSyzygyTerms::Output: \n");
323//     dPrint(newid, r, r, 1);
324//   }
325
326  Sort_c_ds(newid, r);
327
328  return newid;
329}
330
331
332
333
334ideal Compute2LeadingSyzygyTerms(const ideal& id, const ring r)
335{
336#ifndef NDEBUG
337  const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)TRUE)));
338#else
339  const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)FALSE)));
340#endif
341
342  const BOOLEAN __TAILREDSYZ__ = (BOOLEAN)((long)(atGet(currRingHdl,"TAILREDSYZ",INT_CMD, (void*)0)));
343  const BOOLEAN __SYZCHECK__ = (BOOLEAN)((long)(atGet(currRingHdl,"SYZCHECK",INT_CMD, (void*)0)));   
344
345
346
347  // 1. set of components S?
348  // 2. for each component c from S: set of indices of leading terms
349  // with this component?
350  // 3. short exp. vectors for each leading term?
351
352  const int size = IDELEMS(id);
353
354  if( size < 2 )
355  {
356    const ideal newid = idInit(1, 1); newid->m[0] = NULL; // zero module...   
357    return newid;
358  }
359
360
361    // TODO/NOTE: input is supposed to be sorted wrt "C,ds"!??
362
363    // components should come in groups: count elements in each group
364    // && estimate the real size!!!
365
366
367    // use just a vector instead???
368  ideal newid = idInit( (size * (size-1))/2, size); // maximal size: ideal case!
369
370  int k = 0;
371
372  for (int j = 0; j < size; j++)
373  {
374    const poly p = id->m[j];
375    assume( p != NULL );
376    const int  c = p_GetComp(p, r);
377
378    for (int i = j - 1; i >= 0; i--)
379    {
380      const poly pp = id->m[i];
381      assume( pp != NULL );
382      const int  cc = p_GetComp(pp, r);
383
384      if( c != cc )
385        continue;
386
387        // allocate memory & zero it out!
388      const poly m = p_Init(r); const poly mm = p_Init(r);
389
390
391        // m = LCM(p, pp) / p! mm = LCM(p, pp) / pp!
392        // TODO: optimize: knowing the ring structure: (C/lp)!
393
394      for (int v = rVar(r); v > 0; v--)
395      {
396        assume( v > 0 );
397        assume( v <= rVar(r) );
398
399        const short e1 = p_GetExp(p , v, r);
400        const short e2 = p_GetExp(pp, v, r);
401
402        if( e1 >= e2 )
403          p_SetExp(mm, v, e1 - e2, r); //            p_SetExp(m, v, 0, r);
404        else
405          p_SetExp(m, v, e2 - e1, r); //            p_SetExp(mm, v, 0, r);
406
407      }
408
409      assume( (j > i) && (i >= 0) );
410
411      p_SetComp(m, j + 1, r);
412      p_SetComp(mm, i + 1, r);
413
414      const number& lc1 = p_GetCoeff(p , r);
415      const number& lc2 = p_GetCoeff(pp, r);
416
417      number g = n_Lcm( lc1, lc2, r );
418
419      p_SetCoeff0(m ,       n_Div(g, lc1, r), r);
420      p_SetCoeff0(mm, n_Neg(n_Div(g, lc2, r), r), r);
421
422      n_Delete(&g, r);
423
424      p_Setm(m, r); // should not do anything!!!
425      p_Setm(mm, r); // should not do anything!!!
426
427      pNext(m) = mm; //        pNext(mm) = NULL;
428
429      newid->m[k++] = m;
430    }
431  }
432
433//   if( __DEBUG__ && FALSE )
434//   {
435//     PrintS("Compute2LeadingSyzygyTerms::Temp0: \n");
436//     dPrint(newid, r, r, 1);
437//   }
438
439  if( !__TAILREDSYZ__ )
440  {
441      // simplify(newid, 2 + 32)??
442      // sort(newid, "C,ds")[1]???
443    id_DelDiv(newid, r); // #define SIMPL_LMDIV 32
444
445//     if( __DEBUG__ && FALSE )
446//     {
447//       PrintS("Compute2LeadingSyzygyTerms::Temp1 (deldiv): \n");
448//       dPrint(newid, r, r, 1);
449//     }
450  }
451  else
452  {
453      //      option(redSB); option(redTail);
454      //      TEST_OPT_REDSB
455      //      TEST_OPT_REDTAIL
456    assume( r == currRing );
457    BITSET _save_test = test;
458    test |= (Sy_bit(OPT_REDTAIL) | Sy_bit(OPT_REDSB));
459
460    intvec* w=new intvec(IDELEMS(newid));
461    ideal tmp = kStd(newid, currQuotient, isHomog, &w);
462    delete w;
463
464    test = _save_test;
465
466    id_Delete(&newid, r);
467    newid = tmp;
468
469//     if( __DEBUG__ && FALSE )
470//     {
471//       PrintS("Compute2LeadingSyzygyTerms::Temp1 (std): \n");
472//       dPrint(newid, r, r, 1);
473//     }
474
475  }
476
477  idSkipZeroes(newid);
478
479  Sort_c_ds(newid, r);
480 
481  return newid;
482}
483
484poly FindReducer(poly product, poly syzterm,
485                        ideal L, ideal LS,
486                        const ring r)
487{
488  assume( product != NULL );
489  assume( L != NULL );
490
491  int c = 0;
492
493  if (syzterm != NULL)
494    c = p_GetComp(syzterm, r) - 1;
495
496  assume( c >= 0 && c < IDELEMS(L) );
497
498#ifndef NDEBUG
499  const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)TRUE)));
500#else
501  const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)FALSE)));
502#endif
503
504  long debug = __DEBUG__;
505  const BOOLEAN __SYZCHECK__ = (BOOLEAN)((long)(atGet(currRingHdl,"SYZCHECK",INT_CMD, (void*)debug)));   
506
507  if (__SYZCHECK__ && syzterm != NULL)
508  {
509    const poly m = L->m[c];
510
511    assume( m != NULL ); assume( pNext(m) == NULL );
512
513    poly lm = p_Mult_mm(leadmonom(syzterm, r), m, r);
514    assume( p_EqualPolys(lm, product, r) );
515
516    //  def @@c = leadcomp(syzterm); int @@r = int(@@c);
517    //  def @@product = leadmonomial(syzterm) * L[@@r];
518
519    p_Delete(&lm, r);   
520  }
521
522  // looking for an appropriate diviser q = L[k]...
523  for( int k = IDELEMS(L)-1; k>= 0; k-- )
524  {
525    const poly p = L->m[k];   
526
527    // ... which divides the product, looking for the _1st_ appropriate one!
528    if( !p_LmDivisibleBy(p, product, r) )
529      continue;
530
531
532    const poly q = p_New(r);
533    pNext(q) = NULL;
534    p_ExpVectorDiff(q, product, p, r); // (LM(product) / LM(L[k]))
535    p_SetComp(q, k + 1, r);
536    p_Setm(q, r);
537
538    // cannot allow something like: a*gen(i) - a*gen(i)
539    if (syzterm != NULL && (k == c))
540      if (p_ExpVectorEqual(syzterm, q, r))
541      {
542        if( __DEBUG__ )
543        {
544          Print("FindReducer::Test SYZTERM: q == syzterm !:((, syzterm is: ");
545          dPrint(syzterm, r, r, 1);
546        }   
547
548        p_LmFree(q, r);
549        continue;
550      }
551
552    // while the complement (the fraction) is not reducible by leading syzygies
553    if( LS != NULL )
554    {
555      BOOLEAN ok = TRUE;
556
557      for(int kk = IDELEMS(LS)-1; kk>= 0; kk-- )
558      {
559        const poly pp = LS->m[kk];
560
561        if( p_LmDivisibleBy(pp, q, r) )
562        {
563
564          if( __DEBUG__ )
565          {
566            Print("FindReducer::Test LS: q is divisible by LS[%d] !:((, diviser is: ", kk+1);
567            dPrint(pp, r, r, 1);
568          }   
569
570          ok = FALSE; // q in <LS> :((
571          break;                 
572        }
573      }
574
575      if(!ok)
576      {
577        p_LmFree(q, r);
578        continue;
579      }
580    }
581
582    p_SetCoeff0(q, n_Neg( n_Div( p_GetCoeff(product, r), p_GetCoeff(p, r), r), r), r);
583    return q;
584
585  }
586
587
588  return NULL;
589}
590
591poly TraverseTail(poly multiplier, poly tail, 
592                         ideal L, ideal T, ideal LS,
593                         const ring r)
594{
595  assume( multiplier != NULL );
596
597  assume( L != NULL );
598  assume( T != NULL );
599
600  poly s = NULL;
601
602  // iterate over the tail
603  for(poly p = tail; p != NULL; p = pNext(p))
604    s = p_Add_q(s, ReduceTerm(multiplier, p, NULL, L, T, LS, r), r); 
605
606  return s;
607}
608
609
610poly ReduceTerm(poly multiplier, poly term4reduction, poly syztermCheck,
611                       ideal L, ideal T, ideal LS, const ring r)
612{
613  assume( multiplier != NULL );
614  assume( term4reduction != NULL );
615
616
617  assume( L != NULL );
618  assume( T != NULL );
619
620  // assume(r == currRing); // ?
621
622  // simple implementation with FindReducer:
623  poly s = NULL;
624
625  if(1)
626  {
627    // NOTE: only LT(term4reduction) should be used in the following:
628    poly product = pp_Mult_mm(multiplier, term4reduction, r);
629    s = FindReducer(product, syztermCheck, L, LS, r);
630    p_Delete(&product, r);
631  }
632
633  if( s == NULL ) // No Reducer?
634    return s;
635
636  poly b = leadmonom(s, r);
637
638  const int c = p_GetComp(s, r) - 1;
639  assume( c >= 0 && c < IDELEMS(T) );
640
641  const poly tail = T->m[c];
642
643  if( tail != NULL )
644    s = p_Add_q(s, TraverseTail(b, tail, L, T, LS, r), r); 
645
646  return s;
647}
648
649
650poly SchreyerSyzygyNF(poly syz_lead, poly syz_2, ideal L, ideal T, ideal LS, const ring r)
651{
652  assume( syz_lead != NULL );
653  assume( syz_2 != NULL );
654
655  assume( L != NULL );
656  assume( T != NULL );
657
658  assume( IDELEMS(L) == IDELEMS(T) );
659
660  int  c = p_GetComp(syz_lead, r) - 1;
661
662  assume( c >= 0 && c < IDELEMS(T) );
663
664  poly p = leadmonom(syz_lead, r); // :( 
665  poly spoly = pp_Mult_qq(p, T->m[c], r);
666  p_Delete(&p, r);
667
668
669  c = p_GetComp(syz_2, r) - 1;
670  assume( c >= 0 && c < IDELEMS(T) );
671
672  p = leadmonom(syz_2, r); // :(
673  spoly = p_Add_q(spoly, pp_Mult_qq(p, T->m[c], r), r);
674  p_Delete(&p, r);
675
676  poly tail = p_Copy(syz_2, r); // TODO: use bucket!?
677
678  while (spoly != NULL)
679  {
680    poly t = FindReducer(spoly, NULL, L, LS, r);
681
682    p_LmDelete(&spoly, r);
683
684    if( t != NULL )
685    {
686      p = leadmonom(t, r); // :(
687      c = p_GetComp(t, r) - 1;
688
689      assume( c >= 0 && c < IDELEMS(T) );
690
691      spoly = p_Add_q(spoly, pp_Mult_qq(p, T->m[c], r), r);
692
693      p_Delete(&p, r);
694
695      tail = p_Add_q(tail, t, r);
696    }   
697  }
698
699  return tail;
700}
701
702
703void ComputeSyzygy(const ideal L, const ideal T, ideal& LL, ideal& TT, const ring R)
704{
705  assume( R == currRing ); // For attributes :-/
706
707  assume( IDELEMS(L) == IDELEMS(T) );
708
709#ifndef NDEBUG
710  const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)TRUE)));
711#else
712  const BOOLEAN __DEBUG__ = (BOOLEAN)((long)(atGet(currRingHdl,"DEBUG",INT_CMD, (void*)FALSE)));
713#endif
714
715  const BOOLEAN __LEAD2SYZ__ = (BOOLEAN)((long)(atGet(currRingHdl,"LEAD2SYZ",INT_CMD, (void*)1)));
716  const BOOLEAN __TAILREDSYZ__ = (BOOLEAN)((long)(atGet(currRingHdl,"TAILREDSYZ",INT_CMD, (void*)1)));
717  const BOOLEAN __SYZCHECK__ = (BOOLEAN)((long)(atGet(currRingHdl,"SYZCHECK",INT_CMD, (void*)__DEBUG__)));
718
719  const BOOLEAN __HYBRIDNF__ = (BOOLEAN)((long)(atGet(currRingHdl,"HYBRIDNF",INT_CMD, (void*)0)));
720
721
722  if( __LEAD2SYZ__ )
723    LL = Compute2LeadingSyzygyTerms(L, R); // 2 terms!
724  else
725    LL = ComputeLeadingSyzygyTerms(L, R); // 1 term!
726
727  const int size = IDELEMS(LL);
728
729  TT = idInit(size, 0);
730
731  if( size == 1 && LL->m[0] == NULL )
732    return;
733
734
735  ideal LS = NULL;
736
737  if( __TAILREDSYZ__ )
738    LS = LL;
739
740  for( int k = size - 1; k >= 0; k-- )
741  {
742    const poly a = LL->m[k]; assume( a != NULL );
743
744    const int r = p_GetComp(a, R) - 1; 
745
746    assume( r >= 0 && r < IDELEMS(T) );
747    assume( r >= 0 && r < IDELEMS(L) );
748
749    poly aa = leadmonom(a, R); assume( aa != NULL); // :(   
750
751    poly a2 = pNext(a);   
752
753    if( a2 != NULL )
754    {
755      TT->m[k] = a2; pNext(a) = NULL;
756    }
757
758    if( ! __HYBRIDNF__ )
759    {
760      poly t = TraverseTail(aa, T->m[r], L, T, LS, R);
761
762      if( a2 != NULL )
763      {
764        assume( __LEAD2SYZ__ );
765
766        const int r2 = p_GetComp(a2, R) - 1; poly aa2 = leadmonom(a2, R); // :(
767
768        assume( r2 >= 0 && r2 < IDELEMS(T) );
769
770        TT->m[k] = p_Add_q(a2, p_Add_q(t, TraverseTail(aa2, T->m[r2], L, T, LS, R), R), R);
771
772        p_Delete(&aa2, R);
773      } else
774        TT->m[k] = p_Add_q(t, ReduceTerm(aa, L->m[r], a, L, T, LS, R), R);
775
776    } else
777    {
778      if( a2 == NULL )
779      {
780        aa = p_Mult_mm(aa, L->m[r], R);
781        a2 = FindReducer(aa, a, L, LS, R); 
782      }
783      assume( a2 != NULL );
784
785      TT->m[k] = SchreyerSyzygyNF(a, a2, L, T, LS, R); // will copy a2 :(
786
787      p_Delete(&a2, R);
788    }
789    p_Delete(&aa, R);   
790  }
791
792  TT->rank = id_RankFreeModule(TT, R);
793}
794
795END_NAMESPACE
796
797
798void SchreyerSyzygyComputation::ComputeSyzygy()
799{
800  /// assumes m_syzLeads == m_syzTails == NULL!
801  INTERNAL::ComputeSyzygy(m_idLeads, m_idTails, m_syzLeads, m_syzTails, m_rBaseRing); // TODO: just a wrapper for now :/
802}
803
804void SchreyerSyzygyComputation::ComputeLeadingSyzygyTerms(bool bComputeSecondTerms)
805{
806  if( bComputeSecondTerms )
807    m_syzLeads = INTERNAL::Compute2LeadingSyzygyTerms(m_idLeads, m_rBaseRing);
808  else
809    m_syzLeads = INTERNAL::ComputeLeadingSyzygyTerms(m_idLeads, m_rBaseRing);
810 
811  // NOTE: set m_LS if tails are to be reduced!
812}
813
814poly SchreyerSyzygyComputation::FindReducer(poly product, poly syzterm)
815{
816  return INTERNAL::FindReducer(product, syzterm, m_idLeads, m_LS, m_rBaseRing);
817}
818
819poly SchreyerSyzygyComputation::SchreyerSyzygyNF(poly syz_lead, poly syz_2)
820{
821  return INTERNAL::SchreyerSyzygyNF(syz_lead, syz_2, m_idLeads, m_idTails, m_LS, m_rBaseRing);
822}
823
824poly SchreyerSyzygyComputation::TraverseTail(poly multiplier, poly tail)
825{
826  return INTERNAL::TraverseTail(multiplier, tail, m_idLeads, m_idTails, m_LS, m_rBaseRing);
827}
828
829poly SchreyerSyzygyComputation::ReduceTerm(poly multiplier, poly term4reduction, poly syztermCheck)
830{
831  return INTERNAL::ReduceTerm(multiplier, term4reduction, syztermCheck, m_idLeads, m_idTails, m_LS, m_rBaseRing);
832}
833
834   
835
836
837END_NAMESPACE               END_NAMESPACE_SINGULARXX
838
839
840// Vi-modeline: vim: filetype=c:syntax:shiftwidth=2:tabstop=8:textwidth=0:expandtab
Note: See TracBrowser for help on using the repository browser.