Changeset 1:bf5417bc8931
- Timestamp:
- 02/11/06 13:33:33 (7 years ago)
- Branch:
- default
- Files:
-
- 1 added
- 30 edited
-
PKG-INFO (modified) (1 diff)
-
boring (modified) (2 diffs)
-
sage/categories/homset.py (modified) (2 diffs)
-
sage/coding/linear_code.py (modified) (27 diffs)
-
sage/databases/sloane.py (modified) (3 diffs)
-
sage/ext/integer.pyx (modified) (3 diffs)
-
sage/ext/ring.pyx (modified) (3 diffs)
-
sage/ext/sage_object.pyx (modified) (1 diff)
-
sage/interfaces/expect.py (modified) (5 diffs)
-
sage/interfaces/gap.py (modified) (4 diffs)
-
sage/interfaces/maple.py (modified) (3 diffs)
-
sage/interfaces/maxima.py (modified) (1 diff)
-
sage/interfaces/singular.py (modified) (5 diffs)
-
sage/misc/functional.py (modified) (16 diffs)
-
sage/rings/all.py (modified) (1 diff)
-
sage/rings/arith.py (modified) (1 diff)
-
sage/rings/fraction_field.py (modified) (1 diff)
-
sage/rings/laurent_series_ring.py (modified) (2 diffs)
-
sage/rings/multi_polynomial_element.py (modified) (3 diffs)
-
sage/rings/multi_polynomial_ideal.py (modified) (3 diffs)
-
sage/rings/multi_polynomial_ring.py (modified) (1 diff)
-
sage/rings/notes/multi-polynomial_nonsense.txt (added)
-
sage/schemes/elliptic_curves/ell_rational_field.py (modified) (8 diffs)
-
sage/schemes/generic/algebraic_scheme.py (modified) (1 diff)
-
sage/schemes/generic/divisor.py (modified) (3 diffs)
-
sage/schemes/generic/homset.py (modified) (1 diff)
-
sage/schemes/generic/spec.py (modified) (1 diff)
-
sage/schemes/plane_curves/affine_curve.py (modified) (1 diff)
-
sage/schemes/plane_curves/projective_curve.py (modified) (1 diff)
-
sage/structure/formal_sum.py (modified) (3 diffs)
-
sage/version.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
PKG-INFO
r0 r1 1 1 Metadata-Version: 1.0 2 2 Name: sage 3 Version: 0.10.1 23 Version: 0.10.13 4 4 Summary: SAGE: System for Algebra and Geometry Experimentation 5 5 Home-page: http://modular.ucsd.edu/sage -
boring
r0 r1 16 16 \.orig$ 17 17 (^|/)vssver\.scc$ 18 \.sw p$18 \.sw?$ 19 19 (^|/)MT($|/) 20 20 (^|/)\{arch\}($|/) … … 32 32 (^|/)Thumbs\.db$ 33 33 # sage files to ignore: 34 (^|/).doctest($|/) 34 35 ^build($|/) 35 36 ^sage/ext/arith.c$ -
sage/categories/homset.py
r0 r1 66 66 if cat is None: 67 67 if cat_X.is_subcategory(cat_Y): 68 cat = cat_ X69 if cat_Y.is_subcategory(cat_X):68 cat = cat_Y 69 elif cat_Y.is_subcategory(cat_X): 70 70 if not (cat is None) and not (cat_X is cat_Y): 71 71 raise ValueError, "No unambiguous category found for Hom from %s to %s."%(X,Y) 72 cat = cat_ Y72 cat = cat_X 73 73 else: 74 74 raise TypeError, "No suitable category found for Hom from %s to %s."%(X,Y) … … 202 202 if not isinstance(cat, category.Category): 203 203 raise TypeError, "cat (=%s) must be a category"%cat 204 if not X in cat:205 raise TypeError, "X (=%s) must be in cat (=%s)"%(X, cat)206 if not Y in cat:207 raise TypeError, "Y (=%s) must be in cat (=%s)"%(Y, cat)204 #if not X in cat: 205 # raise TypeError, "X (=%s) must be in cat (=%s)"%(X, cat) 206 #if not Y in cat: 207 # raise TypeError, "Y (=%s) must be in cat (=%s)"%(Y, cat) 208 208 209 209 def _repr_(self): -
sage/coding/linear_code.py
r0 r1 1 r""" 1 r"""nodoctest 2 2 Linear Codes 3 3 … … 9 9 -- David Joyner (2005-11-22, 2006-12-03): written 10 10 -- William Stein (2006-01-23) -- Inclusion in SAGE 11 -- David Joyner (2006-01- 25, 2006-12-03): small fixedto use sage_eval11 -- David Joyner (2006-01-30, 2006-12-03): small fixes to use sage_eval 12 12 13 13 This file contains … … 23 23 \end{enumerate} 24 24 25 26 EXAMPLES: 27 sage: MS = MatrixSpace(GF(2),4,7) 28 sage: G = MS([[1,1,1,0,0,0,0], [ 1, 0, 0, 1, 1, 0, 0], [ 0, 1, 0, 1, 0, 1, 0], [1, 1, 0, 1, 0, 0, 1]]) 29 sage: C = LinearCode(G) 30 sage: C.basis() 31 32 [(1, 1, 1, 0, 0, 0, 0), 33 (1, 0, 0, 1, 1, 0, 0), 34 (0, 1, 0, 1, 0, 1, 0), 35 (1, 1, 0, 1, 0, 0, 1)] 36 sage: c = C.basis()[1] 37 sage: c in C 38 True 39 sage: c.nonzero_positions() 40 [0, 3, 4] 41 sage: c.support() 42 [0, 3, 4] 43 sage: c.parent() 44 Vector space of dimension 7 over Finite Field of size 2 45 25 46 To be added: 26 47 \begin{enumerate} … … 70 91 71 92 EXAMPLES: 72 sage: Gstr = 'Z(2)*[[1,1,1,0,0,0,0], [1,0,0,1,1,0,0], [0,1,0,1,0,1,0], [1,1,0,1,0,0,1]]'73 sage: F = GF(2)74 sage:wtdist(Gstr, F)75 [1, 0, 0, 7, 7, 0, 0, 1]93 sage: Gstr = 'Z(2)*[[1,1,1,0,0,0,0], [1,0,0,1,1,0,0], [0,1,0,1,0,1,0], [1,1,0,1,0,0,1]]' 94 sage: F = GF(2) 95 sage: sage.coding.linear_code.wtdist(Gstr, F) 96 [1, 0, 0, 7, 7, 0, 0, 1] 76 97 77 98 Here Gstr is a generator matrix of the Hamming [7,4,3] binary code. 78 99 79 ALGORITHM: Uses C programs written by Steve Linton in the kernel 80 of GAP, so is fairly fast. 100 ALGORITHM: 101 Uses C programs written by Steve Linton in the kernel 102 of GAP, so is fairly fast. 81 103 82 104 AUTHOR: David Joyner (2005-11) … … 88 110 n = int(C.WordLength()) 89 111 z = 'Z(%s)*%s'%(q, [0]*n) # GAP zero vector as a string 90 d = G.DistancesDistributionMatFFEVecFFE(k, z) 91 return d.sage() 112 dist = gap.eval("w:=DistancesDistributionMatFFEVecFFE("+Gmat+", GF("+str(q)+"),"+z+")") 113 #d = G.DistancesDistributionMatFFEVecFFE(k, z) 114 v = [sage_eval(gap.eval("w["+str(i)+"]")) for i in range(1,n+2)] 115 return v 92 116 93 117 def min_wt_vec(Gmat,F): 94 118 """ 119 Uses C programs written by Steve Linton in the kernel of GAP, so is fairly fast. 120 95 121 INPUT: 96 Same as wtdist. 97 OUTPUT: 98 Returns a minimum weight vector v, the "message" vector m such that m*G = v, 122 Same as wtdist. 123 124 OUTPUT: 125 Returns a minimum weight vector v, the "message" vector m such that m*G = v, 99 126 and the (minimum) weight, as a triple. 100 127 101 128 EXAMPLES: 102 sage: Gstr = "Z(2)*[[1,1,1,0,0,0,0], [1,0,0,1,1,0,0], [0,1,0,1,0,1,0], [1,1,0,1,0,0,1]]"103 sage:min_wt_vec(Gstr,GF(2))104 [[0, 1, 0, 1, 0, 1, 0], [0, 0, 1, 0], 3]129 sage: Gstr = "Z(2)*[[1,1,1,0,0,0,0], [1,0,0,1,1,0,0], [0,1,0,1,0,1,0], [1,1,0,1,0,0,1]]" 130 sage: sage.coding.linear_code.min_wt_vec(Gstr,GF(2)) 131 [[0, 1, 0, 1, 0, 1, 0], [0, 0, 1, 0], 3] 105 132 106 133 Here Gstr is a generator matrix of the Hamming [7,4,3] binary code. 107 Uses C programs written by Steve Linton in the kernel of GAP, so it fairly fast.108 134 109 135 AUTHOR: David Joyner (11-2005) … … 142 168 143 169 EXAMPLES: 144 sage: coding.minimum_distance_upper_bound(7,4,GF(2))145 3170 sage: sage.coding.linear_code.minimum_distance_upper_bound(7,4,GF(2)) 171 3 146 172 147 173 Obviously requires an internet connection. … … 158 184 159 185 EXAMPLES: 160 sage: coding.minimum_distance_upper_bound(7,4,GF(2))161 3186 sage: sage.coding.linear_code.minimum_distance_upper_bound(7,4,GF(2)) 187 3 162 188 163 189 Obviously requires an internet connection. … … 174 200 175 201 EXAMPLES: 176 sage: coding.minimum_distance_why(7,4,GF(2))177 Lb(7,4) = 3 is found by truncation of:178 Lb(8,4) = 4 is found by the (u|u+v) construction179 applied to [4,3,2] and [4,1,4]-codes180 Ub(7,4) = 3 follows by the Griesmer bound.202 sage: sage.coding.linear_code.minimum_distance_why(7,4,GF(2)) 203 Lb(7,4) = 3 is found by truncation of: 204 Lb(8,4) = 4 is found by the (u|u+v) construction 205 applied to [4,3,2] and [4,1,4]-codes 206 Ub(7,4) = 3 follows by the Griesmer bound. 181 207 182 208 Obviously requires an internet connection. … … 191 217 class LinearCode(module.Module): 192 218 """ 193 class for linear codes over a finite field or finite ring 219 A class for linear codes over a finite field or finite ring. 220 194 221 INPUT: 195 A $k\times n$ matrix $G$ of rank $k$, $k\leq n$, over 196 a finite field $F$. 197 OUTPUT: 198 The linear code of length $n$ over $F$ having $G$ as a 199 generator matrix. 222 G -- A $k\times n$ matrix of (full) rank $k$, $k\leq n$, over 223 a finite field $F$. 224 225 OUTPUT: 226 The linear code of length $n$ over $F$ having $G$ as a 227 generator matrix. 200 228 201 229 EXAMPLES: … … 204 232 sage: C = LinearCode(G) 205 233 sage: C 206 Linear code of length 7, dimension 4 over Finite field of size 2234 Linear code of length 7, dimension 4 over Finite Field of size 2 207 235 sage: C.minimum_distance_upper_bound() 208 236 3 209 237 sage: C.base_ring() 210 Finite field of size 2238 Finite Field of size 2 211 239 sage: C.dimension() 212 240 4 … … 298 326 299 327 EXAMPLES: 300 sage: MS = MatrixSpace(GF(3),4,7) 301 sage: G = MS([[1,1,1,0,0,0,0], [1,0,0,1,1,0,0], [0,1,0,1,0,1,0], [1,1,0,1,0,0,1]]) 302 sage: C = LinearCode(G) 303 sage: C.minimum_distance() 304 3 305 sage: C=RandomLinearCode(10,5,GF(4)) 306 sage: C.gen_mat() 307 308 [ 1 0 0 0 0 x + 1 1 0 0 0] 309 [x + 1 1 0 1 0 x + 1 1 1 0 0] 310 [ 0 x + 1 0 x + 1 0 x x + 1 x + 1 x + 1 0] 311 [ 1 0 x 0 1 0 0 0 0 1] 312 [ 0 0 1 1 0 0 0 0 x x + 1] 313 sage: C.minimum_distance() 314 2 315 sage: C.minimum_distance_upper_bound() 316 5 317 sage: C.minimum_distance_why() 318 Ub(10,5) = 5 follows by the Griesmer bound. 328 sage: MS = MatrixSpace(GF(3),4,7) 329 sage: G = MS([[1,1,1,0,0,0,0], [1,0,0,1,1,0,0], [0,1,0,1,0,1,0], [1,1,0,1,0,0,1]]) 330 sage: C = LinearCode(G) 331 sage: C.minimum_distance() 332 3 333 sage: C=RandomLinearCode(10,5,GF(4)) 334 sage: C.gen_mat() ## random 335 [ 1 0 0 0 0 x + 1 1 0 0 0] 336 [x + 1 1 0 1 0 x + 1 1 1 0 0] 337 [ 0 x + 1 0 x + 1 0 x x + 1 x + 1 x + 1 0] 338 [ 1 0 x 0 1 0 0 0 0 1] 339 [ 0 0 1 1 0 0 0 0 x x + 1] 340 sage: C.minimum_distance() ## random 341 2 342 sage: C.minimum_distance_upper_bound() 343 5 344 sage: C.minimum_distance_why() 345 Ub(10,5) = 5 follows by the Griesmer bound. 319 346 320 347 … … 332 359 """ 333 360 Uses a GAP kernel function (in C) written by Steve Linton. 361 334 362 EXAMPLES: 363 sage: MS = MatrixSpace(GF(2),4,7) 364 sage: G = MS([[1,1,1,0,0,0,0], [ 1, 0, 0, 1, 1, 0, 0], [ 0, 1, 0,1, 0, 1, 0], [1, 1, 0, 1, 0, 0, 1]]) 365 sage: C = LinearCode(G) 366 sage: C.spectrum() 367 [1, 0, 0, 7, 7, 0, 0, 1] 335 368 336 369 """ … … 352 385 def decode(self, right): 353 386 """ 354 Wraps GUAVA's Decodeword. 387 Wraps GUAVA's Decodeword. Hamming codes have a special 388 decoding algorithm. Otherwise, syndrome decoding is used. 389 355 390 INPUT: 356 right must be a vector of length = length(self) 391 right must be a vector of length = length(self) 392 357 393 OUTPUT: 358 The codeword c in C closest to r. 359 360 Hamming codes have a special decoding algorithm. Otherwise, syndrome decoding is used. 394 The codeword c in C closest to r. 361 395 362 396 EXAMPLES: 363 sage: C = HammingCode(3,GF(2))364 sage: MS = MatrixSpace(GF(2),1,7)365 sage: F=GF(2); a=F.gen()366 sage: v=MS([a,a,F(0),a,a,F(0),a]); v367 [1 1 0 1 1 0 1]368 sage: C.decode(v)369 [1 1 0 1 0 01]397 sage: C = HammingCode(3,GF(2)) 398 sage: MS = MatrixSpace(GF(2),1,7) 399 sage: F=GF(2); a=F.gen() 400 sage: v=MS([a,a,F(0),a,a,F(0),a]); v 401 [1 1 0 1 1 0 1] 402 sage: C.decode(v) 403 [1, 1, 0, 1, 0, 0, 1] 370 404 371 405 Does not work for very long codes since the syndrome table grows too large. … … 376 410 n = len(G.columns()) 377 411 k = len(G.rows()) 378 Gstr = s age2gap_matrix_finite_field_string(G,k,n,F)379 vstr = s age2gap_matrix_finite_field_string(right,1,n,F)412 Gstr = str(gap(G)) 413 vstr = str(gap(right)) 380 414 v = vstr[1:-1] 381 415 gap.eval("C:=GeneratorMatCode("+Gstr+",GF("+str(q)+"))") 382 ans =gap.eval("c:=VectorCodeword(Decodeword( C, Codeword( "+v+" )))")383 return gap2sage_matrix_finite_field(ans,1,n,F)384 416 gap.eval("c:=VectorCodeword(Decodeword( C, Codeword( "+v+" )))") 417 ans = [sage_eval(gap.eval("c["+str(i)+"]")) for i in range(1,n+1)] 418 return ans 385 419 386 420 def dual_code(self): 387 421 """ 388 422 Wraps GUAVA's DualCode. 423 389 424 OUTPUT: 390 The dual code.425 The dual code. 391 426 392 427 EXAMPLES: 393 sage: C = HammingCode(3,GF(2))394 sage: C.dual_code()395 Linear code of length 7, dimension 3 over Finite field of size 2396 sage: C = HammingCode(3,GF(4))397 sage: C.dual_code()398 Linear code of length 21, dimension 3 over Finite field in x of size 2^2428 sage: C = HammingCode(3,GF(2)) 429 sage: C.dual_code() 430 Linear code of length 7, dimension 3 over Finite Field of size 2 431 sage: C = HammingCode(3,GF(4)) 432 sage: C.dual_code() 433 Linear code of length 21, dimension 3 over Finite Field in x of size 2^2 399 434 400 435 """ … … 417 452 418 453 EXAMPLES: 419 420 sage: C = HammingCode(3,GF(2)) 421 sage: Cperp = C.dual_code() 422 sage: C; Cperp 423 Linear code of length 7, dimension 4 over Finite field of size 2 424 Linear code of length 7, dimension 3 over Finite field of size 2 425 sage: C.gen_mat() 426 427 [1 1 1 0 0 0 0] 428 [1 0 0 1 1 0 0] 429 [0 1 0 1 0 1 0] 430 [1 1 0 1 0 0 1] 431 sage: C.check_mat() 432 433 [0 1 1 1 1 0 0] 434 [1 0 1 1 0 1 0] 435 [1 1 0 1 0 0 1] 436 sage: Cperp.check_mat() 437 438 [1 1 1 0 0 0 0] 439 [1 0 0 1 1 0 0] 440 [0 1 0 1 0 1 0] 441 [1 1 0 1 0 0 1] 442 sage: Cperp.gen_mat() 443 444 [0 1 1 1 1 0 0] 445 [1 0 1 1 0 1 0] 446 [1 1 0 1 0 0 1] 447 448 454 sage: C = HammingCode(3,GF(2)) 455 sage: Cperp = C.dual_code() 456 sage: C; Cperp 457 Linear code of length 7, dimension 4 over Finite Field of size 2 458 Linear code of length 7, dimension 3 over Finite Field of size 2 459 sage: C.gen_mat() 460 [1 1 1 0 0 0 0] 461 [1 0 0 1 1 0 0] 462 [0 1 0 1 0 1 0] 463 [1 1 0 1 0 0 1] 464 sage: C.check_mat() 465 [0 1 1 1 1 0 0] 466 [1 0 1 1 0 1 0] 467 [1 1 0 1 0 0 1] 468 sage: Cperp.check_mat() 469 [1 1 1 0 0 0 0] 470 [1 0 0 1 1 0 0] 471 [0 1 0 1 0 1 0] 472 [1 1 0 1 0 0 1] 473 sage: Cperp.gen_mat() 474 [0 1 1 1 1 0 0] 475 [1 0 1 1 0 1 0] 476 [1 1 0 1 0 0 1] 449 477 """ 450 478 Cperp = self.dual_code() … … 455 483 Codeword.support = fme.FreeModuleElement.nonzero_positions 456 484 is_Codeword = fme.is_FreeModuleElement 457 """ 458 EXAMPLE: 459 sage: MS = MatrixSpace(GF(2),4,7) 460 sage: G = MS([[1,1,1,0,0,0,0], [ 1, 0, 0, 1, 1, 0, 0], [ 0, 1, 0, 1, 0, 1, 0], [1, 1, 0, 1, 0, 0, 1]]) 461 sage: C = LinearCode(G) 462 sage: C.basis() 463 464 [(1, 1, 1, 0, 0, 0, 0), 465 (1, 0, 0, 1, 1, 0, 0), 466 (0, 1, 0, 1, 0, 1, 0), 467 (1, 1, 0, 1, 0, 0, 1)] 468 sage: c = C.basis()[1] 469 sage: c in C 470 True 471 sage: c.nonzero_positions() 472 [0, 3, 4] 473 sage: c.support() 474 [0, 3, 4] 475 sage: is_Codeword(c) 476 True 477 sage: c.parent() 478 Vector space of dimension 7 over Finite field of size 2 479 """ 485 480 486 481 487 ##################### wrapped GUAVA functions ############################ … … 484 490 """ 485 491 INPUT: 486 Integer r>1 and finite field F. 487 OUTPUT: 488 Returns the $r^{th}$ Hamming code over $F=GF(q)$ of length $n=(q^r-1)/(q-1)$. 492 r, F -- r>1 an integer, F a finite field. 493 494 OUTPUT: 495 Returns the $r^{th}$ Hamming code over $F=GF(q)$ of length $n=(q^r-1)/(q-1)$. 496 489 497 Requires GUAVA. 490 498 491 499 EXAMPLES: 492 sage: C = HammingCode(3,GF(3)) 493 sage: C 494 Linear code of length 13, dimension 10 over Finite field of size 3 495 sage: C.minimum_distance() 496 3 497 sage: C.gen_mat() 498 499 [2 2 1 0 0 0 0 0 0 0 0 0 0] 500 [1 2 0 1 0 0 0 0 0 0 0 0 0] 501 [2 0 0 0 2 1 0 0 0 0 0 0 0] 502 [1 0 0 0 2 0 1 0 0 0 0 0 0] 503 [0 2 0 0 2 0 0 1 0 0 0 0 0] 504 [2 2 0 0 2 0 0 0 1 0 0 0 0] 505 [1 2 0 0 2 0 0 0 0 1 0 0 0] 506 [0 1 0 0 2 0 0 0 0 0 1 0 0] 507 [2 1 0 0 2 0 0 0 0 0 0 1 0] 508 [1 1 0 0 2 0 0 0 0 0 0 0 1] 509 sage: C = HammingCode(3,GF(4)) 510 sage: C 511 Linear code of length 21, dimension 16 over Finite field in x of size 2^2 500 sage: C = HammingCode(3,GF(3)) 501 sage: C 502 Linear code of length 13, dimension 10 over Finite Field of size 3 503 sage: C.minimum_distance() 504 3 505 sage: C.gen_mat() 506 [2 2 1 0 0 0 0 0 0 0 0 0 0] 507 [1 2 0 1 0 0 0 0 0 0 0 0 0] 508 [2 0 0 0 2 1 0 0 0 0 0 0 0] 509 [1 0 0 0 2 0 1 0 0 0 0 0 0] 510 [0 2 0 0 2 0 0 1 0 0 0 0 0] 511 [2 2 0 0 2 0 0 0 1 0 0 0 0] 512 [1 2 0 0 2 0 0 0 0 1 0 0 0] 513 [0 1 0 0 2 0 0 0 0 0 1 0 0] 514 [2 1 0 0 2 0 0 0 0 0 0 1 0] 515 [1 1 0 0 2 0 0 0 0 0 0 0 1] 516 sage: C = HammingCode(3,GF(4)) 517 sage: C 518 Linear code of length 21, dimension 16 over Finite Field in x of size 2^2 512 519 513 520 AUTHOR: David Joyner (11-2005) … … 525 532 """ 526 533 INPUT: 527 Prime n>2 and finite prime field F of order q. Moreover, 528 q must be a quadratic residue modulo n. 529 OUTPUT: 530 Returns a quadratic residue code. Its generator polynomial is the product 531 of the polynomials $x-\alpha^i$ ($\alpha$ is a primitive $n^{th}$ root of unity, 532 and $i$ is an integer in the set of quadratic residues modulo $n$). 534 n, F -- n>2 a prime and F a finite prime field F of order q. 535 Moreover, q must be a quadratic residue modulo n. 536 537 OUTPUT: 538 Returns a quadratic residue code. Its generator polynomial 539 is the product of the polynomials $x-\alpha^i$ 540 ($\alpha$ is a primitive $n^{th}$ root of unity, 541 and $i$ is an integer in the set of quadratic residues 542 modulo $n$). 543 544 EXAMPLES: 545 sage: C = QuadraticResidueCode(7,GF(2)) 546 sage: C 547 Linear code of length 7, dimension 4 over Finite Field of size 2 548 sage: C = QuadraticResidueCode(17,GF(2)) 549 sage: C 550 Linear code of length 17, dimension 9 over Finite Field of size 2 551 533 552 Requires GUAVA. 534 535 EXAMPLES:536 sage: C = QuadraticResidueCode(7,GF(2))537 sage: C538 Linear code of length 7, dimension 4 over Finite field of size 2539 sage: C = QuadraticResidueCode(17,GF(2))540 sage: C541 Linear code of length 17, dimension 9 over Finite field of size 2542 553 543 554 AUTHOR: David Joyner (11-2005) … … 555 566 """ 556 567 INPUT: 557 p must be a prime >2. 568 p -- a prime >2. 569 558 570 OUTPUT: 559 Returns a (binary) quasi-quadratic residue code, as defined by 560 Proposition 2.2 in Bazzi-Mittel ({\it Some constructions of codes from group actions}, 561 (preprint March 2003). Its generator matrix has the block form $G=(Q,N)$. 562 Here $Q$ is a $p\times p$ circulant matrix whose top row 563 is $(0,x_1,...,x_{p-1})$, where $x_i=1$ if and only if $i$ 564 is a quadratic residue $\mod p$, and $N$ is a $p\times p$ 565 circulant matrix whose top row is $(0,y_1,...,y_{p-1})$, where 566 $x_i+y_i=1$ for all i. (In fact, this matrix can be recovered 567 as the component DoublyCirculant of the code.) 571 Returns a (binary) quasi-quadratic residue code, as defined by 572 Proposition 2.2 in Bazzi-Mittel ({\it Some constructions of 573 codes from group actions}, (preprint March 2003). Its 574 generator matrix has the block form $G=(Q,N)$. 575 Here $Q$ is a $p\times p$ circulant matrix whose top row 576 is $(0,x_1,...,x_{p-1})$, where $x_i=1$ if and only if $i$ 577 is a quadratic residue $\mod p$, and $N$ is a $p\times p$ 578 circulant matrix whose top row is $(0,y_1,...,y_{p-1})$, where 579 $x_i+y_i=1$ for all i. (In fact, this matrix can be recovered 580 as the component DoublyCirculant of the code.) 581 582 EXAMPLES: 583 sage: C = QuasiQuadraticResidueCode(31) 584 sage: C 585 Linear code of length 62, dimension 31 over Finite Field of size 2 586 568 587 Requires GUAVA. 569 570 EXAMPLES:571 sage: time C = QuasiQuadraticResidueCode(31)572 Time: CPU 2.11 s, Wall: 102.49 s573 sage: C574 Linear code of length 62, dimension 31 over Finite field of size 2575 588 576 589 AUTHOR: David Joyner (11-2005) … … 588 601 """ 589 602 INPUT: 590 Positive integers r,k with $2^k>r$. 591 OUTPUT: 592 Returns a binary 'Reed-Muller code' with dimension k and order r. 593 This is a code with length $2^k$ and minimum distance $2^k-r$ (see 594 for example, section 1.10 in Huffman-Pless {\it Fundamentals of Coding Theory}). 595 By definition, the $r^{th}$ order binary Reed-Muller code of 596 length $n=2^m$, for $0 \leq r \leq m$, is the set of 597 all vectors $(f(p)\ |\ p in GF(2)^m)$, where $f$ is a 598 multivariate polynomial of degree at most $r$ in $m$ variables. 599 Requires GUAVA. 600 603 r, k -- positive integers with $2^k>r$. 604 605 OUTPUT: 606 Returns a binary 'Reed-Muller code' with dimension k and 607 order r. This is a code with length $2^k$ and minimum 608 distance $2^k-r$ (see for example, section 1.10 in 609 Huffman-Pless {\it Fundamentals of Coding Theory}). 610 By definition, the $r^{th}$ order binary Reed-Muller code of 611 length $n=2^m$, for $0 \leq r \leq m$, is the set of 612 all vectors $(f(p)\ |\ p in GF(2)^m)$, where $f$ is a 613 multivariate polynomial of degree at most $r$ in $m$ variables. 614 601 615 EXAMPLE: 602 sage: C = BinaryReedMullerCode(2,4) 603 sage: C 604 Linear code of length 16, dimension 11 over Finite field of size 2 605 sage: C.minimum_distance() 606 4 607 sage: C.gen_mat() 608 616 sage: C = BinaryReedMullerCode(2,4) 617 sage: C 618 Linear code of length 16, dimension 11 over Finite Field of size 2 619 sage: C.minimum_distance() 620 4 621 sage: C.gen_mat() 609 622 [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1] 610 623 [0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1] … … 619 632 [0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1] 620 633 634 Requires GUAVA. 635 621 636 AUTHOR: David Joyner (11-2005) 622 637 """ … … 632 647 def BinaryGolayCode(): 633 648 """ 634 BinaryGolayCode returns a binary Golay code. This is a 635 perfect [23,12,7] code. It is also cyclic, and has 636 generator polynomial $g(x)=1+x^2+x^4+x^5+x^6+x^{10}+x^{11}$. 637 Extending it results in an extended Golay code (see 638 ExtendedBinaryGolayCode). 649 OUTPUT: 650 BinaryGolayCode returns a binary Golay code. This is a 651 perfect [23,12,7] code. It is also cyclic, and has 652 generator polynomial $g(x)=1+x^2+x^4+x^5+x^6+x^{10}+x^{11}$. 653 Extending it results in an extended Golay code (see 654 ExtendedBinaryGolayCode). 655 656 EXAMPLE: 657 sage: C = BinaryGolayCode() 658 sage: C 659 Linear code of length 23, dimension 12 over Finite Field of size 2 660 sage: C.minimum_distance() 661 7 662 639 663 Requires GUAVA. 640 641 EXAMPLE:642 sage: C = BinaryGolayCode()643 sage: C644 Linear code of length 23, dimension 12 over Finite field of size 2645 sage: C.minimum_distance()646 7647 664 648 665 AUTHOR: David Joyner (11-2005) … … 659 676 def ExtendedBinaryGolayCode(): 660 677 """ 661 BinaryGolayCode returns the extended binary Golay code. This 662 is a perfect [24,12,8] code. This code is self-dual. 678 OUTPUT: 679 BinaryGolayCode returns the extended binary Golay code. This 680 is a perfect [24,12,8] code. This code is self-dual. 681 682 EXAMPLES: 683 sage: C = ExtendedBinaryGolayCode() 684 sage: C 685 Linear code of length 24, dimension 12 over Finite Field of size 2 686 sage: C.minimum_distance() 687 8 688 663 689 Requires GUAVA. 664 665 EXAMPLE: 666 sage: C = ExtendedBinaryGolayCode() 667 sage: C 668 Linear code of length 24, dimension 12 over Finite field of size 2 669 sage: C.minimum_distance() 670 8 671 690 672 691 AUTHOR: David Joyner (11-2005) 673 692 """ … … 683 702 def TernaryGolayCode(): 684 703 """ 685 TernaryGolayCode returns a ternary Golay code. This is a 686 perfect [11,6,5] code. It is also cyclic, and has generator 687 polynomial $g(x)=2+x^2+2x^3+x^4+x^5$. 704 OUTPUT: 705 TernaryGolayCode returns a ternary Golay code. This is a 706 perfect [11,6,5] code. It is also cyclic, and has generator 707 polynomial $g(x)=2+x^2+2x^3+x^4+x^5$. 708 709 EXAMPLES: 710 sage: C = TernaryGolayCode() 711 sage: C 712 Linear code of length 11, dimension 6 over Finite Field of size 3 713 sage: C.minimum_distance() 714 5 715 688 716 Requires GUAVA. 689 690 EXAMPLE:691 sage: C = TernaryGolayCode()692 sage: C693 Linear code of length 11, dimension 6 over Finite field of size 3694 sage: C.minimum_distance()695 5696 717 697 718 AUTHOR: David Joyner (11-2005) … … 708 729 def ExtendedTernaryGolayCode(): 709 730 """ 710 ExtendedTernaryGolayCode returns a ternary Golay code. 711 This is a self-dual perfect [12,6,6] code. 712 Requires GUAVA. 713 714 EXAMPLE: 715 sage: C = ExtendedTernaryGolayCode() 716 sage: C 717 Linear code of length 11, dimension 6 over Finite field of size 3 718 sage: C.minimum_distance() 719 6 720 sage: C.gen_mat() 721 731 OUTPUT: 732 ExtendedTernaryGolayCode returns a ternary Golay code. 733 This is a self-dual perfect [12,6,6] code. 734 735 EXAMPLES: 736 sage: C = ExtendedTernaryGolayCode() 737 sage: C 738 Linear code of length 11, dimension 6 over Finite Field of size 3 739 sage: C.minimum_distance() 740 6 741 sage: C.gen_mat() 722 742 [1 0 2 1 2 2 0 0 0 0 0 1] 723 743 [0 1 0 2 1 2 2 0 0 0 0 1] … … 726 746 [0 0 0 0 1 0 2 1 2 2 0 1] 727 747 [0 0 0 0 0 1 0 2 1 2 2 1] 748 749 Requires GUAVA. 728 750 729 751 AUTHOR: David Joyner (11-2005) … … 741 763 """ 742 764 INPUT: 743 Integers n,k, with n>k>1. 744 OUTPUT: 745 Returns a random linear code with length n, dimension k over field F. 746 The method used is to first construct a $k\times n$ matrix of the block form $(I,A)$, 747 where $I$ is a $k\times k$ identity matrix and $A$ is a $k\times (n-k)$ 748 matrix constructed using random elements of $F$. Then the columns are permuted 749 using a randomly selected element of SymmetricGroup(n). 765 Integers n,k, with n>k>1. 766 767 OUTPUT: 768 Returns a "random" linear code with length n, 769 dimension k over field F. The method used is to first 770 construct a $k\times n$ matrix of the block form $(I,A)$, 771 where $I$ is a $k\times k$ identity matrix and $A$ is a 772 $k\times (n-k)$ matrix constructed using random elements 773 of $F$. Then the columns are permuted 774 using a randomly selected element of SymmetricGroup(n). 775 776 EXAMPLES: 777 sage: C = RandomLinearCode(30,15,GF(2)) 778 sage: C 779 Linear code of length 30, dimension 15 over Finite Field of size 2 780 sage: C = RandomLinearCode(10,5,GF(4)) 781 sage: C 782 Linear code of length 10, dimension 5 over Finite Field in x of size 2^2 783 750 784 Requires GUAVA. 751 752 EXAMPLES:753 sage: time C = RandomLinearCode(30,15,GF(2))754 Time: CPU 0.31 s, Wall: 0.44 s755 sage: C756 Linear code of length 30, dimension 15 over Finite field of size 2757 sage: time C = RandomLinearCode(10,5,GF(4))758 Time: CPU 0.02 s, Wall: 0.10 s759 sage: C760 Linear code of length 10, dimension 5 over Finite field in x of size 2^2761 785 762 786 AUTHOR: David Joyner (11-2005) -
sage/databases/sloane.py
r0 r1 95 95 """ 96 96 return "Sloane Online Encyclopedia of Integer Sequences" 97 97 98 98 def __iter__(self): 99 99 """ … … 222 222 def sloane_sequence(number): 223 223 try: 224 print "Looking up in Sloane's online database (this requires a net connection and is slow)..." 225 f = urllib.urlopen("http://www.research.att.com/cgi-bin/access.cgi/as/njas/sequences/eisA2.cgi?Anum=A%s"%number) 224 print "Looking up in Sloane's online database (this requires a net connection and is slow)..." 225 url = "http://www.research.att.com/cgi-bin/access.cgi/as/njas/sequences/eisA2.cgi?Anum=A%s"%number 226 f = urllib.urlopen(url) 226 227 s = f.read() 227 228 f.close() 228 except IOError: 229 s = '' 230 231 i = s.find("<PRE>") 232 j = s.find("</PRE>") 229 except IOError, msg: 230 raise IOError, "%s\nError fetching the following website:\n %s\nTry checking your internet connection."%(msg, url) 231 232 t = s.lower() 233 i = t.find("<pre>") 234 j = t.find("</pre>") 233 235 if i == -1 or j == -1: 234 236 raise IOError, "Error parsing data (missing pre tags)." … … 247 249 try: 248 250 print "Searching Sloane's online database (this requires a net connection and is slow)..." 249 f = urllib.urlopen("http://www.research.att.com/cgi-bin/access.cgi/as/njas/sequences/eismum2.cgi", urlparams); 251 url = "http://www.research.att.com/cgi-bin/access.cgi/as/njas/sequences/eismum2.cgi" 252 f = urllib.urlopen(url, urlparams); 250 253 s = f.read() 251 254 f.close() 252 except IOError: 253 s = '' 254 255 i = s.find("<PRE>") 256 j = s.find("</PRE>") 255 except IOError, msg: 256 raise IOError, "%s\nError fetching the following website:\n %s\nTry checking your internet connection."%(msg, url) 257 258 t = s.lower() 259 i = t.find("<pre>") 260 j = t.find("</pre>") 257 261 if i == -1 or j == -1: 258 262 raise IOError, "Error parsing data (missing pre tags)." -
sage/ext/integer.pyx
r0 r1 32 32 import sage.rings.coerce 33 33 import sage.rings.infinity 34 import sage.rings.complex_field 34 35 import rational as rational 35 36 import sage.libs.pari.all … … 792 793 793 794 794 def sqrt(self, int bits=53):795 def sqrt(self, bits=None): 795 796 r""" 796 Returns the positive square root of self \emph{as a real 797 number} to the given number of bits of precision if self is 798 nonnegative, and raises a \exception{ValueError} exception 799 otherwise. 800 801 For the integer square root of a perfect square (with error 802 checking), use \code{self.square_root()}. 797 Returns the positive square root of self, possibly as a 798 \emph{a real number} if self is not a perfect integer 799 square. 800 801 INPUT: 802 bits -- number of bits of precision. 803 If bits is not specified, the number of 804 bits of precision is at least twice the 805 number of bits of self (the precision 806 is always at least 53 bits if not specified). 807 OUTPUT: 808 integer, real number, or complex number. 809 810 For the guaranteed integer square root of a perfect square 811 (with error checking), use \code{self.square_root()}. 803 812 804 813 EXAMPLE: 805 814 sage: Z = IntegerRing() 806 sage: Z(2).sqrt( )815 sage: Z(2).sqrt(53) 807 816 1.4142135623730951 808 817 sage: Z(2).sqrt(100) … … 810 819 sage: 39188072418583779289.square_root() 811 820 6260037733 812 sage: 39188072418583779289.sqrt() 813 6260037732.9999990 814 """ 821 sage: (100^100).sqrt() 822 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 823 sage: (-1).sqrt() 824 1.0000000000000000*I 825 sage: sqrt(-2) 826 1.4142135623730949*I 827 sage: sqrt(97) 828 9.8488578017961039 829 sage: 97.sqrt(200) 830 9.8488578017961047217462114149176244816961362874427641717231516 831 """ 832 if bits is None: 833 bits = max(53, 2*(mpz_sizeinbase(self.value, 2)+2)) 815 834 if self < 0: 816 raise ValueError, "square root of negative number not (yet) defined." 817 R = mpfr.RealField(bits) 818 return self._mpfr_(R).sqrt() 835 x = sage.rings.complex_field.ComplexField(bits)(self) 836 return x.sqrt() 837 else: 838 try: 839 return self.square_root() 840 except ValueError: 841 pass 842 R = mpfr.RealField(bits) 843 return self._mpfr_(R).sqrt() 819 844 820 845 def square_root(self): -
sage/ext/ring.pyx
r0 r1 21 21 import sage.rings.coerce 22 22 23 import sage.rings.finite_field 24 import sage.rings.integer_ring 25 import sage.rings.rational_field 23 26 24 27 cdef class Ring(gens.Generators): … … 109 112 return self(x) 110 113 114 def base_ring(self): 115 return sage.rings.integer_ring.Z 116 111 117 def category(self): 112 118 """ … … 430 436 Generic field 431 437 """ 438 def base_ring(self): 439 """ 440 Return the base ring of this field. This is the prime 441 subfield of this field. 442 """ 443 p = self.characteristic() 444 if p == 0: 445 return sage.rings.rational_field.Q 446 return sage.rings.finite_field.GF(p) 447 448 def category(self): 449 from sage.categories.all import Fields 450 return Fields() 451 432 452 def fraction_field(self): 433 453 """ -
sage/ext/sage_object.pyx
r0 r1 192 192 from sage.categories.all import Objects 193 193 return Objects() 194 195 ## def category(self): 196 ## try: 197 ## return self.__category 198 ## except AttributeError: 199 ## from sage.categories.all import Objects 200 ## return Objects() 201 202 ## def _set_category(self, C): 203 ## self.__category = C 194 204 195 205 ############################################################################# -
sage/interfaces/expect.py
r0 r1 133 133 self._eval_line('') 134 134 135 def pid(self): 136 if self._expect is None: 137 self._start() 138 return self._expect.pid 139 135 140 def _start(self, alt_message=None): 141 self.quit() # in case one is already running 136 142 global failed_to_start 137 143 if self.__name in failed_to_start: … … 196 202 if self._expect is None: 197 203 return 198 try: 199 self._expect.timeout = 1 # give it at most 1 second to quit 200 #self._expect.sendline(self._quit_string()+';;') 201 self._eval_line(self._quit_string(), allow_use_file=False) 202 self._expect.timeout = 9999999 203 except (OSError, pexpect.TIMEOUT, pexpect.EOF, RuntimeError): # intentional EOF or RuntimeError if already quit 204 pass 204 # Send a kill -9 to the process *group*. 205 # this is *very useful* when external binaries are started up 206 # by shell scripts, and killing the shell script doesn't 207 # kill the binary. 208 try: 209 os.killpg(self._expect.pid, 9) 210 except OSError: 211 # this is OK, it just means the process was already dead. 212 pass 205 213 206 214 def _quit_string(self): … … 218 226 219 227 def _eval_line(self, line, allow_use_file=True): 220 if line.find('\n') != -1:221 raise ValueError, "line must not contain any newlines"228 #if line.find('\n') != -1: 229 # raise ValueError, "line must not contain any newlines" 222 230 if allow_use_file and self._eval_using_file_cutoff and len(line) > self._eval_using_file_cutoff: 223 231 return self._eval_line_using_file(line, tmp) … … 239 247 print "** %s crashed or quit executing '%s' **"%(self, line) 240 248 print "Restarting %s and trying again"%self 241 self._expect.close(force=1)242 249 self._start() 243 250 if line != '': … … 252 259 self._keyboard_interrupt() 253 260 raise KeyboardInterrupt, "Ctrl-c pressed while running %s"%self 254 255 261 i = out.find("\n") 256 262 j = out.rfind("\r") -
sage/interfaces/gap.py
r0 r1 108 108 109 109 sage: t = '"%s"'%10^10000 # ten thousand character string. 110 sage: a = gap(t) 110 sage: a = gap(t) 111 112 AUTHORS: 113 -- David Joyner and William Stein; initial version(s) 114 -- William Stein (2006-02-01): modified gap_console command 115 so it uses exactly the same startup command as Gap.__init__. 111 116 112 117 """ … … 133 138 WORKSPACE = "%s/tmp/gap-workspace"%SAGE_ROOT 134 139 140 def gap_command(use_workspace_cache=True): 141 if use_workspace_cache and os.path.exists(WORKSPACE): 142 return "gap -L %s"%WORKSPACE, False 143 else: 144 return "gap ", True 145 146 135 147 class Gap(Expect): 136 148 r""" … … 146 158 147 159 self.__use_workspace_cache = use_workspace_cache 148 if use_workspace_cache and os.path.exists(WORKSPACE): 149 cmd = "gap -T -n -b -L %s"%WORKSPACE 150 self.__make_workspace = False 151 else: 152 cmd = "gap -T -n -b" 153 self.__make_workspace = True 160 cmd, self.__make_workspace = gap_command(use_workspace_cache) 161 cmd += ' -T -n -b ' 154 162 if max_workspace_size != None: 155 163 cmd += " -o %s"%int(max_workspace_size) … … 419 427 import os 420 428 def gap_console(use_workspace_cache=True): 421 if use_workspace_cache and os.path.exists(WORKSPACE): 422 cmd = "gap -L %s"%WORKSPACE 423 else: 424 cmd = "gap" 429 cmd, _ = gap_command(use_workspace_cache=use_workspace_cache) 425 430 os.system(cmd) 426 431 -
sage/interfaces/maple.py
r0 r1 1 """1 r""" 2 2 Interface to Maple 3 3 4 You must have the maple interpreter installed and available as 5 the command "maple" in your PATH in order to use this interface. 4 You must have the optional commercial Maple interpreter installed and 5 available as the command \code{maple} in your PATH in order to use 6 this interface. You do not have to install any special \sage packages. 7 6 8 7 9 EXAMPLES: 8 sage: maple('3 * 5') # needs optional maple10 sage: maple('3 * 5') 9 11 15 10 sage: maple.eval('ifactor(2005)') # needs optional maple12 sage: maple.eval('ifactor(2005)') 11 13 '``(5)*``(401)' 12 sage: maple.ifactor(2005) # needs optional maple14 sage: maple.ifactor(2005) 13 15 ``(5)*``(401) 14 sage: maple.fsolve('x^2=cos(x)+4', 'x=0..5') # needs optional maple16 sage: maple.fsolve('x^2=cos(x)+4', 'x=0..5') 15 17 1.914020619 16 sage: maple.factor('x^5 - y^5') # needs optional maple18 sage: maple.factor('x^5 - y^5') 17 19 (x-y)*(x^4+x^3*y+x^2*y^2+x*y^3+y^4) 18 20 … … 20 22 output of anything from Maple, a RuntimeError exception is raised. 21 23 24 \subsection{Tutorial} 25 26 AUTHOR: 27 -- Gregg Musiker (2006-02-02): initial version. 28 29 30 This tutorial is based on the Maple Tutorial for number theory 31 from \url{http://www.math.mun.ca/~drideout/m3370/numtheory.html}. 32 33 There are several ways to use the Maple Interface in \SAGE. We will 34 discuss two of those ways in this tutorial. 35 36 \begin{enumerate} 37 \item If you have a maple expression such as 38 \begin{verbatim} 39 factor( (x^5-1)); 40 \end{verbatim} 41 We can write that in sage as 42 43 sage: maple('factor(x^5-1)') 44 (x-1)*(x^4+x^3+x^2+x+1) 45 46 Notice, there is no need to use a semicolon. 47 48 \item Since \SAGE is written in Python, we can also import maple 49 commands and write our scripts in a pythonic way. 50 For example, \code{factor()} is a maple command, so we can also factor 51 in \sage using 52 53 sage: maple('(x^5-1)').factor() 54 (x-1)*(x^4+x^3+x^2+x+1) 55 56 where \code{expression.command()} means the same thing as 57 \code{command(expression)} in Maple. We will use this second type of 58 syntax whenever possible, resorting to the first when needed. 59 60 sage: maple('(x^12-1)/(x-1)').simplify() 61 x^11+x^10+x^9+x^8+x^7+x^6+x^5+x^4+x^3+x^2+x+1 62 63 \end{enumerate} 64 65 The normal command will always reduce a rational function to the 66 lowest terms. The factor command will factor a polynomial with 67 rational coefficients into irreducible factors over the ring of 68 integers. So for example, 69 70 sage: maple('(x^12-1)').factor( ) 71 (x-1)*(x+1)*(x^2+x+1)*(x^2-x+1)*(x^2+1)*(x^4-x^2+1) 72 73 sage: maple('(x^28-1)').factor( ) 74 (x-1)*(x^6+x^5+x^4+x^3+x^2+x+1)*(x+1)*(1-x+x^2-x^3+x^4-x^5+x^6)*(x^2+1)*(x^12- 75 x^10+x^8-x^6+x^4-x^2+1) 76 77 78 Another important feature of maple is its online help. We can access 79 this through sage as well. After reading the description of the 80 command, you can press q to immediately get back to your original 81 prompt. 82 83 % NOTE: DOESN'T BRING UP NEW SCREEN IN SSH 84 85 Incidentally you can always get into a maple console by the command 86 87 sage.: maple.console() 88 sage.: !maple 89 90 Note that the above two commands are slightly different, and the first 91 is preferred. 92 93 For example, for help on the maple command fibonacci, we type 94 95 sage.: maple.help('fibonacci') 96 97 We see there are two choices. Type 98 99 sage.: maple.help('combinat, fibonacci') 100 101 We now see how the Maple command fibonacci works under the 102 combinatorics package. Try typing in 103 104 sage: maple.fibonacci(10) 105 fibonacci(10) 106 107 You will get fibonacci(10) as output since Maple has not loaded the combinatorics package yet. To rectify this type 108 109 sage: maple('combinat[fibonacci]')(10) 110 55 111 112 instead. 113 114 If you want to load the combinatorics package for future calculations, 115 in \sage this can be done as 116 117 sage: maple.with('combinat') 118 119 or 120 121 sage: maple.load('combinat') 122 123 Now if we type \code{maple.fibonacci(10)}, we get the correct output: 124 125 sage: maple.fibonacci(10) 126 55 127 128 Some common maple packages include \code{combinat}, \code{linalg}, and 129 \code{numtheory}. To produce the first 19 Fibonacci 130 numbers, use the sequence command. 131 132 sage: maple('seq(fibonacci(i),i=1..19)') 133 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 134 4181 135 136 Two other useful Maple commands are ifactor and isprime. For example 137 138 sage: maple.isprime(maple.fibonacci(27)) 139 false 140 sage: maple.ifactor(maple.fibonacci(27)) 141 ``(2)*``(17)*``(53)*``(109) 142 143 Note that the isprime function that is included with \sage (which uses 144 PARI) is better than the Maple one (it is faster and gives a provably 145 correct answer, whereas Maple is sometimes wrong). 146 147 sage: alpha = maple('(1+sqrt(5))/2') 148 sage: beta = maple('(1-sqrt(5))/2') 149 sage: f19 = alpha^19 - beta^19/maple('sqrt(5)') 150 sage: f19 151 (1/2+1/2*5^(1/2))^19-1/5*(1/2-1/2*5^(1/2))^19*5^(1/2) 152 sage: f19.simplify() 153 5778/5*5^(1/2)+6765 154 155 Let's say we want to write a maple program now that squares a number 156 if it is positive and cubes it if it is negative. In maple, that 157 would look like 158 159 \begin{verbatim} 160 mysqcu := proc(x) 161 if x > 0 then x^2; 162 else x^3; fi; 163 end; 164 \end{verbatim} 165 In SAGE, we write 166 167 sage: mysqcu = maple('proc(x) if x > 0 then x^2 else x^3 fi end') 168 sage: mysqcu(5) 169 25 170 sage: mysqcu(-5) 171 -125 172 173 More complicated programs should be put in a separate file and 174 loaded. 22 175 """ 23 176 … … 184 337 the appropriate package. 185 338 186 sage : maple('partition(10)')# optional339 sage.: maple('partition(10)') # optional 187 340 partition(10) 188 sage : maple('bell(10)')# optional341 sage.: maple('bell(10)') # optional 189 342 bell(10) 190 343 sage: maple.with('combinat') # optional 191 sage: maple('partition(10)') # optional 192 [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 2], [1, 1, 1, 1, 1,193 1, 2, 2], [1, 1, 1, 1, 2, 2, 2], [1, 1, 2, 2, 2, 2], [2, 2, 2, 2, 2], [1, 1, 1194 , 1, 1, 1, 1, 3], [1, 1, 1, 1, 1, 2, 3], [1, 1, 1, 2, 2, 3], [1, 2, 2, 2, 3],195 [1, 1, 1, 1, 3, 3], [1, 1, 2, 3, 3], [2, 2, 3, 3], [1, 3, 3, 3], [1, 1, 1, 1,196 1, 1, 4], [1, 1, 1, 1, 2, 4], [1, 1, 2, 2, 4], [2, 2, 2, 4], [1, 1, 1, 3, 4],197 [1, 2, 3, 4], [3, 3, 4], [1, 1, 4, 4], [2, 4, 4], [1, 1, 1, 1, 1, 5], [1, 1, 1198 , 2, 5], [1, 2, 2, 5], [1, 1, 3, 5], [2, 3, 5], [1, 4, 5], [5, 5], [1, 1, 1, 1199 , 6], [1, 1, 2, 6], [2, 2, 6], [1, 3, 6], [4, 6], [1, 1, 1, 7], [1, 2, 7], [3,200 7], [1, 1, 8], [2, 8], [1, 9], [10]]344 sage: maple('partition(10)') # optional 345 [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 2], [1, 1, 1, 1, 1, 346 1, 2, 2], [1, 1, 1, 1, 2, 2, 2], [1, 1, 2, 2, 2, 2], [2, 2, 2, 2, 2], [1, 1, 1 347 , 1, 1, 1, 1, 3], [1, 1, 1, 1, 1, 2, 3], [1, 1, 1, 2, 2, 3], [1, 2, 2, 2, 3], 348 [1, 1, 1, 1, 3, 3], [1, 1, 2, 3, 3], [2, 2, 3, 3], [1, 3, 3, 3], [1, 1, 1, 1, 349 1, 1, 4], [1, 1, 1, 1, 2, 4], [1, 1, 2, 2, 4], [2, 2, 2, 4], [1, 1, 1, 3, 4], 350 [1, 2, 3, 4], [3, 3, 4], [1, 1, 4, 4], [2, 4, 4], [1, 1, 1, 1, 1, 5], [1, 1, 1 351 , 2, 5], [1, 2, 2, 5], [1, 1, 3, 5], [2, 3, 5], [1, 4, 5], [5, 5], [1, 1, 1, 1 352 , 6], [1, 1, 2, 6], [2, 2, 6], [1, 3, 6], [4, 6], [1, 1, 1, 7], [1, 2, 7], [3, 353 7], [1, 1, 8], [2, 8], [1, 9], [10]] 201 354 sage: maple('bell(10)') # optional 202 355 115975 -
sage/interfaces/maxima.py
r0 r1 903 903 return self.comma('numer') 904 904 905 def real(self): 906 return self.realpart() 907 908 def imag(self): 909 return self.imagpart() 910 905 911 def str(self): 906 912 self._check_valid() -
sage/interfaces/singular.py
r0 r1 268 268 AUTHORS: David Joyner and William Stein 269 269 """ 270 def __init__(self, maxread=100000, script_subdirectory="user", logfile=None, server=None): 270 def __init__(self, maxread=1000, script_subdirectory="user", 271 logfile=None, server=None): 271 272 Expect.__init__(self, 272 273 name = 'singular', … … 279 280 verbose_start = False, 280 281 logfile = logfile, 281 eval_using_file_cutoff=100 )282 eval_using_file_cutoff=1000) 282 283 self.__libs = [] 283 284 … … 302 303 return '< "%s";'%filename 303 304 304 def __to_delete_xxx_eval_line(self, line, allow_use_file=True):305 def xxx_eval_line(self, line, allow_use_file=True): 305 306 if line.find('\n') != -1: 306 307 raise ValueError, "line must not contain any newlines" … … 313 314 E.expect('__SAGE_START__') 314 315 E.expect(self._prompt) 315 E.sendline(line )316 E.sendline(line+';') 316 317 E.sendline('"__SAGE_END__";') 317 318 E.expect('__SAGE_END__') … … 339 340 340 341 s = Expect.eval(self, x) 341 342 342 if s.find("error") != -1 or s.find("Segment fault") != -1: 343 343 raise RuntimeError, 'Singular error:\n%s'%s -
sage/misc/functional.py
r0 r1 37 37 from sage.libs.all import pari 38 38 39 import math40 41 39 ############################################################################## 42 40 # There are many functions on elements of a ring, which mathematicians … … 151 149 """ 152 150 try: return x.cos() 153 except AttributeError: return math.cos(float(x))151 except AttributeError: return R(x).cos() 154 152 155 153 ## def cuspidal_submodule(x): … … 265 263 """ 266 264 try: return x.exp() 267 except AttributeError: return math.exp(x)265 except AttributeError: return R(x).exp() 268 266 269 267 def factor(x, *args, **kwds): … … 516 514 3.3219280948873626 517 515 sage: log(8,2) 518 3.0 516 3.0000000000000000 519 517 sage: log(10) 520 518 2.3025850929940459 … … 525 523 try: return x.log() 526 524 except AttributeError: 527 #return math.log(x) 528 return float(pari(x).log()) 525 return R(x).log() 529 526 else: 530 527 try: return x.log(b) … … 572 569 573 570 EXAMPLES: 574 sage: z = CC(1+2*i)575 sage: norm(z)576 5.0000000000000000571 sage: z = CC(1+2*i) 572 sage: norm(z) 573 5.0000000000000000 577 574 """ 578 575 return x.norm() … … 583 580 584 581 EXAMPLES: 585 sage: R = PolynomialRing(RationalField(), 'x')586 sage: F = FractionField(R)587 sage: r = (x+1)/(x-1)588 sage: numerator(r)589 x + 1590 sage: numerator(17/11111)591 17582 sage: R = PolynomialRing(RationalField(), 'x') 583 sage: F = FractionField(R) 584 sage: r = (x+1)/(x-1) 585 sage: numerator(r) 586 x + 1 587 sage: numerator(17/11111) 588 17 592 589 """ 593 590 if isinstance(x, (int, long)): … … 637 634 638 635 EXAMPLES: 639 sage: C = CyclicPermutationGroup(10) 640 sage: order(C) 641 10 642 sage: F = GF(7) 643 sage: order(F) 644 7 645 636 sage: C = CyclicPermutationGroup(10) 637 sage: order(C) 638 10 639 sage: F = GF(7) 640 sage: order(F) 641 7 646 642 """ 647 643 return x.order() … … 652 648 653 649 EXAMPLES: 654 sage: M = MatrixSpace(QQ,3,3) 655 sage: A = M([1,2,3,4,5,6,7,8,9]) 656 sage: rank(A) 657 2 658 650 sage: M = MatrixSpace(QQ,3,3) 651 sage: A = M([1,2,3,4,5,6,7,8,9]) 652 sage: rank(A) 653 2 659 654 """ 660 655 return x.rank() … … 665 660 666 661 EXAMPLES: 667 sage: z = CC(1+2*i) 668 sage: real(z) 669 1.0000000000000000 670 662 sage: z = CC(1+2*i) 663 sage: real(z) 664 1.0000000000000000 671 665 """ 672 666 try: return x.real() … … 696 690 697 691 EXAMPLES: 698 sage: sqrt(10.1) 699 3.1780497164141406 700 sage: sqrt(9) 701 3.0000000000000000 702 692 sage: sqrt(10.1) 693 3.1780497164141406 694 sage: sqrt(9) 695 3 703 696 """ 704 697 try: return x.sqrt() … … 711 704 712 705 EXAMPLES: 713 sage: isqrt(10) 714 3 715 706 sage: isqrt(10) 707 3 716 708 """ 717 709 try: return x.isqrt() … … 724 716 """ 725 717 try: return x.sin() 726 except AttributeError: return math.sin(float(x))718 except AttributeError: return R(x).sin() 727 719 728 720 def square_free_part(x): … … 769 761 770 762 EXAMPLES: 771 sage: square_root(9) 772 3 773 sage: square_root(100) 774 10 775 763 sage: square_root(9) 764 3 765 sage: square_root(100) 766 10 776 767 """ 777 768 try: … … 785 776 786 777 EXAMPLES: 787 sage: tan(3.1415) 788 -0.000092653590058635411 789 sage: tan(3.1415/4) 790 0.99995367427815607 791 778 sage: tan(3.1415) 779 -0.000092653590058635411 780 sage: tan(3.1415/4) 781 0.99995367427815607 792 782 """ 793 783 try: return x.tan() 794 except AttributeError: return math.tan(float(x))784 except AttributeError: return R(x).tan() 795 785 796 786 def transpose(x): 797 787 """ 798 788 EXAMPLES: 799 sage: M = MatrixSpace(QQ,3,3) 800 sage: A = M([1,2,3,4,5,6,7,8,9]) 801 sage: transpose(A) 802 [1 4 7] 803 [2 5 8] 804 [3 6 9] 805 789 sage: M = MatrixSpace(QQ,3,3) 790 sage: A = M([1,2,3,4,5,6,7,8,9]) 791 sage: transpose(A) 792 [1 4 7] 793 [2 5 8] 794 [3 6 9] 806 795 """ 807 796 return x.transpose() … … 823 812 824 813 EXAMPLES: 825 sage: R = PolynomialRing(RationalField(), 'x')826 sage: zero(R) in R827 True828 sage: zero(R)*x == zero(R)829 True814 sage: R = PolynomialRing(RationalField(), 'x') 815 sage: zero(R) in R 816 True 817 sage: zero(R)*x == zero(R) 818 True 830 819 """ 831 820 return R(0) -
sage/rings/all.py
r0 r1 116 116 117 117 # Arithmetic 118 from arith import * 119 from arith import factor as integer_factor 120 118 from arith import * 121 119 122 120 from morphism import is_RingHomomorphism -
sage/rings/arith.py
r0 r1 834 834 835 835 def mqrr_rational_reconstruction(u, m, T): 836 """Maximal Quotient Rational Reconstruction. 836 """ 837 Maximal Quotient Rational Reconstruction. 837 838 838 839 Input: -
sage/rings/fraction_field.py
r0 r1 84 84 85 85 def base_ring(self): 86 return self.__R.base_ring() 86 return self.__R.base_ring().fraction_field() 87 87 88 88 def characteristic(self): -
sage/rings/laurent_series_ring.py
r0 r1 155 155 return self.__power_series_ring 156 156 157 class LaurentSeriesRing_domain( integral_domain.IntegralDomain, LaurentSeriesRing_generic):157 class LaurentSeriesRing_domain(LaurentSeriesRing_generic, integral_domain.IntegralDomain): 158 158 def __init__(self, base_ring, name=None): 159 159 LaurentSeriesRing_generic.__init__(self, base_ring, name) … … 166 166 return self.__fraction_field 167 167 168 class LaurentSeriesRing_field( field.Field, LaurentSeriesRing_generic):168 class LaurentSeriesRing_field(LaurentSeriesRing_generic, field.Field): 169 169 def __init__(self, base_ring, name=None): 170 170 LaurentSeriesRing_generic.__init__(self, base_ring, name) -
sage/rings/multi_polynomial_element.py
r0 r1 95 95 y = K(0) 96 96 for (m,c) in self.element().dict().iteritems(): 97 y += K(c)*misc.mul([ x[i]**m[i] for i in range(n) ])97 y += c*misc.mul([ x[i]**m[i] for i in range(n) ]) 98 98 return y 99 99 … … 750 750 751 751 def factor(self): 752 """752 r""" 753 753 Compute the irreducible factorization of this polynomial. 754 754 755 755 ALGORITHM: Use Singular. 756 756 757 757 EXAMPLES: 758 758 sage: x, y = PolynomialRing(QQ, 2, ['x','y']).gens() … … 771 771 sage: F 772 772 2 * x * (2 + x)^2 * (y + x) * (y + 2*x) 773 774 Next we factor a larger product involving many variables. 775 sage: 773 776 """ 774 777 R = self.parent() -
sage/rings/multi_polynomial_ideal.py
r0 r1 9 9 sage: I = ideal(x^5 + y^4 + z^3 - 1, x^3 + y^3 + z^2 - 1) 10 10 sage: B = I.groebner_basis() 11 sage: B[0]12 5*z^2 - 3*z^3 - 10*z^4 + 13*z^6 - 5*z^8 - z^9 + z^10 + 5*y^3 - 20*y^3*z^2 + 30*y^3*z^4 - 20*y^3*z^6 + 5*y^3*z^8 - 3*y^4 + 6*y^4*z^3 - 3*y^4*z^6 - 10*y^6 + 30*y^6*z^2 - 30*y^6*z^4 + 10*y^6*z^6 + 3*y^8 - 3*y^8*z^3 + 10*y^9 - 20*y^9*z^2 + 10*y^9*z^4 - 6*y^12 + 5*y^12*z^2 + y^1513 11 sage: len(B) 14 12 8 … … 27 25 x^2 28 26 27 We compute a Groebner basis for cyclic 6, which is a standard 28 benchmark and test ideal. 29 30 sage: x,y,z,t,u,v = QQ['x,y,z,t,u,v'].gens() 31 sage: I = ideal(x + y + z + t + u + v, x*y + y*z + z*t + t*u + u*v + v*x, x*y*z + y*z*t + z*t*u + t*u*v + u*v*x + v*x*y, x*y*z*t + y*z*t*u + z*t*u*v + t*u*v*x + u*v*x*y + v*x*y*z, x*y*z*t*u + y*z*t*u*v + z*t*u*v*x + t*u*v*x*y + u*v*x*y*z + v*x*y*z*t, x*y*z*t*u*v - 1) 32 sage: B = I.groebner_basis() 33 sage: len(B) 34 17 29 35 """ 30 36 … … 232 238 Ideal (d + c + b + a, -1 + a*b*c*d, c*d + b*c + a*d + a*b, b*c*d + a*c*d + a*b*d + a*b*c) of Polynomial Ring in a, b, c, d over Rational Field 233 239 sage: I.groebner_basis() 234 [ 1 - d^4 - c^2*d^2 + c^2*d^6,235 -1*d - c + c^2*d^3 + c^3*d^2,236 -1*d + d^5 - b + b*d^4,237 -1*d^2 - d^6 + c*d + c^2*d^4 - b*d^5 + b*c,238 d ^2 + 2*b*d + b^2,239 d + c + b + a]240 [d^2 + 2*b*d + b^2, 241 1 - d^4 - c^2*d^2 + c^2*d^6, 242 -1*d + d^5 - b + b*d^4, 243 -1*d - c + c^2*d^3 + c^3*d^2, 244 d + c + b + a, 245 -1*d^2 - d^6 + c*d + c^2*d^4 - b*d^5 + b*c] 240 246 """ 241 247 try: -
sage/rings/multi_polynomial_ring.py
r0 r1 295 295 return multi_polynomial_element.MPolynomial_polydict(self, {self._zero_tuple:c}) 296 296 297 class MPolynomialRing_polydict_domain( MPolynomialRing_polydict, integral_domain.IntegralDomain):297 class MPolynomialRing_polydict_domain(integral_domain.IntegralDomain, MPolynomialRing_polydict): 298 298 pass 299 299 -
sage/schemes/elliptic_curves/ell_rational_field.py
r0 r1 330 330 as a small divisor of the order is detected. 331 331 332 \note{As of 2006-02-02 this function does not work on 333 Microsoft Windows.} 334 332 335 EXAMPLES: 333 336 sage: E = EllipticCurve('37a') … … 627 630 """ 628 631 if self.torsion_order() % 2 == 0: 629 raise ArithmeticError, "curve must not have rational 2-torsion "632 raise ArithmeticError, "curve must not have rational 2-torsion\nThe *only* reason for this is that I haven't finished implementing the wrapper\nin this case. It wouldn't be too difficult.\nPerhaps you could do it?! Email me (wstein@ucsd.edu)." 630 633 F = self.weierstrass_model() 631 634 a1,a2,a3,a4,a6 = F.a_invariants() … … 670 673 if not only_use_mwrank: 671 674 N = self.conductor() 672 prec = int(4* sqrt(N)) + 10675 prec = int(4*float(sqrt(N))) + 10 673 676 if self.root_number() == 1: 674 677 L, err = self.Lseries_at1(prec) … … 1173 1176 if self.root_number() == -1: 1174 1177 return 0 1175 sqrtN = self.conductor().sqrt()1178 sqrtN = float(self.conductor().sqrt()) 1176 1179 k = int(k) 1177 1180 if k == 0: k = int(math.ceil(sqrtN)) … … 1230 1233 if self.root_number() == 1: return 0 1231 1234 k = int(k) 1232 sqrtN = self.conductor().sqrt()1235 sqrtN = float(self.conductor().sqrt()) 1233 1236 if k == 0: k = int(math.ceil(sqrtN)) 1234 1237 an = self.anlist(k) # list of C ints … … 1283 1286 a = self.anlist(prec) 1284 1287 eps = self.root_number() 1285 sqrtN = arith.sqrt(N)1288 sqrtN = float(arith.sqrt(N)) 1286 1289 def F(n, t): 1287 1290 return Gamma_inc(t+1, 2*pi*n/sqrtN) * C(sqrtN/(2*pi*n))**(t+1) … … 1311 1314 a = self.anlist(prec) 1312 1315 eps = self.root_number() 1313 sqrtN = arith.sqrt(N)1316 sqrtN = float(arith.sqrt(N)) 1314 1317 def F(n, t): 1315 1318 return Gamma_inc(t+1, 2*pi*n/sqrtN) * C(sqrtN/(2*pi*n))**(t+1) … … 2387 2390 ind2 = ht/(h/2) 2388 2391 misc.verbose("index squared = %s"%ind2) 2389 ind = ind2.sqrt()2392 ind = float(ind2.sqrt()) 2390 2393 misc.verbose("index = %s"%ind) 2391 2394 # Compute upper bound on square root of index. -
sage/schemes/generic/algebraic_scheme.py
r0 r1 185 185 return self._coordinate_ring 186 186 except AttributeError: 187 R = self.__A.coordinate_ring() 187 try: 188 R = self.__A.coordinate_ring() 189 except AttributeError: 190 raise NotImplementedError, "computation of coordinate ring of %s not implmented"%self 188 191 if len(self.__X) == 0: 189 192 Q = R -
sage/schemes/generic/divisor.py
r0 r1 94 94 3*(0 : 0 : 1) - 4*(1/4 : -5/8 : 1) 95 95 """ 96 def __init__(self, v, check=True, reduce=True ):96 def __init__(self, v, check=True, reduce=True, parent=None): 97 97 """ 98 98 INPUT: … … 114 114 else: 115 115 C = v[0][1].scheme() 116 116 117 if check: 117 118 w = [] … … 123 124 v = w 124 125 126 if parent is None: 127 parent = DivisorGroup(C) 128 125 129 Divisor_generic.__init__(self, v, check=False, reduce=True, 126 parent = DivisorGroup(C))130 parent = parent) 127 131 128 132 -
sage/schemes/generic/homset.py
r0 r1 49 49 """ 50 50 EXAMPLES: 51 sage: f = Z .hom(Q); f51 sage: f = ZZ.hom(QQ); f 52 52 Coercion morphism: 53 53 From: Integer Ring 54 54 To: Rational Field 55 55 56 sage: H = Hom(Spec(Q ), Spec(Z)); H56 sage: H = Hom(Spec(QQ, ZZ), Spec(ZZ)); H 57 57 Set of points of Spectrum of Integer Ring defined over Rational Field 58 58 -
sage/schemes/generic/spec.py
r0 r1 76 76 raise TypeError, "R (=%s) must be a commutative ring"%R 77 77 self.__R = R 78 if not S is None: 79 if not is_CommutativeRing(S): 80 raise TypeError, "S (=%s) must be a commutative ring"%S 81 try: 82 S.hom(R) 83 except TypeError: 84 raise ValueError, "There must be a natural map S --> R, but S = %s and R = %s"%(S,R) 85 self._base_ring = S 78 if S is None: 79 if R == Z: 80 return 81 else: 82 S = R.base_ring() 83 if not is_CommutativeRing(S): 84 raise TypeError, "S (=%s) must be a commutative ring"%S 85 try: 86 S.hom(R) 87 except TypeError: 88 raise ValueError, "There must be a natural map S --> R, but S = %s and R = %s"%(S,R) 89 self._base_ring = S 86 90 87 91 def _cmp_(self, X): -
sage/schemes/plane_curves/affine_curve.py
r0 r1 148 148 b = ["c["+str(i)+",1]," for i in range(2,N/2-4)] 149 149 b = ''.join(b) 150 b = b[:len(b)-1] # to cut off the trailing comma150 b = b[:len(b)-1] # to cut off the trailing comma 151 151 cmd = 'ideal I = '+b 152 152 S.eval(cmd) 153 S.eval('short=0') # print using *'s and ^'s. 153 154 c = S.eval('slimgb(I)') 154 155 d = c.split("=") -
sage/schemes/plane_curves/projective_curve.py
r0 r1 298 298 sage: C = Curve(f); pts = C.rational_points() 299 299 sage: D = C.divisor([ (3, pts[0]), (-1,pts[1]), (10, pts[5]) ]) 300 sage: C.riemann_roch_basis(D) # output is somewhat random300 sage: C.riemann_roch_basis(D) # output is random (!!!!) 301 301 [x/(y + x), (z + y)/(y + x)] 302 302 303 \note{The Brill-Noether package does not always work (i.e., the 'bn'304 algorithm. When it fails a RuntimeError exception is raised.}303 \note{The Brill-Noether package does not always work (i.e., 304 the 'bn' algorithm. Do *not* trust this.} 305 305 """ 306 306 f = self.defining_polynomial()._singular_() -
sage/structure/formal_sum.py
r0 r1 23 23 24 24 from sage.ext.element import AdditiveGroupElement 25 from sage.ext.group import AbelianGroup 26 27 class FormalSums(AbelianGroup): 28 def _repr_(self): 29 return "Abelian Group of all Formal Finite Sums" 30 31 formal_sums = FormalSums() 25 32 26 33 class FormalSum(AdditiveGroupElement, list): 27 def __init__(self, x, check=True, reduce=True, parent=None):34 def __init__(self, x, parent=None, check=True, reduce=True): 28 35 if x == 0: 29 36 x = [] … … 33 40 raise TypeError, "Invalid formal sum" 34 41 list.__init__(self, x) 35 if not parent is None: 36 AdditiveGroupElement.__init__(self, parent) 42 if parent is None: 43 parent = formal_sums 44 AdditiveGroupElement.__init__(self, parent) 37 45 self.reduce() 38 46 … … 48 56 49 57 def _add_(self, other): 50 return self.__class__(list.__add__(self,other) )58 return self.__class__(list.__add__(self,other), parent=self.parent()) 51 59 52 60 def __mul__(self, s): 53 return self.__class__([(c*s, x) for c,x in self], check=False )61 return self.__class__([(c*s, x) for c,x in self], check=False, parent=self.parent()) 54 62 55 63 def __rmul__(self, s): 56 return self.__class__([(s*c, x) for c,x in self] )64 return self.__class__([(s*c, x) for c,x in self], parent=self.parent()) 57 65 58 66 def reduce(self): -
sage/version.py
r0 r1 1 version='0.10.1 2'; date='2006-01-30-0901'1 version='0.10.13'; date='2006-02-03-0358'
Note: See TracChangeset
for help on using the changeset viewer.
