My Project
Loading...
Searching...
No Matches
Functions
syz.cc File Reference
#include "kernel/mod2.h"
#include "misc/options.h"
#include "kernel/polys.h"
#include "kernel/GBEngine/kstd1.h"
#include "kernel/GBEngine/kutil.h"
#include "kernel/combinatorics/stairc.h"
#include "misc/intvec.h"
#include "coeffs/numbers.h"
#include "kernel/ideals.h"
#include "polys/monomials/ring.h"
#include "kernel/GBEngine/syz.h"
#include "polys/prCopy.h"
#include "polys/nc/sca.h"

Go to the source code of this file.

Functions

static intvecsyPrepareModComp (ideal arg, intvec **w)
 
static void syDeleteAbove (ideal up, int k)
 
static void syMinStep (ideal mod, ideal &syz, BOOLEAN final=FALSE, ideal up=NULL, tHomog h=isNotHomog)
 
void syGaussForOne (ideal syz, int elnum, int ModComp, int from, int till)
 
static void syDeleteAbove1 (ideal up, int k)
 
static void syMinStep1 (resolvente res, int length)
 
void syMinimizeResolvente (resolvente res, int length, int first)
 
resolvente syResolvente (ideal arg, int maxlength, int *length, intvec ***weights, BOOLEAN minim)
 
syStrategy syResolution (ideal arg, int maxlength, intvec *w, BOOLEAN minim)
 
static poly sypCopyConstant (poly inp)
 
int syDetect (ideal id, int index, BOOLEAN homog, int *degrees, int *tocancel)
 
void syDetect (ideal id, int index, int rsmin, BOOLEAN homog, intvec *degrees, intvec *tocancel)
 
intvecsyBetti (resolvente res, int length, int *regularity, intvec *weights, BOOLEAN tomin, int *row_shift)
 
ideal syMinBase (ideal arg)
 
syStrategy syMres_with_map (ideal arg, int maxlength, intvec *w, ideal &trans)
 
void syMinimize_with_map (syStrategy res, ideal &trans)
 
syStrategy syMinimizeCopy (syStrategy org)
 

Function Documentation

◆ syBetti()

intvec * syBetti ( resolvente  res,
int  length,
int regularity,
intvec weights,
BOOLEAN  tomin,
int row_shift 
)

Definition at line 783 of file syz.cc.

