コード例 #1
0
ファイル: projective_homset.py プロジェクト: kliem/sage
        INPUT:

        - ``R`` -- a ring.

        EXAMPLES::

            sage: E = EllipticCurve('37a')
            sage: Hom = E.point_homset();  Hom
            Abelian group of points on Elliptic Curve defined
            by y^2 + y = x^3 - x over Rational Field
            sage: Hom.base_ring()
            Integer Ring
            sage: Hom.base_extend(QQ)
            Traceback (most recent call last):
            ...
            NotImplementedError: Abelian variety point sets are not
            implemented as modules over rings other than ZZ
        """
        if R is not ZZ:
            raise NotImplementedError(
                'Abelian variety point sets are not '
                'implemented as modules over rings other than ZZ')
        return self


from sage.misc.persist import register_unpickle_override
register_unpickle_override(
    'sage.schemes.generic.homset',
    'SchemeHomsetModule_abelian_variety_coordinates_field',
    SchemeHomset_points_abelian_variety_field)
コード例 #2
0
ファイル: powersum.py プロジェクト: BrentBaccala/sage
            - an element of the base ring

            EXAMPLES::

                sage: p = SymmetricFunctions(QQ).p()
                sage: p([3,3]).eval_at_permutation_roots([6])
                0
                sage: p([3,3]).eval_at_permutation_roots([3])
                9
                sage: p([3,3]).eval_at_permutation_roots([1])
                1
                sage: p([3,3]).eval_at_permutation_roots([3,3])
                36
                sage: p([3,3]).eval_at_permutation_roots([1,1,1,1,1])
                25
                sage: (p[1]+p[2]+p[3]).eval_at_permutation_roots([3,2])
                5
            """
            p = self.parent()
            R = self.base_ring()
            on_basis = lambda lam: R.prod(
                p.eval_at_permutation_roots_on_generators(k, rho) for k in lam)
            return p._apply_module_morphism(self, on_basis, R)


# Backward compatibility for unpickling
from sage.misc.persist import register_unpickle_override
register_unpickle_override('sage.combinat.sf.powersum',
                           'SymmetricFunctionAlgebraElement_power',
                           SymmetricFunctionAlgebra_power.Element)
コード例 #3
0
            sage: SC4 = SignedCompositions(4)
            sage: SC4.cardinality() == len(SC4.list())
            True
            sage: SignedCompositions(3).cardinality()
            18
        """
        return ZZ.sum(
            binomial(self.n - 1, i - 1) * 2**i for i in range(1, self.n + 1))

    def __iter__(self):
        """
        TESTS::

            sage: SignedCompositions(0).list()   #indirect doctest
            [[]]
            sage: SignedCompositions(1).list()   #indirect doctest
            [[1], [-1]]
            sage: SignedCompositions(2).list()   #indirect doctest
            [[1, 1], [1, -1], [-1, 1], [-1, -1], [2], [-2]]
        """
        for comp in Compositions_n.__iter__(self):
            l = len(comp)
            for sign in itertools.product([1, -1], repeat=l):
                yield [sign[i] * comp[i] for i in range(l)]


from sage.misc.persist import register_unpickle_override
register_unpickle_override('sage.combinat.composition_signed',
                           'SignedCompositions_n', SignedCompositions)
コード例 #4
0
            sage: eps = DirichletGroup(4).gen(0)
            sage: from sage.modular.modsym.manin_symbol_list import ManinSymbolList_character
            sage: m = ManinSymbolList_character(eps,4); m
            Manin Symbol List of weight 4 for Gamma1(4) with character [-1]
            sage: [m.normalize(s.tuple()) for s in m.manin_symbol_list()]
            [((0, 0, 1), 1),
             ((0, 1, 0), 1),
             ((0, 1, 1), 1),
             ...
             ((2, 1, 3), 1),
             ((2, 2, 1), 1)]
        """
        u, v, s = self.__P1.normalize_with_scalar(x[1], x[2])
        return (x[0], u, v), self.__character(s)


register_unpickle_override('sage.modular.modsym.manin_symbols',
                           'ManinSymbolList', ManinSymbolList)
register_unpickle_override('sage.modular.modsym.manin_symbols',
                           'ManinSymbolList_group', ManinSymbolList_group)
register_unpickle_override('sage.modular.modsym.manin_symbols',
                           'ManinSymbolList_gamma0', ManinSymbolList_gamma0)
register_unpickle_override('sage.modular.modsym.manin_symbols',
                           'ManinSymbolList_gamma1', ManinSymbolList_gamma1)
register_unpickle_override('sage.modular.modsym.manin_symbols',
                           'ManinSymbolList_gamma_h', ManinSymbolList_gamma_h)
register_unpickle_override('sage.modular.modsym.manin_symbols',
                           'ManinSymbolList_character',
                           ManinSymbolList_character)
コード例 #5
0
ファイル: llt.py プロジェクト: sagemath/sage
        INPUT:

        - ``self`` -- an instance of the LLT hcospin basis
        - ``part`` -- a partition

        OUTPUT:

        - returns a function which accepts a partition and returns the coefficient
          in the expansion of the monomial basis

        EXAMPLES::

            sage: HCosp3 = SymmetricFunctions(FractionField(QQ['t'])).llt(3).hcospin()
            sage: f21 = HCosp3._to_m(Partition([2,1]))
            sage: [f21(p) for p in Partitions(3)]
            [1, t + 1, 2*t + 1]
            sage: HCosp3.symmetric_function_ring().m()( HCosp3[2,1] )
            (2*t+1)*m[1, 1, 1] + (t+1)*m[2, 1] + m[3]
        """
        level = self.level()
        f = lambda part2: QQt(ribbon_tableau.cospin_polynomial([level*i for i in part], part2, level))
        return f

    class Element(LLT_generic.Element):
        pass

# Backward compatibility for unpickling
from sage.misc.persist import register_unpickle_override
register_unpickle_override('sage.combinat.sf.llt', 'LLTElement_spin',  LLT_spin.Element)
register_unpickle_override('sage.combinat.sf.llt', 'LLTElement_cospin',  LLT_cospin.Element)
コード例 #6
0
        """
        for p in descents_composition_list(self.shape):
            yield self.from_permutation(p)


class Ribbon_class(RibbonShapedTableau):
    """
    This exists solely for unpickling ``Ribbon_class`` objects.
    """
    def __setstate__(self, state):
        r"""
        Unpickle old ``Ribbon_class`` objects.

        EXAMPLES::

            sage: loads(b'x\x9ck`J.NLO\xd5K\xce\xcfM\xca\xccK,\xd1+\xcaLJ\xca\xcf\xe3\n\x02S\xf1\xc99\x89\xc5\xc5\\\x85\x8c\x9a\x8d\x85L\xb5\x85\xcc\x1a\xa1\xac\xf1\x19\x89\xc5\x19\x85,~@VNfqI!kl!\x9bFl!\xbb\x06\xc4\x9c\xa2\xcc\xbc\xf4b\xbd\xcc\xbc\x92\xd4\xf4\xd4"\xae\xdc\xc4\xec\xd4x\x18\xa7\x90#\x94\xd1\xb05\xa8\x903\x03\xc80\x022\xb8Rc\x0b\xb95@<c \x8f\x07\xc40\x012xSSK\x93\xf4\x00l\x811\x17')
            [[None, 1, 2], [3, 4]]
            sage: loads(dumps( RibbonShapedTableau([[3,2,1], [1,1]]) ))  # indirect doctest
            [[None, 3, 2, 1], [1, 1]]
        """
        self.__class__ = RibbonShapedTableau
        self.__init__(RibbonShapedTableaux(), state['_list'])


