# HG changeset patch
# User Mike Hansen <mhansen@gmail.com>
# Date 1215636097 18000
# Node ID 5264d43d46adb88ec78de470a3a51a71c0162803
# Parent aadde55709efb9226c112b55edd79893b57bc4d5
imported patch tensor_product3601review.patch
diff r aadde55709ef r 5264d43d46ad sage/combinat/crystals/tensor_product.py
a

b


216  216  [[2, 1, 1], [1, 2, 1]] 
217  217  """ 
218  218  if options.has_key('generators'): 
219   if all(isinstance(crystal,ClassicalCrystal) for crystal in crystals): 
220   return TensorProductOfClassicalCrystalsWithGenerators(generators=options['generators'], *crystals) 
221   else: 
222   return TensorProductOfCrystalsWithGenerators(generators=options['generators'], *crystals) 
 219  if all(isinstance(crystal,ClassicalCrystal) for crystal in crystals): 
 220  return TensorProductOfClassicalCrystalsWithGenerators(generators=options['generators'], *crystals) 
 221  else: 
 222  return TensorProductOfCrystalsWithGenerators(generators=options['generators'], *crystals) 
223  223  else: 
224   if all(isinstance(crystal,ClassicalCrystal) for crystal in crystals): 
225   return FullTensorProductOfClassicalCrystals(*crystals) 
226   else: 
227   return FullTensorProductOfCrystals(*crystals) 
 224  if all(isinstance(crystal,ClassicalCrystal) for crystal in crystals): 
 225  return FullTensorProductOfClassicalCrystals(*crystals) 
 226  else: 
 227  return FullTensorProductOfCrystals(*crystals) 
228  228  
229  229  class TensorProductOfCrystalsWithGenerators(Crystal): 
230   
231  230  def __init__(self, *crystals, **options): 
232  231  """ 
233  232  EXAMPLES: 
… 
… 

247  246  else: 
248  247  self.cartan_type = crystals[0].cartan_type 
249  248  self.index_set = self.cartan_type.index_set() 
250   # if options.has_key('generators'): 
251   # if options['generators'] == "all": 
252   # self.module_generators = [] 
253   # for c in list(xmrange_iter([D.list() for D in crystals])): 
254   # candidate = self(*c) 
255   # if all(candidate.e(k) == None for k in self.index_set): 
256   # self.module_generators.append(candidate) 
257   # else: 
258   # self.module_generators = [ self(*x) for x in options['generators']] 
259   self.module_generators = [ self(*x) for x in options['generators']] 
 249  self.module_generators = [ self(*x) for x in options['generators']] 
260  250  
261  251  def __call__(self, *args): 
262  252  """ 
… 
… 

273  263  pass 
274  264  
275  265  class FullTensorProductOfCrystals(Crystal): 
276   
277  266  def __init__(self, *crystals, **options): 
278   crystals = [ crystal for crystal in crystals] 
 267  """ 
 268  TESTS: 
 269  sage: from sage.combinat.crystals.tensor_product import FullTensorProductOfCrystals 
 270  sage: C = CrystalOfLetters(['A',2]) 
 271  sage: T = TensorProductOfCrystals(C,C) 
 272  sage: isinstance(T, FullTensorProductOfCrystals) 
 273  True 
 274  sage: T == loads(dumps(T)) 
 275  True 
 276  """ 
 277  crystals = list(crystals) 
279  278  self._name = "Full tensor product of the crystals %s"%crystals 
280  279  self.crystals = crystals 
281  280  if options.has_key('cartan_type'): 
… 
… 

285  284  raise ValueError, "you need to specify the Cartan type if the tensor product list is empty" 
286  285  else: 
287  286  self.cartan_type = crystals[0].cartan_type 
288   self.index_set = self.cartan_type.index_set() 
289   self.cartesian_product = CartesianProduct(*self.crystals) 
290   self.module_generators = self 
 287  self.index_set = self.cartan_type.index_set() 
 288  self.cartesian_product = CartesianProduct(*self.crystals) 
 289  self.module_generators = self 
291  290  
292  291  def iterator(self): 
293   for x in self.cartesian_product: 
294   yield self(*x) 
 292  """ 
 293  EXAMPLES: 
 294  sage: C = CrystalOfLetters(['A',2]) 
 295  sage: T = TensorProductOfCrystals(C,C) 
 296  sage: list(T.iterator()) 
 297  [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]] 
 298  sage: _[0].parent() 
 299  Full tensor product of the crystals [The crystal of letters for type ['A', 2], The crystal of letters for type ['A', 2]] 
 300  """ 
 301  for x in self.cartesian_product: 
 302  yield self(*x) 
295  303  
296  304  __iter__ = iterator 
297  305  
298  306  list = CombinatorialClass._CombinatorialClass__list_from_iterator 
299  307  
300  308  def count(self): 
301   return self.cartesian_product.count() 
 309  """ 
 310  EXAMPLES: 
 311  sage: C = CrystalOfLetters(['A',2]) 
 312  sage: T = TensorProductOfCrystals(C,C) 
 313  sage: T.count() 
 314  9 
 315  """ 
 316  return self.cartesian_product.count() 
302  317  
303   def __call__(self, *args): 
304   return TensorProductOfCrystalsElement(self, 
305   [crystalElement for crystalElement in args]) 
 318  def __call__(self, *crystalElements): 
 319  """ 
 320  EXAMPLES: 
 321  sage: C = CrystalOfLetters(['A',2]) 
 322  sage: T = TensorProductOfCrystals(C,C) 
 323  sage: T(1,1) 
 324  [1, 1] 
 325  sage: _.parent() 
 326  Full tensor product of the crystals [The crystal of letters for type ['A', 2], The crystal of letters for type ['A', 2]] 
 327  """ 
 328  return TensorProductOfCrystalsElement(self, list(crystalElements)) 
 329  
306  330  
307  331  class FullTensorProductOfClassicalCrystals(FullTensorProductOfCrystals, ClassicalCrystal): 
308  332  pass 