785{
786//#define BETTI_WITH_ZEROS
787 //tomin = FALSE;
788 int i,j=0,k=0,l,rows,cols,mr;
789 int *temp1,*temp2,*temp3;/*used to compute degrees*/
790 int *tocancel; /*(BOOLEAN)tocancel[i]=element is superfluous*/
791 int r0_len;
792
793 /*------ compute size --------------*/
794 *regularity = -1;
795 cols = length;
796 while ((cols>0)
797 && ((res[cols-1]==NULL)
798 || (idIs0(res[cols-1]))))
799 {
800 cols--;
801 }
802 intvec * result;
803 if (idIs0(res[0]))
804 {
805 if (res[0]==NULL)
806 result = new intvec(1,1,1);
807 else
808 result = new intvec(1,1,res[0]->rank);
809 return result;
810 }
811 intvec *w=NULL;
812 if (weights!=NULL)
813 {
814 if (!idTestHomModule(res[0],currRing->qideal,weights))
815 {
816 WarnS("wrong weights given(3):");weights->show();PrintLn();
817 idHomModule(res[0],currRing->qideal,&w);
818 if (w!=NULL) { w->show();PrintLn();}
819 weights=NULL;
820 }
821 }
822#if 0
823 if (idHomModule(res[0],currRing->qideal,&w)!=isHomog)
824 {
825 WarnS("betti-command: Input is not homogeneous!");
826 weights=NULL;
827 }
828#endif
829 if (weights==NULL) weights=w;
830 else delete w;
831 r0_len=IDELEMS(res[0]);
832 while ((r0_len>0) && (res[0]->m[r0_len-1]==NULL)) r0_len--;
833 #ifdef SHOW_W
834 PrintS("weights:");if (weights!=NULL) weights->show(); else Print("NULL"); PrintLn();
835 #endif
836 int rkl=l = si_max(id_RankFreeModule(res[0],currRing),res[0]->rank);
837 i = 0;
838 while ((i<length) && (res[i]!=NULL))
839 {
840 if (IDELEMS(res[i])>l) l = IDELEMS(res[i]);
841 i++;
842 }
843 temp1 = (int*)omAlloc0((l+1)*sizeof(int));
844 temp2 = (int*)omAlloc((l+1)*sizeof(int));
845 rows = 1;
846 mr = 1;
847 cols++;
848 for (i=0;i<cols-1;i++)
849 {
850 if ((i==0) && (weights!=NULL)) p_SetModDeg(weights, currRing);
851 memset(temp2,0,(l+1)*sizeof(int));
852 for (j=0;j<IDELEMS(res[i]);j++)
853 {
854 if (res[i]->m[j]!=NULL)
855 {
856 if ((pGetComp(res[i]->m[j])>l)
857 // usual resolutions do not the following, but artifulal built may: (tr. #763)
858 //|| ((i>1) && (res[i-1]->m[pGetComp(res[i]->m[j])-1]==NULL))
859 )
860 {
861 WerrorS("input not a resolution");
862 omFreeSize((ADDRESS)temp1,(l+1)*sizeof(int));
863 omFreeSize((ADDRESS)temp2,(l+1)*sizeof(int));
864 return NULL;
865 }
866 temp2[j+1] = p_FDeg(res[i]->m[j],currRing)+temp1[pGetComp(res[i]->m[j])];
867 if (temp2[j+1]-i>rows) rows = temp2[j+1]-i;
868 if (temp2[j+1]-i<mr) mr = temp2[j+1]-i;
869 }
870 }
871 if ((i==0) && (weights!=NULL)) p_SetModDeg(NULL, currRing);
872 temp3 = temp1;
873 temp1 = temp2;
874 temp2 = temp3;
875 }
876 mr--;
877 if (weights!=NULL)
878 {
879 for(j=0;j<weights->length();j++)
880 {
881 if (rows <(*weights)[j]+1) rows=(-mr)+(*weights)[j]+1;
882 }
883 }
884 /*------ computation betti numbers --------------*/
885 rows -= mr;
886 result = new intvec(rows+1,cols,0);
887 if (weights!=NULL)
888 {
889 for(j=0;j<weights->length();j++)
890 {
891 IMATELEM((*result),(-mr)+(*weights)[j]+1,1) ++;
892 //Print("imat(%d,%d)++ -> %d\n",(-mr)+(*weights)[j]+1, 1, IMATELEM((*result),(-mr)+(*weights)[j]+1,1));
893 }
894 }
895 else
896 {
897 (*result)[(-mr)*cols] = /*idRankFreeModule(res[0])*/ rkl;
898 if ((!idIs0(res[0])) && ((*result)[(-mr)*cols]==0))
899 (*result)[(-mr)*cols] = 1;
900 }
901 tocancel = (int*)omAlloc0((rows+1)*sizeof(int));
902 memset(temp1,0,(l+1)*sizeof(int));
903 if (weights!=NULL)
904 {
905 memset(temp2,0,l*sizeof(int));
906 p_SetModDeg(weights, currRing);
907 }
908 else
909 memset(temp2,0,l*sizeof(int));
911 if (weights!=NULL) p_SetModDeg(NULL, currRing);
912 if (tomin)
913 {
914 //(*result)[(-mr)*cols] -= dummy;
915 for(j=0;j<=rows+mr;j++)
916 {
917 //Print("tocancel[%d]=%d imat(%d,%d)=%d\n",j,tocancel[j],(-mr)+j+1,1,IMATELEM((*result),(-mr)+j+1,1));
918 IMATELEM((*result),(-mr)+j+1,1) -= tocancel[j];
919 }
920 }
921 for (i=0;i<cols-1;i++)
922 {
923 if ((i==0) && (weights!=NULL)) p_SetModDeg(weights, currRing);
924 memset(temp2,0,l*sizeof(int));
925 for (j=0;j<IDELEMS(res[i]);j++)
926 {
927 if (res[i]->m[j]!=NULL)
928 {
929 temp2[j+1] = p_FDeg(res[i]->m[j],currRing)+temp1[pGetComp(res[i]->m[j])];
930 //(*result)[i+1+(temp2[j+1]-i-1)*cols]++;
931 //if (temp2[j+1]>i) IMATELEM((*result),temp2[j+1]-i-mr,i+2)++;
932 IMATELEM((*result),temp2[j+1]-i-mr,i+2)++;
933 }
934 else if (i==0)
935 {
936 if (j<r0_len) IMATELEM((*result),-mr,2)++;
937 }
938 }
939 /*------ computation betti numbers, if res not minimal --------------*/
940 if (tomin)
941 {
942 for (j=mr;j<rows+mr;j++)
943 {
944 //(*result)[i+1+j*cols] -= tocancel[j+1];
945 IMATELEM((*result),j+1-mr,i+2) -= tocancel[j+1];
946 }
947 if ((i<length-1) && (res[i+1]!=NULL))
948 {
949 memset(tocancel,0,(rows+1)*sizeof(int));
951 for (j=0;j<rows;j++)
952 {
953 //(*result)[i+1+j*cols] -= tocancel[j];
954 IMATELEM((*result),j+1,i+2) -= tocancel[j];
955 }
956 }
957 }
958 temp3 = temp1;
959 temp1 = temp2;
960 temp2 = temp3;
961 for (j=0;j<=rows;j++)
962 {
963 // if (((*result)[i+1+j*cols]!=0) && (j>*regularity)) *regularity = j;
964 if ((IMATELEM((*result),j+1,i+2)!=0) && (j>*regularity)) *regularity = j;
965 }
966 if ((i==0) && (weights!=NULL)) p_SetModDeg(NULL, currRing);
967 }
968 // Print("nach minim:\n"); result->show(); PrintLn();
969 /*------ clean up --------------*/
970 omFreeSize((ADDRESS)tocancel,(rows+1)*sizeof(int));
971 omFreeSize((ADDRESS)temp1,(l+1)*sizeof(int));
972 omFreeSize((ADDRESS)temp2,(l+1)*sizeof(int));
973 if ((tomin) && (mr<0)) // deletes the first (zero) line
974 {
975 for (j=1;j<=rows+mr+1;j++)
976 {
977 for (k=1;k<=cols;k++)
978 {
979 IMATELEM((*result),j,k) = IMATELEM((*result),j-mr,k);
980 }
981 }
982 for (j=rows+mr+1;j<=rows+1;j++)
983 {
984 for (k=1;k<=cols;k++)
985 {
986 IMATELEM((*result),j,k) = 0;
987 }
988 }
989 }
990 j = 0;
991 k = 0;
992 for (i=1;i<=result->rows();i++)
993 {
994 for(l=1;l<=result->cols();l++)
995 if (IMATELEM((*result),i,l) != 0)
996 {
997 j = si_max(j, i-1);
998 k = si_max(k, l-1);
999 }
1000 }
1001 intvec * exactresult=new intvec(j+1,k+1,0);
1002 for (i=0;i<exactresult->rows();i++)
1003 {
1004 for (j=0;j<exactresult->cols();j++)
1005 {
1006 IMATELEM(*exactresult,i+1,j+1) = IMATELEM(*result,i+1,j+1);
1007 }
1008 }
1009 if (row_shift!=NULL) *row_shift = mr;
1010 delete result;
1011 return exactresult;
1012}
static int si_max(const int a, const int b)
Definition auxiliary.h:124
#define TRUE
Definition auxiliary.h:100
int l
Definition cfEzgcd.cc:100
int m
Definition cfEzgcd.cc:128
int i
Definition cfEzgcd.cc:132
int k
Definition cfEzgcd.cc:99
void show(int mat=0, int spaces=0) const
Definition intvec.cc:149
int length() const
Definition intvec.h:94
#define Print
Definition emacs.cc:80
#define WarnS
Definition emacs.cc:78
return result
CanonicalForm res
Definition facAbsFact.cc:60
const CanonicalForm & w
Definition facAbsFact.cc:51
int j
Definition facHensel.cc:110
void WerrorS(const char *s)
Definition feFopen.cc:24
BOOLEAN idTestHomModule(ideal m, ideal Q, intvec *w)
Definition ideals.cc:2077
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
static BOOLEAN idHomModule(ideal m, ideal Q, intvec **w)
Definition ideals.h:96
static BOOLEAN length(leftv result, leftv arg)
Definition interval.cc:257
#define IMATELEM(M, I, J)
Definition intvec.h:85
#define omFreeSize(addr, size)
#define omAlloc(size)
#define omAlloc0(size)
#define NULL
Definition omList.c:12
void p_SetModDeg(intvec *w, ring r)
Definition p_polys.cc:3694
static long p_FDeg(const poly p, const ring r)
Definition p_polys.h:380
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
#define pGetComp(p)
Component.
Definition polys.h:37
void PrintS(const char *s)
Definition reporter.cc:284
void PrintLn()
Definition reporter.cc:310
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
#define IDELEMS(i)
@ isHomog
Definition structs.h:37
int syDetect(ideal id, int index, BOOLEAN homog, int *degrees, int *tocancel)
Definition syz.cc:714