from sage.misc.persist import register_unpickle_override

register_unpickle_override('sage.combinat.ribbon', 'Ribbon_class',
                           Ribbon_class)
register_unpickle_override('sage.combinat.ribbon', 'StandardRibbons_shape',
                           StandardRibbonShapedTableaux)
コード例 #7
0
            sage: all = iter(K)
            sage: next(all)
            0
            sage: next(all)
            1
            sage: next(all)
            2
        """
        yield self(0)
        i = one = self(1)
        while i:
            yield i
            i += one

    def degree(self):
        """
        Return the degree of ``self`` over its prime field.

        This always returns 1.

        EXAMPLES::

            sage: FiniteField(3).degree()
            1
        """
        return Integer(1)

register_unpickle_override(
    'sage.rings.finite_field_prime_modn', 'FiniteField_prime_modn',
    FiniteField_prime_modn)
コード例 #8
0
ファイル: coxeter_group.py プロジェクト: sagemath/sage
    if implementation is None:
        implementation = "matrix"

    if implementation == "reflection":
        return CoxeterMatrixGroup(cartan_type, base_ring, index_set)
    if implementation == "coxeter3":
        try:
            from sage.libs.coxeter3.coxeter_group import CoxeterGroup
        except ImportError:
            raise RuntimeError("coxeter3 must be installed")
        else:
            return CoxeterGroup(cartan_type)
    if implementation == "permutation":
        if not cartan_type.is_finite():
            raise ValueError("the type must be finite")
        if cartan_type.is_crystallographic():
            return WeylGroup(cartan_type, implementation="permutation")
        return ReflectionGroup(cartan_type, index_set=index_set)
    elif implementation == "matrix":
        if cartan_type.is_crystallographic():
            return WeylGroup(cartan_type)
        return CoxeterMatrixGroup(cartan_type, base_ring, index_set)
    elif implementation == "chevie":
        return ReflectionGroup(cartan_type, index_set=index_set)

    raise NotImplementedError("Coxeter group of type {} as {} group not implemented".format(cartan_type, implementation))

from sage.misc.persist import register_unpickle_override
register_unpickle_override('sage.combinat.root_system.coxeter_group', 'CoxeterGroupAsPermutationGroup',  ReflectionGroup)
コード例 #9
0
ファイル: orthotriang.py プロジェクト: sagemath/sage
    def _multiply(self, left, right):
        """
        Returns ``left`` * ``right`` by converting both to the base and then
        converting back to ``self``.

        INPUT:

        - ``self`` -- a basis determined by an orthotriangular definition
        - ``left``, ``right`` -- elements in ``self``

        OUTPUT:

        - the expansion of the product of ``left`` and ``right`` in the basis ``self``.

        EXAMPLES::

            sage: from sage.combinat.sf.sfa import zee
            sage: from sage.combinat.sf.orthotriang import SymmetricFunctionAlgebra_orthotriang
            sage: Sym = SymmetricFunctions(QQ)
            sage: m = Sym.m()
            sage: s = SymmetricFunctionAlgebra_orthotriang(Sym, m, zee, 's', 'Schur functions')
            sage: s([1])*s([2,1]) #indirect doctest
            s[2, 1, 1] + s[2, 2] + s[3, 1]
        """
        return self( self._sf_base(left)*self._sf_base(right) )

# Backward compatibility for unpickling
from sage.misc.persist import register_unpickle_override
register_unpickle_override('sage.combinat.sf.orthotriang', 'SymmetricFunctionAlgebraElement_orthotriang',  SymmetricFunctionAlgebra_orthotriang.Element)
コード例 #10
0
ファイル: alphabet.py プロジェクト: sagemath/sage
            sage: from sage.combinat.words.alphabet import OrderedAlphabet
            sage: O = OrderedAlphabet()
            doctest:...: DeprecationWarning: OrderedAlphabet is deprecated; use Alphabet instead.
            See http://trac.sagemath.org/8920 for details.
            sage: O._alphabet = ['a', 'b']
            sage: O._elements
            ('a', 'b')
        """
        if name == '_elements':
            if not hasattr(self, '_alphabet'):
                raise AttributeError("no attribute '_elements'")
            self._elements = tuple(self._alphabet)
            from sage.structure.parent import Parent
            from sage.categories.finite_enumerated_sets import FiniteEnumeratedSets
            Parent.__init__(self, category=FiniteEnumeratedSets(), facade=True)
            return self._elements
        raise AttributeError("no attribute %s" % name)


register_unpickle_override(
    'sage.combinat.words.alphabet',
    'OrderedAlphabet_NaturalNumbers',
    NonNegativeIntegers,
    call_name=('sage.sets.non_negative_integers', 'NonNegativeIntegers'))

register_unpickle_override(
    'sage.combinat.words.alphabet',
    'OrderedAlphabet_PositiveIntegers',
    PositiveIntegers,
    call_name=('sage.sets.positive_integers', 'PositiveIntegers'))
コード例 #11
0
ファイル: __init__.py プロジェクト: sagemath/sage
from __future__ import absolute_import

from .base import IntegerListsBackend, Envelope
from .lists import IntegerLists
from .invlex import IntegerListsLex

from sage.misc.persist import register_unpickle_override
register_unpickle_override('sage.combinat.integer_list', 'IntegerListsLex', IntegerListsLex)
コード例 #12
0
ファイル: powersum.py プロジェクト: sagemath/sage
            OUTPUT:

            - an element of the base ring

            EXAMPLES::

                sage: p = SymmetricFunctions(QQ).p()
                sage: p([3,3]).eval_at_permutation_roots([6])
                0
                sage: p([3,3]).eval_at_permutation_roots([3])
                9
                sage: p([3,3]).eval_at_permutation_roots([1])
                1
                sage: p([3,3]).eval_at_permutation_roots([3,3])
                36
                sage: p([3,3]).eval_at_permutation_roots([1,1,1,1,1])
                25
                sage: (p[1]+p[2]+p[3]).eval_at_permutation_roots([3,2])
                5
            """
            p = self.parent()
            R = self.base_ring()
            on_basis = lambda lam: R.prod(
                p.eval_at_permutation_roots_on_generators(k, rho) for k in lam)
            return p._apply_module_morphism(self, on_basis, R)

# Backward compatibility for unpickling
from sage.misc.persist import register_unpickle_override
register_unpickle_override('sage.combinat.sf.powersum', 'SymmetricFunctionAlgebraElement_power',  SymmetricFunctionAlgebra_power.Element)
コード例 #13
0
ファイル: error.py プロジェクト: sagemath/sage
    def _derivative_(self, x, diff_param=None):
        """
        Derivative of inverse erf function.

        EXAMPLES::

            sage: erfinv(x).diff(x)
            1/2*sqrt(pi)*e^(erfinv(x)^2)
        """
        return sqrt(pi)*exp(erfinv(x)**2)/2

erfinv = Function_erfinv()

from sage.misc.persist import register_unpickle_override
register_unpickle_override('sage.functions.other', 'Function_erf', Function_erf)

############################
# Fresnel integrals        #
############################
class Function_Fresnel_sin(BuiltinFunction):
    def __init__(self):
        r"""
        The sine Fresnel integral.

        It is defined by the integral

        .. MATH ::

            \operatorname{S}(x) = \int_0^x \sin\left(\frac{\pi t^2}{2}\right)\, dt
