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 b  
    49454945        sage: cube = polytopes.n_cube(3).vertices()
    49464946        sage: proj = ProjectionFuncStereographic([1.1,1.1,1.1])
    49474947        sage: ppoints = [proj(vector(x)) for x in cube]
    4948         sage: ppoints[0]
    4949         (0.0, 0.0)
     4948        sage: ppoints[1]
     4949        (-0.3182829598..., 1.18784817...)
    49504950    """
    49514951    def __init__(self, projection_point):
    49524952        """
  • sage/matrix/matrix2.pyx

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

    diff -r dd733faf1a55 -r eba750e5aeda sage/matrix/matrix_double_dense.pyx
    a b  
    579579                \left(\sum_{i,j}\left\lvert{a_{i,j}}\right\rvert^2\right)^{1/2}
    580580
    581581        - ``p = Infinity`` or ``p = oo``: the maximum row sum.
    582         - ``p = -Infinity`` or ``p = -oo``: the minimum colum sum.
     582        - ``p = -Infinity`` or ``p = -oo``: the minimum column sum.
    583583        - ``p = 1``: the maximum column sum.
    584584        - ``p = -1``: the minimum column sum.
    585585        - ``p = 2``: the 2-norm, equal to the maximum singular value.
     
    683683            Traceback (most recent call last):
    684684            ...
    685685            ValueError: condition number integer values of 'p' must be -2, -1, 1 or 2, not 632
     686
     687        TESTS:
     688
     689        Some condition numbers, first by the definition which also exercises
     690        :meth:`norm`, then by this method.  ::
     691
     692            sage: A = matrix(CDF, [[1,2,4],[5,3,9],[7,8,6]])
     693            sage: c = A.norm(2)*A.inverse().norm(2)
     694            sage: d = A.condition(2)
     695            sage: abs(c-d) < 1.0e-14
     696            True
     697            sage: c = A.norm(1)*A.inverse().norm(1)
     698            sage: d = A.condition(1)
     699            sage: abs(c-d) < 1.0e-14
     700            True
    686701        """
    687702        if not self.is_square():
    688703            raise TypeError("matrix must be square, not %s x %s" % (self.nrows(), self.ncols()))
     
    703718                p = sage.rings.integer.Integer(p)
    704719            except:
    705720                raise ValueError("condition number 'p' must be +/- infinity, 'frob' or an integer, not %s" % p)
    706             if not p in [-2,-1,1,2]:
     721            if p not in [-2,-1,1,2]:
    707722                raise ValueError("condition number integer values of 'p' must be -2, -1, 1 or 2, not %s" % p)
    708723        # may raise a LinAlgError if matrix is singular
    709724        c = numpy.linalg.cond(self._matrix_numpy, p=p)
     
    740755                \left(\sum_{i,j}\left\lvert{a_{i,j}}\right\rvert^2\right)^{1/2}
    741756
    742757        - ``p = Infinity`` or ``p = oo``: the maximum row sum.
    743         - ``p = -Infinity`` or ``p = -oo``: the minimum colum sum.
     758        - ``p = -Infinity`` or ``p = -oo``: the minimum column sum.
    744759        - ``p = 1``: the maximum column sum.
    745760        - ``p = -1``: the minimum column sum.
    746761        - ``p = 2``: the 2-norm, equal to the maximum singular value.
     
    809824            sage: abs(f-s) < 1.0e-12
    810825            True
    811826
    812         Return values are in `RDF`.
     827        Return values are in `RDF`. ::
    813828
    814829            sage: A = matrix(CDF, 2, range(4))
    815830            sage: A.norm() in RDF
  • sage/modules/vector_double_dense.pyx

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