# HG changeset patch
# User Michael Orlitzky <michael@orlitzky.com>
# Date 1354383176 18000
# Node ID 7290151c5a697e69c72b9dbe184e9a3328e53321
# Parent ddfab2ba7a2ee5b3d270487189c91fc6bd6e5649
Use underscores to separate indices
diff git a/sage/symbolic/ring.pyx b/sage/symbolic/ring.pyx
a

b


526  526  INPUT: 
527  527  
528  528   ``name``  The sequence name. For example, if you name the 
529   sequence `x`, the variables will be called `x0`, `x1`,... 
 529  sequence `x`, the variables will be called `x_0`, `x_1`,... 
530  530  
531  531   ``latex_name``  An optional latex expression (string) to 
532  532  use instead of `name` when converting the symbols to latex. 
… 
… 

544  544  
545  545  sage: a = SR.symbols('a') 
546  546  sage: a[0] 
547   a0 
 547  a_0 
548  548  sage: a[1] 
549   a1 
 549  a_1 
550  550  
551  551  Create polynomials with symbolic coefficients of arbitrary 
552  552  degree:: 
… 
… 

554  554  sage: a = SR.symbols('a') 
555  555  sage: p = sum([ a[i]*x^i for i in range(0,5)]) 
556  556  sage: p 
557   a4*x^4 + a3*x^3 + a2*x^2 + a1*x + a0 
 557  a_4*x^4 + a_3*x^3 + a_2*x^2 + a_1*x + a_0 
558  558  
559  559  Using a different latex name since 'lambda' is reserved:: 
560  560  
561  561  sage: l = SR.symbols('l', '\lambda') 
562  562  sage: l[0] 
563   l0 
 563  l_0 
564  564  sage: latex(l[0]) 
565  565  \lambda_{0} 
566  566  
… 
… 

568  568  
569  569  sage: a = SR.symbols('a') 
570  570  sage: a[0,1,2] 
571   a012 
 571  a_0_1_2 
572  572  sage: latex(a[0,1,2]) 
573  573  a_{0}_{1}_{2} 
574  574  sage: [ a[i,j] for i in range(0,2) for j in range(0,2) ] 
575   [a00, a01, a10, a11] 
 575  [a_0_0, a_0_1, a_1_0, a_1_1] 
576  576  
577  577  You can pass slices instead of integers to obtain a list of 
578  578  symbols:: 
579  579  
580  580  sage: a = SR.symbols('a') 
581  581  sage: a[5:7] 
582   [a5, a6] 
 582  [a_5, a_6] 
583  583  
584  584  This even works for the second, third, etc. indices:: 
585  585  
586  586  sage: a = SR.symbols('a') 
587  587  sage: a[0:2, 0:2] 
588   [a00, a01, a10, a11] 
 588  [a_0_0, a_0_1, a_1_0, a_1_1] 
589  589  
590  590  TESTS: 
591  591  
592  592  We shouldn't overwrite variables in the global namespace:: 
593  593  
594  594  sage: a = SR.symbols('a') 
595   sage: a0 = 4 
 595  sage: a_0 = 4 
596  596  sage: a[0] 
597   a0 
598   sage: a0 
 597  a_0 
 598  sage: a_0 
599  599  4 
600  600  
601  601  The symbol at a given index should always be the same, even 
… 
… 

611  611  
612  612  sage: a = SR.symbols('a') 
613  613  sage: a[3, 0:2] 
614   [a30, a31] 
 614  [a_3_0, a_3_1] 
615  615  sage: a[0:2, 3] 
616   [a03, a13] 
 616  [a_0_3, a_1_3] 
 617  
 618  Multiple indices shouldn't overlap with single indices:: 
 619  
 620  sage: a = SR.symbols('a') 
 621  sage: bool(a[11] == a[1,1]) 
 622  False 
617  623  
618  624  """ 
619  625  return SymbolSequence(name, latex_name, domain) 
… 
… 

1027  1033  
1028  1034  sage: from sage.symbolic.ring import SymbolSequence 
1029  1035  sage: a = SymbolSequence('a', 'alpha', 'real') 
1030   sage: a1 = a._create_symbol_(1) 
1031   sage: a1 
1032   a1 
1033   sage: latex(a1) 
 1036  sage: a_1 = a._create_symbol_(1) 
 1037  sage: a_1 
 1038  a_1 
 1039  sage: latex(a_1) 
1034  1040  alpha_{1} 
1035  1041  
1036  1042  """ 
… 
… 

1038  1044  # SR.symbol(). 
1039  1045  name = None 
1040  1046  if self._name is not None: 
1041   name = '%s%d' % (self._name, subscript) 
 1047  name = '%s_%d' % (self._name, subscript) 
1042  1048  
1043  1049  latex_name = None 
1044  1050  if self._latex_name is not None: 
… 
… 

1092  1098  sage: from sage.symbolic.ring import SymbolSequence 
1093  1099  sage: a = SymbolSequence('a') 
1094  1100  sage: a.__getitem__(1) 
1095   a1 
 1101  a_1 
1096  1102  
1097  1103  A tuple argument:: 
1098  1104  
1099  1105  sage: from sage.symbolic.ring import SymbolSequence 
1100  1106  sage: a = SymbolSequence('a') 
1101  1107  sage: a.__getitem__((1,2)) 
1102   a12 
 1108  a_1_2 
1103  1109  
1104  1110  A slice argument:: 
1105  1111  
1106  1112  sage: from sage.symbolic.ring import SymbolSequence 
1107  1113  sage: a = SymbolSequence('a') 
1108  1114  sage: a.__getitem__(slice(1,4)) 
1109   [a1, a2, a3] 
 1115  [a_1, a_2, a_3] 
1110  1116  
1111  1117  """ 
1112  1118  if isinstance(key, tuple): 
… 
… 

1131  1137  sage: from sage.symbolic.ring import SymbolSequence 
1132  1138  sage: a = SymbolSequence('a') 
1133  1139  sage: a._subscript_integer_(123) 
1134   a123 
 1140  a_123 
1135  1141  
1136  1142  """ 
1137  1143  if n < 0: 
… 
… 

1156  1162  sage: from sage.symbolic.ring import SymbolSequence 
1157  1163  sage: a = SymbolSequence('a') 
1158  1164  sage: a._subscript_slice_(slice(1,3)) 
1159   [a1, a2] 
 1165  [a_1, a_2] 
1160  1166  
1161  1167  """ 
1162  1168  (start, step) = (s.start, s.step) 
… 
… 

1188  1194  sage: from sage.symbolic.ring import SymbolSequence 
1189  1195  sage: a = SymbolSequence('a') 
1190  1196  sage: a._subscript_tuple_((1,8)) 
1191   a18 
 1197  a_1_8 
1192  1198  
1193  1199  Nested tuples:: 
1194  1200  
1195  1201  sage: a._subscript_tuple_(( (1,2), (3,(4,5,6)) )) 
1196   a123456 
 1202  a_1_2_3_4_5_6 
1197  1203  
1198  1204  """ 
1199  1205  