コード例 #14
0
ファイル: composition_signed.py プロジェクト: sagemath/sage
        TESTS::

            sage: SC4 = SignedCompositions(4)
            sage: SC4.cardinality() == len(SC4.list())
            True
            sage: SignedCompositions(3).cardinality()
            18
        """
        return sum([binomial(self.n-1, i-1)*2**(i) for i in range(1, self.n+1)])

    def __iter__(self):
        """
        TESTS::

            sage: SignedCompositions(0).list()   #indirect doctest
            [[]]
            sage: SignedCompositions(1).list()   #indirect doctest
            [[1], [-1]]
            sage: SignedCompositions(2).list()   #indirect doctest
            [[1, 1], [1, -1], [-1, 1], [-1, -1], [2], [-2]]
        """
        for comp in Compositions_n.__iter__(self):
            l = len(comp)
            for sign in itertools.product([1,-1], repeat=l):
                yield [ sign[i]*comp[i] for i in range(l)]

from sage.misc.persist import register_unpickle_override
register_unpickle_override('sage.combinat.composition_signed', 'SignedCompositions_n', SignedCompositions)

コード例 #15
0

def unpickle_PolynomialRing(base_ring, arg1=None, arg2=None, sparse=False):
    """
    Custom unpickling function for polynomial rings.

    This has the same positional arguments as the old
    ``PolynomialRing`` constructor before :trac:`23338`.
    """
    args = [arg for arg in (arg1, arg2) if arg is not None]
    return PolynomialRing(base_ring, *args, sparse=sparse)


from sage.misc.persist import register_unpickle_override

register_unpickle_override('sage.rings.polynomial.polynomial_ring_constructor',
                           'PolynomialRing', unpickle_PolynomialRing)


def _get_from_cache(key):
    key = tuple(key)
    return _cache.get(key)


def _save_in_cache(key, R):
    key = tuple(key)
    _cache[key] = R


def _single_variate(base_ring,
                    name,
                    sparse=None,
コード例 #16
0
ファイル: combination.py プロジェクト: sagemath/sage
        b = b - 1

    for i in range(k):
        comb[i] = (n - 1) - comb[i]

    return tuple(comb)

##########################################################
# Deprecations

class ChooseNK(Combinations_setk):
    def __setstate__(self, state):
        r"""
        For unpickling old ``ChooseNK`` objects.

        TESTS::

            sage: loads(b"x\x9ck`J.NLO\xd5K\xce\xcfM\xca\xccK,\xd1K\xce\xc8\xcf"
            ....:   b"/N\x8d\xcf\xcb\xe6r\x06\xb3\xfc\xbc\xb9\n\x195\x1b\x0b"
            ....:   b"\x99j\x0b\x995B\x99\xe2\xf3\nY :\x8a2\xf3\xd2\x8b\xf52"
            ....:   b"\xf3JR\xd3S\x8b\xb8r\x13\xb3S\xe3a\x9cB\xd6PF\xd3\xd6\xa0"
            ....:   b"B6\xa0\xfa\xecB\xf6\x0c \xd7\x08\xc8\xe5(M\xd2\x03\x00{"
            ....:   b"\x82$\xd8")
            Combinations of [0, 1, 2, 3, 4] of length 2
        """
        self.__class__ = Combinations_setk
        Combinations_setk.__init__(self, list(range(state['_n'])), state['_k'])

from sage.misc.persist import register_unpickle_override
register_unpickle_override("sage.combinat.choose_nk", "ChooseNK", ChooseNK)
コード例 #17
0
        """
        for p in descents_composition_list(self.shape):
            yield self.from_permutation(p)

class Ribbon_class(RibbonShapedTableau):
    """
    This exists solely for unpickling ``Ribbon_class`` objects.
    """
    def __setstate__(self, state):
        r"""
        Unpickle old ``Ribbon_class`` objects.

        EXAMPLES::

            sage: loads(b'x\x9ck`J.NLO\xd5K\xce\xcfM\xca\xccK,\xd1+\xcaLJ\xca\xcf\xe3\n\x02S\xf1\xc99\x89\xc5\xc5\\\x85\x8c\x9a\x8d\x85L\xb5\x85\xcc\x1a\xa1\xac\xf1\x19\x89\xc5\x19\x85,~@VNfqI!kl!\x9bFl!\xbb\x06\xc4\x9c\xa2\xcc\xbc\xf4b\xbd\xcc\xbc\x92\xd4\xf4\xd4"\xae\xdc\xc4\xec\xd4x\x18\xa7\x90#\x94\xd1\xb05\xa8\x903\x03\xc80\x022\xb8Rc\x0b\xb95@<c \x8f\x07\xc40\x012xSSK\x93\xf4\x00l\x811\x17')
            [[None, 1, 2], [3, 4]]
            sage: loads(dumps( RibbonShapedTableau([[3,2,1], [1,1]]) ))  # indirect doctest
            [[None, 3, 2, 1], [1, 1]]
        """
        self.__class__ = RibbonShapedTableau
        self.__init__(RibbonShapedTableaux(), state['_list'])

from sage.misc.persist import register_unpickle_override
register_unpickle_override('sage.combinat.ribbon', 'Ribbon_class', Ribbon_class)
register_unpickle_override('sage.combinat.ribbon', 'StandardRibbons_shape', StandardRibbonShapedTableaux)

# Deprecations from trac:18555. July 2016
from sage.misc.superseded import deprecated_function_alias
RibbonShapedTableaux.global_options = deprecated_function_alias(18555, RibbonShapedTableaux.options)
StandardRibbonShapedTableaux.global_options = deprecated_function_alias(18555, StandardRibbonShapedTableaux.options)
コード例 #18
0
ファイル: all.py プロジェクト: sagemath/sage
    import sage.libs.flint.flint
    sage.libs.flint.flint.free_flint_stack()

    # Free globally allocated mpir integers.
    import sage.rings.integer
    sage.rings.integer.free_integer_pool()
    import sage.algebras.quatalg.quaternion_algebra_element
    sage.algebras.quatalg.quaternion_algebra_element._clear_globals()

    from sage.libs.all import symmetrica
    symmetrica.end()


from sage.misc.persist import register_unpickle_override
register_unpickle_override('sage.categories.category', 'Sets', Sets)
register_unpickle_override('sage.categories.category_types', 'HeckeModules', HeckeModules)
register_unpickle_override('sage.categories.category_types', 'Objects', Objects)
register_unpickle_override('sage.categories.category_types', 'Rings', Rings)
register_unpickle_override('sage.categories.category_types', 'Fields', Fields)
register_unpickle_override('sage.categories.category_types', 'VectorSpaces', VectorSpaces)
register_unpickle_override('sage.categories.category_types', 'Schemes_over_base', sage.categories.schemes.Schemes_over_base)
register_unpickle_override('sage.categories.category_types', 'ModularAbelianVarieties', ModularAbelianVarieties)
register_unpickle_override('sage.libs.pari.gen_py', 'pari', pari)

