Ticket #13393: combined.patch
File combined.patch, 3.1 KB (added by , 7 years ago) 


sage/modules/free_module_element.pyx
# HG changeset patch # User Eviatar Bach <eviatarbach@gmail.com> # Date 1356684325 28800 # Node ID 7a7a592adc31337ff132997b899bb45be2ad4f01 # Parent 33242a07d2ab0920994f3125881c78458b96181b * * * Trac 13393: new 'normalized' method for vectors, deprecating 'normalize' * * * Trac 13393: proper deprecation * * * Trac 13393: Docstring and doctest for .normalize() diff git a/sage/modules/free_module_element.pyx b/sage/modules/free_module_element.pyx
a b 2500 2500 self[i] = x 2501 2501 2502 2502 2503 def normalize(self):2503 def monic(self): 2504 2504 """ 2505 2505 Return this vector divided through by the first nonzero entry of 2506 2506 this vector. 2507 2507 2508 2508 EXAMPLES:: 2509 2509 2510 sage: v = vector(QQ, [0,4/3,5,1,2])2511 sage: v. normalize()2510 sage: v = vector(QQ, [0, 4/3, 5, 1, 2]) 2511 sage: v.monic() 2512 2512 (0, 1, 15/4, 3/4, 3/2) 2513 2513 """ 2514 2514 cdef Py_ssize_t i … … 2517 2517 return (~self[i]) * self 2518 2518 return self 2519 2519 2520 def normalize(self): 2521 """ 2522 This function is deprecated. For division by the pnorm use 2523 'normalized', and for division by the first nonzero entry use 2524 'monic' (previously the purpose of this function). 2525 2526 EXAMPLES:: 2527 2528 sage: v = vector(QQ, [0, 4/3, 5, 1, 2]) 2529 sage: v.normalize() 2530 doctest:...: DeprecationWarning: 'normalize' is deprecated... 2531 (0, 1, 15/4, 3/4, 3/2) 2532 """ 2533 from sage.misc.superseded import deprecation 2534 deprecation(13393, "'normalize' is deprecated. For division by the \ 2535 pnorm use 'normalized', and for division by the first nonzero entry use \ 2536 'monic'.") 2537 return self.monic() 2538 2539 def normalized(self, p=sage.rings.integer.Integer(2)): 2540 """ 2541 Return the input vector divided by the pnorm. 2542 2543 INPUT: 2544 2545 * "p"  default: 2  p value for the norm 2546 2547 EXAMPLES:: 2548 2549 sage: v = vector(QQ, [4, 1, 3, 2]) 2550 sage: v.normalized() 2551 (2/15*sqrt(30), 1/30*sqrt(30), 1/10*sqrt(30), 1/15*sqrt(30)) 2552 sage: sum(v.normalized(1)) 2553 1 2554 2555 Note that normalizing the vector may change the base ring:: 2556 2557 sage: v.base_ring() == v.normalized().base_ring() 2558 False 2559 sage: u = vector(RDF, [3, 4, 6, 9]) 2560 sage: u.base_ring() == u.normalized().base_ring() 2561 True 2562 """ 2563 return self / self.norm(p) 2564 2520 2565 def conjugate(self): 2521 2566 r""" 2522 2567 Returns a vector where every entry has been replaced by its complex conjugate. … … 2574 2619 sage: I*(x  x.conjugate()) in RDF^n 2575 2620 True 2576 2621 2577 The parent of the conjugate is the same as that of the or ginal vector.2622 The parent of the conjugate is the same as that of the original vector. 2578 2623 We test this by building a specialized vector space with a nonstandard 2579 2624 inner product, and constructing a test vector in this space. :: 2580 2625