Ticket #4539: plural_1.patch

File plural_1.patch, 3.4 KB (added by burcin, 8 years ago)

initial wrapper for plural

  • module_list.py

    # HG changeset patch
    # User Burcin Erocal <burcin@erocal.org>
    # Date 1223885551 -7200
    # Node ID 1611ab2e6f45c6b11ace32518e8d36e8231179ed
    # Parent  5e45f3ee796ad08b6a3467a21f4809ba9e2d69dc
    Initial wrapper for plural.
    
    diff --git a/module_list.py b/module_list.py
    a b  
    550550
    551551    Extension('sage.rings.polynomial.multi_polynomial_ideal_libsingular',
    552552              sources = ['sage/rings/polynomial/multi_polynomial_ideal_libsingular.pyx'],
     553              libraries = ['m', 'readline', 'singular', 'singcf', 'singfac', 'omalloc', 'givaro', 'gmpxx', 'gmp'],
     554              language="c++",
     555              include_dirs=debian_include_dirs + [SAGE_ROOT +'/local/include/singular']),
     556
     557    Extension('sage.rings.polynomial.plural',
     558              sources = ['sage/rings/polynomial/plural.pyx'],
    553559              libraries = ['m', 'readline', 'singular', 'singcf', 'singfac', 'omalloc', 'givaro', 'gmpxx', 'gmp'],
    554560              language="c++",
    555561              include_dirs=debian_include_dirs + [SAGE_ROOT +'/local/include/singular']),
  • sage/libs/singular/singular-cdefs.pxi

    diff --git a/sage/libs/singular/singular-cdefs.pxi b/sage/libs/singular/singular-cdefs.pxi
    a b  
    690690   
    691691    int MATROWS(matrix *)
    692692
     693# Plural functions
     694   
     695    int nc_CallPlural(matrix* CC, matrix* DD, poly* CN, poly* DN, ring* r)
     696
    693697cdef extern from "stairc.h":
    694698    # Computes the monomial basis for R[x]/I
    695699    ideal *scKBase(int deg, ideal *s, ideal *Q)
  • new file sage/rings/polynomial/plural.pxd

    diff --git a/sage/rings/polynomial/plural.pxd b/sage/rings/polynomial/plural.pxd
    new file mode 100644
    - +  
     1include "../../libs/singular/singular-cdefs.pxi"
     2
     3from sage.rings.polynomial.multi_polynomial_libsingular cimport MPolynomialRing_libsingular, MPolynomial_libsingular
     4
     5cdef class MPolynomialRing_plural(MPolynomialRing_libsingular):
     6    pass
     7
  • new file sage/rings/polynomial/plural.pyx

    diff --git a/sage/rings/polynomial/plural.pyx b/sage/rings/polynomial/plural.pyx
    new file mode 100644
    - +  
     1include "sage/ext/stdsage.pxi"
     2include "sage/ext/interrupt.pxi"
     3
     4cdef class MPolynomialRing_plural(MPolynomialRing_libsingular):
     5    def __init__(self, base_ring, n, names, order='degrevlex'):
     6        MPolynomialRing_libsingular.__init__(self, base_ring, n, names, order)
     7
     8        cdef matrix* matc=mpNew(n,n)
     9        cdef matrix* matd=mpNew(n,n)
     10
     11        for i from 0 <= i < n:
     12            for j from i+1 <= j < n:
     13                matc.m[n*i+j] = p_ISet(-1, self._ring)
     14
     15        for i from 0 <= i < n:
     16            for j from i+1 <= j < n:
     17                matd.m[n*i+j] = p_ISet(-1, self._ring)
     18
     19        nc_CallPlural(matc, matd, NULL, NULL, self._ring)
     20
     21        id_Delete(<ideal**>&matc, self._ring)
     22        id_Delete(<ideal**>&matd, self._ring)
     23 
     24    def _repr_(self):
     25        """
     26        EXAMPLE:
     27            sage: from sage.rings.polynomial.plural import MPolynomial_plural
     28            sage: P = MPolynomialRing_plural(QQ, 2, 'x,y')
     29            sage: P # indirect doctest
     30            Multivariate Polynomial Ring in x, y over Rational Field
     31        """
     32#TODO: print the relations
     33        varstr = ", ".join([ rRingVar(i,self._ring)  for i in range(self.__ngens) ])
     34        return "Noncommutative Multivariate Polynomial Ring in %s over %s"%(varstr,self.base_ring())