# Cache the contents of star imports.
sage.misc.lazy_import.save_cache_file()


### Debugging for Singular, see trac #10903
# from sage.libs.singular.ring import poison_currRing
コード例 #19
0

##########################################################
# Deprecations


class SplitNK(OrderedSetPartitions_scomp):
    def __setstate__(self, state):
        r"""
        For unpickling old ``SplitNK`` objects.

        TESTS::

            sage: loads(b"x\x9ck`J.NLO\xd5K\xce\xcfM\xca\xccK,\xd1+.\xc8\xc9,"
            ....:   b"\x89\xcf\xcb\xe6\n\x061\xfc\xbcA\xccBF\xcd\xc6B\xa6\xda"
            ....:   b"Bf\x8dP\xa6\xf8\xbcB\x16\x88\x96\xa2\xcc\xbc\xf4b\xbd\xcc"
            ....:   b"\xbc\x92\xd4\xf4\xd4\"\xae\xdc\xc4\xec\xd4x\x18\xa7\x905"
            ....:   b"\x94\xd1\xb45\xa8\x90\r\xa8>\xbb\x90=\x03\xc85\x02r9J\x93"
            ....:   b"\xf4\x00\xb4\xc6%f")
            Ordered set partitions of {0, 1, 2, 3, 4} into parts of size [2, 3]
        """
        self.__class__ = OrderedSetPartitions_scomp
        n = state['_n']
        k = state['_k']
        OrderedSetPartitions_scomp.__init__(self, range(state['_n']),
                                            (k, n - k))


from sage.misc.persist import register_unpickle_override
register_unpickle_override("sage.combinat.split_nk", "SplitNK_nk", SplitNK)
コード例 #20
0
ファイル: homogeneous.py プロジェクト: sagemath/sage
            EXAMPLES::

                sage: h = SymmetricFunctions(QQ).h()
                sage: h([3]).expand(2)
                x0^3 + x0^2*x1 + x0*x1^2 + x1^3
                sage: h([1,1,1]).expand(2)
                x0^3 + 3*x0^2*x1 + 3*x0*x1^2 + x1^3
                sage: h([2,1]).expand(3)
                x0^3 + 2*x0^2*x1 + 2*x0*x1^2 + x1^3 + 2*x0^2*x2 + 3*x0*x1*x2 + 2*x1^2*x2 + 2*x0*x2^2 + 2*x1*x2^2 + x2^3
                sage: h([3]).expand(2,alphabet='y')
                y0^3 + y0^2*y1 + y0*y1^2 + y1^3
                sage: h([3]).expand(2,alphabet='x,y')
                x^3 + x^2*y + x*y^2 + y^3
                sage: h([3]).expand(3,alphabet='x,y,z')
                x^3 + x^2*y + x*y^2 + y^3 + x^2*z + x*y*z + y^2*z + x*z^2 + y*z^2 + z^3
                sage: (h([]) + 2*h([1])).expand(3)
                2*x0 + 2*x1 + 2*x2 + 1
                sage: h([1]).expand(0)
                0
                sage: (3*h([])).expand(0)
                3
            """
            if n == 0:   # Symmetrica crashes otherwise...
                return self.counit()
            condition = lambda part: False
            return self._expand(condition, n, alphabet)

# Backward compatibility for unpickling
from sage.misc.persist import register_unpickle_override
register_unpickle_override('sage.combinat.sf.homogeneous', 'SymmetricFunctionAlgebraElement_homogeneous',  SymmetricFunctionAlgebra_homogeneous.Element)
コード例 #21
0
            OUTPUT:

            A monomial expansion of ``self`` in the `n` variables
            labelled by ``alphabet``.

            EXAMPLES::

                sage: m = SymmetricFunctions(QQ).monomial()
                sage: zee = sage.combinat.sf.sfa.zee
                sage: h = m.dual_basis(zee)
                sage: a = h([2,1])+h([3])
                sage: a.expand(2)
                2*x0^3 + 3*x0^2*x1 + 3*x0*x1^2 + 2*x1^3
                sage: a.dual().expand(2)
                2*x0^3 + 3*x0^2*x1 + 3*x0*x1^2 + 2*x1^3
                sage: a.expand(2,alphabet='y')
                2*y0^3 + 3*y0^2*y1 + 3*y0*y1^2 + 2*y1^3
                sage: a.expand(2,alphabet='x,y')
                2*x^3 + 3*x^2*y + 3*x*y^2 + 2*y^3
                sage: h([1]).expand(0)
                0
                sage: (3*h([])).expand(0)
                3
            """
            return self._dual.expand(n, alphabet)

# Backward compatibility for unpickling
from sage.misc.persist import register_unpickle_override
register_unpickle_override('sage.combinat.sf.dual', 'SymmetricFunctionAlgebraElement_dual',  SymmetricFunctionAlgebra_dual.Element)

