source: git/Singular/wrapper.cc @ 2f5b71

spielwiese
Last change on this file since 2f5b71 was 2f5b71, checked in by Hans Schönemann <hannes@…>, 20 years ago
*hannes: 2-1: new directory: kernel git-svn-id: file:///usr/local/Singular/svn/trunk@6947 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100755
File size: 2.8 KB
Line 
1#include "mod2.h"
2#include "janet.h"
3#include "kstd1.h"
4#include "ipid.h"
5
6#define pow_(x) pTotaldegree((x))
7
8//extern int (*ListGreatMove)(jList *,jList *,poly);
9extern int ComputeBasis(jList *,jList *);
10extern void Initialization(char *);
11
12BOOLEAN jjJanetBasis(leftv res, leftv v)
13{
14        Initialization(rOrdStr(currRing));
15
16          jList *Q=(jList *)GCM(sizeof(jList));
17        Q->root=NULL;
18               
19        jList *T=(jList *)GCM(sizeof(jList));
20        T->root=NULL;
21
22        ideal input = (ideal)(v->Data());
23        /* the second arg is an integer, defining what to return:
24         0 (default case) = Groebner basis,
25         1                = Janet basis.
26        */
27        int doJanet;
28        if ((v->next!=NULL) && (v->next->Typ() == INT_CMD))
29        {
30          doJanet = (int)v->next->CopyD();
31          //          Print("doJanet:%d\n",doJanet);
32        }               
33        else 
34        {
35          doJanet = 0;
36        }
37        ideal result;
38        int dpO = !doJanet; /* compatibility */
39
40        for (int i=0; i < input->idelems(); i++)       
41        {
42          /* nonzero constant check */
43          if (pIsConstant(input->m[i])) { goto zero; }
44          Poly *beg=NewPoly(pCopy(input->m[i]));
45          InitHistory(beg);
46          InitProl(beg);
47          InitLead(beg);
48          InsertInCount(Q,beg);
49        }
50
51        if (ComputeBasis(T,Q))
52        {
53          //                dpO=(strstr(rOrdStr(currRing),"dp")!=NULL);
54          int ideal_length= dpO ? GB_length() : CountList(T);
55          result=idInit(ideal_length,1);
56          int ideal_index=0;
57         
58          LCI iT=T->root;
59         
60          while (iT) 
61          {
62#ifdef PDEBUG                 
63            pTest(iT->info->root);
64#endif
65            if (!(dpO && (pow_(iT->info->lead) != pow_(iT->info->history)))) 
66            {
67              result->m[ideal_length-ideal_index-1]=pCopy(iT->info->root);
68              if (!nGreaterZero(pGetCoeff(iT->info->root)))
69              {
70                result->m[ideal_length-ideal_index-1]=pNeg(result->m[ideal_length-ideal_index-1]); 
71              }
72              ideal_index++;
73            }   
74            iT=iT->next; 
75          }
76        }
77        else
78        {
79zero:
80          result=idInit(1,1);
81          result->m[0]=pOne();       
82        }
83       
84        /* now we make the basis shorter... getting Groebner */
85        if (!doJanet) /* if (!dpO) */ 
86        {
87          if (TEST_OPT_PROT)
88          {
89            Print ("interred\n");
90          }
91          result=kInterRed(result);
92          idSkipZeroes(result);
93        }
94        res->data = (char *)result;
95        res->rtyp = v->Typ();
96        if (!doJanet) setFlag(res,FLAG_STD);
97
98        DestroyList(Q);
99        DestroyList(T);
100       
101        return FALSE;
102}
Note: See TracBrowser for help on using the repository browser.