Changeset 57e95ce in git
- Timestamp:
- Apr 19, 2000, 5:45:00 PM (23 years ago)
- Branches:
- (u'spielwiese', 'f6c3dc58b0df4bd712574325fe76d0626174ad97')
- Children:
- 13d076b1deb4bfd0d554b81f02cd622c8b6b5f6d
- Parents:
- c78e8bf1856fddae986219c7747c226eb90cb1c7
- Location:
- Singular
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/sparsmat.cc
rc78e8b r57e95ce 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: sparsmat.cc,v 1.2 5 2000-02-09 08:15:09pohl Exp $ */4 /* $Id: sparsmat.cc,v 1.26 2000-04-19 15:45:00 pohl Exp $ */ 5 5 6 6 /* … … 42 42 static BOOLEAN smCheckLead(const poly, const poly); 43 43 static poly smDMult(poly, const poly); 44 static void smPolyDivN(poly a, const number); 44 static void smComplete(poly, const poly, const poly); 45 static void smPolyDivN(poly, const number); 45 46 static BOOLEAN smSmaller(poly, poly); 46 47 static void smCombineChain(poly *, poly); … … 1860 1861 lead = smCheckLead(a, e); 1861 1862 r = smDMult(a, e); 1863 smComplete(r, b, c); 1862 1864 } 1863 1865 else … … 1894 1896 { 1895 1897 r = smDMult(a, e); 1898 smComplete(r, b, c); 1896 1899 if (smCheckLead(a, e)) 1897 1900 smCombineChain(&pa, r); … … 1941 1944 pSetCoeff0(e,yn); 1942 1945 if (smIsNegQuot(e, a, b)) 1946 { 1943 1947 h = smDMult(tail, e); 1948 smComplete(h, a, b); 1949 } 1944 1950 else 1945 1951 h = smEMult(tail, e); … … 1954 1960 int i; 1955 1961 1956 for (i=pVariables; i; i--) 1957 { 1958 pSetExp(a,i,pGetExp(b,i)-pGetExp(c,i)); 1959 if (pGetExp(a,i) < 0) 1960 { 1961 while(--i) pSetExp(a,i,pGetExp(b,i)-pGetExp(c,i)); 1962 return TRUE; 1963 } 1964 } 1965 return FALSE; 1962 i=pVariables; 1963 while (i&&(pGetExp(b,i)<pGetExp(c,i))) i--; 1964 if(i) 1965 { 1966 for (i=pVariables; i; i--) 1967 { 1968 if(pGetExp(b,i)<pGetExp(c,i)) 1969 pSetExp(a,i,pGetExp(c,i)-pGetExp(b,i)); 1970 else 1971 pSetExp(a,i,0); 1972 } 1973 return TRUE; 1974 } 1975 else 1976 { 1977 for (i=pVariables; i; i--) 1978 { 1979 pSetExp(a,i,pGetExp(b,i)-pGetExp(c,i)); 1980 } 1981 return FALSE; 1982 } 1966 1983 } 1967 1984 … … 1972 1989 int i; 1973 1990 1974 h = res = p Init();1991 h = res = pNew(); 1975 1992 loop 1976 1993 { 1977 //pSetComp(h,0);1994 pCopy2(h,t); 1978 1995 for (i=pVariables; i; i--) 1979 p SetExp(h,i,pGetExp(e,i)+pGetExp(t,i));1996 pAddExp(h,i,pGetExp(e,i)); 1980 1997 pSetm(h); 1981 1998 pSetCoeff0(h,nMult(y,pGetCoeff(t))); … … 1986 2003 return res; 1987 2004 } 1988 h = pNext(h) = p Init();2005 h = pNext(h) = pNew(); 1989 2006 } 1990 2007 } … … 1992 2009 static BOOLEAN smCheckLead(const poly t, const poly e) 1993 2010 { 1994 int i;1995 for (i=pVariables; i; i--)1996 {1997 if ((pGetExp(e,i)+pGetExp(t,i)) < 0)1998 return FALSE;1999 }2000 return TRUE;2001 }2002 2003 static poly smDMult(poly t, const poly e)2004 {2005 const number y = pGetCoeff(e);2006 poly r = NULL;2007 poly res, h;2008 2011 int i; 2009 2012 Exponent_t w; 2010 2011 h = res = pInit(); 2013 for (i=pVariables; i; i--) 2014 { 2015 w = pGetExp(e,i); 2016 if (w&&(w>pGetExp(t,i))) 2017 return FALSE; 2018 } 2019 return TRUE; 2020 } 2021 2022 static poly smDMult(poly t, const poly e) 2023 { 2024 const number y = pGetCoeff(e); 2025 poly res, h; 2026 2012 2027 loop 2013 2028 { 2014 i=pVariables; 2029 if(smCheckLead(t,e)) break; 2030 pIter(t); 2031 if(t==NULL) return NULL; 2032 } 2033 h = res = pNew(); 2034 loop 2035 { 2036 pCopy2(h,t); 2037 pSetCoeff0(h,nMult(y,pGetCoeff(t))); 2015 2038 loop 2016 2039 { 2017 w = pGetExp(e,i)+pGetExp(t,i); 2018 if (w < 0) break; 2019 pSetExp(h,i,w); 2020 i--; 2021 if (i == 0) 2022 { 2023 pSetm(h); 2024 pSetCoeff0(h,nMult(y,pGetCoeff(t))); 2025 pIter(t); 2026 if (t == NULL) 2027 { 2028 pNext(h) = NULL; 2029 return res; 2030 } 2031 r = h; 2032 h = pNext(h) = pInit(); 2033 i=pVariables; 2034 } 2040 pIter(t); 2041 if(t==NULL) 2042 { 2043 pNext(h)=NULL; 2044 return res; 2045 } 2046 if(smCheckLead(t,e)) break; 2047 } 2048 h=pNext(h)=pNew(); 2049 } 2050 } 2051 2052 static void smComplete(poly t, const poly b, const poly c) 2053 { 2054 int i; 2055 while(t!=NULL) 2056 { 2057 for (i=pVariables; i; i--) 2058 { 2059 pAddExp(t,i,pGetExp(b,i)); 2060 pSubExp(t,i,pGetExp(c,i)); 2061 pSetm(t); 2035 2062 } 2036 2063 pIter(t); 2037 if (t == NULL)2038 {2039 if (r != NULL)2040 pNext(r) = NULL;2041 else2042 res = NULL;2043 pFree1(h);2044 return res;2045 }2046 2064 } 2047 2065 } -
Singular/sparsmat.h
rc78e8b r57e95ce 8 8 * 9 9 *******************************************************************/ 10 /* $Id: sparsmat.h,v 1. 5 2000-02-09 08:45:16pohl Exp $ */10 /* $Id: sparsmat.h,v 1.6 2000-04-19 15:45:00 pohl Exp $ */ 11 11 12 12 … … 16 16 void smSpecialPolyDiv(poly, poly); 17 17 /* ----------------- macros ------------------ */ 18 #define OLD_DIV 1 18 /* #define OLD_DIV 1 */ 19 19 20 20 #ifdef OLD_DIV
Note: See TracChangeset
for help on using the changeset viewer.