Changeset 7456:f60ec7365b2b
- Timestamp:
- 12/01/07 10:48:42 (6 years ago)
- Branch:
- default
- Parents:
- 7454:0cb746e1a4bd (diff), 7455:3eda63e6eb1a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Files:
-
- 2 edited
-
sage/rings/arith.py (modified) (3 diffs)
-
sage/rings/arith.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sage/rings/arith.py
r7453 r7456 385 385 def valuation(m, p): 386 386 """ 387 The exact power of p>0 that divides the integer m. 388 We do not require that p be prime, and if m is 0, 389 then this function returns rings.infinity. 390 391 EXAMPLES:: 392 387 The exact power of p that divides m. 388 389 m should be an integer or rational (but maybe other types 390 work too.) 391 392 This actually just calls the m.valuation() method. 393 394 If m is 0, this function returns rings.infinity. 395 396 EXAMPLES: 393 397 sage: valuation(512,2) 394 398 9 395 399 sage: valuation(1,2) 396 400 0 397 398 Valuation of 0 is defined, but valuation with respect to 0 is not:: 399 401 sage: valuation(5/9, 3) 402 -2 403 404 Valuation of 0 is defined, but valuation with respect to 0 is not: 400 405 sage: valuation(0,7) 401 406 +Infinity … … 403 408 Traceback (most recent call last): 404 409 ... 405 ValueError: valuation at 0 not defined 406 407 Here are some other example:: 408 410 ValueError: You can only compute the valuation with respect to a integer larger than 1. 411 412 Here are some other examples: 409 413 sage: valuation(100,10) 410 414 2 … … 418 422 1 419 423 """ 420 if p <= 0: 421 raise ValueError, "valuation at 0 not defined" 422 if m == 0: 423 import sage.rings.all 424 return sage.rings.all.infinity 425 r=0 426 power=p 427 while m%power==0: 428 r += 1 429 power *= p 430 return r 424 return m.valuation(p) 431 425 432 426 -
sage/rings/arith.py
r7455 r7456 281 281 r""" 282 282 Returns True if $x$ is prime, and False otherwise. The result 283 is proven correct -- {\emthis is NOT a pseudo-primality test!}.283 is proven correct -- \emph{this is NOT a pseudo-primality test!}. 284 284 285 285 INPUT: … … 317 317 r""" 318 318 Returns True if $x$ is a pseudo-prime, and False otherwise. The result 319 is \em {NOT} proven correct -- {\emthis is a pseudo-primality test!}.319 is \emph{NOT} proven correct -- \emph{this is a pseudo-primality test!}. 320 320 321 321 INPUT: … … 353 353 r""" 354 354 Returns True if $x$ is a prime power, and False otherwise. 355 The result is proven correct -- {\emthis is NOT a355 The result is proven correct -- \emph{this is NOT a 356 356 pseudo-primality test!}. 357 357 … … 1524 1524 The qsieve and ecm commands give access to highly optimized 1525 1525 implementations of algorithms for doing certain integer 1526 factorization problems. These implementation are not used by1526 factorization problems. These implementations are not used by 1527 1527 the generic factor command, which currently just calls PARI 1528 1528 (note that PARI also implements sieve and ecm algorithms, but … … 2386 2386 [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1] 2387 2387 sage: continued_fraction_list(sqrt(4/19)) 2388 [0, 2, 5, 1, 1, 2, 1, 16, 1, 2, 1, 1, 5, 4, 5, 1, 1, 2, 1, 1 8]2388 [0, 2, 5, 1, 1, 2, 1, 16, 1, 2, 1, 1, 5, 4, 5, 1, 1, 2, 1, 15, 2] 2389 2389 sage: continued_fraction_list(RR(pi), partial_convergents=True) 2390 2390 ([3, 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 3],
Note: See TracChangeset
for help on using the changeset viewer.
