fix imports after changing to py files
authorAlexandru Ghitza <aghitza@alum.mit.edu>
Thu Mar 25 15:49:50 2010 +1100 (2010-03-25)
changeset 30c7ff24efd6af
parent 29 0c537f4b5a0e
child 31 5d1c40257852
fix imports after changing to py files
nils/siegelmodforms/fastmult.pyx
nils/siegelmodforms/group_algebra.py
nils/siegelmodforms/siegel_modular_form.py
nils/siegelmodforms/theta_constant.py
     1.1 --- a/nils/siegelmodforms/fastmult.pyx	Thu Mar 25 15:46:49 2010 +1100
     1.2 +++ b/nils/siegelmodforms/fastmult.pyx	Thu Mar 25 15:49:50 2010 +1100
     1.3 @@ -14,8 +14,7 @@
     1.4  from sage.rings.integer cimport Integer
     1.5  from sage.rings.ring cimport Ring
     1.6  from sage.rings.polynomial.polynomial_ring import is_PolynomialRing
     1.7 -#from group_algebra import GroupAlgebra
     1.8 -import group_algebra
     1.9 +from sage.algebras.group_algebra import GroupAlgebra
    1.10  from siegel_modular_form_prec import SiegelModularFormPrecision
    1.11  
    1.12  #def get_annotated_file():
    1.13 @@ -302,7 +301,7 @@
    1.14      except KeyError:
    1.15          return None
    1.16  
    1.17 -    if isinstance( R, group_algebra.GroupAlgebra):
    1.18 +    if isinstance( R, GroupAlgebra):
    1.19          B = R.base_ring()
    1.20      else:
    1.21          B = R
     2.1 --- a/nils/siegelmodforms/group_algebra.py	Thu Mar 25 15:46:49 2010 +1100
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,393 +0,0 @@
     2.4 -r"""
     2.5 -Class for group algebras of arbitrary groups (over a general commutative base
     2.6 -ring).
     2.7 -
     2.8 -NOTE:
     2.9 -    -- It seems to be impossible to make this fit nicely with Sage's coercion
    2.10 -    model. The problem is that (for example) if G is the additive group (ZZ,+),
    2.11 -    and R = ZZ[G] is its group ring, then the integer 2 can be coerced into R
    2.12 -    in two ways -- via G, or via the base ring -- and *the answers are
    2.13 -    different*. In practice we get around this by preventing elements of G
    2.14 -    coercing automatically into ZZ[G], which is a shame, but makes more sense
    2.15 -    than preventing elements of the base ring doing so.
    2.16 -
    2.17 -AUTHOR:
    2.18 -    -- David Loeffler (2008-08-24): initial version
    2.19 -"""
    2.20 -
    2.21 -#*****************************************************************************
    2.22 -#       Copyright (C) 2008 William Stein <wstein@gmail.com>
    2.23 -#                     2008 David Loeffler <d.loeffler.01@cantab.net>
    2.24 -#
    2.25 -#  Distributed under the terms of the GNU General Public License (GPL)
    2.26 -#                  http://www.gnu.org/licenses/
    2.27 -#*****************************************************************************
    2.28 -
    2.29 -from sage.algebras.algebra import Algebra
    2.30 -from sage.algebras.algebra_element import AlgebraElement
    2.31 -from sage.rings.all import IntegerRing
    2.32 -from sage.groups.group import Group
    2.33 -from sage.structure.formal_sum import FormalSums_generic, FormalSums, FormalSum
    2.34 -from sage.sets.set import Set
    2.35 -from copy import copy
    2.36 -from operator import xor
    2.37 -
    2.38 -class GroupAlgebra(Algebra):
    2.39 -
    2.40 -    def __init__(self, group, base_ring = IntegerRing()):
    2.41 -        r""" Create the given group algebra.
    2.42 -        INPUT:
    2.43 -            -- (Group) group: a generic group.
    2.44 -            -- (Ring) base_ring: a commutative ring.
    2.45 -        OUTPUT:
    2.46 -            -- a GroupAlgebra instance.
    2.47 -
    2.48 -        EXAMPLES:
    2.49 -            sage: GroupAlgebra(GL(3, GF(7)))
    2.50 -            Group algebra of group "General Linear Group of degree 3 over Finite
    2.51 -            Field of size 7" over base ring Integer Ring
    2.52 -            sage: GroupAlgebra(1)
    2.53 -            Traceback (most recent call last):
    2.54 -            ...
    2.55 -            TypeError: "1" is not a group
    2.56 -        """
    2.57 -        if not base_ring.is_commutative():
    2.58 -            raise NotImplementedError, "Base ring must be commutative"
    2.59 -        
    2.60 -        if not isinstance(group, Group):
    2.61 -            raise TypeError, '"%s" is not a group' % group
    2.62 -
    2.63 -        Algebra.__init__(self, base_ring)
    2.64 -        self._formal_sum_module = FormalSums(base_ring)
    2.65 -        self._group = group
    2.66 -
    2.67 -    def group(self):
    2.68 -        r""" Return the group of this group algebra.
    2.69 -        EXAMPLES:
    2.70 -            sage: GroupAlgebra(GL(3, GF(11))).group()
    2.71 -            General Linear Group of degree 3 over Finite Field of size 11
    2.72 -            sage: GroupAlgebra(SymmetricGroup(10)).group()
    2.73 -            Symmetric group of order 10! as a permutation group
    2.74 -        """
    2.75 -        return self._group
    2.76 -
    2.77 -    def is_commutative(self):
    2.78 -        r""" Return True if self is a commutative ring. True if and only if
    2.79 -        self.group() is abelian.
    2.80 -
    2.81 -        EXAMPLES:
    2.82 -            sage: GroupAlgebra(SymmetricGroup(2)).is_commutative()
    2.83 -            True
    2.84 -            sage: GroupAlgebra(SymmetricGroup(3)).is_commutative()
    2.85 -            False
    2.86 -        """
    2.87 -        return self.group().is_abelian()
    2.88 -
    2.89 -    def is_field(self):
    2.90 -        r""" Return True if self is a field. This is always false unless
    2.91 -        self.group() is trivial and self.base_ring() is a field.
    2.92 -        EXAMPLES:
    2.93 -            sage: GroupAlgebra(SymmetricGroup(2)).is_field()
    2.94 -            False
    2.95 -            sage: GroupAlgebra(SymmetricGroup(1)).is_field()
    2.96 -            False
    2.97 -            sage: GroupAlgebra(SymmetricGroup(1), QQ).is_field()
    2.98 -            True
    2.99 -        """
   2.100 -        if not self.base_ring().is_field():
   2.101 -            return False
   2.102 -        return (self.group().order() == 1)
   2.103 -
   2.104 -    def is_finite(self):
   2.105 -        r""" Return True if self is finite, which is true if and only if
   2.106 -        self.group() and self.base_ring() are both finite.
   2.107 -        
   2.108 -        EXAMPLES:
   2.109 -            sage: GroupAlgebra(SymmetricGroup(2), IntegerModRing(10)).is_finite()
   2.110 -            True
   2.111 -            sage: GroupAlgebra(SymmetricGroup(2)).is_finite()
   2.112 -            False
   2.113 -            sage: GroupAlgebra(AbelianGroup(1), IntegerModRing(10)).is_finite()
   2.114 -            False
   2.115 -        """
   2.116 -        return (self.base_ring().is_finite() and self.group().is_finite())
   2.117 -
   2.118 -    def is_exact(self):
   2.119 -        r""" Return True if elements of self have exact representations,
   2.120 -        which is true of self if and only if it is true of self.group()
   2.121 -        and self.base_ring().
   2.122 -
   2.123 -        EXAMPLES:
   2.124 -            sage: GroupAlgebra(GL(3, GF(7))).is_exact()
   2.125 -            True
   2.126 -            sage: GroupAlgebra(GL(3, GF(7)), RR).is_exact()
   2.127 -            False
   2.128 -            sage: GroupAlgebra(GL(3, pAdicRing(7))).is_exact() # not implemented correctly (not my fault)!
   2.129 -            False
   2.130 -        """
   2.131 -        return self.group().is_exact() and self.base_ring().is_exact()
   2.132 -
   2.133 -    def is_integral_domain(self):
   2.134 -        r""" Return True if self is an integral domain. 
   2.135 -        
   2.136 -        This is false unless
   2.137 -        self.base_ring() is an integral domain, and even then it is false unless
   2.138 -        self.group() has no nontrivial elements of finite order. I don't know if 
   2.139 -        this condition suffices, but it obviously does if the group is abelian and
   2.140 -        finitely generated.
   2.141 -
   2.142 -        EXAMPLES:
   2.143 -            sage: GroupAlgebra(SymmetricGroup(2)).is_integral_domain()
   2.144 -            False
   2.145 -            sage: GroupAlgebra(SymmetricGroup(1)).is_integral_domain()
   2.146 -            True
   2.147 -            sage: GroupAlgebra(SymmetricGroup(1), IntegerModRing(4)).is_integral_domain()
   2.148 -            False
   2.149 -            sage: GroupAlgebra(AbelianGroup(1)).is_integral_domain()
   2.150 -            True
   2.151 -            sage: GroupAlgebra(AbelianGroup(2, [0,2])).is_integral_domain()
   2.152 -            False
   2.153 -            sage: GroupAlgebra(GL(2, ZZ)).is_integral_domain() # not implemented
   2.154 -            False
   2.155 -        """
   2.156 -        if not self.base_ring().is_integral_domain():
   2.157 -            return False
   2.158 -        if self.group().is_finite():
   2.159 -            if self.group().order() > 1:
   2.160 -                return False
   2.161 -            else:
   2.162 -                return True
   2.163 -        if self.group().is_abelian():
   2.164 -            invs = self.group().invariants()
   2.165 -            if Set(invs) != Set([0]):
   2.166 -                return False
   2.167 -            else:
   2.168 -                return True
   2.169 -        if not self.group().is_abelian():
   2.170 -            raise NotImplementedError
   2.171 -
   2.172 -    # I haven't written is_noetherian(), because I don't know when group
   2.173 -    # algebras are noetherian, and I haven't written is_prime_field(), because
   2.174 -    # I don't know if that means "is canonically isomorphic to a prime field"
   2.175 -    # or "is identical to a prime field".
   2.176 -
   2.177 -    def _coerce_impl(self, x):
   2.178 -        return self(self.base_ring().coerce(x))
   2.179 -
   2.180 -    def _an_element_impl(self):
   2.181 -        """
   2.182 -        Return an element of self. 
   2.183 -        
   2.184 -        EXAMPLE:
   2.185 -            sage: GroupAlgebra(SU(2, 13), QQ).an_element() # random; hideous formatting!
   2.186 -            -1/95*[       9 2*a + 12]
   2.187 -            [       0        3] - 4*[      9 9*a + 2]
   2.188 -            [3*a + 5       1]
   2.189 -        """
   2.190 -        try:
   2.191 -            return self(self._formal_sum_module([
   2.192 -                (self.base_ring().random_element(), self.group().random_element()),
   2.193 -                (self.base_ring().random_element(), self.group().random_element()),
   2.194 -                ]))
   2.195 -        except: # base ring or group might not implement .random_element()
   2.196 -            return self(self._formal_sum_module([ (self.base_ring().an_element(), self.group().an_element()) ]))
   2.197 -
   2.198 -    def __call__(self, x, check=True):
   2.199 -        r"""
   2.200 -        Create an element of this group algebra.
   2.201 -        
   2.202 -        INPUT:
   2.203 -            -- x: either a FormalSum element consisting of elements of
   2.204 -            self.group(), an element of self.base_ring(), or an element 
   2.205 -            of self.group().
   2.206 -            -- check (boolean): whether or not to check that the given elements
   2.207 -            really do lie in self.group(). Chiefly provided to speed up
   2.208 -            arithmetic operations with elements that have already been checked
   2.209 -            to lie in the group.
   2.210 -
   2.211 -        OUTPUT:
   2.212 -            -- a GroupAlgebraElement instance whose parent is self.
   2.213 -
   2.214 -        EXAMPLES:
   2.215 -            sage: G = AbelianGroup(1)
   2.216 -            sage: f = G.gen()
   2.217 -            sage: ZG = GroupAlgebra(G)
   2.218 -            sage: ZG(f)
   2.219 -            f
   2.220 -            sage: ZG(1) == ZG(G(1))
   2.221 -            True
   2.222 -            sage: ZG(FormalSum([(1,f), (2, f**2)]))
   2.223 -            2*f^2 + f
   2.224 -            sage: G = GL(2,7)
   2.225 -            sage: OG = GroupAlgebra(G, ZZ[sqrt(5)])
   2.226 -            sage: OG(2)
   2.227 -            2*[1 0]
   2.228 -            [0 1]
   2.229 -            sage: OG(G(2)) # conversion is not the obvious one
   2.230 -            [2 0]
   2.231 -            [0 2]
   2.232 -            sage: OG(FormalSum([ (1, G(2)), (2, RR(0.77)) ]) )
   2.233 -            Traceback (most recent call last):
   2.234 -            ...
   2.235 -            TypeError: 0.770000000000000 is not an element of group General Linear Group of degree 2 over Finite Field of size 7
   2.236 -
   2.237 -        Ordering of elements in output unpredictable as sort order of such wildly 
   2.238 -        dissimilar elements is subject to change between platforms and versions 
   2.239 -        (see trac ticket \#4373).
   2.240 -            sage: OG(FormalSum([ (1, G(2)), (2, RR(0.77)) ]), check=False) # random 
   2.241 -            [2 0]
   2.242 -            [0 2] + 2*0.770000000000000
   2.243 -            sage: OG(OG.base_ring().gens()[1])
   2.244 -            sqrt5*[1 0]
   2.245 -            [0 1]
   2.246 -            """
   2.247 -        return GroupAlgebraElement(self, x, check)
   2.248 -
   2.249 -    def __eq__(self, other):
   2.250 -        r""" Test for equality. 
   2.251 -        EXAMPLES:
   2.252 -            sage: GroupAlgebra(AbelianGroup(1)) == GroupAlgebra(AbelianGroup(1))
   2.253 -            True
   2.254 -            sage: GroupAlgebra(AbelianGroup(1), QQ) == GroupAlgebra(AbelianGroup(1), ZZ)
   2.255 -            False
   2.256 -            sage: GroupAlgebra(AbelianGroup(2)) == GroupAlgebra(AbelianGroup(1))
   2.257 -            False
   2.258 -            """
   2.259 -        if not isinstance(other, GroupAlgebra):
   2.260 -            return False
   2.261 -        else:
   2.262 -            return self.base_ring() == other.base_ring() and self.group() == other.group()
   2.263 -
   2.264 -    def __hash__(self) :
   2.265 -        return xor(hash(self.base_ring()), hash(self.group()))
   2.266 -
   2.267 -    def _repr_(self):
   2.268 -        r""" String representation of self. See GroupAlgebra.__init__ for a
   2.269 -        doctest."""
   2.270 -        return "Group algebra of group \"%s\" over base ring %s" % (self.group(), self.base_ring())
   2.271 -
   2.272 -    def element_class(self):
   2.273 -        r"""
   2.274 -        The class of elements of self, which is GroupAlgebraElement.
   2.275 -
   2.276 -        EXAMPLES:
   2.277 -            sage: GroupAlgebra(SU(2, GF(4,'a'))).element_class()
   2.278 -            <class 'sage.algebras.group_algebra.GroupAlgebraElement'>
   2.279 -        """
   2.280 -        return GroupAlgebraElement
   2.281 -
   2.282 -
   2.283 -    def category(self):
   2.284 -        r"""
   2.285 -        The category to which self belongs, which is the category of group algebras over self.base_ring().
   2.286 -
   2.287 -        EXAMPLES:
   2.288 -            sage: GroupAlgebra(SU(2, GF(4, 'a')), IntegerModRing(12)).category()
   2.289 -            Category of group algebras over Ring of integers modulo 12
   2.290 -        """
   2.291 -        from sage.categories.category_types import GroupAlgebras
   2.292 -        return GroupAlgebras(self.base_ring())
   2.293 -
   2.294 -
   2.295 -
   2.296 -class GroupAlgebraElement(AlgebraElement):
   2.297 -    
   2.298 -    def __init__(self, parent, x, check):
   2.299 -        r""" Create an element of the parent group algebra. Not intended to be
   2.300 -        called by the user; see GroupAlgebra.__call__ for examples and
   2.301 -        doctests."""
   2.302 -        AlgebraElement.__init__(self, parent)
   2.303 -        
   2.304 -        if not hasattr(x, 'parent'):
   2.305 -            x = IntegerRing()(x) # occasionally coercion framework tries to pass a Python int
   2.306 -
   2.307 -        if isinstance(x, FormalSum):
   2.308 -            if check:
   2.309 -                for c,d in x._data:
   2.310 -                    if d.parent() != self.parent().group():
   2.311 -                        raise TypeError, "%s is not an element of group %s" % (d, self.parent().group())
   2.312 -                self._fs = x
   2.313 -            else:
   2.314 -                self._fs = x
   2.315 -
   2.316 -        elif self.base_ring().has_coerce_map_from(x.parent()):
   2.317 -            self._fs = self.parent()._formal_sum_module([ (x, self.parent().group()(1)) ])
   2.318 -        elif self.parent() is x.parent():
   2.319 -            self._fs = copy(x._fs)
   2.320 -        elif self.parent().group().has_coerce_map_from(x.parent()):
   2.321 -            self._fs = self.parent()._formal_sum_module([ (1, self.parent().group()(x)) ])
   2.322 -        elif isinstance(x.parent(), GroupAlgebra) and self.parent().group().has_coerce_map_from(x.parent().group()) \
   2.323 -             and self.parent().base_ring().has_coerce_map_from(x.parent().base_ring()) :
   2.324 -            self._fs = self.parent()._formal_sum_module([ (self.parent().base_ring()(f[0]), self.parent().group()(f[1]))
   2.325 -                                                          for f in x._fs ])
   2.326 -        else:
   2.327 -            raise TypeError, "Don't know how to create an element of %s from %s" % (self.parent(), x)
   2.328 -
   2.329 -    def _repr_(self):
   2.330 -        return self._fs._repr_()
   2.331 -
   2.332 -    def _add_(self, other):
   2.333 -        r"""
   2.334 -        Add self to other.
   2.335 -        
   2.336 -        EXAMPLE:
   2.337 -            sage: G = GL(3, GF(7))
   2.338 -            sage: ZG = GroupAlgebra(G)
   2.339 -            sage: g1 = G([0,0,2,2,5,0,6,6,2])
   2.340 -            sage: s = ZG(g1)
   2.341 -            sage: s + s
   2.342 -            2*[0  0  2]
   2.343 -            [2  5  0]
   2.344 -            [6  6  2]
   2.345 -"""
   2.346 -        fs_sum = self._fs + other._fs
   2.347 -        return self.parent()(fs_sum, check=False)
   2.348 -
   2.349 -    def _mul_(self, right):
   2.350 -        r""" Calculate self*right, where both self and right are GroupAlgebraElements.
   2.351 -        
   2.352 -        EXAMPLE:
   2.353 -            sage: G = GL(3, GF(7))
   2.354 -            sage: ZG = GroupAlgebra(G)
   2.355 -            sage: a, b = G.random_element(), G.random_element()
   2.356 -            sage: za, zb = ZG(a), ZG(b)
   2.357 -            sage: za*ZG(2) # random
   2.358 -            2*[4,5,0]
   2.359 -            [0,5,1]
   2.360 -            [2,5,1]
   2.361 -            sage: za*2 == za*ZG(2)
   2.362 -            True
   2.363 -            sage: (ZG(1) + za)*(ZG(2) + zb) == ZG(FormalSum([ (2,G(1)), (2,a), (1, b), (1, a*b)]))
   2.364 -            True
   2.365 -            sage: za*za == za^2
   2.366 -            True
   2.367 -        """
   2.368 -        d1 = self._fs._data
   2.369 -        d2 = right._fs._data
   2.370 -        new = []
   2.371 -        for (a1, g1) in d1:
   2.372 -            for a2,g2 in d2:
   2.373 -                if self.parent().group().is_multiplicative():
   2.374 -                    new.append( (a1*a2, g1*g2) )
   2.375 -                else:
   2.376 -                    new.append( (a1*a2, g1 + g2) )
   2.377 -        return self.parent()( self.parent()._formal_sum_module(new), check=False)
   2.378 -
   2.379 -    def __eq__(self, other):
   2.380 -        r""" Test if self is equal to other.
   2.381 -
   2.382 -        EXAMPLES:
   2.383 -            sage: G = AbelianGroup(1,[4])
   2.384 -            sage: a = GroupAlgebra(G)(1)
   2.385 -            sage: b = GroupAlgebra(G)(2)
   2.386 -            sage: a + a == b
   2.387 -            True
   2.388 -            sage: a == b
   2.389 -            False
   2.390 -            sage: a == GroupAlgebra(AbelianGroup(1, [5]))(1)
   2.391 -            False
   2.392 -        """
   2.393 -        if isinstance(other, GroupAlgebraElement) and self.parent() == other.parent():
   2.394 -            return self._fs == other._fs
   2.395 -        else:
   2.396 -            return False
     3.1 --- a/nils/siegelmodforms/siegel_modular_form.py	Thu Mar 25 15:46:49 2010 +1100
     3.2 +++ b/nils/siegelmodforms/siegel_modular_form.py	Thu Mar 25 15:49:50 2010 +1100
     3.3 @@ -48,15 +48,15 @@
     3.4  from siegel_modular_form_prec import SiegelModularFormPrecision
     3.5  from sage.categories.pushout import ConstructionFunctor
     3.6  from sage.categories.functor import Functor
     3.7 -#from group_algebra import (GroupAlgebra, GroupAlgebraElement)
     3.8  from sage.rings.morphism import RingHomomorphism_im_gens
     3.9 +from sage.algebras.algebra import Algebra
    3.10 +from sage.algebras.algebra_element import AlgebraElement
    3.11 +from sage.algebras.group_algebra import GroupAlgebra, GroupAlgebraElement
    3.12 +from sage.structure.sage_object import SageObject
    3.13 +from sage.misc.all import xsrange
    3.14 +from sage.rings.all import infinity, ZZ
    3.15 +from fastmult import mult_coeff_int, mult_coeff_generic, mult_coeff_generic_with_action
    3.16  
    3.17 -#load theta_constant.sage
    3.18 -
    3.19 -if __name__ != '__main__':
    3.20 -    from fastmult import (reduce_GL, sreduce_GL, xreduce_GL, mult_coeff_generic, mult_coeff_int, mult_coeff_generic_with_action, chi35, get_coeff_with_action)
    3.21 -    
    3.22 -load 'fastmult.spyx'
    3.23  
    3.24  _cache = dict()
    3.25  
    3.26 @@ -140,7 +140,15 @@
    3.27          return False
    3.28  
    3.29      def _element_constructor_( self, x):
    3.30 -        if self.base_ring().has_coerce_map_from( parent(x)):
    3.31 +        if isinstance(x, (int, long)):
    3.32 +            x = ZZ(x)
    3.33 +        if isinstance(x, float):
    3.34 +            from sage.rings.all import RR
    3.35 +            x = RR(x)
    3.36 +        if isinstance(x, complex):
    3.37 +            from sage.rings.all import CC
    3.38 +            x = CC(x)
    3.39 +        if self.base_ring().has_coerce_map_from(x.parent()):
    3.40              return self( SiegelModularForm( self.base_ring()( x)))
    3.41          if isinstance( x.parent(), SiegelModularFormsAlgebra_class):
    3.42              d = dict( (f,self.coeff_ring()(x[f])) for f in x.coeffs())
    3.43 @@ -171,6 +179,7 @@
    3.44      rank = 9
    3.45  
    3.46      def __init__( self):
    3.47 +        from sage.categories.all import Rings
    3.48          Functor.__init__( self, Rings(), Rings())
    3.49  
    3.50      def __call__( self, R):
    3.51 @@ -370,6 +379,7 @@
    3.52          r"""
    3.53          Dump to a file in a portable format.
    3.54          """
    3.55 +        from sage.rings.all import QQ
    3.56          if QQ == self.base_ring().fraction_field():
    3.57              pol = [0,1]
    3.58              coeffs = self.coeffs()
    3.59 @@ -508,15 +518,16 @@
    3.60          4
    3.61      """
    3.62      arg0 = _pysa(arg0)
    3.63 -
    3.64 -    if isinstance( arg0, sage.modular.modform.element.ModularFormElement)\
    3.65 -           and isinstance( arg1, sage.modular.modform.element.ModularFormElement):
    3.66 +    from sage.modular.modform.element import ModularFormElement
    3.67 +    from sage.rings.all import RingElement
    3.68 +    if isinstance( arg0, ModularFormElement)\
    3.69 +           and isinstance( arg1, ModularFormElement):
    3.70          return _SiegelModularForm_as_Maass_spezial_form( arg0, arg1, prec, name)
    3.71 -    if isinstance( arg0, sage.modular.modform.element.ModularFormElement) \
    3.72 +    if isinstance( arg0, ModularFormElement) \
    3.73             and ( 0 == arg1 or None == arg1 ):
    3.74          M = ModularForms(1, arg0.weight() + 2)
    3.75          return _SiegelModularForm_as_Maass_spezial_form( arg0, M(0), prec, name)
    3.76 -    if 0 == arg0 and isinstance( arg1, sage.modular.modform.element.ModularFormElement):
    3.77 +    if 0 == arg0 and isinstance( arg1, ModularFormElement):
    3.78          M = ModularForms(1, arg1.weight() - 2)
    3.79          return _SiegelModularForm_as_Maass_spezial_form( M(0), arg1, prec, name)
    3.80      if isinstance( arg0, RingElement) and None == arg1:
    3.81 @@ -584,10 +595,13 @@
    3.82      """
    3.83      ## print 'Creating I(f,g)'
    3.84  
    3.85 +    from sage.rings.all import PowerSeriesRing, QQ
    3.86      PS.<q> = PowerSeriesRing(QQ)
    3.87  
    3.88      ## Create the quasi Dedekind eta^-6 power series:
    3.89      pari_prec = max( 1, precision - 1) # next line yields error if 0 == pari_prec
    3.90 +    from sage.libs.pari.gen import pari
    3.91 +    from sage.rings.all import O
    3.92      pari.set_series_precision( pari_prec)
    3.93      eta_quasi = PS(pari('Vec(eta(q))')) + O(q^precision)
    3.94      etapow = eta_quasi^-6
    3.95 @@ -655,6 +669,8 @@
    3.96      ## in a dictionary (hash table) maassc.
    3.97      maassc = dict();
    3.98      ## First calculate maass coefficients corresponding to strictly positive definite matrices:
    3.99 +    from sage.rings.all import is_fundamental_discriminant
   3.100 +    from sage.misc.all import isqrt
   3.101      for disc in [ d for d in range(maxD,0) if is_fundamental_discriminant(d)]:
   3.102          for s in range(1,(maxD//disc).isqrt()+1):
   3.103              ## add (disc*s^2,t) as a hash key, for each t that divides s
   3.104 @@ -665,6 +681,7 @@
   3.105      siegelq = dict();                
   3.106      if isinstance( prec, tuple):
   3.107          ## Note: m>=n>=r, n>=1 implies m>=n>r^2/4n
   3.108 +        from sage.rings.all import gcd
   3.109          for r in range(0,bmax):
   3.110              for n in range(max( r, 1),amax):
   3.111                  for m in range(n,cmax):
   3.112 @@ -685,6 +702,7 @@
   3.113      ## Secondly, deal with the singular part.
   3.114      ## Include the coeff corresponding to (0,0,0):
   3.115      ## maassc = {(0,0): -bernoulli(k)/(2*k)*Cphi[0]}
   3.116 +    from sare.rings.all import bernoulli, sigma
   3.117      siegelq[(0,0,0)] = -bernoulli(k)/(2*k)*Cphi[0]
   3.118      
   3.119      ## Calculate the other discriminant-zero maass coefficients:
   3.120 @@ -733,6 +751,7 @@
   3.121      """
   3.122      coeffs = dict()
   3.123      smf_prec = SiegelModularFormPrecision( prec)
   3.124 +    from theta_constant import _compute_theta_char_poly
   3.125      for f in smf_prec:
   3.126          if 'cusp_form' == hint:
   3.127              a,b,c = f
   3.128 @@ -790,6 +809,7 @@
   3.129      Create an instance of SiegelModularForm_class(), where the parent
   3.130      is computed from the coeffs.
   3.131      """
   3.132 +    from sage.structure.all import Sequence
   3.133      s = Sequence( coeffs.values())
   3.134      A = SiegelModularFormsAlgebra( s.universe())
   3.135      return SiegelModularForm_class( A, group, wt, coeffs, prec, name)
   3.136 @@ -798,6 +818,7 @@
   3.137  
   3.138  def siegel_modular_forms_generators( group = 'Sp(2,Z)', weights = 'even', degree = 0, prec = 101):
   3.139      if 'Sp(2,Z)' == group and 0 == degree:
   3.140 +        from sage.modular.all import ModularForms
   3.141          E4 = ModularForms(1,4).gen(0)
   3.142          M6 = ModularForms(1,6)
   3.143          E6 = ModularForms(1,6).gen(0)
   3.144 @@ -853,6 +874,7 @@
   3.145          respectively $4ac-b^2 < floor(prec)$.
   3.146      """
   3.147      if prec is infinity: return prec
   3.148 +    from sage.functions.all import floor
   3.149      if isinstance( prec, tuple):
   3.150          a,b,c = prec
   3.151          a = min( floor(a), floor(c))
   3.152 @@ -869,7 +891,8 @@
   3.153  
   3.154  def _pysa(x):
   3.155      try:
   3.156 -        x = sage.structure.element.py_scalar_to_element( x)
   3.157 +        from sage.structure.element import py_scalar_to_element
   3.158 +        x = py_scalar_to_element( x)
   3.159      except TypeError:
   3.160          pass
   3.161      return x
   3.162 @@ -1115,10 +1138,13 @@
   3.163          try:
   3.164              return self.__rep_lists[t]
   3.165          except KeyError:
   3.166 +            from sage.matrix.all import MatrixSpace
   3.167              M = MatrixSpace(ZZ, 2,2)
   3.168          if t == 1:
   3.169              return [M([1,0,0,1])]
   3.170 +        from sage.modular.all import P1List
   3.171          P = list(P1List(t))
   3.172 +        from sage.rings.all import IntegerModRing, xgcd
   3.173          ZZt = IntegerModRing(t)
   3.174          rep_list = []
   3.175          for x,y in P1List(t):
   3.176 @@ -1135,6 +1161,7 @@
   3.177          quadratic form [nprime,rprime,mprime] given by $Q((x,y) V)$
   3.178          where $Q=[n,r,m]$ and $V$ is a 2 by 2 matrix
   3.179          """
   3.180 +        from sage.rings.all import PolynomialRing
   3.181          R.<x,y> = PolynomialRing(ZZ,2)
   3.182          g = R(n*x^2+r*x*y+m*y^2)
   3.183          a = V[0][0]
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/nils/siegelmodforms/theta_constant.py	Thu Mar 25 15:49:50 2010 +1100
     4.3 @@ -0,0 +1,51 @@
     4.4 +def _compute_theta_char_poly( char_dict, f):
     4.5 +    r"""
     4.6 +    Return the coefficient at $f$ of the Siegel modular form
     4.7 +    $\sum_{l \in char_dict} \alpha[l] * \prod_i \theta_l[i](8Z)$.   
     4.8 +
     4.9 +    INPUT
    4.10 +        char_dict - a dictionary whose keys are *tuples* of theta characteristics
    4.11 +                    and whose values ar in some ring.
    4.12 +        f         - a triple (a,b,c) of rational numbers such that
    4.13 +                    [a,b,c] is semi positive definite
    4.14 +                    ( i.e. a,c >= 0 and b^2-4ac <=0)
    4.15 +    """
    4.16 +    return sum(_multiply_theta_char( list(l), f)*char_dict[l] for l in char_dict )
    4.17 +
    4.18 +
    4.19 +
    4.20 +def _multiply_theta_char( l, f):
    4.21 +    r"""
    4.22 +    Return the coefficient at f of the theta series
    4.23 +    $\prod _c \theta_c$ where $c$ runs through the list l of
    4.24 +    theta characteristics.
    4.25 +
    4.26 +    INPUT
    4.27 +        l - a list of quadruples c in {0,1}^4
    4.28 +        f - a triple (a,b,c) of rational numbers such that
    4.29 +            [a,b,c] is semi positive definite
    4.30 +            ( i.e. a,c >= 0 and b^2-4ac <=0)
    4.31 +    """
    4.32 +    if 0 == len(l):
    4.33 +        return (1 if (0,0,0) == f else 0)
    4.34 +    a,b,c = f
    4.35 +    m1,m2,m3,m4 = l[0]
    4.36 +    # if the characteristic is not even:
    4.37 +    if 1 == (m1*m3+m2*m4)%2: return 0
    4.38 +    coeff = 0
    4.39 +    from sage.misc.all import isqrt, xsrange
    4.40 +    for u in xsrange(m1,isqrt(a)+1,2):
    4.41 +        for v in xsrange(m2,isqrt(c)+1,2):
    4.42 +            if 0 == u and 0 == v:
    4.43 +                coeff += _multiply_theta_char( l[1:], (a,b,c))
    4.44 +                continue
    4.45 +            ap,bp,cp = (a-u*u,b-2*u*v,c-v*v)
    4.46 +            if bp*bp-4*ap*cp <= 0:
    4.47 +                val = (2 if  0 == (u*m3 + v*m4)%4 else -2)
    4.48 +                coeff += val * _multiply_theta_char( l[1:], (ap,bp,cp))
    4.49 +            if u != 0 and v != 0:
    4.50 +                ap,bp,cp = (a-u*u,b+2*u*v,c-v*v)
    4.51 +                if bp*bp-4*ap*cp <= 0:
    4.52 +                    val = (2 if  0 == (u*m3 - v*m4)%4 else -2)
    4.53 +                    coeff += val * _multiply_theta_char( l[1:], (ap,bp,cp))
    4.54 +    return coeff