code / alex / psage / psage / modform / fourier_expansion_framework / gradedexpansions / fourierexpansionwrapper.py
241849 viewsr"""1Interface for elements which provide a Fourier expansion.23AUTHOR :4-- Martin Raum (2009 - 08 - 03) Initial version5"""67#===============================================================================8#9# Copyright (C) 2009 Martin Raum10#11# This program is free software; you can redistribute it and/or12# modify it under the terms of the GNU General Public License13# as published by the Free Software Foundation; either version 314# of the License, or (at your option) any later version.15#16# This program is distributed in the hope that it will be useful,17# but WITHOUT ANY WARRANTY; without even the implied warranty of18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU19# General Public License for more details.20#21# You should have received a copy of the GNU General Public License22# along with this program; if not, see <http://www.gnu.org/licenses/>.23#24#===============================================================================2526class FourierExpansionWrapper :27r"""28Abstract class for elements, which do not represent Fourier29expansions on their own, but encapsulate one.3031SEE:32:class:~`fourier_expansion_framework.gradedexpansions.GradedExpansion_class`.33"""3435def fourier_expansion(self, cache = True) :36r"""37The Fourier expansion which is associated with ``self``.3839INPUT:40- ``cache`` -- A boolean (default: ``True``); If ``True`` the return value41will be cached.4243OUTPUT:44A (equivariant) monoid power series.4546NOTE:47The parent has to implement the function ``_fourier_expansion_of_element``.4849TESTS::50sage: from psage.modform.fourier_expansion_framework.gradedexpansions import *51sage: from psage.modform.fourier_expansion_framework.monoidpowerseries import *52sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *53sage: emps = EquivariantMonoidPowerSeriesRing(NNMonoid(True), TrivialCharacterMonoid("1", ZZ), TrivialRepresentation("1", ZZ))54sage: em = ExpansionModule(Sequence([emps.one_element().truncate(3), emps.one_element(), emps.one_element()]))55sage: h = em([1,2,-3])56sage: fe = h.fourier_expansion()57"""58try :59return self.__fourier_expansion60except AttributeError :61if cache :62self.__fourier_expansion = \63self.parent()._fourier_expansion_of_element(self)64return self.__fourier_expansion65else :66return self.parent()._fourier_expansion_of_element(self)6768def _set_fourier_expansion(self, expansion ) :69r"""70Set the cache for the Fourier expansion to an given monoid power series.7172INPUT:73- ``expansion`` -- A (equivariant) monoid power series.7475OUTPUT:76``None``7778TESTS::79sage: from psage.modform.fourier_expansion_framework.gradedexpansions import *80sage: from psage.modform.fourier_expansion_framework.monoidpowerseries import *81sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *82sage: emps = EquivariantMonoidPowerSeriesRing(NNMonoid(True), TrivialCharacterMonoid("1", ZZ), TrivialRepresentation("1", ZZ))83sage: em = ExpansionModule(Sequence([emps.one_element().truncate(3), emps.one_element(), emps.one_element()]))84sage: h = em([1,2,5])85sage: fe = h.fourier_expansion()86sage: h = em([1,2,0])87sage: h._set_fourier_expansion(fe)88sage: h.fourier_expansion() == fe89True90"""91self.__fourier_expansion = expansion929394