Changeset 6c0f53 in git
- Timestamp:
- Dec 16, 2003, 7:30:31 PM (20 years ago)
- Branches:
- (u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
- Children:
- e61522918b2254939e8f5c1fbcdb1982946ae305
- Parents:
- dc2d3d3725e2a3e556468159c56087e7f195c37f
- Location:
- kernel
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/gring.cc
rdc2d3d r6c0f53 7 7 * Author: levandov (Viktor Levandovsky) 8 8 * Created: 8/00 - 11/00 9 * Version: $Id: gring.cc,v 1. 2 2003-12-08 17:31:02 SingularExp $9 * Version: $Id: gring.cc,v 1.3 2003-12-16 18:30:31 levandov Exp $ 10 10 *******************************************************************/ 11 11 #include "mod2.h" … … 1589 1589 } 1590 1590 1591 void ncCleanUp(ring r) 1592 { 1593 /* small CleanUp of r->nc */ 1594 omFreeSize((ADDRESS)r->nc,sizeof(nc_struct)); 1595 r->nc = NULL; 1596 } 1597 1591 1598 poly nc_p_CopyGet(poly a, ring r) 1592 1599 /* for use in getting the mult. martix elements*/ … … 1680 1687 // } 1681 1688 1682 #endif 1689 BOOLEAN nc_CallPlural(matrix CC, matrix DD, poly CN, poly DN, ring r) 1690 /* returns TRUE if there were errors */ 1691 /* analyze inputs, check them for consistency */ 1692 /* detect nc_type, DO NOT initialize multiplication */ 1693 /* check the ordering condition and evtl. NDC */ 1694 { 1695 matrix C; 1696 matrix D; 1697 number nN,pN,qN; 1698 int tmpIsSkewConstant; 1699 int i,j; 1700 if (r->nc != NULL) 1701 { 1702 WarnS("redefining algebra structure"); 1703 if (r->nc->ref>1) /* in use by somebody else */ 1704 { 1705 r->nc->ref--; 1706 } 1707 else /* kill the previous nc data */ 1708 { 1709 ncKill(r); 1710 } 1711 } 1712 r->nc = (nc_struct *)omAlloc0(sizeof(nc_struct)); 1713 r->nc->ref = 1; 1714 r->nc->basering = r; 1715 r->nc->type = nc_undef; 1716 /* initialition of the matrix C */ 1717 if (CN != NULL) /* create matrix C = CN * Id */ 1718 { 1719 nN = p_GetCoeff(CN,r); 1720 if (n_IsZero(nN,r)) 1721 { 1722 Werror("Incorrect input : zero coefficients are not allowed"); 1723 ncCleanUp(r); 1724 return TRUE; 1725 } 1726 if (nIsOne(nN)) 1727 { 1728 r->nc->type = nc_lie; 1729 } 1730 else 1731 { 1732 r->nc->type = nc_general; 1733 } 1734 r->nc->IsSkewConstant = 1; 1735 C = mpNew(r->N,r->N); 1736 for(i=1; i<r->N; i++) 1737 { 1738 for(j=i+1; j<=r->N; j++) 1739 { 1740 MATELEM(C,i,j) = nc_p_CopyPut(CN,r); 1741 } 1742 } 1743 } 1744 if (CC != NULL) /* copy matrix C */ 1745 { 1746 assume( CN==NULL ); 1747 C = mpCopy(CC); 1748 /* analyze C */ 1749 pN = p_GetCoeff(MATELEM(C,1,2),r); 1750 tmpIsSkewConstant = 1; 1751 for(i=1; i<r->N; i++) 1752 { 1753 for(j=i+1; j<=r->N; j++) 1754 { 1755 qN = p_GetCoeff(MATELEM(C,i,j),r); 1756 if ( qN == NULL ) /* check the consistency: Cij!=0 */ 1757 { 1758 Werror("Incorrect input : matrix of coefficients contains zeros in the upper triangle"); 1759 ncCleanUp(r); 1760 return TRUE; 1761 } 1762 if (!nEqual(pN,qN)) tmpIsSkewConstant = 0; 1763 } 1764 } 1765 r->nc->IsSkewConstant=tmpIsSkewConstant; 1766 if ( (tmpIsSkewConstant) && (nIsOne(pN)) ) 1767 { 1768 r->nc->type = nc_lie; 1769 } 1770 else 1771 { 1772 r->nc->type = nc_general; 1773 } 1774 } 1775 1776 /* initialition of the matrix D */ 1777 if (DD == NULL) /* we treat DN only (it could also be NULL) */ 1778 { 1779 D = mpNew(r->N,r->N); 1780 if (DN == NULL) 1781 { 1782 if ( (currRing->nc->type == nc_lie) || (currRing->nc->type == nc_undef) ) 1783 { 1784 currRing->nc->type = nc_comm; /* it was nc_skew earlier */ 1785 } 1786 else /* nc_general, nc_skew */ 1787 { 1788 currRing->nc->type = nc_skew; 1789 } 1790 } 1791 else /* DN != NULL */ 1792 { 1793 for(i=1; i<r->N; i++) 1794 { 1795 for(j=i+1; j<=r->N; j++) 1796 { 1797 MATELEM(D,i,j) = nc_p_CopyPut(DN,r); 1798 } 1799 } 1800 } 1801 } 1802 else /* DD != NULL */ 1803 { 1804 assume( DN==NULL ); 1805 D = mpCopy(DD); 1806 } 1807 /* analyze D */ 1808 /* check the ordering condition for D (both matrix and poly cases) */ 1809 poly p,q; 1810 int report = 1; 1811 for(i=1; i<r->N; i++) 1812 { 1813 for(j=i+1; j<=r->N; j++) 1814 { 1815 p = MATELEM(D,i,j); 1816 if ( p != NULL) 1817 { 1818 q = pOne(); 1819 p_SetExp(q,i,1,r); 1820 p_SetExp(q,j,1,r); 1821 p_Setm(q,r); 1822 if (p_LmCmp(q,p,r) != 1) /* i.e. lm(p)<=lm(q) */ 1823 { 1824 Print("Bad ordering at %d,%d",i,j); 1825 report = 0; 1826 } 1827 p_Delete(&q,r); 1828 p = NULL; 1829 } 1830 } 1831 } 1832 if (!report) 1833 { 1834 Werror("Matrix of polynomials violates the ordering condition"); 1835 ncCleanUp(r); 1836 return TRUE; 1837 } 1838 r->nc->C = C; 1839 r->nc->D = D; 1840 return nc_InitMultiplication(r); 1841 } 1842 1843 BOOLEAN nc_InitMultiplication(ring r) 1844 { 1845 /* returns TRUE if there were errors */ 1846 /* initialize the multiplication */ 1847 int i,j; 1848 matrix COM; 1849 r->nc->MT = (matrix *)omAlloc0(r->N*(r->N-1)/2*sizeof(matrix)); 1850 r->nc->MTsize = (int *)omAlloc0(r->N*(r->N-1)/2*sizeof(int)); 1851 COM = mpCopy(r->nc->C); 1852 poly p; 1853 short DefMTsize=7; 1854 int IsNonComm=0; 1855 int tmpIsSkewConstant; 1856 1857 for(i=1; i<r->N; i++) 1858 { 1859 for(j=i+1; j<=r->N; j++) 1860 { 1861 if ( MATELEM(r->nc->D,i,j) == NULL ) /* quasicommutative case */ 1862 { 1863 /* 1x1 mult.matrix */ 1864 r->nc->MTsize[UPMATELEM(i,j,r->N)] = 1; 1865 r->nc->MT[UPMATELEM(i,j,r->N)] = mpNew(1,1); 1866 } 1867 else /* pure noncommutative case */ 1868 { 1869 /* TODO check the special multiplication properties */ 1870 IsNonComm = 1; 1871 MATELEM(COM,i,j) = NULL; 1872 r->nc->MTsize[UPMATELEM(i,j,r->N)] = DefMTsize; /* default sizes */ 1873 r->nc->MT[UPMATELEM(i,j,r->N)] = mpNew(DefMTsize, DefMTsize); 1874 } 1875 /* set MT[i,j,1,1] to c_i_j*x_i*x_j + D_i_j */ 1876 p = pOne(); 1877 p_SetCoeff(p,nCopy(pGetCoeff(MATELEM(r->nc->C,i,j))),r); 1878 p_SetExp(p,i,1,r); 1879 p_SetExp(p,j,1,r); 1880 p_Setm(p,r); 1881 p = p_Add_q(p, nc_p_CopyGet(MATELEM(r->nc->D,i,j),r),r); 1882 MATELEM(r->nc->MT[UPMATELEM(i,j,r->N)],1,1) = nc_p_CopyPut(p,r); 1883 pDelete(&p); 1884 p = NULL; 1885 } 1886 } 1887 if (r->nc->type==nc_undef) 1888 { 1889 if (IsNonComm==1) 1890 { 1891 // assume(pN!=NULL); 1892 // if ((tmpIsSkewConstant==1) && (nIsOne(pGetCoeff(pN)))) r->nc->type=nc_lie; 1893 // else r->nc->type=nc_general; 1894 } 1895 if (IsNonComm==0) 1896 { 1897 r->nc->type=nc_skew; /* TODO: check whether it is commutative */ 1898 r->nc->IsSkewConstant=tmpIsSkewConstant; 1899 } 1900 } 1901 r->nc->COM=COM; 1902 return FALSE; 1903 } 1904 1905 #endif -
kernel/gring.h
rdc2d3d r6c0f53 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: gring.h,v 1. 2 2003-11-04 16:44:19 SingularExp $ */6 /* $Id: gring.h,v 1.3 2003-12-16 18:30:31 levandov Exp $ */ 7 7 /* 8 8 * ABSTRACT additional defines etc for --with-plural … … 12 12 #include "structs.h" 13 13 14 void ncKill(ring r); 14 /* MACROS */ 15 15 16 16 #define UPMATELEM(i,j,nVar) ( (nVar * ((i)-1) - ((i) * ((i)-1))/2 + (j)-1)-(i) ) 17 18 /* the part, related to the interface */ 19 BOOLEAN nc_CallPlural(matrix CC, matrix DD, poly CN, poly DN, ring r); 20 BOOLEAN nc_InitMultiplication(ring r); 21 22 void ncKill(ring r); 23 void ncCleanUp(ring r); /* smaller than kill */ 24 17 25 // poly functions defined in p_Procs : 18 26 poly nc_pp_Mult_mm(poly p, poly m, const ring r, poly &last); -
kernel/structs.h
rdc2d3d r6c0f53 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: structs.h,v 1. 2 2003-12-09 18:15:39 SingularExp $ */6 /* $Id: structs.h,v 1.3 2003-12-16 18:30:31 levandov Exp $ */ 7 7 /* 8 8 * ABSTRACT … … 73 73 nc_general=0, /* yx=q xy+... */ 74 74 nc_skew, /*1*/ /* yx=q xy */ 75 nc_lie, /*2*/ /* yx=xy+... */ 76 nc_undef /*3*/ /* for internal reasons */ 75 nc_comm, /*2*/ /* yx= xy */ 76 nc_lie, /*3*/ /* yx=xy+... */ 77 nc_undef /*4*/ /* for internal reasons */ 77 78 }; 78 79 #endif
Note: See TracChangeset
for help on using the changeset viewer.