Changeset ea68ed in git
- Timestamp:
- Apr 21, 2005, 6:16:47 PM (19 years ago)
- Branches:
- (u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '98550b669234b32be762076c32b3be2c35188ac4')
- Children:
- 8c8c809bf53ba83e18c7c2ebd0c767279e305509
- Parents:
- eeb1337dbd6e03efdc6f0d3d5aa17c7b2655e1b9
- Location:
- kernel
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/gring.cc
reeb133 rea68ed 7 7 * Author: levandov (Viktor Levandovsky) 8 8 * Created: 8/00 - 11/00 9 * Version: $Id: gring.cc,v 1.2 1 2005-02-11 20:19:46levandov Exp $9 * Version: $Id: gring.cc,v 1.22 2005-04-21 16:16:45 levandov Exp $ 10 10 *******************************************************************/ 11 11 #include "mod2.h" … … 137 137 { 138 138 /* REPORT_ERROR */ 139 #ifdef PDEBUG 139 140 const char* s; 140 141 if (side==1) s="nc_p_Mult_mm"; 141 142 else s="nc_mm_Mult_p"; 142 143 Print("%s: exponent mismatch %d and %d\n",s,expP,expM); 144 #endif 143 145 expOut=0; 144 146 } … … 1210 1212 if (p_GetComp(p1,r)!=p_GetComp(p2,r)) 1211 1213 { 1214 #ifdef PDEBUG 1212 1215 Print("spShort:exponent mismatch!"); 1216 #endif 1213 1217 return(NULL); 1214 1218 } … … 1595 1599 id_Delete((ideal *)&(r->nc->C),r->nc->basering); 1596 1600 id_Delete((ideal *)&(r->nc->D),r->nc->basering); 1601 r->nc->basering->ref--; 1602 if (r->nc->basering<=0) 1603 { 1604 rKill(r->nc->basering); 1605 } 1597 1606 omFreeSize((ADDRESS)r->nc,sizeof(nc_struct)); 1598 1607 r->nc=NULL; … … 1613 1622 else 1614 1623 { 1615 // nFunc nMap = nSetMap();1616 1624 return(prCopyR_NoSort(a,r->nc->basering,r)); 1617 1625 } … … 1630 1638 1631 1639 int nc_CheckSubalgebra(poly PolyVar, ring r) 1632 /* returns TRUE if product of vars from PolyVar defines */ 1640 /* returns TRUE if there were errors */ 1641 /* checks whether product of vars from PolyVar defines */ 1633 1642 /* an admissible subalgebra of r */ 1634 { 1643 /* r is indeed currRing */ 1644 { 1645 ring save = currRing; 1646 int WeChangeRing = 0; 1647 if (currRing != r) 1648 { 1649 rChangeCurrRing(r); 1650 WeChangeRing = 1; 1651 } 1635 1652 int rN=r->N; 1636 1653 int *ExpVar=(int*)omAlloc0((rN+1)*sizeof(int)); … … 1640 1657 poly test=NULL; 1641 1658 int OK=1; 1642 for (i=1; i<rN;i++)1659 for (i=1; i<rN; i++) 1643 1660 { 1644 1661 if (ExpVar[i]==0) /* i.e. not in PolyVar */ 1645 1662 { 1646 for (j=i+1; j<=rN;j++)1663 for (j=i+1; j<=rN; j++) 1647 1664 { 1648 1665 if (ExpVar[j]==0) 1649 1666 { 1650 test =nc_p_CopyGet(MATELEM(r->nc->D,i,j),r);1667 test = nc_p_CopyGet(MATELEM(r->nc->D,i,j),r); 1651 1668 while (test!=NULL) 1652 1669 { … … 1660 1677 } 1661 1678 } 1662 if (!OK) return( FALSE);1679 if (!OK) return(TRUE); 1663 1680 pIter(test); 1664 1681 } … … 1670 1687 freeT(ExpVar,rN); 1671 1688 freeT(ExpTmp,rN); 1672 return(TRUE); 1673 } 1674 1675 // int Commutative_Context(ring r, leftv expression) 1676 // /* returns 1 if expression consists */ 1677 // /* of commutative elements */ 1678 // { 1679 // /* crucial: poly -> ideal, module, matrix */ 1680 1681 // } 1682 1683 // int Comm_Context_Poly(ring r, poly p) 1684 // { 1685 // poly COMM=r->nc->COMM; 1686 // poly pp=pOne(); 1687 // memset(pp->exp,0,r->ExpL_Size*sizeof(long)); 1688 // while (p!=NULL) 1689 // { 1690 // for (i=0;i<=r->ExpL_Size;i++) 1691 // { 1692 // if ((p->exp[i]) && (pp->exp[i])) return(FALSE); 1693 // /* nonzero exponent of non-comm variable */ 1694 // } 1695 // pIter(p); 1696 // } 1697 // return(TRUE); 1698 // } 1689 if ( WeChangeRing ) 1690 rChangeCurrRing(save); 1691 return(FALSE); 1692 } 1693 1694 int nc_CheckOrdCondition(matrix D, ring r) 1695 /* returns TRUE if there were errors */ 1696 /* checks whether the current ordering */ 1697 /* is admissible for r and D == r->nc->D */ 1698 /* to be executed in a currRing */ 1699 { 1700 /* analyze D: an upper triangular matrix of polys */ 1701 /* check the ordering condition for D */ 1702 ring save = currRing; 1703 int WeChangeRing = 0; 1704 if (currRing != r) 1705 { 1706 rChangeCurrRing(r); 1707 WeChangeRing = 1; 1708 } 1709 poly p,q; 1710 int i,j; 1711 int report = 1; 1712 for(i=1; i<r->N; i++) 1713 { 1714 for(j=i+1; j<=r->N; j++) 1715 { 1716 p = nc_p_CopyGet(MATELEM(D,i,j),r); 1717 if ( p != NULL) 1718 { 1719 q = p_ISet(1,r); // replaces pOne(); 1720 p_SetExp(q,i,1,r); 1721 p_SetExp(q,j,1,r); 1722 p_Setm(q,r); 1723 if (p_LmCmp(q,p,r) != 1) /* i.e. lm(p)< lm(q) */ 1724 { 1725 Print("Bad ordering at %d,%d\n",i,j); 1726 #ifdef PDEBUG 1727 p_Write(p,r); 1728 p_Write(q,r); 1729 #endif 1730 report = 0; 1731 } 1732 p_Delete(&q,r); 1733 p_Delete(&p,r); 1734 p = NULL; 1735 } 1736 } 1737 } 1738 if ( WeChangeRing ) 1739 rChangeCurrRing(save); 1740 return(!report); 1741 } 1742 1743 1699 1744 1700 1745 BOOLEAN nc_CallPlural(matrix CCC, matrix DDD, poly CCN, poly DDN, ring r) … … 1725 1770 } 1726 1771 } 1772 ring save = currRing; 1773 int WeChangeRing = 0; 1774 if (currRing!=r) 1775 { 1776 rChangeCurrRing(r); 1777 WeChangeRing = 1; 1778 } 1727 1779 r->nc = (nc_struct *)omAlloc0(sizeof(nc_struct)); 1728 1780 r->nc->ref = 1; 1729 1781 r->nc->basering = r; 1782 r->ref++; 1730 1783 r->nc->type = nc_undef; 1731 1784 … … 1743 1796 Werror("Square %d x %d matrix expected",r->N,r->N); 1744 1797 ncCleanUp(r); 1798 if (WeChangeRing) 1799 rChangeCurrRing(save); 1745 1800 return TRUE; 1746 1801 } … … 1762 1817 Werror("Square %d x %d matrix expected",r->N,r->N); 1763 1818 ncCleanUp(r); 1819 if (WeChangeRing) 1820 rChangeCurrRing(save); 1764 1821 return TRUE; 1765 1822 } … … 1777 1834 Werror("Incorrect input : zero coefficients are not allowed"); 1778 1835 ncCleanUp(r); 1836 if (WeChangeRing) 1837 rChangeCurrRing(save); 1779 1838 return TRUE; 1780 1839 } … … 1819 1878 Werror("Incorrect input : matrix of coefficients contains zeros in the upper triangle"); 1820 1879 ncCleanUp(r); 1880 if (WeChangeRing) 1881 rChangeCurrRing(save); 1821 1882 return TRUE; 1822 1883 } … … 1868 1929 /* analyze D */ 1869 1930 /* check the ordering condition for D (both matrix and poly cases) */ 1870 poly p,q; 1871 int report = 1; 1872 for(i=1; i<r->N; i++) 1873 { 1874 for(j=i+1; j<=r->N; j++) 1875 { 1876 p = MATELEM(D,i,j); 1877 if ( p != NULL) 1878 { 1879 q = p_ISet(1,r); // replaces pOne(); 1880 p_SetExp(q,i,1,r); 1881 p_SetExp(q,j,1,r); 1882 p_Setm(q,r); 1883 if (p_LmCmp(q,p,r) != 1) /* i.e. lm(p)<=lm(q) */ 1884 { 1885 Print("Bad ordering at %d,%d",i,j); 1886 report = 0; 1887 } 1888 p_Delete(&q,r); 1889 p = NULL; 1890 } 1891 } 1892 } 1893 if (!report) 1894 { 1931 1932 if ( nc_CheckOrdCondition(D, r) ) 1933 { 1934 ncCleanUp(r); 1935 if (WeChangeRing) 1936 rChangeCurrRing(save); 1895 1937 Werror("Matrix of polynomials violates the ordering condition"); 1896 ncCleanUp(r);1897 1938 return TRUE; 1898 1939 } 1899 1940 r->nc->C = C; 1900 1941 r->nc->D = D; 1942 if (WeChangeRing) 1943 rChangeCurrRing(save); 1901 1944 return nc_InitMultiplication(r); 1902 1945 } … … 2016 2059 pSetExpV(pre,PRE); 2017 2060 pSetm(pre); 2018 pSetComp(pre,PRE[0]);2019 2061 res = nc_mm_Mult_p(pre,res,currRing); 2020 2062 /* multiply with suffix */ … … 2022 2064 pSetExpV(suf,SUF); 2023 2065 pSetm(suf); 2024 pSetComp(suf,PRE[0]);2025 2066 res = nc_p_Mult_mm(res,suf,currRing); 2026 2067 res = p_Mult_nn(res,C,currRing); 2068 pSetComp(res,PRE[0]); 2027 2069 } 2028 2070 else /* pow==0 */ … … 2410 2452 2411 2453 #endif 2454 2455 2456 // int Commutative_Context(ring r, leftv expression) 2457 // /* returns 1 if expression consists */ 2458 // /* of commutative elements */ 2459 // { 2460 // /* crucial: poly -> ideal, module, matrix */ 2461 // } 2462 2463 // int Comm_Context_Poly(ring r, poly p) 2464 // { 2465 // poly COMM=r->nc->COMM; 2466 // poly pp=pOne(); 2467 // memset(pp->exp,0,r->ExpL_Size*sizeof(long)); 2468 // while (p!=NULL) 2469 // { 2470 // for (i=0;i<=r->ExpL_Size;i++) 2471 // { 2472 // if ((p->exp[i]) && (pp->exp[i])) return(FALSE); 2473 // /* nonzero exponent of non-comm variable */ 2474 // } 2475 // pIter(p); 2476 // } 2477 // return(TRUE); 2478 // } -
kernel/gring.h
reeb133 rea68ed 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: gring.h,v 1. 9 2004-10-18 18:57:06levandov Exp $ */6 /* $Id: gring.h,v 1.10 2005-04-21 16:16:45 levandov Exp $ */ 7 7 /* 8 8 * ABSTRACT additional defines etc for --with-plural … … 18 18 /* the part, related to the interface */ 19 19 BOOLEAN nc_CallPlural(matrix CC, matrix DD, poly CN, poly DN, ring r); 20 int nc_CheckOrdCondition(matrix D, ring r); 21 int nc_CheckSubalgebra(poly PolyVar, ring r); 20 22 BOOLEAN nc_InitMultiplication(ring r); 21 23 BOOLEAN rIsLikeOpposite(ring rBase, ring rCandidate); … … 82 84 matrix nc_PrintMat(int a, int b, ring r, int metric); 83 85 84 int nc_CheckSubalgebra(poly PolyVar, ring r);85 86 86 poly p_CopyEmbed(poly p, ring srcRing, int shift, int par_shift); 87 87 poly pOppose(ring Rop, poly p); -
kernel/ideals.cc
reeb133 rea68ed 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: ideals.cc,v 1. 8 2005-03-17 14:13:02 SingularExp $ */4 /* $Id: ideals.cc,v 1.9 2005-04-21 16:16:46 levandov Exp $ */ 5 5 /* 6 6 * ABSTRACT - all basic methods to manipulate ideals … … 2376 2376 if (currRing->nc->type!=nc_skew) 2377 2377 { 2378 if ( !nc_CheckSubalgebra(delVar,currRing))2378 if (nc_CheckSubalgebra(delVar,currRing)) 2379 2379 { 2380 2380 WerrorS("no elimination is possible: subalgebra is not admissible"); … … 2425 2425 rComplete(&tmpR, 1); 2426 2426 2427 #ifdef HAVE_PLURAL 2428 // update nc structure on tmpR 2429 // in particular, tests the admissibility of the ordering 2430 if (nc_rComplete(origR, &tmpR)) 2431 { 2432 WerrorS("no elimination is possible: subalgebra is not admissible"); 2433 // goto cleanup 2434 omFree((ADDRESS)wv[0]); 2435 omFreeSize((ADDRESS)wv,ordersize*sizeof(int**)); 2436 omFreeSize((ADDRESS)ord,ordersize*sizeof(int)); 2437 omFreeSize((ADDRESS)block0,ordersize*sizeof(int)); 2438 omFreeSize((ADDRESS)block1,ordersize*sizeof(int)); 2439 rUnComplete(&tmpR); 2440 if (w!=NULL) 2441 delete w; 2442 return idCopy(h1); 2443 } 2444 #endif 2427 2445 // change into the new ring 2428 2446 //pChangeRing(pVariables,currRing->OrdSgn,ord,block0,block1,wv); 2429 2447 rChangeCurrRing(&tmpR); 2448 2430 2449 h = idInit(IDELEMS(h1),h1->rank); 2431 2450 // fetch data from the old ring -
kernel/ring.cc
reeb133 rea68ed 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: ring.cc,v 1.3 1 2005-03-14 16:45:15 SingularExp $ */4 /* $Id: ring.cc,v 1.32 2005-04-21 16:16:46 levandov Exp $ */ 5 5 6 6 /* … … 3915 3915 return Renv; 3916 3916 } 3917 3918 BOOLEAN nc_rComplete(ring src, ring dest) 3919 /* returns TRUE is there were errors */ 3920 /* dest is actualy equals src with the different ordering */ 3921 /* we map src->nc correctly to dest->src */ 3922 /* to be executed after rComplete, before rChangeCurrRing */ 3923 3924 { 3925 if (!rIsPluralRing(src)) 3926 return FALSE; 3927 int i,j; 3928 int N = dest->N; 3929 if (src->N != N) 3930 { 3931 WarnS("wrong nc_rComplete call"); 3932 return TRUE; 3933 } 3934 // ncKill(dest); // in order to init new 3935 // if (nc_CallPlural(src->nc->C, src->nc->D, NULL, NULL, dest)) 3936 // { 3937 // return TRUE; 3938 // } 3939 // else 3940 // return FALSE; 3941 // if (dest->nc != NULL) 3942 // ncKill(dest); 3943 // dest->nc = (nc_struct *)omAlloc0(sizeof(nc_struct)); 3944 // dest->nc->ref = 1; 3945 // dest->nc->basering = dest; 3946 // dest->nc->type = src->nc->type; 3947 ring save = currRing; 3948 int WeChangeRing = 0; 3949 if (dest != currRing) 3950 { 3951 WeChangeRing = 1; 3952 rChangeCurrRing(dest); 3953 } 3954 matrix C = mpNew(N,N); 3955 matrix D = mpNew(N,N); 3956 matrix C0 = src->nc->C; 3957 matrix D0 = src->nc->D; 3958 poly p = NULL; 3959 number n = NULL; 3960 for (i=1; i< N; i++) 3961 { 3962 for (j= i+1; j<= N; j++) 3963 { 3964 // n = p_GetCoeff(MATELEM(C0,i,j), src); 3965 // p = pOne(); 3966 // p_SetCoeff(p,n,dest); 3967 // MATELEM(C,i,j) = nc_p_CopyPut(p, dest); 3968 p = prCopyR(MATELEM(C0,i,j), src, dest); // like in nc_p_CopyGet 3969 MATELEM(C,i,j) = p; //nc_p_CopyPut(p, dest); 3970 // p_Delete(&p,dest); 3971 p = NULL; 3972 if (MATELEM(D0,i,j) != NULL) 3973 { 3974 p = prCopyR(MATELEM(D0,i,j), src, dest); // like in nc_p_CopyGet 3975 MATELEM(D,i,j) = p; //nc_p_CopyPut(p, dest); 3976 // p_Delete(&p,dest); 3977 p = NULL; 3978 } 3979 } 3980 } 3981 idTest((ideal)C); 3982 idTest((ideal)D); 3983 id_Delete((ideal *)&(dest->nc->C),dest->nc->basering); 3984 id_Delete((ideal *)&(dest->nc->D),dest->nc->basering); 3985 dest->nc->C = C; 3986 dest->nc->D = D; 3987 if ( WeChangeRing ) 3988 rChangeCurrRing(save); 3989 if (nc_InitMultiplication(dest)) 3990 { 3991 WarnS("Error initializing multiplication!"); 3992 return TRUE; 3993 } 3994 return FALSE; 3995 } -
kernel/ring.h
reeb133 rea68ed 7 7 * ABSTRACT - the interpreter related ring operations 8 8 */ 9 /* $Id: ring.h,v 1. 6 2004-11-04 19:56:12levandov Exp $ */9 /* $Id: ring.h,v 1.7 2005-04-21 16:16:47 levandov Exp $ */ 10 10 11 11 /* includes */ … … 143 143 BOOLEAN rComplete(ring r, int force = 0); 144 144 // use this to free fields created by rComplete 145 146 BOOLEAN nc_rComplete(ring src, ring dest); 147 145 148 void rUnComplete(ring r); 146 149 inline int rBlocks(ring r)
Note: See TracChangeset
for help on using the changeset viewer.