785{
786
787
788 int i,
j=0,
k=0,
l,rows,cols,mr;
789 int *temp1,*temp2,*temp3;
790 int *tocancel;
791 int r0_len;
792
793
794 *regularity = -1;
796 while ((cols>0)
799 {
800 cols--;
801 }
804 {
807 else
810 }
813 {
815 {
820 }
821 }
822#if 0
824 {
825 WarnS(
"betti-command: Input is not homogeneous!");
827 }
828#endif
829 if (weights==
NULL) weights=
w;
832 while ((r0_len>0) && (
res[0]->
m[r0_len-1]==
NULL)) r0_len--;
833 #ifdef SHOW_W
835 #endif
839 {
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 {
851 memset(temp2,0,(
l+1)*
sizeof(
int));
853 {
855 {
857
858
859 )
860 {
861 WerrorS(
"input not a resolution");
865 }
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 }
872 temp3 = temp1;
873 temp1 = temp2;
874 temp2 = temp3;
875 }
876 mr--;
878 {
880 {
881 if (rows <(*weights)[
j]+1) rows=(-mr)+(*weights)[
j]+1;
882 }
883 }
884
885 rows -= mr;
888 {
890 {
892
893 }
894 }
895 else
896 {
897 (*result)[(-mr)*cols] = rkl;
899 (*result)[(-mr)*cols] = 1;
900 }
901 tocancel = (
int*)
omAlloc0((rows+1)*
sizeof(
int));
902 memset(temp1,0,(
l+1)*
sizeof(
int));
904 {
905 memset(temp2,0,
l*
sizeof(
int));
907 }
908 else
909 memset(temp2,0,
l*
sizeof(
int));
912 if (tomin)
913 {
914
915 for(
j=0;
j<=rows+mr;
j++)
916 {
917
919 }
920 }
921 for (
i=0;
i<cols-1;
i++)
922 {
924 memset(temp2,0,
l*
sizeof(
int));
926 {
928 {
930
931
933 }
935 {
937 }
938 }
939
940 if (tomin)
941 {
942 for (
j=mr;
j<rows+mr;
j++)
943 {
944
946 }
948 {
949 memset(tocancel,0,(rows+1)*sizeof(int));
952 {
953
955 }
956 }
957 }
958 temp3 = temp1;
959 temp1 = temp2;
960 temp2 = temp3;
961 for (
j=0;
j<=rows;
j++)
962 {
963
965 }
967 }
968
969
973 if ((tomin) && (mr<0))
974 {
975 for (
j=1;
j<=rows+mr+1;
j++)
976 {
977 for (
k=1;
k<=cols;
k++)
978 {
980 }
981 }
982 for (
j=rows+mr+1;
j<=rows+1;
j++)
983 {
984 for (
k=1;
k<=cols;
k++)
985 {
987 }
988 }
989 }
993 {
996 {
999 }
1000 }
1002 for (
i=0;
i<exactresult->
rows();
i++)
1003 {
1004 for (
j=0;
j<exactresult->
cols();
j++)
1005 {
1007 }
1008 }
1009 if (row_shift!=
NULL) *row_shift = mr;
1011 return exactresult;
1012}
static int si_max(const int a, const int b)
void show(int mat=0, int spaces=0) const
void WerrorS(const char *s)
BOOLEAN idTestHomModule(ideal m, ideal Q, intvec *w)
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
static BOOLEAN idHomModule(ideal m, ideal Q, intvec **w)
static BOOLEAN length(leftv result, leftv arg)
#define IMATELEM(M, I, J)
#define omFreeSize(addr, size)
void p_SetModDeg(intvec *w, ring r)
static long p_FDeg(const poly p, const ring r)
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
#define pGetComp(p)
Component.
void PrintS(const char *s)
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
int syDetect(ideal id, int index, BOOLEAN homog, int *degrees, int *tocancel)