コード例 #22
0
ファイル: dual.py プロジェクト: sagemath/sage
            OUTPUT:

            A monomial expansion of ``self`` in the `n` variables
            labelled by ``alphabet``.

            EXAMPLES::

                sage: m = SymmetricFunctions(QQ).monomial()
                sage: zee = sage.combinat.sf.sfa.zee
                sage: h = m.dual_basis(zee)
                sage: a = h([2,1])+h([3])
                sage: a.expand(2)
                2*x0^3 + 3*x0^2*x1 + 3*x0*x1^2 + 2*x1^3
                sage: a.dual().expand(2)
                2*x0^3 + 3*x0^2*x1 + 3*x0*x1^2 + 2*x1^3
                sage: a.expand(2,alphabet='y')
                2*y0^3 + 3*y0^2*y1 + 3*y0*y1^2 + 2*y1^3
                sage: a.expand(2,alphabet='x,y')
                2*x^3 + 3*x^2*y + 3*x*y^2 + 2*y^3
                sage: h([1]).expand(0)
                0
                sage: (3*h([])).expand(0)
                3
            """
            return self._dual.expand(n, alphabet)

# Backward compatibility for unpickling
from sage.misc.persist import register_unpickle_override
register_unpickle_override('sage.combinat.sf.dual', 'SymmetricFunctionAlgebraElement_dual',  SymmetricFunctionAlgebra_dual.Element)

コード例 #23
0
ファイル: all.py プロジェクト: swewers/mein_sage
    import sage.libs.flint.flint
    sage.libs.flint.flint.free_flint_stack()

    # Free globally allocated mpir integers.
    import sage.rings.integer
    sage.rings.integer.free_integer_pool()
    import sage.algebras.quatalg.quaternion_algebra_element
    sage.algebras.quatalg.quaternion_algebra_element._clear_globals()

    from sage.libs.all import symmetrica
    symmetrica.end()


from sage.misc.persist import register_unpickle_override
register_unpickle_override('sage.categories.category', 'Sets', Sets)
register_unpickle_override('sage.categories.category_types', 'HeckeModules', HeckeModules)
register_unpickle_override('sage.categories.category_types', 'Objects', Objects)
register_unpickle_override('sage.categories.category_types', 'Rings', Rings)
register_unpickle_override('sage.categories.category_types', 'Fields', Fields)
register_unpickle_override('sage.categories.category_types', 'VectorSpaces', VectorSpaces)
register_unpickle_override('sage.categories.category_types', 'Schemes_over_base', sage.categories.schemes.Schemes_over_base)
register_unpickle_override('sage.categories.category_types', 'ModularAbelianVarieties', ModularAbelianVarieties)
register_unpickle_override('sage.libs.pari.gen_py', 'pari', pari)

# Cache the contents of star imports.
sage.misc.lazy_import.save_cache_file()


### Debugging for Singular, see trac #10903
# from sage.libs.singular.ring import poison_currRing
コード例 #24
0
ファイル: all.py プロジェクト: sagemath/sage
from __future__ import absolute_import
import sage.crypto.sbox
from sage.misc.persist import register_unpickle_override
register_unpickle_override('sage.crypto.mq.sbox', 'SBox', sage.crypto.sbox.SBox)

from sage.misc.lazy_import import lazy_import

lazy_import('sage.crypto.classical', ['AffineCryptosystem',
                                      'HillCryptosystem',
                                      'SubstitutionCryptosystem',
                                      'ShiftCryptosystem',
                                      'TranspositionCryptosystem',
                                      'VigenereCryptosystem',
                                     ])

lazy_import('sage.crypto.stream', ['LFSRCryptosystem',
                                   'ShrinkingGeneratorCryptosystem',
                                  ])

lazy_import('sage.crypto.lfsr', ['lfsr_sequence',
                                 'lfsr_autocorrelation',
                                 'lfsr_connection_polynomial',
                                ])
コード例 #25
0
ファイル: homogeneous.py プロジェクト: lwhsu/sagemath
                sage: h([3]).expand(2)
                x0^3 + x0^2*x1 + x0*x1^2 + x1^3
                sage: h([1,1,1]).expand(2)
                x0^3 + 3*x0^2*x1 + 3*x0*x1^2 + x1^3
                sage: h([2,1]).expand(3)
                x0^3 + 2*x0^2*x1 + 2*x0*x1^2 + x1^3 + 2*x0^2*x2 + 3*x0*x1*x2 + 2*x1^2*x2 + 2*x0*x2^2 + 2*x1*x2^2 + x2^3
                sage: h([3]).expand(2,alphabet='y')
                y0^3 + y0^2*y1 + y0*y1^2 + y1^3
                sage: h([3]).expand(2,alphabet='x,y')
                x^3 + x^2*y + x*y^2 + y^3
                sage: h([3]).expand(3,alphabet='x,y,z')
                x^3 + x^2*y + x*y^2 + y^3 + x^2*z + x*y*z + y^2*z + x*z^2 + y*z^2 + z^3
                sage: (h([]) + 2*h([1])).expand(3)
                2*x0 + 2*x1 + 2*x2 + 1
                sage: h([1]).expand(0)
                0
                sage: (3*h([])).expand(0)
                3
            """
            if n == 0:  # Symmetrica crashes otherwise...
                return self.counit()
            condition = lambda part: False
            return self._expand(condition, n, alphabet)


# Backward compatibility for unpickling
from sage.misc.persist import register_unpickle_override
register_unpickle_override('sage.combinat.sf.homogeneous',
                           'SymmetricFunctionAlgebraElement_homogeneous',
                           SymmetricFunctionAlgebra_homogeneous.Element)
コード例 #26
0
ファイル: elementary.py プロジェクト: sagemath/sage
            labelled by ``alphabet``.

            EXAMPLES::

                sage: e = SymmetricFunctions(QQ).e()
                sage: e([2,1]).expand(3)
                x0^2*x1 + x0*x1^2 + x0^2*x2 + 3*x0*x1*x2 + x1^2*x2 + x0*x2^2 + x1*x2^2
                sage: e([1,1,1]).expand(2)
                x0^3 + 3*x0^2*x1 + 3*x0*x1^2 + x1^3
                sage: e([3]).expand(2)
                0
                sage: e([2]).expand(3)
                x0*x1 + x0*x2 + x1*x2
                sage: e([3]).expand(4,alphabet='x,y,z,t')
                x*y*z + x*y*t + x*z*t + y*z*t
                sage: e([3]).expand(4,alphabet='y')
                y0*y1*y2 + y0*y1*y3 + y0*y2*y3 + y1*y2*y3
                sage: e([]).expand(2)
                1
                sage: e([]).expand(0)
                1
                sage: (3*e([])).expand(0)
                3
            """
            condition = lambda part: max(part) > n
            return self._expand(condition, n, alphabet)

# Backward compatibility for unpickling
from sage.misc.persist import register_unpickle_override
register_unpickle_override('sage.combinat.sf.elementary', 'SymmetricFunctionAlgebraElement_elementary',  SymmetricFunctionAlgebra_elementary.Element)
コード例 #27
0
            D[j] = e
            j += 1
    else:
        D[k - 1] = n0 + r + k - 1 - B
    return tuple(D)

##########################################################
# Deprecations


class ChooseNK(Combinations_setk):
    def __setstate__(self, state):
        r"""
        For unpickling old ``ChooseNK`` objects.

        TESTS::

            sage: loads(b"x\x9ck`J.NLO\xd5K\xce\xcfM\xca\xccK,\xd1K\xce\xc8\xcf"
            ....:   b"/N\x8d\xcf\xcb\xe6r\x06\xb3\xfc\xbc\xb9\n\x195\x1b\x0b"
            ....:   b"\x99j\x0b\x995B\x99\xe2\xf3\nY :\x8a2\xf3\xd2\x8b\xf52"
            ....:   b"\xf3JR\xd3S\x8b\xb8r\x13\xb3S\xe3a\x9cB\xd6PF\xd3\xd6\xa0"
            ....:   b"B6\xa0\xfa\xecB\xf6\x0c \xd7\x08\xc8\xe5(M\xd2\x03\x00{"
            ....:   b"\x82$\xd8")
            Combinations of [0, 1, 2, 3, 4] of length 2
        """
        self.__class__ = Combinations_setk
        Combinations_setk.__init__(self, list(range(state['_n'])), state['_k'])


register_unpickle_override("sage.combinat.choose_nk", "ChooseNK", ChooseNK)
コード例 #28
0
ファイル: schur.py プロジェクト: sagemath/sage
            EXAMPLES::

                sage: s = SymmetricFunctions(QQ).s()
                sage: a = s([2,1])
                sage: a.expand(2)
                x0^2*x1 + x0*x1^2
                sage: a.expand(3)
                x0^2*x1 + x0*x1^2 + x0^2*x2 + 2*x0*x1*x2 + x1^2*x2 + x0*x2^2 + x1*x2^2
                sage: a.expand(4)
                x0^2*x1 + x0*x1^2 + x0^2*x2 + 2*x0*x1*x2 + x1^2*x2 + x0*x2^2 + x1*x2^2 + x0^2*x3 + 2*x0*x1*x3 + x1^2*x3 + 2*x0*x2*x3 + 2*x1*x2*x3 + x2^2*x3 + x0*x3^2 + x1*x3^2 + x2*x3^2
                sage: a.expand(2, alphabet='y')
                y0^2*y1 + y0*y1^2
                sage: a.expand(2, alphabet=['a','b'])
                a^2*b + a*b^2
                sage: s([1,1,1,1]).expand(3)
                0
                sage: (s([]) + 2*s([1])).expand(3)
                2*x0 + 2*x1 + 2*x2 + 1
                sage: s([1]).expand(0)
                0
                sage: (3*s([])).expand(0)
                3
            """
            condition = lambda part: len(part) > n
            return self._expand(condition, n, alphabet)

