Ticket #13290: 13290_mpc_1_0.patch

File 13290_mpc_1_0.patch, 38.7 KB (added by jdemeyer, 10 years ago)

Patch for the Sage library

  • doc/en/developer/producing_spkgs.rst

    # HG changeset patch
    # User Jeroen Demeyer <jdemeyer@cage.ugent.be>
    # Date 1343383018 -7200
    # Node ID 69b752a001c262d96d94934778ba16981c01b393
    # Parent  698ec14c513f99fa5a3a7aeca982cc14fd249a89
    Upgrade to mpc-1.0.
    
    diff --git a/doc/en/developer/producing_spkgs.rst b/doc/en/developer/producing_spkgs.rst
    a b  
    194194The ``spkg-install`` script should copy your files to the appropriate
    195195place after doing any build that is necessary.  Here is a template::
    196196
    197        #!/usr/bin/env bash
     197    #!/usr/bin/env bash
    198198
    199        if [ -z "$SAGE_LOCAL" ]; then
    200            echo >&2 "SAGE_LOCAL undefined ... exiting"
    201            echo >&2 "Maybe run 'sage --sh'?"
    202            exit 1
    203        fi
     199    if [ -z "$SAGE_LOCAL" ]; then
     200        echo >&2 "SAGE_LOCAL undefined ... exiting"
     201        echo >&2 "Maybe run 'sage --sh'?"
     202        exit 1
     203    fi
    204204
    205        cd src
     205    cd src
    206206
    207        # Apply patches.  See SPKG.txt for information about what each patch
    208        # does.
    209        for patch in ../patches/*.patch; do
    210            patch -p1 <"$patch"
    211            if [ $? -ne 0 ]; then
    212                echo >&2 "Error applying '$patch'"
    213                exit 1
    214            fi
    215        done
     207    # Apply patches.  See SPKG.txt for information about what each patch
     208    # does.
     209    for patch in ../patches/*.patch; do
     210        [ -r "$patch" ] || continue  # Skip non-existing or non-readable patches
     211        patch -p1 <"$patch"
     212        if [ $? -ne 0 ]; then
     213            echo >&2 "Error applying '$patch'"
     214            exit 1
     215        fi
     216    done
    216217
    217        ./configure --prefix="$SAGE_LOCAL"
    218        if [ $? -ne 0 ]; then
    219            echo >&2 "Error configuring PACKAGE_NAME."
    220            exit 1
    221        fi
     218    ./configure --prefix="$SAGE_LOCAL"
     219    if [ $? -ne 0 ]; then
     220        echo >&2 "Error configuring PACKAGE_NAME."
     221        exit 1
     222    fi
    222223
    223        $MAKE
    224        if [ $? -ne 0 ]; then
    225            echo >&2 "Error building PACKAGE_NAME."
    226            exit 1
    227        fi
     224    $MAKE
     225    if [ $? -ne 0 ]; then
     226        echo >&2 "Error building PACKAGE_NAME."
     227        exit 1
     228    fi
    228229
    229        $MAKE install
    230        if [ $? -ne 0 ]; then
    231            echo >&2 "Error installing PACKAGE_NAME."
    232            exit 1
    233        fi
     230    $MAKE install
     231    if [ $? -ne 0 ]; then
     232        echo >&2 "Error installing PACKAGE_NAME."
     233        exit 1
     234    fi
    234235
    235        if [ "$SAGE_SPKG_INSTALL_DOCS" = yes ] ; then
    236           # Before trying to build the documentation, check if any
    237           # needed programs are present. In the example below, we
    238           # check for 'latex', but this will depend on the package.
    239           # Some packages may need no extra tools installed, others
    240           # may require some.  We use 'command -v' for testing this,
    241           # and not 'which' since 'which' is not portable, whereas
    242           # 'command -v' is defined by POSIX.
     236    if [ "$SAGE_SPKG_INSTALL_DOCS" = yes ] ; then
     237        # Before trying to build the documentation, check if any
     238        # needed programs are present. In the example below, we
     239        # check for 'latex', but this will depend on the package.
     240        # Some packages may need no extra tools installed, others
     241        # may require some.  We use 'command -v' for testing this,
     242        # and not 'which' since 'which' is not portable, whereas
     243        # 'command -v' is defined by POSIX.
    243244
    244           # if [ `command -v latex` ] ; then
    245           #    echo "Good, latex was found, so building the documentation"
    246           # else
    247           #    echo "Sorry, can't build the documentation for PACKAGE_NAME as latex is not installed"
    248           #    exit 1
    249           # fi
     245        # if [ `command -v latex` ] ; then
     246        #    echo "Good, latex was found, so building the documentation"
     247        # else
     248        #    echo "Sorry, can't build the documentation for PACKAGE_NAME as latex is not installed"
     249        #    exit 1
     250        # fi
    250251
    251252
    252           # make the documentation in a package-specific way
    253           # for example, we might have
    254           # cd doc
    255           # $MAKE html
     253        # make the documentation in a package-specific way
     254        # for example, we might have
     255        # cd doc
     256        # $MAKE html
    256257
    257           if [ $? -ne 0 ]; then
    258               echo >&2 "Error building PACKAGE_NAME docs."
    259               exit 1
    260           fi
    261           mkdir -p $SAGE_ROOT/local/share/doc/PACKAGE_NAME
    262           # assuming the docs are in doc/*
    263           cp -r doc/* $SAGE_ROOT/local/share/doc/PACKAGE_NAME/
    264        fi
     258        if [ $? -ne 0 ]; then
     259            echo >&2 "Error building PACKAGE_NAME docs."
     260            exit 1
     261        fi
     262        mkdir -p "$SAGE_ROOT/local/share/doc/PACKAGE_NAME"
     263        # assuming the docs are in doc/*
     264        cp -R doc/* "$SAGE_ROOT/local/share/doc/PACKAGE_NAME"
     265    fi
    265266
    266267
    267268Note that the first line is ``#!/usr/bin/env bash``; this is important
  • doc/en/reference/rings_numerical.rst

    diff --git a/doc/en/reference/rings_numerical.rst b/doc/en/reference/rings_numerical.rst
    a b  
    2727   sage/rings/real_mpfr
    2828   sage/rings/complex_field
    2929   sage/rings/complex_number
    30    sage/rings/real_mpfi
    31  No newline at end of file
     30   sage/rings/complex_mpc
     31   sage/rings/real_mpfi
  • sage/rings/all.py

    diff --git a/sage/rings/all.py b/sage/rings/all.py
    a b  
    110110
    111111from complex_double import ComplexDoubleField, ComplexDoubleElement, CDF, is_ComplexDoubleElement
    112112
     113from complex_mpc import MPComplexField
     114
    113115# Power series rings
    114116from power_series_ring import PowerSeriesRing, is_PowerSeriesRing
    115117from power_series_ring_element import PowerSeries, is_PowerSeries
  • sage/rings/complex_mpc.pyx

    diff --git a/sage/rings/complex_mpc.pyx b/sage/rings/complex_mpc.pyx
    a b  
    11"""
    2 Arbitrary Precision Complex Numbers
     2Arbitrary Precision Complex Numbers using GNU MPC
    33
    44This is a binding for the MPC arbitrary-precision floating point library.
    55It is adaptated from real_mpfr.pyx and complex_number.pyx.
    66
    7 We define a class \class{MPComplexField}, where each instance of
    8 \class{MPComplexField} specifies a field of floating-point complex numbers with
     7We define a class :class:`MPComplexField`, where each instance of
     8``MPComplexField`` specifies a field of floating-point complex numbers with
    99a specified precision shared by the real and imaginary part and a rounding
    1010mode stating the rounding mode directions specific to real and imaginary
    1111parts.
    1212
    13 Individual floating-point numbers are of class \class{MPComplexNumber}.
     13Individual floating-point numbers are of class :class:`MPComplexNumber`.
    1414
    1515For floating-point representation and rounding mode description see the
    1616documentation for the module sage.rings.real_mpfr
     
    2828
    2929EXAMPLES::
    3030
    31     sage: from sage.rings.complex_mpc import *
    3231    sage: MPC = MPComplexField(42)
    3332    sage: a = MPC(12, '15.64E+32'); a
    3433    12.0000000000 + 1.56400000000e33*I
     
    238237
    239238    EXAMPLES::
    240239
    241         sage: from sage.rings.complex_mpc import MPComplexField
    242240        sage: MPComplexField()
    243241        Complex Field with 53 bits of precision
    244242        sage: MPComplexField(100)
     
    285283
    286284        EXAMPLES::
    287285
    288             sage: from sage.rings.complex_mpc import MPComplexField
    289286            sage: MPComplexField(17)
    290287            Complex Field with 17 bits of precision
    291288            sage: MPComplexField()
     
    317314
    318315    cdef MPComplexNumber _new(self):
    319316        """
    320         Return a new complex number with parent self.
     317        Return a new complex number with parent ``self`.
    321318        """
    322319        cdef MPComplexNumber z
    323320        z = PY_NEW(MPComplexNumber)
     
    330327        """
    331328        EXAMPLES::
    332329
    333             sage: from sage.rings.complex_mpc import MPComplexField
    334330            sage: MPComplexField(200, 'RNDDU')
    335331            Complex Field with 200 bits of precision and rounding RNDDU
    336332        """
     
    343339        """
    344340        EXAMPLES::
    345341
    346             sage: from sage.rings.complex_mpc import MPComplexField
    347342            sage: MPC = MPComplexField(10)
    348343            sage: latex(MPC)
    349344            \C
     
    356351
    357352        EXAMPLES::
    358353
    359             sage: from sage.rings.complex_mpc import MPComplexField
    360354            sage: MPC = MPComplexField()
    361355            sage: MPC(2)
    362356            2.00000000000000
     
    380374
    381375        EXAMPLES::
    382376
    383             sage: from sage.rings.complex_mpc import MPComplexField
    384377            sage: C20 = MPComplexField(20)
    385378
    386379        The value can be set with a couple of reals::
     
    440433
    441434        EXAMPLES::
    442435
    443             sage: from sage.rings.complex_mpc import MPComplexField
    444436            sage: MPComplexField(100)(17, '4.2') + MPComplexField(20)('6.0', -23)
    445437            23.000 - 18.800*I
    446438            sage: a = MPComplexField(100)(17, '4.2') + MPComplexField(20)('6.0', -23)
     
    475467        """
    476468        EXAMPLES::
    477469
    478             sage: from sage.rings.complex_mpc import MPComplexField
    479470            sage: C = MPComplexField(prec=200, rnd='RNDDZ')
    480471            sage: loads(dumps(C)) == C
    481472            True
     
    486477        """
    487478        EXAMPLES::
    488479
    489             sage: from sage.rings.complex_mpc import MPComplexField
    490480            sage: MPComplexField(10) == MPComplexField(11)
    491481            False
    492482            sage: MPComplexField(10) == MPComplexField(10)
     
    512502
    513503        EXAMPLES::
    514504
    515             sage: from sage.rings.complex_mpc import MPComplexField
    516505            sage: MPComplexField(34).gen()
    517506            1.00000000*I
    518507        """
     
    527516
    528517        EXAMPLES::
    529518
    530             sage: from sage.rings.complex_mpc import MPComplexField
    531519            sage: MPComplexField(34).ngens()
    532520            1
    533521        """
     
    539527
    540528        EXAMPLES::
    541529
    542             sage: from sage.rings.complex_mpc import MPComplexField
    543530            sage: MPC = MPComplexField(20)
    544531            sage: MPC._an_element_()
    545532            1.0000*I
     
    553540
    554541        EXAMPLES::
    555542
    556             sage: from sage.rings.complex_mpc import MPComplexField
    557543            sage: MPComplexField(100).random_element(-5, 10)  # random
    558544            1.9305310520925994224072377281 + 0.94745292506956219710477444855*I
    559545            sage: MPComplexField(10).random_element()  # random
     
    576562
    577563        EXAMPLES::
    578564
    579             sage: from sage.rings.complex_mpc import MPComplexField
    580565            sage: MPComplexField(42).is_atomic_repr()
    581566            False
    582567        """
     
    591576
    592577        EXAMPLES::
    593578
    594             sage: from sage.rings.complex_mpc import MPComplexField
    595579            sage: MPComplexField(17).is_finite()
    596580            False
    597581        """
     
    603587
    604588        EXAMPLES::
    605589
    606             sage: from sage.rings.complex_mpc import MPComplexField
    607590            sage: MPComplexField(42).characteristic()
    608591            0
    609592        """
     
    615598
    616599        EXAMPLES::
    617600
    618             sage: from sage.rings.complex_mpc import MPComplexField
    619601            sage: C = MPComplexField(10, 'RNDNZ'); C.name()
    620602            'MPComplexField10_RNDNZ'
    621603        """
     
    625607        """
    626608        EXAMPLES::
    627609
    628             sage: from sage.rings.complex_mpc import MPComplexField
    629610            sage: MPC = MPComplexField()
    630611            sage: hash(MPC) % 2^32 == hash(MPC.name()) % 2^32
    631612            True
     
    638619
    639620        EXAMPLES::
    640621
    641             sage: from sage.rings.complex_mpc import MPComplexField
    642622            sage: MPComplexField().prec()
    643623            53
    644624            sage: MPComplexField(22).prec()
     
    652632
    653633        EXAMPLES::
    654634
    655             sage: from sage.rings.complex_mpc import MPComplexField
    656635            sage: MPComplexField().rounding_mode()
    657636            'RNDNN'
    658637            sage: MPComplexField(rnd='RNDZU').rounding_mode()
     
    666645
    667646        EXAMPLES::
    668647
    669             sage: from sage.rings.complex_mpc import MPComplexField
    670648            sage: MPComplexField(rnd='RNDZU').rounding_mode_real()
    671649            'RNDZ'
    672650        """
     
    678656
    679657        EXAMPLES::
    680658
    681             sage: from sage.rings.complex_mpc import MPComplexField
    682659            sage: MPComplexField(rnd='RNDZU').rounding_mode_imag()
    683660            'RNDU'
    684661        """
     
    690667
    691668        EXAMPLES::
    692669
    693             sage: from sage.rings.complex_mpc import MPComplexField
    694670            sage: MPComplexField()._real_field()
    695671            Real Field with 53 bits of precision
    696672        """
     
    702678
    703679        EXAMPLES::
    704680
    705             sage: from sage.rings.complex_mpc import MPComplexField
    706681            sage: MPComplexField(prec=100)._imag_field()
    707682            Real Field with 100 bits of precision
    708683        """
     
    722697    """
    723698    cdef MPComplexNumber _new(self):
    724699        """
    725         Return a new complex number with same parent as self.
     700        Return a new complex number with same parent as ``self``.
    726701        """
    727702        cdef MPComplexNumber z
    728703        z = PY_NEW(MPComplexNumber)
     
    745720
    746721        EXAMPLES::
    747722
    748             sage: from sage.rings.complex_mpc import MPComplexField
    749723            sage: C200 = MPComplexField(200)
    750724            sage: C200(1/3, '0.6789')
    751725            0.33333333333333333333333333333333333333333333333333333333333 + 0.67890000000000000000000000000000000000000000000000000000000*I
     
    781755        """
    782756        EXAMPLES::
    783757
    784             sage: from sage.rings.complex_mpc import MPComplexField
    785758            sage: MPC = MPComplexField(100)
    786759            sage: r = RealField(100).pi()
    787760            sage: z = MPC(r); z
     
    879852        """
    880853        EXAMPLES::
    881854
    882             sage: from sage.rings.complex_mpc import *
    883855            sage: C = MPComplexField(prec=200, rnd='RNDUU')
    884856            sage: b = C(393.39203845902384098234098230948209384028340)
    885857            sage: loads(dumps(b)) == b;
     
    910882        """
    911883        EXAMPLES::
    912884
    913             sage: from sage.rings.complex_mpc import MPComplexField
    914885            sage: MPComplexField()(2, -3)
    915886            2.00000000000000 - 3.00000000000000*I
    916887        """
     
    920891        """
    921892        EXAMPLES::
    922893
    923             sage: from sage.rings.complex_mpc import MPComplexField
    924894            sage: latex(MPComplexField()(2, -3))
    925895            2.00000000000000 - 3.00000000000000i
    926896        """
     
    930900
    931901    def __hash__(self):
    932902        """
    933         Returns the hash of self, which coincides with the python
     903        Returns the hash of ``self``, which coincides with the python
    934904        complex and float (and often int) types.
    935905
    936906        This has the drawback that two very close high precision
    937907        numbers will have the same hash, but allows them to play
    938908        nicely with other real types.
    939909
    940         EXAMPLE:
    941             sage: from sage.rings.complex_mpc import *
     910        EXAMPLES::
     911
    942912            sage: hash(MPComplexField()('1.2', 33)) == hash(complex(1.2, 33))
    943913            True
    944914        """
     
    946916
    947917    def __getitem__(self, i):
    948918        r"""
    949         Returns either the real or imaginary component of self depending on
    950         the choice of i: real (i=0), imaginary (i=1)
     919        Returns either the real or imaginary component of ``self``
     920        depending on the choice of i: real (i=0), imaginary (i=1).
    951921
    952922        INPUTS:
    953923
     
    959929
    960930        EXAMPLES::
    961931
    962             sage: from sage.rings.complex_mpc import MPComplexField
    963932            sage: MPC = MPComplexField()
    964933            sage: a = MPC(2,1)
    965934            sage: a.__getitem__(0)
     
    987956
    988957        EXAMPLES::
    989958
    990             sage: from sage.rings.complex_mpc import *
    991959            sage: i = MPComplexField(2000).0
    992960            sage: i.prec()
    993961            2000
     
    996964
    997965    def real(self):
    998966        """
    999         Return the real part of self.
     967        Return the real part of ``self``.
    1000968
    1001969        EXAMPLES::
    1002970
    1003             sage: from sage.rings.complex_mpc import *
    1004971            sage: C = MPComplexField(100)
    1005972            sage: z = C(2, 3)
    1006973            sage: x = z.real(); x
     
    1015982
    1016983    def imag(self):
    1017984        """
    1018         Return imaginary part of self.
     985        Return imaginary part of ``self``.
    1019986
    1020987        EXAMPLES::
    1021988
    1022             sage: from sage.rings.complex_mpc import *
    1023989            sage: C = MPComplexField(100)
    1024990            sage: z = C(2, 3)
    1025991            sage: x = z.imag(); x
     
    10381004
    10391005        EXAMPLES::
    10401006
    1041             sage: from sage.rings.complex_mpc import *
    10421007            sage: C = MPComplexField()
    10431008            sage: a = C(1.2456, 987.654)
    10441009            sage: a.parent()
     
    10561021
    10571022        EXAMPLES::
    10581023
    1059             sage: from sage.rings.complex_mpc import *
    10601024            sage: MPC = MPComplexField(64)
    10611025            sage: z = MPC(-4, 3)/7
    10621026            sage: z.str()
     
    10841048
    10851049    def __copy__(self):
    10861050        """
    1087         Return copy of self -- since self is immutable, we just return self again.
     1051        Return copy of ``self`` -- since ``self`` is immutable, we just
     1052        return ``self`` again.
    10881053
    10891054        EXAMPLES::
    10901055
    1091             sage: from sage.rings.complex_mpc import *
    10921056            sage: a = MPComplexField()(3.5, 3)
    10931057            sage: copy(a) is  a
    10941058            True
     
    11041068
    11051069        EXAMPLES::
    11061070
    1107             sage: from sage.rings.complex_mpc import *
    11081071            sage: MPC = MPComplexField()
    11091072            sage: a = MPC(2,1)
    11101073            sage: int(a)
     
    11271090
    11281091        EXAMPLES::
    11291092
    1130             sage: from sage.rings.complex_mpc import *
    11311093            sage: MPC = MPComplexField()
    11321094            sage: a = MPC(2,1)
    11331095            sage: long(a)
     
    11491111
    11501112        EXAMPLES::
    11511113
    1152             sage: from sage.rings.complex_mpc import *
    11531114            sage: MPC = MPComplexField()
    11541115            sage: a = MPC(1, 0)
    11551116            sage: float(a)
     
    11771138
    11781139        EXAMPLES::
    11791140
    1180             sage: from sage.rings.complex_mpc import *
    11811141            sage: MPC = MPComplexField()
    11821142            sage: a = MPC(2,1)
    11831143            sage: complex(a)
     
    11961156        r"""
    11971157        EXAMPLES::
    11981158
    1199             sage: from sage.rings.complex_mpc import *
    12001159            sage: MPC = MPComplexField()
    12011160            sage: a = MPC(2,1)
    12021161            sage: b = MPC(1,2)
     
    12231182
    12241183    def __nonzero__(self):
    12251184        """
    1226         Return True if self is not zero.  This is an internal
    1227         function; use self.is_zero() instead.
     1185        Return True if ``self`` is not zero.  This is an internal
     1186        function; use ``self.is_zero()`` instead.
    12281187
    12291188        EXAMPLES::
    12301189
    1231             sage: from sage.rings.complex_mpc import *
    12321190            sage: MPC = MPComplexField()
    12331191            sage: z = 1 + MPC(I)
    12341192            sage: z.is_zero()
     
    12381196
    12391197    def is_square(self):
    12401198        """
    1241         This function always returns true as $\C$ is algebraically closed.
     1199        This function always returns true as `\CC` is algebraically closed.
    12421200
    12431201        EXAMPLES::
    12441202
    1245             sage: from sage.rings.complex_mpc import MPComplexField
    12461203            sage: C200 = MPComplexField(200)
    12471204            sage: a = C200(2,1)
    12481205            sage: a.is_square()
    12491206            True
    12501207
    1251         $\C$ is algebraically closed, hence every element is a square::
     1208        `\CC` is algebraically closed, hence every element is a square::
    12521209
    12531210            sage: b = C200(5)
    12541211            sage: b.is_square()
     
    12581215
    12591216    def is_real(self):
    12601217        """
    1261         Return True if self is real, i.e. has imaginary part zero.
     1218        Return True if ``self`` is real, i.e. has imaginary part zero.
    12621219
    12631220        EXAMPLES::
    12641221
    1265             sage: from sage.rings.complex_mpc import MPComplexField
    12661222            sage: C200 = MPComplexField(200)
    12671223            sage: C200(1.23).is_real()
    12681224            True
     
    12731229
    12741230    def is_imaginary(self):
    12751231        """
    1276         Return True if self is imaginary, i.e. has real part zero.
     1232        Return True if ``self`` is imaginary, i.e. has real part zero.
    12771233
    12781234        EXAMPLES::
    12791235
    1280             sage: from sage.rings.complex_mpc import MPComplexField
    12811236            sage: C200 = MPComplexField(200)
    12821237            sage: C200(1.23*i).is_imaginary()
    12831238            True
     
    13011256
    13021257        EXAMPLES::
    13031258
    1304             sage: from sage.rings.complex_mpc import MPComplexField
    13051259            sage: MPC = MPComplexField()
    13061260            sage: z = (1/2)*(1 + sqrt(3.0) * MPC.0); z
    13071261            0.500000000000000 + 0.866025403784439*I
     
    13271281
    13281282        EXAMPLES::
    13291283
    1330            sage: from sage.rings.complex_mpc import MPComplexField
    13311284           sage: MPC = MPComplexField(30)
    13321285           sage: MPC(-1.5, 2) + MPC(0.2, 1)
    13331286           -1.3000000 + 3.0000000*I
     
    13431296
    13441297        EXAMPLES::
    13451298
    1346            sage: from sage.rings.complex_mpc import MPComplexField
    13471299           sage: MPC = MPComplexField(30)
    13481300           sage: MPC(-1.5, 2) - MPC(0.2, 1)
    13491301           -1.7000000 + 1.0000000*I
     
    13591311
    13601312        EXAMPLES::
    13611313
    1362            sage: from sage.rings.complex_mpc import MPComplexField
    13631314           sage: MPC = MPComplexField(30)
    13641315           sage: MPC(-1.5, 2) * MPC(0.2, 1)
    13651316           -2.3000000 - 1.1000000*I
     
    13751326
    13761327        EXAMPLES::
    13771328
    1378            sage: from sage.rings.complex_mpc import MPComplexField
    13791329           sage: MPC = MPComplexField(30)
    13801330           sage: MPC(-1.5, 2) / MPC(0.2, 1)
    13811331           1.6346154 + 1.8269231*I
     
    13951345
    13961346        EXAMPLES::
    13971347
    1398             sage: from sage.rings.complex_mpc import MPComplexField
    13991348            sage: MPC = MPComplexField(30)
    14001349            sage: - MPC(-1.5, 2)
    14011350            1.5000000 - 2.0000000*I
     
    14131362
    14141363        EXAMPLES::
    14151364
    1416             sage: from sage.rings.complex_mpc import MPComplexField
    14171365            sage: C = MPComplexField()
    14181366            sage: a = ~C(5, 1)
    14191367            sage: a * C(5, 1)
     
    14331381
    14341382        EXAMPLES::
    14351383
    1436             sage: from sage.rings.complex_mpc import MPComplexField
    14371384            sage: MPC = MPComplexField()
    14381385            sage: a = MPC(2,1)
    14391386            sage: -a
     
    14481395
    14491396    def __abs__(self):
    14501397        r"""
    1451         Absolute value or modulus of this complex number.
    1452 
    1453             $|a + ib| = sqrt(a^2 + b^2)$
    1454 
    1455         rounded with the rounding mode of the real part.
     1398        Absolute value or modulus of this complex number,
     1399        rounded with the rounding mode of the real part:
     1400
     1401        .. MATH::
     1402
     1403            |a + ib| = \sqrt(a^2 + b^2).
    14561404
    14571405        OUTPUT:
    14581406
     
    14641412        Note that the absolute value of a complex number with imaginary
    14651413        component equal to zero is the absolute value of the real component::
    14661414
    1467             sage: from sage.rings.complex_mpc import *
    14681415            sage: MPC = MPComplexField()
    14691416            sage: a = MPC(2,1)
    14701417            sage: abs(a)
     
    14891436
    14901437    def norm(self):
    14911438        r"""
    1492         Returns the norm of self.
    1493 
    1494             $norm(a + ib) = a^2 + b^2$
    1495 
    1496         rounded with the rounding mode of the real part.
     1439        Return the norm of a complex number, rounded with the rounding
     1440        mode of the real part.  The norm is the square of the absolute
     1441        value:
     1442
     1443        .. MATH::
     1444
     1445            \mathrm{norm}(a + ib) = a^2 + b^2.
    14971446
    14981447        OUTPUT:
    14991448
     
    15051454        This indeed acts as the square function when the imaginary
    15061455        component of self is equal to zero::
    15071456
    1508             sage: from sage.rings.complex_mpc import *
    15091457            sage: MPC = MPComplexField()
    15101458            sage: a = MPC(2,1)
    15111459            sage: a.norm()
     
    15351483
    15361484        EXAMPLES::
    15371485
    1538             sage: from sage.rings.complex_mpc import MPComplexField
    15391486            sage: MPC = MPComplexField()
    15401487            sage: a = MPC(2, 2)
    15411488            sage: a.__rdiv__(MPC(1))
     
    15521499
    15531500        EXAMPLES::
    15541501
    1555             sage: from sage.rings.complex_mpc import MPComplexField
    15561502            sage: MPC.<i> = MPComplexField(20)
    15571503            sage: a = i^2; a
    15581504            -1.0000
     
    15911537    ################################
    15921538
    15931539    def cos(self):
    1594         """
    1595         Return the cosine of this complex number.
    1596 
    1597         $cos(a +ib) = cos a cosh b -i sin a sinh b$
     1540        r"""
     1541        Return the cosine of this complex number:
     1542
     1543        .. MATH::
     1544
     1545            \cos(a + ib) = \cos a \cosh b -i \sin a \sinh b.
    15981546
    15991547        EXAMPLES::
    16001548
    1601             sage: from sage.rings.complex_mpc import MPComplexField
    16021549            sage: MPC = MPComplexField()
    16031550            sage: u = MPC(2, 4)
    16041551            sage: cos(u)
     
    16101557        return z
    16111558
    16121559    def sin(self):
    1613         """
    1614         Return the sine of this complex number.
    1615 
    1616         $sin(a+ib) = sin a cosh b + i cos x sinh b$
     1560        r"""
     1561        Return the sine of this complex number:
     1562
     1563        .. MATH::
     1564
     1565            \sin(a + ib) = \sin a \cosh b + i \cos x \sinh b.
    16171566
    16181567        EXAMPLES::
    16191568
    1620             sage: from sage.rings.complex_mpc import MPComplexField
    16211569            sage: MPC = MPComplexField()
    16221570            sage: u = MPC(2, 4)
    16231571            sage: sin(u)
     
    16291577        return z
    16301578
    16311579    def tan(self):
    1632         """
    1633         Return the tangent of this complex number.
    1634 
    1635         $tan(a+ib) = (sin 2a +i sinh 2b)/(cos 2a + cosh 2b)$
     1580        r"""
     1581        Return the tangent of this complex number:
     1582
     1583        .. MATH::
     1584
     1585            \tan(a + ib) = (\sin 2a + i \sinh 2b)/(\cos 2a + \cosh 2b).
    16361586
    16371587        EXAMPLES::
    16381588
    1639             sage: from sage.rings.complex_mpc import MPComplexField
    16401589            sage: MPC = MPComplexField()
    16411590            sage: u = MPC(-2, 4)
    16421591            sage: tan(u)
     
    16491598
    16501599    def cosh(self):
    16511600        """
    1652         Return the hyperbolic cosine of this complex number.
    1653 
    1654         $cosh(a+ib) = cosh a cos b +i sinh a sin b$
     1601        Return the hyperbolic cosine of this complex number:
     1602
     1603        .. MATH::
     1604
     1605            \cosh(a + ib) = \cosh a \cos b + i \sinh a \sin b.
    16551606
    16561607        EXAMPLES::
    16571608
    1658             sage: from sage.rings.complex_mpc import MPComplexField
    16591609            sage: MPC = MPComplexField()
    16601610            sage: u = MPC(2, 4)
    16611611            sage: cosh(u)
     
    16681618
    16691619    def sinh(self):
    16701620        """
    1671         Return the hyperbolic sine of this complex number.
    1672 
    1673         $sinh(a+ib) = sinh a cos b +i cosh a sin b$
     1621        Return the hyperbolic sine of this complex number:
     1622
     1623        .. MATH::
     1624
     1625            \sinh(a + ib) = \sinh a \cos b + i \cosh a \sin b.
    16741626
    16751627        EXAMPLES::
    16761628
    1677             sage: from sage.rings.complex_mpc import MPComplexField
    16781629            sage: MPC = MPComplexField()
    16791630            sage: u = MPC(2, 4)
    16801631            sage: sinh(u)
     
    16861637        return z
    16871638
    16881639    def tanh(self):
    1689         """
    1690         Return the hyperbolic tangent of this complex number.
    1691 
    1692         $tanh(a+ib) = (sinh 2a +i sin 2b)/(cosh 2a + cos 2b)$
     1640        r"""
     1641        Return the hyperbolic tangent of this complex number:
     1642
     1643        .. MATH::
     1644
     1645            \tanh(a + ib) = (\sinh 2a + i \sin 2b)/(\cosh 2a + \cos 2b).
    16931646
    16941647        EXAMPLES::
    16951648
    1696             sage: from sage.rings.complex_mpc import MPComplexField
    16971649            sage: MPC = MPComplexField()
    16981650            sage: u = MPC(2, 4)
    16991651            sage: tanh(u)
     
    17081660        """
    17091661        EXAMPLES::
    17101662
    1711             sage: from sage.rings.complex_mpc import MPComplexField
    17121663            sage: MPC = MPComplexField()
    17131664            sage: u = MPC(2, 4)
    17141665            sage: arccos(u)
     
    17231674        """
    17241675        EXAMPLES::
    17251676
    1726             sage: from sage.rings.complex_mpc import MPComplexField
    17271677            sage: MPC = MPComplexField()
    17281678            sage: u = MPC(2, 4)
    17291679            sage: arcsin(u)
     
    17381688        """
    17391689        EXAMPLES::
    17401690
    1741             sage: from sage.rings.complex_mpc import MPComplexField
    17421691            sage: MPC = MPComplexField()
    17431692            sage: u = MPC(-2, 4)
    17441693            sage: arctan(u)
     
    17551704
    17561705        EXAMPLES::
    17571706
    1758             sage: from sage.rings.complex_mpc import MPComplexField
    17591707            sage: MPC = MPComplexField()
    17601708            sage: u = MPC(2, 4)
    17611709            sage: arccosh(u)
     
    17721720
    17731721        EXAMPLES::
    17741722
    1775             sage: from sage.rings.complex_mpc import MPComplexField
    17761723            sage: MPC = MPComplexField()
    17771724            sage: u = MPC(2, 4)
    17781725            sage: arcsinh(u)
     
    17891736
    17901737        EXAMPLES::
    17911738
    1792             sage: from sage.rings.complex_mpc import MPComplexField
    17931739            sage: MPC = MPComplexField()
    17941740            sage: u = MPC(2, 4)
    17951741            sage: arctanh(u)
     
    18041750        """
    18051751        EXAMPLES::
    18061752
    1807             sage: from sage.rings.complex_mpc import MPComplexField
    18081753            sage: MPC = MPComplexField(100)
    18091754            sage: MPC(1,1).coth()
    18101755            0.86801414289592494863584920892 - 0.21762156185440268136513424361*I
     
    18151760        """
    18161761        EXAMPLES::
    18171762
    1818             sage: from sage.rings.complex_mpc import MPComplexField
    18191763            sage: MPC = MPComplexField(100)
    18201764            sage: MPC(1,1).arccoth()
    18211765            0.40235947810852509365018983331 - 0.55357435889704525150853273009*I
     
    18261770        """
    18271771        EXAMPLES::
    18281772
    1829             sage: from sage.rings.complex_mpc import MPComplexField
    18301773            sage: MPC = MPComplexField(100)
    18311774            sage: MPC(1,1).csc()
    18321775            0.62151801717042842123490780586 - 0.30393100162842645033448560451*I
     
    18371780        """
    18381781        EXAMPLES::
    18391782
    1840             sage: from sage.rings.complex_mpc import MPComplexField
    18411783            sage: MPC = MPComplexField(100)
    18421784            sage: MPC(1,1).csch()
    18431785            0.30393100162842645033448560451 - 0.62151801717042842123490780586*I
     
    18481790        """
    18491791        EXAMPLES::
    18501792
    1851             sage: from sage.rings.complex_mpc import MPComplexField
    18521793            sage: MPC = MPComplexField(100)
    18531794            sage: MPC(1,1).arccsch()
    18541795            0.53063753095251782601650945811 - 0.45227844715119068206365839783*I
     
    18591800        """
    18601801        EXAMPLES::
    18611802
    1862             sage: from sage.rings.complex_mpc import MPComplexField
    18631803            sage: MPC = MPComplexField(100)
    18641804            sage: MPC(1,1).sec()
    18651805            0.49833703055518678521380589177 + 0.59108384172104504805039169297*I
     
    18701810        """
    18711811        EXAMPLES::
    18721812
    1873             sage: from sage.rings.complex_mpc import MPComplexField
    18741813            sage: MPC = MPComplexField(100)
    18751814            sage: MPC(1,1).sech()
    18761815            0.49833703055518678521380589177 - 0.59108384172104504805039169297*I
     
    18811820        """
    18821821        EXAMPLES::
    18831822
    1884             sage: from sage.rings.complex_mpc import MPComplexField
    18851823            sage: MPC = MPComplexField(100)
    18861824            sage: MPC(1,1).arcsech()
    18871825            0.53063753095251782601650945811 - 1.1185178796437059371676632938*I
     
    18921830        """
    18931831        EXAMPLES::
    18941832
    1895             sage: from sage.rings.complex_mpc import MPComplexField
    18961833            sage: MPC = MPComplexField(53)
    18971834            sage: (1+MPC(I)).cotan()
    18981835            0.217621561854403 - 0.868014142895925*I
     
    19161853
    19171854        EXAMPLES::
    19181855
    1919             sage: from sage.rings.complex_mpc import *
    19201856            sage: MPC = MPComplexField()
    19211857            sage: i = MPC.0
    19221858            sage: (i^2).argument()
     
    19361872        return x
    19371873
    19381874    def conjugate(self):
    1939         """
    1940         Return the complex conjugate of this complex number.
    1941 
    1942         $conjugate(a+ib) = a -ib$
     1875        r"""
     1876        Return the complex conjugate of this complex number:
     1877
     1878        .. MATH::
     1879
     1880            \mathrm{conjugate}(a + ib) = a - ib.
    19431881
    19441882        EXAMPLES::
    19451883
    1946             sage: from sage.rings.complex_mpc import *
    19471884            sage: MPC = MPComplexField()
    19481885            sage: i = MPC(0, 1)
    19491886            sage: (1+i).conjugate()
     
    19561893
    19571894    def sqr(self):
    19581895        """
    1959         Return the square.
    1960 
    1961         $sqr(a+ib) = a^2-b^2 +i 2ab$
     1896        Return the square of a complex number:
     1897
     1898        .. MATH::
     1899
     1900            (a + ib)^2 = (a^2 - b^2) + 2iab.
    19621901
    19631902        EXAMPLES::
    19641903
    1965             sage: from sage.rings.complex_mpc import MPComplexField
    19661904            sage: C = MPComplexField()
    19671905            sage: a = C(5, 1)
    19681906            sage: a.sqr()
     
    19741912        return z
    19751913
    19761914    def sqrt(self):
    1977         """
    1978         Return the square root, taking the branch cut to be the negative real axis.
    1979 
    1980         $sqrt(a+ib) = sqrt(abs(a+ib))(cos(arg(a+ib)/2) + sin(arg(a+ib)/2))$
     1915        r"""
     1916        Return the square root, taking the branch cut to be the negative real axis:
     1917
     1918        .. MATH::
     1919
     1920            \sqrt z = \sqrt{|z|}(\cos(\arg(z)/2) + i \sin(\arg(z)/2)).
    19811921
    19821922        EXAMPLES::
    19831923
    1984             sage: from sage.rings.complex_mpc import MPComplexField
    19851924            sage: C = MPComplexField()
    19861925            sage: a = C(24, 10)
    19871926            sage: a.sqrt()
     
    19941933
    19951934    def exp(self):
    19961935        """
    1997         Return the exponential of this complex number.
    1998 
    1999         $exp(a+ib) = exp(a) (cos b +i sin b)$
     1936        Return the exponential of this complex number:
     1937
     1938        .. MATH::
     1939
     1940            \exp(a + ib) = \exp(a) (\cos b + i \sin b).
    20001941
    20011942        EXAMPLES::
    20021943
    2003             sage: from sage.rings.complex_mpc import MPComplexField
    20041944            sage: MPC = MPComplexField()
    20051945            sage: u = MPC(2, 4)
    20061946            sage: exp(u)
     
    20121952        return z
    20131953
    20141954    def log(self):
    2015         """
     1955        r"""
    20161956        Return the logarithm of this complex number with the branch
    2017         cut on the negative real axis.
    2018 
    2019         $log(a+ib) = log(a^2+b^2)/2 + arg(a+ib)$
     1957        cut on the negative real axis:
     1958
     1959        .. MATH::
     1960
     1961            \log(z) = \log |z| + i \arg(z).
    20201962
    20211963        EXAMPLES::
    20221964
    2023             sage: from sage.rings.complex_mpc import MPComplexField
    20241965            sage: MPC = MPComplexField()
    20251966            sage: u = MPC(2, 4)
    20261967            sage: log(u)
     
    20371978
    20381979        EXAMPLES::
    20391980
    2040             sage: from sage.rings.complex_mpc import MPComplexField
    20411981            sage: MPC = MPComplexField()
    20421982            sage: u = MPC(2, 4)
    20431983            sage: u<<2
     
    20481988        cdef MPComplexNumber z, x
    20491989        x = <MPComplexNumber>self
    20501990        z = x._new()
    2051         if n>=0:
    2052             mpc_mul_2exp(z.value , x.value, n, (<MPComplexField_class>x._parent).__rnd)
    2053         else:
    2054             mpc_div_2exp(z.value , x.value, -n, (<MPComplexField_class>x._parent).__rnd)
     1991        mpc_mul_2si(z.value , x.value, n, (<MPComplexField_class>x._parent).__rnd)
    20551992        return z
    20561993
    20571994    def __rshift__(self, n):
     
    20601997
    20611998        EXAMPLES::
    20621999
    2063             sage: from sage.rings.complex_mpc import MPComplexField
    20642000            sage: MPC = MPComplexField()
    20652001            sage: u = MPC(2, 4)
    20662002            sage: u>>2
     
    20712007        cdef MPComplexNumber z, x
    20722008        x = <MPComplexNumber>self
    20732009        z = x._new()
    2074         if n>=0:
    2075             mpc_div_2exp(z.value , x.value, n, (<MPComplexField_class>x._parent).__rnd)
    2076         else:
    2077             mpc_mul_2exp(z.value , x.value, -n, (<MPComplexField_class>x._parent).__rnd)
     2010        mpc_div_2si(z.value , x.value, n, (<MPComplexField_class>x._parent).__rnd)
    20782011        return z
    20792012
    20802013    def nth_root(self, n, all=False):
     
    20882021
    20892022        EXAMPLES::
    20902023
    2091             sage: from sage.rings.complex_mpc import MPComplexField
    20922024            sage: MPC = MPComplexField()
    20932025            sage: a = MPC(27)
    20942026            sage: a.nth_root(3)
     
    21332065
    21342066    def dilog(self):
    21352067        r"""
    2136         Returns the complex dilogarithm of self. The complex dilogarithm,
     2068        Return the complex dilogarithm of ``self``. The complex dilogarithm,
    21372069        or Spence's function, is defined by
    21382070
    2139         `Li_2(z) = - \int_0^z \frac{\log|1-\zeta|}{\zeta} d(\zeta)`
    2140 
    2141         `= \sum_{k=1}^\infty \frac{z^k}{k}`
     2071        .. MATH::
     2072
     2073            Li_2(z) = - \int_0^z \frac{\log|1-\zeta|}{\zeta} d(\zeta)
     2074            = \sum_{k=1}^\infty \frac{z^k}{k^2}.
    21422075
    21432076        Note that the series definition can only be used for
    2144         `|z| < 1`
     2077        `|z| < 1`.
    21452078
    21462079        EXAMPLES::
    21472080
    2148             sage: from sage.rings.complex_mpc import MPComplexField
    21492081            sage: MPC = MPComplexField()
    21502082            sage: a = MPC(1,0)
    21512083            sage: a.dilog()
     
    21692101
    21702102    def eta(self, omit_frac=False):
    21712103        r"""
    2172         Return the value of the Dedekind `\eta` function on self,
     2104        Return the value of the Dedekind `\eta` function on ``self``,
    21732105        intelligently computed using `\mathbb{SL}(2,\ZZ)`
    21742106        transformations.
    21752107
     
    21932125
    21942126        ALGORITHM: Uses the PARI C library.
    21952127
    2196         EXAMPLES:
    2197 
    2198             sage: from sage.rings.complex_mpc import MPComplexField
     2128        EXAMPLES::
     2129
    21992130            sage: MPC = MPComplexField()
    22002131            sage: i = MPC.0
    22012132            sage: z = 1+i; z.eta()
     
    22122143
    22132144        EXAMPLES::
    22142145
    2215             sage: from sage.rings.complex_mpc import MPComplexField
    22162146            sage: MPC = MPComplexField(30)
    22172147            sage: i = MPC.0
    22182148            sage: (1+i).gamma()
     
    22412171
    22422172        EXAMPLES::
    22432173
    2244             sage: from sage.rings.complex_mpc import MPComplexField
    22452174            sage: C, i = MPComplexField(30).objgen()
    22462175            sage: (1+i).gamma_inc(2 + 3*i)
    22472176            0.0020969149 - 0.059981914*I
     
    22592188
    22602189        EXAMPLES::
    22612190
    2262             sage: from sage.rings.complex_mpc import MPComplexField
    22632191            sage: i = MPComplexField(30).gen()
    22642192            sage: z = 1 + i
    22652193            sage: z.zeta()
     
    22692197
    22702198    def agm(self, right, algorithm="optimal"):
    22712199        """
    2272         Returns the algebraic geometrc mean of self and right.
     2200        Returns the algebraic geometrc mean of ``self`` and ``right``.
    22732201
    22742202        EXAMPLES::
    22752203
    2276             sage: from sage.rings.complex_mpc import MPComplexField
    22772204            sage: MPC = MPComplexField()
    22782205            sage: u = MPC(1, 4)
    22792206            sage: v = MPC(-2,5)
     
    23382265                mpc_sqrt(b.value, d.value, rnd)
    23392266
    23402267                # a = s/2
    2341                 mpc_div_2exp(a.value, s.value, 1, rnd)
     2268                mpc_div_2ui(a.value, s.value, 1, rnd)
    23422269
    23432270                # d = a - b
    23442271                mpc_sub(d.value, a.value, b.value, rnd)
  • sage/rings/mpc.pxi

    diff --git a/sage/rings/mpc.pxi b/sage/rings/mpc.pxi
    a b  
    9999    int  mpc_fr_div (mpc_t, mpfr_t, mpc_t, mpc_rnd_t)
    100100    int  mpc_div_ui (mpc_t, mpc_t, unsigned long int, mpc_rnd_t)
    101101    int  mpc_ui_div (mpc_t, unsigned long int, mpc_t, mpc_rnd_t)
    102     int  mpc_div_2exp (mpc_t, mpc_t, unsigned long int, mpc_rnd_t)
    103     int  mpc_mul_2exp (mpc_t, mpc_t, unsigned long int, mpc_rnd_t)
     102    int  mpc_div_2ui (mpc_t, mpc_t, unsigned long int, mpc_rnd_t)
     103    int  mpc_div_2si (mpc_t, mpc_t, long int, mpc_rnd_t)
     104    int  mpc_mul_2ui (mpc_t, mpc_t, unsigned long int, mpc_rnd_t)
     105    int  mpc_mul_2si (mpc_t, mpc_t, long int, mpc_rnd_t)
    104106    #
    105107    int  mpc_abs (mpfr_t, mpc_t, mp_rnd_t)
    106108    int  mpc_norm (mpfr_t, mpc_t, mp_rnd_t)
    107109
    108     int mpc_mul_2exp (mpc_t rop, mpc_t op1, unsigned long int op2, mpc_rnd_t rnd)
    109     int mpc_div_2exp (mpc_t rop, mpc_t op1, unsigned long int op2, mpc_rnd_t rnd)
    110110
    111111    # Power functions and logarithm
    112112    int  mpc_sqrt (mpc_t, mpc_t, mpc_rnd_t)