◆ syDeleteAbove()

static void syDeleteAbove ( ideal  up,
int  k 
)
static

Definition at line 66 of file syz.cc.

67{
68 if (up!=NULL)
69 {
70 for (int i=0;i<IDELEMS(up);i++)
71 {
72 if (up->m[i]!=NULL)
73 pDeleteComp(&(up->m[i]),k+1);
74 }
75 }
76}
#define pDeleteComp(p, k)
Definition polys.h:360

◆ syDeleteAbove1()

static void syDeleteAbove1 ( ideal  up,
int  k 
)
static

Definition at line 264 of file syz.cc.

265{
266 poly p/*,pp*/;
267 if (up!=NULL)
268 {
269 for (int i=0;i<IDELEMS(up);i++)
270 {
271 p = up->m[i];
272 while ((p!=NULL) && ((int)__p_GetComp(p,currRing)==k))
273 {
274 pLmDelete(&p);
275 }
276 up->m[i] = p;
277 if (p!=NULL)
278 {
279 while (pNext(p)!=NULL)
280 {
281 if ((int)__p_GetComp(pNext(p),currRing)==k)
282 {
283 pLmDelete(&pNext(p));
284 }
285 else
286 pIter(p);
287 }
288 }
289 }
290 }
291}
int p
Definition cfModGcd.cc:4086
#define pIter(p)
Definition monomials.h:37
#define pNext(p)
Definition monomials.h:36
#define __p_GetComp(p, r)
Definition monomials.h:63
#define pLmDelete(p)
assume p != NULL, deletes Lm(p)->coef and Lm(p)
Definition polys.h:76

◆ syDetect() [1/2]

int syDetect ( ideal  id,
int  index,
BOOLEAN  homog,
int degrees,
int tocancel 
)

Definition at line 714 of file syz.cc.

715{
716 int i, j, k, subFromRank=0;
717 ideal temp;
718
719 if (idIs0(id)) return 0;
720 temp = idInit(IDELEMS(id),id->rank);
721 for (i=0;i<IDELEMS(id);i++)
722 {
723 temp->m[i] = sypCopyConstant(id->m[i]);
724 }
725 i = IDELEMS(id);
726 while ((i>0) && (temp->m[i-1]==NULL)) i--;
727 if (i==0)
728 {
729 idDelete(&temp);
730 return 0;
731 }
732 j = 0;
733 while ((j<i) && (temp->m[j]==NULL)) j++;
734 while (j<i)
735 {
736 if (homog)
737 {
738 if (index==0) k = p_FDeg(temp->m[j],currRing)+degrees[pGetComp(temp->m[j])];
739 else k = degrees[pGetComp(temp->m[j])];
740 if (k>=index) tocancel[k-index]++;
741 if ((k>=0) && (index==0)) subFromRank++;
742 }
743 else
744 {
745 tocancel[0]--;
746 }
748 j++;
749 while ((j<i) && (temp->m[j]==NULL)) j++;
750 }
751 idDelete(&temp);
752 return subFromRank;
753}
int * degrees(const CanonicalForm &f, int *degs=0)
int * degrees ( const CanonicalForm & f, int * degs )
Definition cf_ops.cc:493
#define idDelete(H)
delete an ideal
Definition ideals.h:29
static int index(p_Length length, p_Ord ord)
ideal idInit(int idsize, int rank)
initialise an ideal / module
static poly sypCopyConstant(poly inp)
Definition syz.cc:692
void syGaussForOne(ideal syz, int elnum, int ModComp, int from, int till)
Definition syz.cc:218

◆ syDetect() [2/2]

void syDetect ( ideal  id,
int  index,
int  rsmin,
BOOLEAN  homog,
intvec degrees,
intvec tocancel 
)

