source: git/kernel/f5gb.cc @ 9a6e9f

spielwiese
Last change on this file since 9a6e9f was 9a6e9f, checked in by Christian Eder, 16 years ago
quicksort, label poly class git-svn-id: file:///usr/local/Singular/svn/trunk@10734 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 2.2 KB
RevLine 
[936551]1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
[9a6e9f]4/* $Id: f5gb.cc,v 1.5 2008-06-01 12:49:42 ederc Exp $ */
[936551]5/*
6* ABSTRACT: f5gb interface
7*/
[9a6e9f]8
[936551]9#include "mod2.h"
10#include "kutil.h"
11#include "structs.h"
12#include "omalloc.h"
13#include "polys.h"
14#include "p_polys.h"
15#include "ideals.h"
16#include "febase.h"
17#include "kstd1.h"
18#include "khstd.h"
19#include "kbuckets.h"
20#include "weight.h"
21#include "intvec.h"
22#include "pInline1.h"
23#include "f5gb.h"
[9a6e9f]24#include "lpoly.h"
[936551]25#ifdef HAVE_F5
[9a6e9f]26
27
28
29
30/*2
31* sorting ideals by decreasing total degree
32* "left" and "right" are the pointer of the first
33* and last polynomial in the considered ideal
34*/
35void qsort_degree(poly* left, poly* right)
36{
37        poly* ptr1 = left;
38        poly* ptr2 = right;
39        poly p1,p2;
40
41        p2 = *(left + (right - left >> 1));
42        do{
43                while(pTotaldegree(*ptr1, currRing) < pTotaldegree(p2, currRing)){
44                        ptr1++;
45                }
46                while(pTotaldegree(*ptr2, currRing) > pTotaldegree(p2,currRing)){
47                        ptr2--;
48                }
49                if(ptr1 > ptr2){
50                        break;
51                }
52                p1    = *ptr1;
53                *ptr1 = *ptr2;
54                *ptr2 = p1;
55        } while(++ptr1 <= --ptr2);
56
57        if(left < ptr2){
58                qsort_degree(left,ptr2);
59        }
60        if(ptr1 < right){
61                qsort_degree(ptr1,right);
62        }
63}
64
65
66/*2
67* computes a gb of the ideal i in the ring r with our f5
68* implementation
69*/
[171950]70ideal F5main(ideal i, ring r)
[936551]71{
[9a6e9f]72      ideal iTmp, g;
73      int j;     
74      lpoly* lp;
75      intvec* sort;
76      iTmp = idInit(IDELEMS(i),i->rank);
[171950]77 
[9a6e9f]78      for(j=0; j<IDELEMS(i); j++)
79      {
80              if(NULL != i->m[j])
81              {
82                      iTmp->m[j] = i->m[j];
83              }
84      }
85
86      iTmp = kInterRed(i,0); 
87      qsort_degree(&iTmp->m[0],&iTmp->m[IDELEMS(iTmp)-1]);
88      idShow(iTmp);
89     
90      lp = new lpoly[IDELEMS(iTmp)];
91      for(j=0; j <IDELEMS(iTmp); j++){
92                lp[j].setPoly(&iTmp->m[j]);
93                pWrite(*(lp[j].getPoly()));
94      }
95               
96
97           
98
99
100        return iTmp;
[936551]101}
[9a6e9f]102
103
[936551]104#endif
Note: See TracBrowser for help on using the repository browser.