Ticket #10837: trac_10837-norms-condition-CDF-edits-v3.patch

File trac_10837-norms-condition-CDF-edits-v3.patch, 4.7 KB (added by rbeezer, 12 years ago)
• sage/geometry/polyhedra.py

# HG changeset patch
# User Rob Beezer <beezer@ups.edu>
# Date 1298569016 28800
# Node ID eba750e5aeda14b399910b9ef8f60f175779bcda
# Parent  dd733faf1a55ee26d532961cd6e6b0b78351a099
10837: norms, condition number edits

diff -r dd733faf1a55 -r eba750e5aeda sage/geometry/polyhedra.py
 a sage: cube = polytopes.n_cube(3).vertices() sage: proj = ProjectionFuncStereographic([1.1,1.1,1.1]) sage: ppoints = [proj(vector(x)) for x in cube] sage: ppoints[0] (0.0, 0.0) sage: ppoints[1] (-0.3182829598..., 1.18784817...) """ def __init__(self, projection_point): """
• sage/matrix/matrix2.pyx

diff -r dd733faf1a55 -r eba750e5aeda sage/matrix/matrix2.pyx
 a Faster routines for double precision entries from RDF or CDF are provided by the :class:~sage.matrix.matrix_double_dense.Matrix_double_dense class.  :: sage: A = matrix(RR, 2, 3, [3*I,4,1-I,1,2,0]) sage: A = matrix(CC, 2, 3, [3*I,4,1-I,1,2,0]) sage: A.norm('frob') 5.65685424949 sage: A.norm(2)
• sage/matrix/matrix_double_dense.pyx

diff -r dd733faf1a55 -r eba750e5aeda sage/matrix/matrix_double_dense.pyx
 a \left(\sum_{i,j}\left\lvert{a_{i,j}}\right\rvert^2\right)^{1/2} - p = Infinity or p = oo: the maximum row sum. - p = -Infinity or p = -oo: the minimum colum sum. - p = -Infinity or p = -oo: the minimum column sum. - p = 1: the maximum column sum. - p = -1: the minimum column sum. - p = 2: the 2-norm, equal to the maximum singular value. Traceback (most recent call last): ... ValueError: condition number integer values of 'p' must be -2, -1, 1 or 2, not 632 TESTS: Some condition numbers, first by the definition which also exercises :meth:norm, then by this method.  :: sage: A = matrix(CDF, [[1,2,4],[5,3,9],[7,8,6]]) sage: c = A.norm(2)*A.inverse().norm(2) sage: d = A.condition(2) sage: abs(c-d) < 1.0e-14 True sage: c = A.norm(1)*A.inverse().norm(1) sage: d = A.condition(1) sage: abs(c-d) < 1.0e-14 True """ if not self.is_square(): raise TypeError("matrix must be square, not %s x %s" % (self.nrows(), self.ncols())) p = sage.rings.integer.Integer(p) except: raise ValueError("condition number 'p' must be +/- infinity, 'frob' or an integer, not %s" % p) if not p in [-2,-1,1,2]: if p not in [-2,-1,1,2]: raise ValueError("condition number integer values of 'p' must be -2, -1, 1 or 2, not %s" % p) # may raise a LinAlgError if matrix is singular c = numpy.linalg.cond(self._matrix_numpy, p=p) \left(\sum_{i,j}\left\lvert{a_{i,j}}\right\rvert^2\right)^{1/2} - p = Infinity or p = oo: the maximum row sum. - p = -Infinity or p = -oo: the minimum colum sum. - p = -Infinity or p = -oo: the minimum column sum. - p = 1: the maximum column sum. - p = -1: the minimum column sum. - p = 2: the 2-norm, equal to the maximum singular value. sage: abs(f-s) < 1.0e-12 True Return values are in RDF. Return values are in RDF. :: sage: A = matrix(CDF, 2, range(4)) sage: A.norm() in RDF
• sage/modules/vector_double_dense.pyx

diff -r dd733faf1a55 -r eba750e5aeda sage/modules/vector_double_dense.pyx
 a OUTPUT: Returned values is a double precision floating point value in RDF (or an integer when p=0.  The default value Returned value is a double precision floating point value in RDF (or an integer when p=0).  The default value of p = 2 is the "usual" Euclidean norm.  For other values: - p = Infinity or p = oo: the maximum of the