# HG changeset patch
# User Rob Beezer <beezer@ups.edu>
# Date 1298569016 28800
# Node ID 3fc398e3f07f6da7f4de83e52a55311953b31c31
# Parent 4af0dfe0fc6673789d1dcb658021db54884cafe6
10837: norms, condition number edits
diff -r 4af0dfe0fc66 -r 3fc398e3f07f sage/geometry/polyhedra.py
a
|
b
|
|
4945 | 4945 | sage: cube = polytopes.n_cube(3).vertices() |
4946 | 4946 | sage: proj = ProjectionFuncStereographic([1.1,1.1,1.1]) |
4947 | 4947 | 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...) |
4950 | 4950 | """ |
4951 | 4951 | def __init__(self, projection_point): |
4952 | 4952 | """ |
diff -r 4af0dfe0fc66 -r 3fc398e3f07f sage/matrix/matrix2.pyx
a
|
b
|
|
6869 | 6869 | Faster routines for double precision entries from `RDF` or `CDF` are provided by |
6870 | 6870 | the :class:`~sage.matrix.matrix_double_dense.Matrix_double_dense` class. :: |
6871 | 6871 | |
6872 | | sage: A = matrix(RR, 2, 3, [3*I,4,1-I,1,2,0]) |
| 6872 | sage: A = matrix(CC, 2, 3, [3*I,4,1-I,1,2,0]) |
6873 | 6873 | sage: A.norm('frob') |
6874 | 6874 | 5.65685424949 |
6875 | 6875 | sage: A.norm(2) |
diff -r 4af0dfe0fc66 -r 3fc398e3f07f sage/matrix/matrix_double_dense.pyx
a
|
b
|
|
683 | 683 | Traceback (most recent call last): |
684 | 684 | ... |
685 | 685 | 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 |
686 | 701 | """ |
687 | 702 | if not self.is_square(): |
688 | 703 | raise TypeError("matrix must be square, not %s x %s" % (self.nrows(), self.ncols())) |
… |
… |
|
703 | 718 | p = sage.rings.integer.Integer(p) |
704 | 719 | except: |
705 | 720 | 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]: |
707 | 722 | raise ValueError("condition number integer values of 'p' must be -2, -1, 1 or 2, not %s" % p) |
708 | 723 | # may raise a LinAlgError if matrix is singular |
709 | 724 | c = numpy.linalg.cond(self._matrix_numpy, p=p) |
… |
… |
|
809 | 824 | sage: abs(f-s) < 1.0e-12 |
810 | 825 | True |
811 | 826 | |
812 | | Return values are in `RDF`. |
| 827 | Return values are in `RDF`. :: |
813 | 828 | |
814 | 829 | sage: A = matrix(CDF, 2, range(4)) |
815 | 830 | sage: A.norm() in RDF |
diff -r 4af0dfe0fc66 -r 3fc398e3f07f sage/modules/vector_double_dense.pyx
a
|
b
|
|
585 | 585 | |
586 | 586 | OUTPUT: |
587 | 587 | |
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 |
590 | 590 | of ``p = 2`` is the "usual" Euclidean norm. For other values: |
591 | 591 | |
592 | 592 | - ``p = Infinity`` or ``p = oo``: the maximum of the |