# Backward compatibility for unpickling
from sage.misc.persist import register_unpickle_override
register_unpickle_override('sage.combinat.sf.schur', 'SymmetricFunctionAlgebraElement_schur',  SymmetricFunctionAlgebra_schur.Element)
コード例 #29
0
        return
    if len(l) == 1:
        if n % l[0] == 0:
            yield [n // l[0]]
        return

    k = 0
    cur = [n // l[k] + one]
    rem = n - cur[-1] * l[k]  # Amount remaining
    while cur:
        cur[-1] -= one
        rem += l[k]
        if rem == zero:
            yield cur + [zero] * (len(l) - len(cur))
        elif cur[-1] < zero or rem < zero:
            rem += cur.pop() * l[k]
            k -= 1
        elif len(l) == len(cur) + 1:
            if rem % l[-1] == zero:
                yield cur + [rem // l[-1]]
        else:
            k += 1
            cur.append(rem // l[k] + one)
            rem -= cur[-1] * l[k]


from sage.misc.persist import register_unpickle_override
register_unpickle_override('sage.combinat.integer_vector_weighted',
                           'WeightedIntegerVectors_nweight',
                           WeightedIntegerVectors)
コード例 #30
0
ファイル: schur.py プロジェクト: yjjcc/sage
                sage: a = s([2,1])
                sage: a.expand(2)
                x0^2*x1 + x0*x1^2
                sage: a.expand(3)
                x0^2*x1 + x0*x1^2 + x0^2*x2 + 2*x0*x1*x2 + x1^2*x2 + x0*x2^2 + x1*x2^2
                sage: a.expand(4)
                x0^2*x1 + x0*x1^2 + x0^2*x2 + 2*x0*x1*x2 + x1^2*x2 + x0*x2^2 + x1*x2^2 + x0^2*x3 + 2*x0*x1*x3 + x1^2*x3 + 2*x0*x2*x3 + 2*x1*x2*x3 + x2^2*x3 + x0*x3^2 + x1*x3^2 + x2*x3^2
                sage: a.expand(2, alphabet='y')
                y0^2*y1 + y0*y1^2
                sage: a.expand(2, alphabet=['a','b'])
                a^2*b + a*b^2
                sage: s([1,1,1,1]).expand(3)
                0
                sage: (s([]) + 2*s([1])).expand(3)
                2*x0 + 2*x1 + 2*x2 + 1
                sage: s([1]).expand(0)
                0
                sage: (3*s([])).expand(0)
                3
            """
            condition = lambda part: len(part) > n
            return self._expand(condition, n, alphabet)


# Backward compatibility for unpickling
from sage.misc.persist import register_unpickle_override

register_unpickle_override('sage.combinat.sf.schur',
                           'SymmetricFunctionAlgebraElement_schur',
                           SymmetricFunctionAlgebra_schur.Element)
コード例 #31
0
            sage: from sage.combinat.words.alphabet import OrderedAlphabet
            sage: O = OrderedAlphabet()
            doctest:...: DeprecationWarning: OrderedAlphabet is deprecated; use Alphabet instead.
            See http://trac.sagemath.org/8920 for details.
            sage: O._alphabet = ['a', 'b']
            sage: O._elements
            ('a', 'b')
        """
        if name == '_elements':
            if not hasattr(self, '_alphabet'):
                raise AttributeError("no attribute '_elements'")
            self._elements = tuple(self._alphabet)
            from sage.structure.parent import Parent
            from sage.categories.finite_enumerated_sets import FiniteEnumeratedSets
            Parent.__init__(self, category=FiniteEnumeratedSets(), facade=True)
            return self._elements
        raise AttributeError("no attribute %s" % name)


register_unpickle_override('sage.combinat.words.alphabet',
                           'OrderedAlphabet_NaturalNumbers',
                           NonNegativeIntegers,
                           call_name=('sage.sets.non_negative_integers',
                                      'NonNegativeIntegers'))

register_unpickle_override('sage.combinat.words.alphabet',
                           'OrderedAlphabet_PositiveIntegers',
                           PositiveIntegers,
                           call_name=('sage.sets.positive_integers',
                                      'PositiveIntegers'))
コード例 #32
0
ファイル: formal_sum.py プロジェクト: BrentBaccala/sage
                if extended is not self:
                    action = PrecomposedAction(
                        action, None, extended._internal_coerce_map_from(self))
            return action

    def _an_element_(self, check=False, reduce=False):
        """
        EXAMPLES::

            sage: FormalSums(ZZ).an_element()     # indirect test
            1
            sage: FormalSums(QQ).an_element()
            1/2*1
            sage: QQ.an_element()
            1/2
        """
        return self.element_class([(self.base_ring().an_element(), 1)],
                                  check=check,
                                  reduce=reduce,
                                  parent=self)


formal_sums = FormalSums()

# Formal sums now derives from UniqueRepresentation, which makes the
# factory function unnecessary. This is why the name was changed from
# class FormalSums_generic to class FormalSums.
from sage.misc.persist import register_unpickle_override
register_unpickle_override('sage.structure.formal_sum', 'FormalSums_generic',
                           FormalSums)
コード例 #33
0
ファイル: homset.py プロジェクト: swewers/mein_sage
            sage: Hom(GF(3^3, 'a'), GF(3^6, 'b')).an_element()
            Ring morphism:
              From: Finite Field in a of size 3^3
              To:   Finite Field in b of size 3^6
              Defn: a |--> 2*b^5 + 2*b^4

            sage: Hom(GF(3^3, 'a'), GF(3^2, 'c')).an_element()
            Traceback (most recent call last):
            ...
            EmptySetError: no homomorphisms from Finite Field in a of size 3^3 to Finite Field in c of size 3^2

        .. TODO::

            Use a more sophisticated algorithm; see also :trac:`8751`.

        """
        K = self.domain()
        L = self.codomain()
        if K.degree() == 1:
            return L.coerce_map_from(K)
        elif not K.degree().divides(L.degree()):
            from sage.categories.sets_cat import EmptySetError
            raise EmptySetError('no homomorphisms from %s to %s' % (K, L))
        return K.hom([K.modulus().any_root(L)])


from sage.misc.persist import register_unpickle_override
register_unpickle_override('sage.rings.finite_field_morphism',
                           'FiniteFieldHomset', FiniteFieldHomset)
コード例 #34
0
ファイル: error.py プロジェクト: swewers/mein_sage
    def _derivative_(self, x, diff_param=None):
        """
        Derivative of inverse erf function.

        EXAMPLES::

            sage: erfinv(x).diff(x)
            1/2*sqrt(pi)*e^(erfinv(x)^2)
        """
        return sqrt(pi) * exp(erfinv(x)**2) / 2


erfinv = Function_erfinv()

from sage.misc.persist import register_unpickle_override
register_unpickle_override('sage.functions.other', 'Function_erf',
                           Function_erf)


############################
# Fresnel integrals        #
############################
class Function_Fresnel_sin(BuiltinFunction):
    def __init__(self):
        r"""
        The sine Fresnel integral.

        It is defined by the integral

        .. MATH ::

            \operatorname{S}(x) = \int_0^x \sin\left(\frac{\pi t^2}{2}\right)\, dt
コード例 #35
0
ファイル: orthotriang.py プロジェクト: timgates42/sage
        Return ``left`` * ``right`` by converting both to the base and then
        converting back to ``self``.

        INPUT:

        - ``self`` -- a basis determined by an orthotriangular definition
        - ``left``, ``right`` -- elements in ``self``

        OUTPUT:

        - the expansion of the product of ``left`` and ``right`` in the basis ``self``.

        EXAMPLES::

            sage: from sage.combinat.sf.sfa import zee
            sage: from sage.combinat.sf.orthotriang import SymmetricFunctionAlgebra_orthotriang
            sage: Sym = SymmetricFunctions(QQ)
            sage: m = Sym.m()
            sage: s = SymmetricFunctionAlgebra_orthotriang(Sym, m, zee, 's', 'Schur functions')
            sage: s([1])*s([2,1]) #indirect doctest
            s[2, 1, 1] + s[2, 2] + s[3, 1]
        """
        return self(self._sf_base(left) * self._sf_base(right))


# Backward compatibility for unpickling
from sage.misc.persist import register_unpickle_override
register_unpickle_override('sage.combinat.sf.orthotriang',
                           'SymmetricFunctionAlgebraElement_orthotriang',
                           SymmetricFunctionAlgebra_orthotriang.Element)
コード例 #36
0
    one = ZZ.one()
    k = int(k)

    pos = 0  # Current position
    rem = zero  # Amount remaining
    cur = [n] + [zero] * (k - 1)  # Current list
    yield list(cur)
    while pos >= 0:
        if not cur[pos]:
            pos -= 1
            continue
        cur[pos] -= one
        rem += one
        if not rem:
            yield list(cur)
        elif pos == k - 2:
            cur[pos + 1] = rem
            yield list(cur)
            cur[pos + 1] = zero
        else:
            pos += 1
            cur[pos] = rem  # Guaranteed to be at least 1
            rem = zero
            yield list(cur)


# October 2012: fixing outdated pickles which use classes being deprecated
from sage.misc.persist import register_unpickle_override
register_unpickle_override('sage.combinat.integer_vector', 'IntegerVectors_nconstraints', IntegerVectorsConstraints)
register_unpickle_override('sage.combinat.integer_vector', 'IntegerVectors_nkconstraints', IntegerVectorsConstraints)
コード例 #37
0
import sage.crypto.sbox
from sage.misc.persist import register_unpickle_override
register_unpickle_override('sage.crypto.mq.sbox', 'SBox',
                           sage.crypto.sbox.SBox)

from sage.misc.lazy_import import lazy_import

lazy_import('sage.crypto.classical', [
    'AffineCryptosystem',
    'HillCryptosystem',
    'SubstitutionCryptosystem',
    'ShiftCryptosystem',
    'TranspositionCryptosystem',
    'VigenereCryptosystem',
])

lazy_import('sage.crypto.stream', [
    'LFSRCryptosystem',
    'ShrinkingGeneratorCryptosystem',
])

lazy_import('sage.crypto.lfsr', [
    'lfsr_sequence',
    'lfsr_autocorrelation',
    'lfsr_connection_polynomial',
])
コード例 #38
0
        EXAMPLES::

            sage: R = Integers(12345678900)
            sage: R.degree()
            1
        """
        return integer.Integer(1)


Zmod = IntegerModRing
Integers = IntegerModRing

# Register unpickling methods for backward compatibility.

from sage.misc.persist import register_unpickle_override
register_unpickle_override('sage.rings.integer_mod_ring',
                           'IntegerModRing_generic', IntegerModRing_generic)


def crt(v):
    """
    INPUT:

    - ``v`` -- (list) a lift of elements of ``rings.IntegerMod(n)``, for
      various coprime moduli ``n``

    EXAMPLES::

        sage: from sage.rings.finite_rings.integer_mod_ring import crt
        sage: crt([mod(3, 8),mod(1,19),mod(7, 15)])
        1027
    """
コード例 #39
0
            1   2
            sage: print(CartanType(['C',3]).ascii_art())
            O---O=<=O
            1   2   3
            sage: print(CartanType(['C',5]).ascii_art(label = lambda x: x+2))
            O---O---O---O=<=O
            3   4   5   6   7
        """
        return self.dual().ascii_art(label=label,
                                     node=node).replace("=>=", "=<=")

    def _default_folded_cartan_type(self):
        """
        Return the default folded Cartan type.

        EXAMPLES::

            sage: CartanType(['C', 3])._default_folded_cartan_type()
            ['C', 3] as a folding of ['A', 5]
        """
        from sage.combinat.root_system.type_folded import CartanTypeFolded
        n = self.n
        return CartanTypeFolded(self, ['A', 2 * n - 1],
                                [[i, 2 * n - i] for i in range(1, n)] + [[n]])


# For unpickling backward compatibility (Sage <= 4.1)
from sage.misc.persist import register_unpickle_override
register_unpickle_override('sage.combinat.root_system.type_C', 'ambient_space',
                           AmbientSpace)
コード例 #40
0
ファイル: type_E.py プロジェクト: sagemath/sage
        EXAMPLES::

            sage: print(CartanType(['E',6]).ascii_art(label = lambda x: x+2))
                    O 4
                    |
                    |
            O---O---O---O---O
            3   5   6   7   8
            sage: print(CartanType(['E',7]).ascii_art(label = lambda x: x+2))
                    O 4
                    |
                    |
            O---O---O---O---O---O
            3   5   6   7   8   9
            sage: print(CartanType(['E',8]).ascii_art(label = lambda x: x+1))
                    O 3
                    |
                    |
            O---O---O---O---O---O---O
            2   4   5   6   7   8   9
        """
        if node is None:
            node = self._ascii_art_node
        labels = [label(_) for _ in [1,3,4,5,6] + list(range(7, self.n+1))] # We exclude 2 because of the special case
        ret = "        {} {}\n        |\n        |\n".format(node(label(2)), label(2))
        return ret + '---'.join(node(i) for i in labels) + '\n' + "".join("{!s:4}".format(i) for i in labels)

# For unpickling backward compatibility (Sage <= 4.1)
from sage.misc.persist import register_unpickle_override
register_unpickle_override('sage.combinat.root_system.type_E', 'ambient_space',  AmbientSpace)
コード例 #41
0
        """
        if name == "_Sequence_generic__cr" and hasattr(self, "_Sequence__cr"):
            self.__cr = self._Sequence__cr
            return self.__cr
        elif name == "_Sequence_generic__cr_str" and hasattr(
                self, "_Sequence__cr_str"):
            self.__cr_str = self._Sequence__cr_str
            return self.__cr_str
        elif name == "_Sequence_generic__immutable" and hasattr(
                self, "_Sequence__immutable"):
            self.__immutable = self._Sequence__immutable
            return self.__immutable
        elif name == "_Sequence_generic__universe" and hasattr(
                self, "_Sequence__universe"):
            self.__universe = self._Sequence__universe
            return self.__universe
        elif name == "_Sequence_generic__hash" and hasattr(
                self, "_Sequence__hash"):
            self.__hash = self._Sequence__hash
            return self.__hash
        else:
            raise AttributeError(
                "'Sequence_generic' object has no attribute '%s'" % name)


seq = Sequence

from sage.misc.persist import register_unpickle_override
register_unpickle_override('sage.structure.sequence', 'Sequence',
                           Sequence_generic)
コード例 #42
0
ファイル: __init__.py プロジェクト: sagemath/sagetrac-mirror
from .base import IntegerListsBackend, Envelope
from .lists import IntegerLists
from .invlex import IntegerListsLex

from sage.misc.persist import register_unpickle_override
register_unpickle_override('sage.combinat.integer_list', 'IntegerListsLex', IntegerListsLex)
コード例 #43
0
ファイル: all.py プロジェクト: timgates42/sage
from .chain_complex import ChainComplex

from .chain_complex_morphism import ChainComplexMorphism

from .simplicial_complex import SimplicialComplex, Simplex

from .simplicial_complex_morphism import SimplicialComplexMorphism

from .delta_complex import DeltaComplex, delta_complexes

from .cubical_complex import CubicalComplex, cubical_complexes

from sage.misc.lazy_import import lazy_import
lazy_import('sage.homology.koszul_complex', 'KoszulComplex')
lazy_import('sage.homology', 'simplicial_complexes_catalog',
            'simplicial_complexes')
lazy_import('sage.homology', 'simplicial_set_catalog', 'simplicial_sets')

# For taking care of old pickles
from sage.misc.persist import register_unpickle_override
register_unpickle_override('sage.homology.examples', 'SimplicialSurface',
                           SimplicialComplex)
コード例 #44
0
ファイル: affine_space.py プロジェクト: sheldoncooper07/sage
        TESTS::

            sage: P2.<x,y,z> = AffineSpace(3, GF(3))
            sage: point_homset = P2._point_homset(Spec(GF(3)), P2)
            sage: P2._point(point_homset, [1, 2, 3])
            (1, 2, 0)
        """
        return SchemeMorphism_point_affine_finite_field(*args, **kwds)

    def _morphism(self, *args, **kwds):
        """
        Construct a morphism.

        For internal use only. See :mod:`morphism` for details.

        TESTS::

            sage: P2.<x,y,z> = AffineSpace(3, GF(3))
            sage: P2._morphism(P2.Hom(P2), [x, y, z])
            Scheme endomorphism of Affine Space of dimension 3 over Finite Field of size 3
              Defn: Defined on coordinates by sending (x, y, z) to
                    (x, y, z)
        """
        return SchemeMorphism_polynomial_affine_space_finite_field(*args, **kwds)

#fix the pickles from moving affine_space.py
from sage.misc.persist import register_unpickle_override
register_unpickle_override('sage.schemes.generic.affine_space',
                           'AffineSpace_generic',
                           AffineSpace_generic)
コード例 #45
0
ファイル: g1list.py プロジェクト: swewers/mein_sage
            sage: from sage.modular.modsym.g1list import _G1list_old_pickle
            sage: L = _G1list_old_pickle()
            sage: type(L) == G1list
            True
        """
        self.__class__ = G1list

    def __setstate__(self, state):
        """
        For unpickling new pickles.

        TESTS::

            sage: from sage.modular.modsym.g1list import G1list
            sage: L = G1list(6)
            sage: Lp = loads(dumps(L))
            sage: L == Lp
            True
            sage: type(Lp) == G1list
            True
        """
        # We don't really want this class, but we want to handle new
        #   pickles without creating a new class
        self.__class__ = G1list
        self.__dict__ = state  # Default pickling is ``state = self.__dict__``


register_unpickle_override('sage.modular.modsym.g1list', 'G1list',
                           _G1list_old_pickle)
コード例 #46
0
        INPUT:

        - ``self`` -- an instance of the LLT hcospin basis
        - ``part`` -- a partition

        OUTPUT:

        - returns a function which accepts a partition and returns the coefficient
          in the expansion of the monomial basis

        EXAMPLES::

            sage: HCosp3 = SymmetricFunctions(FractionField(QQ['t'])).llt(3).hcospin()
            sage: f21 = HCosp3._to_m(Partition([2,1]))
            sage: [f21(p) for p in Partitions(3)]
            [1, t + 1, 2*t + 1]
            sage: HCosp3.symmetric_function_ring().m()( HCosp3[2,1] )
            (2*t+1)*m[1, 1, 1] + (t+1)*m[2, 1] + m[3]
        """
        level = self.level()
        f = lambda part2: QQt(ribbon_tableau.cospin_polynomial([level*i for i in part], part2, level))
        return f

    class Element(LLT_generic.Element):
        pass

# Backward compatibility for unpickling
from sage.misc.persist import register_unpickle_override
register_unpickle_override('sage.combinat.sf.llt', 'LLTElement_spin',  LLT_spin.Element)
register_unpickle_override('sage.combinat.sf.llt', 'LLTElement_cospin',  LLT_cospin.Element)
コード例 #47
0
       to the method

    EXAMPLES::

        sage: f = attrcall('core', 3); f
        *.core(3)
        sage: [f(p) for p in Partitions(5)]
        [[2], [1, 1], [1, 1], [3, 1, 1], [2], [2], [1, 1]]
    """
    return AttrCallObject(name, args, kwds)


def call_method(obj, name, *args, **kwds):
    """
    Call the method ``name`` on ``obj``.

    This has to exist somewhere in Python!!!

    .. SEEALSO:: :func:`operator.methodcaller` :func:`attrcal`

    EXAMPLES::

        sage: from sage.misc.call import call_method
        sage: call_method(1, "__add__", 2)
        3
    """
    return getattr(obj, name)(*args, **kwds)

from sage.misc.persist import register_unpickle_override
register_unpickle_override("sage.misc.misc", "call_method", call_method)
コード例 #48
0
            """
            return richcmp([sorted(s) for s in left], [sorted(s) for s in right], op)

##########################################################
# Deprecations


class SplitNK(OrderedSetPartitions_scomp):
    def __setstate__(self, state):
        r"""
        For unpickling old ``SplitNK`` objects.

        TESTS::

            sage: loads(b"x\x9ck`J.NLO\xd5K\xce\xcfM\xca\xccK,\xd1+.\xc8\xc9,"
            ....:   b"\x89\xcf\xcb\xe6\n\x061\xfc\xbcA\xccBF\xcd\xc6B\xa6\xda"
            ....:   b"Bf\x8dP\xa6\xf8\xbcB\x16\x88\x96\xa2\xcc\xbc\xf4b\xbd\xcc"
            ....:   b"\xbc\x92\xd4\xf4\xd4\"\xae\xdc\xc4\xec\xd4x\x18\xa7\x905"
            ....:   b"\x94\xd1\xb45\xa8\x90\r\xa8>\xbb\x90=\x03\xc85\x02r9J\x93"
            ....:   b"\xf4\x00\xb4\xc6%f")
            Ordered set partitions of {0, 1, 2, 3, 4} into parts of size [2, 3]
        """
        self.__class__ = OrderedSetPartitions_scomp
        n = state['_n']
        k = state['_k']
        OrderedSetPartitions_scomp.__init__(self, range(state['_n']), (k,n-k))

from sage.misc.persist import register_unpickle_override
register_unpickle_override("sage.combinat.split_nk", "SplitNK_nk", SplitNK)