Changeset 9922fa7 in git for kernel/GBEngine/tgb_internal.h
- Timestamp:
- Apr 30, 2018, 4:37:20 PM (5 years ago)
- Branches:
- (u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
- Children:
- 9ae5a3bbc24553f5fdd77d09f6bd086318329be3
- Parents:
- 35a2fb48e744c3334747118a4c8ac8457f0ba3ec
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/GBEngine/tgb_internal.h
r35a2fb4 r9922fa7 129 129 int len; 130 130 BOOLEAN onlyBorrowed; 131 bool operator<(const MonRedRes& other) const{ 131 bool operator<(const MonRedRes& other) const 132 { 132 133 int cmp=p_LmCmp(p,other.p,currRing); 133 if ((cmp<0)||((cmp==0)&&((onlyBorrowed)&&(!(other.onlyBorrowed))))){ 134 if ((cmp<0)||((cmp==0)&&((onlyBorrowed)&&(!(other.onlyBorrowed))))) 135 { 134 136 return true; 135 137 } else return false; 136 138 } 137 139 DataNoroCacheNode* ref; 138 MonRedRes(){ 140 MonRedRes() 141 { 139 142 ref=NULL; 140 143 p=NULL; … … 832 835 */ 833 836 834 template<class number_type> SparseRow<number_type>* convert_to_sparse_row(number_type* temp_array,int temp_size,int non_zeros){ 837 template<class number_type> SparseRow<number_type>* convert_to_sparse_row(number_type* temp_array,int temp_size,int non_zeros) 838 { 835 839 SparseRow<number_type>* res=new SparseRow<number_type>(non_zeros); 836 840 //int pos=0; … … 839 843 int* it_idx=res->idx_array; 840 844 #if 0 841 for(i=0;i<cache->nIrreducibleMonomials;i++){ 842 if (!(0==temp_array[i])){ 845 for(i=0;i<cache->nIrreducibleMonomials;i++) 846 { 847 if (!(0==temp_array[i])) 848 { 843 849 844 850 res->idx_array[pos]=i; … … 1063 1069 #ifndef SING_NDEBUG 1064 1070 assume(idx<temp_size); 1065 1071 #endif 1066 1072 } 1067 1073 } … … 1157 1163 for(i=0;i<cache->nIrreducibleMonomials;i++) 1158 1164 { 1159 //if (!(temp_array[i]==0)){ 1165 //if (!(temp_array[i]==0)) 1166 //{ 1160 1167 // non_zeros++; 1161 1168 //} … … 1403 1410 return res; 1404 1411 } 1405 template<class number_type> SparseRow<number_type> * noro_red_to_non_poly_t(poly p, int &len, NoroCache<number_type>* cache,slimgb_alg* c){ 1412 template<class number_type> SparseRow<number_type> * noro_red_to_non_poly_t(poly p, int &len, NoroCache<number_type>* cache,slimgb_alg* c) 1413 { 1406 1414 assume(len==pLength(p)); 1407 1415 if (p==NULL) … … 1459 1467 1460 1468 1461 template <class number_type > void write_poly_to_row(number_type* row, poly h, poly*terms, int tn, ring r){ 1469 template <class number_type > void write_poly_to_row(number_type* row, poly h, poly*terms, int tn, ring r) 1470 { 1462 1471 //poly* base=row; 1463 while(h!=NULL){ 1472 while(h!=NULL) 1473 { 1464 1474 //Print("h:%i\n",h); 1465 1475 number coef=p_GetCoeff(h,r); … … 1472 1482 } 1473 1483 } 1474 template <class number_type > poly row_to_poly(number_type* row, poly* terms, int tn, ring r){ 1484 template <class number_type > poly row_to_poly(number_type* row, poly* terms, int tn, ring r) 1485 { 1475 1486 poly h=NULL; 1476 1487 int j; 1477 1488 number_type zero=0;//;npInit(0); 1478 for(j=tn-1;j>=0;j--){ 1479 if (!(zero==(row[j]))){ 1489 for(j=tn-1;j>=0;j--) 1490 { 1491 if (!(zero==(row[j]))) 1492 { 1480 1493 poly t=terms[j]; 1481 1494 t=p_LmInit(t,r); … … 1517 1530 this->ncols=nncols; 1518 1531 this->nrows=nnrows; 1519 rows=(number_type**) omalloc( nnrows*sizeof(number_type*));1520 startIndices=(int*)omalloc( nnrows*sizeof(int));1532 rows=(number_type**) omalloc((size_t)nnrows*sizeof(number_type*)); 1533 startIndices=(int*)omalloc((size_t)nnrows*sizeof(int)); 1521 1534 int i; 1522 1535 for(i=0;i<nnrows;i++) 1523 1536 { 1524 rows[i]=array+( i*nncols);1537 rows[i]=array+((long)i*(long)nncols); 1525 1538 updateStartIndex(i,-1); 1526 1539 } … … 1772 1785 int c=0; 1773 1786 int r=0; 1774 while(mat.findPivot(r,c)){ 1787 while(mat.findPivot(r,c)) 1788 { 1775 1789 //int pivot=find_pivot() 1776 1790 mat.reduceOtherRowsForward(r); … … 1785 1799 } 1786 1800 //int term_nodes_sort_crit(const void* a, const void* b); 1787 template <class number_type> void noro_step(poly*p,int &pn,slimgb_alg* c){ 1801 template <class number_type> void noro_step(poly*p,int &pn,slimgb_alg* c) 1802 { 1788 1803 //Print("Input rows %d\n",pn); 1789 1804 int j; … … 1841 1856 // Print("Evaluate Rows \n"); 1842 1857 pn=non_zeros; 1843 number_type* number_array=(number_type*) omalloc0( n*pn*sizeof(number_type));1858 number_type* number_array=(number_type*) omalloc0(((size_t)n)*pn*sizeof(number_type)); 1844 1859 1845 1860 for(j=0;j<pn;j++) 1846 1861 { 1847 1862 int i; 1848 number_type* row=number_array+ n*j;1863 number_type* row=number_array+((long)n)*(long)j; 1849 1864 /*for(i=0;i<n;i++) 1850 1865 { … … 1883 1898 1884 1899 int p_pos=0; 1885 for(j=0;j<pn;j++){ 1886 poly h=row_to_poly(number_array+j*n,terms,n,c->r); 1887 if(h!=NULL){ 1900 for(j=0;j<pn;j++) 1901 { 1902 poly h=row_to_poly(number_array+((long)j)*((long)n),terms,n,c->r); 1903 if(h!=NULL) 1904 { 1888 1905 p[p_pos++]=h; 1889 1906 } … … 1901 1918 } 1902 1919 1903 template <class number_type> void NoroCache<number_type>::collectIrreducibleMonomials( std::vector<DataNoroCacheNode<number_type> *>& res){ 1920 template <class number_type> void NoroCache<number_type>::collectIrreducibleMonomials( std::vector<DataNoroCacheNode<number_type> *>& res) 1921 { 1904 1922 int i; 1905 for(i=0;i<root.branches_len;i++){ 1923 for(i=0;i<root.branches_len;i++) 1924 { 1906 1925 collectIrreducibleMonomials(1,root.branches[i],res); 1907 1926 } 1908 1927 } 1909 template <class number_type> void NoroCache<number_type>::collectIrreducibleMonomials(int level, NoroCacheNode* node, std::vector<DataNoroCacheNode<number_type>*>& res){ 1928 template <class number_type> void NoroCache<number_type>::collectIrreducibleMonomials(int level, NoroCacheNode* node, std::vector<DataNoroCacheNode<number_type>*>& res) 1929 { 1910 1930 assume(level>=0); 1911 1931 if (node==NULL) return; … … 1928 1948 } 1929 1949 1930 template<class number_type> DataNoroCacheNode<number_type>* NoroCache<number_type>::getCacheReference(poly term){ 1950 template<class number_type> DataNoroCacheNode<number_type>* NoroCache<number_type>::getCacheReference(poly term) 1951 { 1931 1952 int i; 1932 1953 NoroCacheNode* parent=&root; 1933 for(i=1;i<(currRing->N);i++){ 1954 for(i=1;i<(currRing->N);i++) 1955 { 1934 1956 parent=parent->getBranch(p_GetExp(term,i,currRing)); 1935 if (!(parent)){ 1957 if (!(parent)) 1958 { 1936 1959 return NULL; 1937 1960 } … … 1940 1963 return res_holder; 1941 1964 } 1942 template<class number_type> poly NoroCache<number_type>::lookup(poly term, BOOLEAN& succ, int & len){ 1965 template<class number_type> poly NoroCache<number_type>::lookup(poly term, BOOLEAN& succ, int & len) 1966 { 1943 1967 int i; 1944 1968 NoroCacheNode* parent=&root; 1945 for(i=1;i<(currRing->N);i++){ 1969 for(i=1;i<(currRing->N);i++) 1970 { 1946 1971 parent=parent->getBranch(p_GetExp(term,i,currRing)); 1947 if (!(parent)){ 1972 if (!(parent)) 1973 { 1948 1974 succ=FALSE; 1949 1975 return NULL; … … 1951 1977 } 1952 1978 DataNoroCacheNode<number_type>* res_holder=(DataNoroCacheNode<number_type>*) parent->getBranch(p_GetExp(term,i,currRing)); 1953 if (res_holder){ 1979 if (res_holder) 1980 { 1954 1981 succ=TRUE; 1955 if ( /*(*/ res_holder->value_len==backLinkCode /*)*/ ){ 1982 if ( /*(*/ res_holder->value_len==backLinkCode /*)*/ ) 1983 { 1956 1984 len=1; 1957 1985 return term;
Note: See TracChangeset
for help on using the changeset viewer.