Definition at line 755 of file syz.cc.

757{
758 int * deg=NULL;
759 int * tocan=(int*) omAlloc0(tocancel->length()*sizeof(int));
760 int i;
761
762 if (homog)
763 {
764 deg = (int*) omAlloc0(degrees->length()*sizeof(int));
765 for (i=degrees->length();i>0;i--)
766 deg[i-1] = (*degrees)[i-1]-rsmin;
767 }
768 syDetect(id,index,homog,deg,tocan);
769 for (i=tocancel->length();i>0;i--)
770 (*tocancel)[i-1] = tocan[i-1];
771 if (homog)
772 omFreeSize((ADDRESS)deg,degrees->length()*sizeof(int));
773 omFreeSize((ADDRESS)tocan,tocancel->length()*sizeof(int));
774}
int length() const

◆ syGaussForOne()

void syGaussForOne ( ideal  syz,
int  elnum,
int  ModComp,
int  from,
int  till 
)

Definition at line 218 of file syz.cc.

219{
220 int /*k,j,i,*/lu;
221 poly unit1,unit2;
222 poly actWith=syz->m[elnum];
223 syz->m[elnum] = NULL;
224
225 if (from<0) from = 0;
226 if ((till<=0) || (till>IDELEMS(syz))) till = IDELEMS(syz);
228/*--makes Gauss alg. for the column ModComp--*/
230 if (lu==1) /*p_IsConstantComp(unit1,currRing)*/
231 {
233 while (from<till)
234 {
235 poly tmp=syz->m[from];
236 if (/*syz->m[from]*/ tmp!=NULL)
237 {
240 syz->m[from] = pSub(tmp,
242 }
243 from++;
244 }
245 }
246 else
247 {
248 while (from<till)
249 {
250 poly tmp=syz->m[from];
251 if (/*syz->m[from]*/ tmp!=NULL)
252 {
254 tmp = pMult(pCopy(unit1),tmp);
255 syz->m[from] = pSub(tmp,
257 }
258 from++;
259 }
260 }
262 pDelete(&unit1);
263}
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition monomials.h:44
poly p_Cleardenom(poly p, const ring r)
Definition p_polys.cc:2849
static poly p_Mult_nn(poly p, number n, const ring r)
Definition p_polys.h:958
#define pDelete(p_ptr)
Definition polys.h:186
#define pSub(a, b)
Definition polys.h:287
#define pMult(p, q)
Definition polys.h:207
void pTakeOutComp(poly *p, long comp, poly *q, int *lq, const ring R=currRing)
Splits *p into two polys: *q which consists of all monoms with component == comp and *p of all other ...
Definition polys.h:338
#define pCopy(p)
return a copy of the poly
Definition polys.h:185
static BOOLEAN rField_has_simple_inverse(const ring r)
Definition ring.h:553

◆ syMinBase()

ideal syMinBase ( ideal  arg)

Definition at line 1017 of file syz.cc.

1018{
1019 intvec ** weights=NULL;
1020 int leng;
1021 if (idIs0(arg)) return idInit(1,arg->rank);
1022 resolvente res=syResolvente(arg,1,&leng,&weights,TRUE);
1023 ideal result=res[0];
1024 omFreeSize((ADDRESS)res,leng*sizeof(ideal));
1025 if (weights!=NULL)
1026 {
1027 if (*weights!=NULL)
1028 {
1029 delete (*weights);
1030 *weights=NULL;
1031 }
1032 if ((leng>=1) && (*(weights+1)!=NULL))
1033 {
1034 delete *(weights+1);
1035 *(weights+1)=NULL;
1036 }
1037 }
1039 return result;
1040}
ideal * resolvente
Definition ideals.h:18
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
resolvente syResolvente(ideal arg, int maxlength, int *length, intvec ***weights, BOOLEAN minim)
Definition syz.cc:401

◆ syMinimize_with_map()

void syMinimize_with_map ( syStrategy  res,
ideal trans 
)

Definition at line 1185 of file syz.cc.

1186{
1187 ideal *r=res->minres;
1188 if (r==NULL) r=res->fullres;
1189 ideal org=idCopy(r[0]);
1191 r=res->minres;
1192 if (r==NULL) r=res->fullres;
1194}
#define FALSE
Definition auxiliary.h:96
ideal idLift(ideal mod, ideal submod, ideal *rest, BOOLEAN goodShape, BOOLEAN isSB, BOOLEAN divide, matrix *unit, GbVariant alg)
represents the generators of submod in terms of the generators of mod (Matrix(SM)*U-Matrix(rest)) = M...
Definition ideals.cc:1105
ideal idCopy(ideal A)
Definition ideals.h:60
syStrategy syMinimize(syStrategy syzstr)
Definition syz1.cc:2393

◆ syMinimizeCopy()

syStrategy syMinimizeCopy ( syStrategy  org)

Definition at line 1196 of file syz.cc.

1197{
1199
1201 if (org->weights!=NULL)
1202 {
1203 result->weights=(intvec**)omAlloc0(org->length*sizeof(intvec*));
1204 for (int i=org->length-1;i>=0;i--)
1205 {
1206 if (org->weights[i]!=NULL)
1207 {
1208 result->weights[i]=ivCopy(org->weights[i]);
1209 }
1210 }
1211 }
1212 result->fullres = (resolvente)omAlloc0((result->length+1)*sizeof(ideal));
1213 resolvente fr = org->minres;
1214 if (fr==NULL) fr=org->fullres;
1215
1216 for (int i=result->length-1;i>=0;i--)
1217 {
1218 if (fr[i]!=NULL)
1219 result->fullres[i] = idCopy(fr[i]);
1220 }
1221 result->list_length=result->length;
1223 return result;
1224}
intvec * ivCopy(const intvec *o)
Definition intvec.h:145
ssyStrategy * syStrategy
Definition syz.h:36

◆ syMinimizeResolvente()

void syMinimizeResolvente ( resolvente  res,
int  length,
int  first 
)

Definition at line 367 of file syz.cc.

368{
369 int syzIndex=first;
370 intvec *dummy;
371
372 if (syzIndex<1) syzIndex=1;
373 if ((syzIndex==1) && (!rIsPluralRing(currRing)) && (idHomModule(res[0],currRing->qideal,&dummy)))
374 {
376 delete dummy;
377 return;
378 }
379 while ((syzIndex<length-1) && (res[syzIndex]!=NULL) && (res[syzIndex+1]!=NULL))
380 {
382 syzIndex++;
383 }
384 if (res[syzIndex]!=NULL)
386 if (!idIs0(res[0]))
388}
ideal idMinEmbedding(ideal arg, BOOLEAN inPlace, intvec **w)
Definition ideals.cc:2814
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition ring.h:405
static void syMinStep1(resolvente res, int length)
Definition syz.cc:296
static void syMinStep(ideal mod, ideal &syz, BOOLEAN final=FALSE, ideal up=NULL, tHomog h=isNotHomog)
Definition syz.cc:82

◆ syMinStep()

static void syMinStep ( ideal  mod,
ideal syz,
BOOLEAN  final = FALSE,
ideal  up = NULL,
tHomog  h = isNotHomog 
)
static

Definition at line 82 of file syz.cc.

84{
85 poly Unit1,Unit2,actWith;
86 int len,i,j,ModComp,m,k,l;
88
89 if (TEST_OPT_PROT) PrintS("m");
90 if ((final) && (h==isHomog))
91 /*minim is TRUE, we are in the module: maxlength, maxlength <>0*/
92 {
94 id_Delete(&syz,currRing);
96 syz=deg0;
97 }
98/*--cancels empty entees and their related components above--*/
99 j = IDELEMS(syz);
100 while ((j>0) && (!syz->m[j-1])) j--;
101 k = 0;
102 while (k<j)
103 {
104 if (syz->m[k]!=NULL)
105 k++;
106 else
107 {
108 if (TEST_OPT_PROT) PrintS(".");
109 for (l=k;l<j-1;l++) syz->m[l] = syz->m[l+1];
110 syz->m[j-1] = NULL;
112 j--;
113 }
114 }
115/*--searches for syzygies coming from superfluous elements
116* in the module below--*/
121 while (searchUnit)
122 {
123 i=0;
124 j=IDELEMS(syz);
125 while ((j>0) && (syz->m[j-1]==NULL)) j--;
128 {
129 while ((i<j) && (!existsUnit))
130 {
132 i++;
133 }
134 }
135 else
136 {
137 int I=0;
138 l = 0;
139 len=0;
140 for (i=0;i<IDELEMS(syz);i++)
141 {
142 if (syz->m[i]!=NULL)
143 {
144 pVectorHasUnit(syz->m[i],&m, &l);
145 if ((len==0) ||((l>0) && (l<len)))
146 {
147 len = l;
148 ModComp = m;
149 I = i;
150 }
151 }
152 }
153//Print("Laenge ist: %d\n",len);
154 if (len>0) existsUnit = TRUE;
155 i = I+1;
156 }
157 if (existsUnit)
158 {
159 i--;
160//--takes out the founded syzygy--
161 if (TEST_OPT_PROT) PrintS("f");
162 actWith = syz->m[i];
164//Print("actWith: ");pWrite(actWith);
165 syz->m[i] = NULL;
166 for (k=i;k<j-1;k++) syz->m[k] = syz->m[k+1];
167 syz->m[j-1] = NULL;
169 j--;
170//--makes Gauss alg. for the column ModComp--
172//PrintS("actWith now: ");pWrite(actWith);
173//Print("Unit1: ");pWrite(Unit1);
174 k=0;
175//Print("j= %d",j);
176 while (k<j)
177 {
178 if (syz->m[k]!=NULL)
179 {
180 Unit2 = pTakeOutComp(&(syz->m[k]), ModComp);
181//Print("element %d: ",k);pWrite(syz->m[k]);
182//PrintS("Unit2: ");pWrite(Unit2);
183 syz->m[k] = pMult(pCopy(Unit1),syz->m[k]);
184 syz->m[k] = pSub(syz->m[k],
186 if (syz->m[k]==NULL)
187 {
188 for (l=k;l<j-1;l++)
189 syz->m[l] = syz->m[l+1];
190 syz->m[j-1] = NULL;
191 j--;
193 k--;
194 }
195 }
196 k++;
197 }
199 pDelete(&Unit1);
200//--deletes superfluous elements from the module below---
201 pDelete(&(mod->m[ModComp-1 - curr_syz_limit]));
202 for (k=ModComp-1 - curr_syz_limit;k<IDELEMS(mod)-1;k++)
203 mod->m[k] = mod->m[k+1];
204 mod->m[IDELEMS(mod)-1] = NULL;
205 }
206 else
208 }
209 if (TEST_OPT_PROT) PrintLn();
211 idSkipZeroes(syz);
212}
int BOOLEAN
Definition auxiliary.h:87
CF_NO_INLINE FACTORY_PUBLIC CanonicalForm mod(const CanonicalForm &, const CanonicalForm &)
STATIC_VAR Poly * h
Definition janet.cc:971
#define TEST_OPT_PROT
Definition options.h:103
#define pVectorHasUnitB(p, k)
Definition polys.h:332
#define pVectorHasUnit(p, k, l)
Definition polys.h:333
static int rGetCurrSyzLimit(const ring r)
Definition ring.h:728
BOOLEAN rHasGlobalOrdering(const ring r)
Definition ring.h:766
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
int idSkipZeroes0(ideal ide)
ideal id_Jet0(const ideal i, const ring R)
static void syDeleteAbove(ideal up, int k)
Definition syz.cc:66

◆ syMinStep1()

static void syMinStep1 ( resolvente  res,
int  length 
)
static

Definition at line 296 of file syz.cc.

297{
298 int i,j,k,index=0;
299 poly p;
301
302 while ((index<length) && (res[index]!=NULL))
303 {
304/*---we take out dependent elements from syz---------------------*/
305 if (res[index+1]!=NULL)
306 {
309 idDelete(&deg0);
311 for (i=0;i<IDELEMS(reddeg0);i++)
312 {
313 if (reddeg0->m[i]!=NULL)
314 {
316 pDelete(&(res[index]->m[j-1]));
317 /*res[index]->m[j-1] = NULL;*/
318 (*have_del)[j-1] = 1;
319 }
320 }
322 }
323 if (index>0)
324 {
325/*--- we search for units and perform Gaussian elimination------*/
326 j = to_del->length();
327 while (j>0)
328 {
329 if ((*to_del)[j-1]==1)
330 {
331 k = 0;
332 while (k<IDELEMS(res[index]))
333 {
334 p = res[index]->m[k];
335 while ((p!=NULL)
336 && ((!pLmIsConstantComp(p)) || ((int)__p_GetComp(p,currRing)!=j)))
337 pIter(p);
338 if ((p!=NULL)
339 && (pLmIsConstantComp(p))
340 && ((int)__p_GetComp(p,currRing)==j)) break;
341 k++;
342 }
343 #ifndef SING_NDEBUG
344 if (k>=IDELEMS(res[index]))
345 {
346 PrintS("out of range\n");
347 }
348 #endif
350 if (res[index+1]!=NULL)
352 (*to_del)[j-1] = 0;
353 }
354 j--;
355 }
356 }
357 if (to_del!=NULL) delete to_del;
359 have_del = NULL;
360 index++;
361 }
362 if (TEST_OPT_PROT) PrintLn();
364 if (to_del!=NULL) delete to_del;
365}
ideal kInterRedOld(ideal F, const ideal Q)
Definition kstd1.cc:3452
#define pLmIsConstantComp(p)
like above, except that p must be != NULL
Definition polys.h:242
static void syDeleteAbove1(ideal up, int k)
Definition syz.cc:264
void syKillEmptyEntres(resolvente res, int length)
Definition syz1.cc:2199

◆ syMres_with_map()

syStrategy syMres_with_map ( ideal  arg,
int  maxlength,
intvec w,
ideal trans 
)

Definition at line 1176 of file syz.cc.

1177{
1179 ideal *r=res->minres;
1180 if (r==NULL) r=res->fullres;
1181 trans=idLift(arg,r[0],NULL,TRUE,FALSE,FALSE,NULL);
1182 return res;
1183}
syStrategy syResolution(ideal arg, int maxlength, intvec *w, BOOLEAN minim)
Definition syz.cc:626

◆ sypCopyConstant()

static poly sypCopyConstant ( poly  inp)
static

Definition at line 692 of file syz.cc.

693{
694 poly outp=NULL,q;
695
696 while (inp!=NULL)
697 {
699 {
700 if (outp==NULL)
701 {
702 q = outp = pHead(inp);
703 }
704 else
705 {
706 pNext(q) = pHead(inp);
707 pIter(q);
708 }
709 }
710 pIter(inp);
711 }
712 return outp;
713}
#define pHead(p)
returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL
Definition polys.h:67

◆ syPrepareModComp()

static intvec * syPrepareModComp ( ideal  arg,
intvec **  w 
)
static

Definition at line 25 of file syz.cc.

26{
27 intvec *w1 = NULL;
28 int i;
30
31 if ((w==NULL) || (*w==NULL)) return w1;
32 int maxxx = (*w)->length();
33 if (maxxx==1)
34 {
35 maxxx = 2;
36 isIdeal = TRUE;
37 }
38 w1 = new intvec(maxxx+IDELEMS(arg));
39 if (!isIdeal)
40 {
41 for (i=0;i<maxxx;i++)
42 {
43 (*w1)[i] = (**w)[i];
44 }
45 }
46 for (i=maxxx;i<maxxx+IDELEMS(arg);i++)
47 {
48 if (arg->m[i-maxxx]!=NULL)
49 {
50 (*w1)[i] = p_FDeg(arg->m[i-maxxx],currRing);
51 if (pGetComp(arg->m[i-maxxx])!=0)
52 {
53 (*w1)[i]+=(**w)[pGetComp(arg->m[i-maxxx])-1];
54 }
55 }
56 }
57 delete (*w);
58 *w = new intvec(IDELEMS(arg)+1);
59 for (i=0;i<IDELEMS(arg);i++)
60 {
61 (**w)[i+1] = (*w1)[i+maxxx];
62 }
63 return w1;
64}

◆ syResolution()

syStrategy syResolution ( ideal  arg,
int  maxlength,
intvec w,
BOOLEAN  minim 
)

Definition at line 626 of file syz.cc.

627{
628
629#ifdef HAVE_PLURAL
630 const ideal idSaveCurrRingQuotient = currRing->qideal;
631 if( rIsSCA(currRing) )
632 {
634 {
635 currRing->qideal = SCAQuotient(currRing);
636 }
637 const unsigned int m_iFirstAltVar = scaFirstAltVar(currRing);
638 const unsigned int m_iLastAltVar = scaLastAltVar(currRing);
639 arg = id_KillSquares(arg, m_iFirstAltVar, m_iLastAltVar, currRing, false); // kill suares in input!
640 }
641#endif
642
644
645 if ((w!=NULL) && (!idTestHomModule(arg,currRing->qideal,w))) // is this right in SCA case???
646 {
647 WarnS("wrong weights given(2):");w->show();PrintLn();
648 idHomModule(arg,currRing->qideal,&w);
649 w->show();PrintLn();
650 w=NULL;
651 }
652 if (w!=NULL)
653 {
654 result->weights = (intvec**)omAlloc0Bin(char_ptr_bin);
655 (result->weights)[0] = ivCopy(w);
656 result->length = 1;
657 }
658 resolvente fr = syResolvente(arg,maxlength,&(result->length),&(result->weights),minim);
660 if (minim)
661 {
662 result->minres = (resolvente)omAlloc0((result->length+1)*sizeof(ideal));
663 fr1 = result->minres;
664 }
665 else
666 {
667 result->fullres = (resolvente)omAlloc0((result->length+1)*sizeof(ideal));
668 fr1 = result->fullres;
669 }
670 for (int i=result->length-1;i>=0;i--)
671 {
672 if (fr[i]!=NULL)
673 fr1[i] = fr[i];
674 fr[i] = NULL;
675 }
676 omFreeSize((ADDRESS)fr,(result->length)*sizeof(ideal));
677
678#ifdef HAVE_PLURAL
679 if( rIsSCA(currRing) )
680 {
682 {
684 }
685 id_Delete(&arg, currRing);
686 }
687#endif
688
689 return result;
690}
static bool rIsSCA(const ring r)
Definition nc.h:190
bool ncExtensions(int iMask)
Definition old.gring.cc:94
const int TESTSYZSCAMASK
Definition nc.h:338
ideal id_KillSquares(const ideal id, const short iFirstAltVar, const short iLastAltVar, const ring r, const bool bSkipZeroes)
Definition sca.cc:1518
#define omAlloc0Bin(bin)
ideal SCAQuotient(const ring r)
Definition sca.h:10
static short scaLastAltVar(ring r)
Definition sca.h:25
static short scaFirstAltVar(ring r)
Definition sca.h:18
EXTERN_VAR omBin char_ptr_bin
Definition structs.h:77

◆ syResolvente()

resolvente syResolvente ( ideal  arg,
int  maxlength,
int length,
intvec ***  weights,
BOOLEAN  minim 
)

Definition at line 401 of file syz.cc.

403{
408 intvec *w = NULL,**tempW;
409 int i,k,syzIndex = 0,j,rk_arg=si_max(1,(int)id_RankFreeModule(arg,currRing));
414 int wlength=*length;
415
416 if (maxlength!=-1) *length = maxlength+1;
417 else *length = 5;
418 if ((wlength!=0) && (*length!=wlength))
419 {
420 intvec **wtmp = (intvec**)omAlloc0((*length)*sizeof(intvec*));
421 wtmp[0]=(*weights)[0];
422 omFreeSize((ADDRESS)*weights,wlength*sizeof(intvec*));
423 *weights=wtmp;
424 }
426
427/*--- initialize the syzygy-ring -----------------------------*/
429 ring syz_ring = rAssure_SyzComp(origR, TRUE); // will do rChangeCurrRing if needed
431
432 if (syz_ring != origR)
433 {
435 res[0] = idrCopyR_NoSort(arg, origR, syz_ring);
436 }
437 else
438 {
439 res[0] = idCopy(arg);
440 }
441
442/*--- creating weights for the module components ---------------*/
443 if ((weights!=NULL) && (*weights!=NULL)&& ((*weights)[0]!=NULL))
444 {
445 if (!idTestHomModule(res[0],currRing->qideal,(*weights)[0]))
446 {
447 WarnS("wrong weights given(1):"); (*weights)[0]->show();PrintLn();
448 idHomModule(res[0],currRing->qideal,&w);
449 w->show();PrintLn();
450 *weights=NULL;
451 }
452 }
453
454 if ((weights==NULL) || (*weights==NULL) || ((*weights)[0]==NULL))
455 {
456 hom=(tHomog)idHomModule(res[0],currRing->qideal,&w);
457 if (hom==isHomog)
458 {
459 *weights = (intvec**)omAlloc0((*length)*sizeof(intvec*));
460 if (w!=NULL) (*weights)[0] = ivCopy(w);
461 }
462 }
463 else
464 {
465 if ((weights!=NULL) && (*weights!=NULL)&& ((*weights)[0]!=NULL))
466 {
467 w = ivCopy((*weights)[0]);
468 hom = isHomog;
469 }
470 }
471
472#ifdef HAVE_PLURAL
474 {
475// quick solution; need theory to apply homog GB stuff for G-Algebras
476 hom = isNotHomog;
477 }
478#endif // HAVE_PLURAL
479
480 if (hom==isHomog)
481 {
483 if (w!=NULL) { delete w;w=NULL; }
484 w = w1;
485 j = 0;
486 while ((j<IDELEMS(res[0])) && (res[0]->m[j]==NULL)) j++;
487 if (j<IDELEMS(res[0]))
488 {
489 if (p_FDeg(res[0]->m[j],currRing)!=pTotaldegree(res[0]->m[j]))
491 }
492 }
493 else
494 {
496 }
497
498/*--- the main loop --------------------------------------*/
499 while ((res[syzIndex]!=NULL) && (!idIs0(res[syzIndex])) &&
500 ((maxlength==-1) || (syzIndex<=maxlength)))
501 // (syzIndex<maxlength+(int)minim)))
502/*--- compute one step more for minimizing-----------------*/
503 {
504 if (Kstd1_deg!=0) Kstd1_deg++;
505 if (syzIndex+1==*length)
506 {
507 newres = (resolvente)omAlloc0((*length+5)*sizeof(ideal));
508 tempW = (intvec**)omAlloc0((*length+5)*sizeof(intvec*));
509 for (j=0;j<*length;j++)
510 {
511 newres[j] = res[j];
512 if (*weights!=NULL) tempW[j] = (*weights)[j];
513 /*else tempW[j] = NULL;*/
514 }
515 omFreeSize((ADDRESS)res,*length*sizeof(ideal));
516 if (*weights != NULL) omFreeSize((ADDRESS)*weights,*length*sizeof(intvec*));
517 *length += 5;
518 res=newres;
519 *weights = tempW;
520 }
521/*--- interreducing first -----------------------------------*/
522 if (syzIndex>0)
523 {
526 }
528 if (minim || (syzIndex!=0))
529 {
533 res[syzIndex] = temp;
534 }
535/*--- computing the syzygy modules --------------------------------*/
536 if ((currRing->qideal==NULL)&&(syzIndex==0)&& (!TEST_OPT_DEGBOUND))
537 {
538 res[/*syzIndex+*/1] = idSyzygies(res[0/*syzIndex*/],hom,&w,FALSE,setRegularity,&Kstd1_deg);
542 }
543 else
544 {
546 }
548 syzIndex++;
549 if (TEST_OPT_PROT) Print("[%d]\n",syzIndex);
550
552 {
553 if ((minim)||(syzIndex>1))
555 if (!completeMinim)
556 /*minim is TRUE, we are in the module: maxlength, maxlength <>0*/
557 {
559 }
560 }
561/*---creating the iterated weights for module components ---------*/
562 if ((hom == isHomog) && (res[syzIndex]!=NULL) && (!idIs0(res[syzIndex])))
563 {
564//Print("die %d Modulegewichte sind:\n",w1->length());
565//w1->show();
566//PrintLn();
569 assume(w != NULL);
570 if (w != NULL)
571 w->resize(max_comp+IDELEMS(res[syzIndex]));
572 else
574 (*weights)[syzIndex] = new intvec(k);
575 for (i=0;i<k;i++)
576 {
577 if (res[syzIndex-1]->m[i]!=NULL) // hs
578 {
580 if (pGetComp(res[syzIndex-1]->m[i])>0)
582 += (*w)[pGetComp(res[syzIndex-1]->m[i])-1];
583 (*((*weights)[syzIndex]))[i] = (*w)[i+rGetCurrSyzLimit(currRing)];
584 }
585 }
586 for (i=k;i<k+IDELEMS(res[syzIndex]);i++)
587 {
588 if (res[syzIndex]->m[i-k]!=NULL)
590 +(*w)[pGetComp(res[syzIndex]->m[i-k])-1];
591 }
592 }
593 }
594/*--- end of the main loop --------------------------------------*/
595/*--- deleting the temporare data structures --------------------*/
596 if ((syzIndex!=0) && (res[syzIndex]!=NULL) && (idIs0(res[syzIndex])))
598 if (w !=NULL) delete w;
599
601 if (!oldDegBound)
602 si_opt_1 &= ~Sy_bit(OPT_DEGBOUND);
603
604 for (i=1; i<=syzIndex; i++)
605 {
606 if ((res[i]!=NULL) && ! idIs0(res[i]))
607 {
609 res[i]->rank=idElem(res[i-1]);
610 }
611 }
612/*--- going back to the original ring -------------------------*/
613 if (origR != syz_ring)
614 {
615 rChangeCurrRing(origR); // should not be needed now?
616 for (i=0; i<=syzIndex; i++)
617 {
619 }
621 }
623 return res;
624}
ideal idSyzygies(ideal h1, tHomog h, intvec **w, BOOLEAN setSyzComp, BOOLEAN setRegularity, int *deg, GbVariant alg)
Definition ideals.cc:830
EXTERN_VAR int Kstd1_deg
Definition kstd1.h:50
#define assume(x)
Definition mod2.h:387
VAR unsigned si_opt_1
Definition options.c:5
#define SI_SAVE_OPT1(A)
Definition options.h:21
#define SI_RESTORE_OPT1(A)
Definition options.h:24
#define Sy_bit(x)
Definition options.h:31
#define TEST_OPT_DEGBOUND
Definition options.h:113
#define TEST_OPT_NOTREGULARITY
Definition options.h:120
#define OPT_DEGBOUND
Definition options.h:90
#define TEST_OPT_NO_SYZ_MINIM
Definition options.h:124
void rChangeCurrRing(ring r)
Definition polys.cc:15
static long pTotaldegree(poly p)
Definition polys.h:282
ideal idrMoveR_NoSort(ideal &id, ring src_r, ring dest_r)
Definition prCopy.cc:261
ideal idrCopyR_NoSort(ideal id, ring src_r, ring dest_r)
Definition prCopy.cc:205
ring rAssure_SyzComp(const ring r, BOOLEAN complete)
Definition ring.cc:4466
int rGetMaxSyzComp(int i, const ring r)
return the max-comonent wchich has syzIndex i Assume: i<= syzIndex_limit
Definition ring.cc:5241
void rDelete(ring r)
unconditionally deletes fields in r
Definition ring.cc:452
void rSetSyzComp(int k, const ring r)
Definition ring.cc:5169
#define rField_is_Ring(R)
Definition ring.h:490
void id_Shift(ideal M, int s, const ring r)
static int idElem(const ideal F)
number of non-zero polys in F
tHomog
Definition structs.h:35
@ isNotHomog
Definition structs.h:36
#define BITSET
Definition structs.h:16
static intvec * syPrepareModComp(ideal arg, intvec **w)
Definition syz.cc:25