passagemath-modules 10.6.31rc3__cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of passagemath-modules might be problematic. Click here for more details.
- passagemath_modules-10.6.31rc3.dist-info/METADATA +281 -0
- passagemath_modules-10.6.31rc3.dist-info/RECORD +806 -0
- passagemath_modules-10.6.31rc3.dist-info/WHEEL +6 -0
- passagemath_modules-10.6.31rc3.dist-info/top_level.txt +2 -0
- passagemath_modules.libs/libgfortran-e1b7dfc8.so.5.0.0 +0 -0
- passagemath_modules.libs/libgmp-93ebf16a.so.10.5.0 +0 -0
- passagemath_modules.libs/libgsl-e3525837.so.28.0.0 +0 -0
- passagemath_modules.libs/libmpc-c5c421e1.so.3.3.1 +0 -0
- passagemath_modules.libs/libmpfr-e0f11cf3.so.6.2.1 +0 -0
- passagemath_modules.libs/libopenblasp-r0-4c5b64b1.3.29.so +0 -0
- sage/algebras/all__sagemath_modules.py +20 -0
- sage/algebras/catalog.py +148 -0
- sage/algebras/clifford_algebra.py +3107 -0
- sage/algebras/clifford_algebra_element.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/algebras/clifford_algebra_element.pxd +16 -0
- sage/algebras/clifford_algebra_element.pyx +997 -0
- sage/algebras/commutative_dga.py +4252 -0
- sage/algebras/exterior_algebra_groebner.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/algebras/exterior_algebra_groebner.pxd +55 -0
- sage/algebras/exterior_algebra_groebner.pyx +727 -0
- sage/algebras/finite_dimensional_algebras/all.py +2 -0
- sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra.py +1029 -0
- sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra_element.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra_element.pxd +12 -0
- sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra_element.pyx +706 -0
- sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra_ideal.py +196 -0
- sage/algebras/finite_dimensional_algebras/finite_dimensional_algebra_morphism.py +255 -0
- sage/algebras/finite_gca.py +528 -0
- sage/algebras/group_algebra.py +232 -0
- sage/algebras/lie_algebras/abelian.py +197 -0
- sage/algebras/lie_algebras/affine_lie_algebra.py +1213 -0
- sage/algebras/lie_algebras/all.py +25 -0
- sage/algebras/lie_algebras/all__sagemath_modules.py +1 -0
- sage/algebras/lie_algebras/bch.py +177 -0
- sage/algebras/lie_algebras/bgg_dual_module.py +1184 -0
- sage/algebras/lie_algebras/bgg_resolution.py +232 -0
- sage/algebras/lie_algebras/center_uea.py +767 -0
- sage/algebras/lie_algebras/classical_lie_algebra.py +2516 -0
- sage/algebras/lie_algebras/examples.py +683 -0
- sage/algebras/lie_algebras/free_lie_algebra.py +973 -0
- sage/algebras/lie_algebras/heisenberg.py +820 -0
- sage/algebras/lie_algebras/lie_algebra.py +1562 -0
- sage/algebras/lie_algebras/lie_algebra_element.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/algebras/lie_algebras/lie_algebra_element.pxd +68 -0
- sage/algebras/lie_algebras/lie_algebra_element.pyx +2122 -0
- sage/algebras/lie_algebras/morphism.py +661 -0
- sage/algebras/lie_algebras/nilpotent_lie_algebra.py +457 -0
- sage/algebras/lie_algebras/onsager.py +1324 -0
- sage/algebras/lie_algebras/poincare_birkhoff_witt.py +816 -0
- sage/algebras/lie_algebras/quotient.py +462 -0
- sage/algebras/lie_algebras/rank_two_heisenberg_virasoro.py +355 -0
- sage/algebras/lie_algebras/representation.py +1040 -0
- sage/algebras/lie_algebras/structure_coefficients.py +459 -0
- sage/algebras/lie_algebras/subalgebra.py +967 -0
- sage/algebras/lie_algebras/symplectic_derivation.py +289 -0
- sage/algebras/lie_algebras/verma_module.py +1630 -0
- sage/algebras/lie_algebras/virasoro.py +1186 -0
- sage/algebras/octonion_algebra.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/algebras/octonion_algebra.pxd +20 -0
- sage/algebras/octonion_algebra.pyx +987 -0
- sage/algebras/orlik_solomon.py +907 -0
- sage/algebras/orlik_terao.py +779 -0
- sage/algebras/steenrod/all.py +7 -0
- sage/algebras/steenrod/steenrod_algebra.py +4258 -0
- sage/algebras/steenrod/steenrod_algebra_bases.py +1179 -0
- sage/algebras/steenrod/steenrod_algebra_misc.py +1167 -0
- sage/algebras/steenrod/steenrod_algebra_mult.py +954 -0
- sage/algebras/weyl_algebra.py +1126 -0
- sage/all__sagemath_modules.py +62 -0
- sage/calculus/all__sagemath_modules.py +19 -0
- sage/calculus/expr.py +205 -0
- sage/calculus/integration.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/calculus/integration.pyx +698 -0
- sage/calculus/interpolation.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/calculus/interpolation.pxd +13 -0
- sage/calculus/interpolation.pyx +387 -0
- sage/calculus/interpolators.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/calculus/interpolators.pyx +326 -0
- sage/calculus/ode.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/calculus/ode.pxd +5 -0
- sage/calculus/ode.pyx +610 -0
- sage/calculus/riemann.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/calculus/riemann.pyx +1521 -0
- sage/calculus/test_sympy.py +201 -0
- sage/calculus/transforms/all.py +7 -0
- sage/calculus/transforms/dft.py +844 -0
- sage/calculus/transforms/dwt.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/calculus/transforms/dwt.pxd +7 -0
- sage/calculus/transforms/dwt.pyx +160 -0
- sage/calculus/transforms/fft.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/calculus/transforms/fft.pxd +12 -0
- sage/calculus/transforms/fft.pyx +487 -0
- sage/calculus/wester.py +662 -0
- sage/coding/abstract_code.py +1108 -0
- sage/coding/ag_code.py +868 -0
- sage/coding/ag_code_decoders.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/coding/ag_code_decoders.pyx +2639 -0
- sage/coding/all.py +15 -0
- sage/coding/bch_code.py +494 -0
- sage/coding/binary_code.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/coding/binary_code.pxd +124 -0
- sage/coding/binary_code.pyx +4139 -0
- sage/coding/bounds_catalog.py +43 -0
- sage/coding/channel.py +819 -0
- sage/coding/channels_catalog.py +29 -0
- sage/coding/code_bounds.py +755 -0
- sage/coding/code_constructions.py +804 -0
- sage/coding/codes_catalog.py +111 -0
- sage/coding/cyclic_code.py +1329 -0
- sage/coding/databases.py +316 -0
- sage/coding/decoder.py +373 -0
- sage/coding/decoders_catalog.py +88 -0
- sage/coding/delsarte_bounds.py +709 -0
- sage/coding/encoder.py +390 -0
- sage/coding/encoders_catalog.py +64 -0
- sage/coding/extended_code.py +468 -0
- sage/coding/gabidulin_code.py +1058 -0
- sage/coding/golay_code.py +404 -0
- sage/coding/goppa_code.py +441 -0
- sage/coding/grs_code.py +2371 -0
- sage/coding/guava.py +107 -0
- sage/coding/guruswami_sudan/all.py +1 -0
- sage/coding/guruswami_sudan/gs_decoder.py +897 -0
- sage/coding/guruswami_sudan/interpolation.py +409 -0
- sage/coding/guruswami_sudan/utils.py +176 -0
- sage/coding/hamming_code.py +176 -0
- sage/coding/information_set_decoder.py +1032 -0
- sage/coding/kasami_codes.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/coding/kasami_codes.pyx +351 -0
- sage/coding/linear_code.py +3067 -0
- sage/coding/linear_code_no_metric.py +1354 -0
- sage/coding/linear_rank_metric.py +961 -0
- sage/coding/parity_check_code.py +353 -0
- sage/coding/punctured_code.py +719 -0
- sage/coding/reed_muller_code.py +999 -0
- sage/coding/self_dual_codes.py +942 -0
- sage/coding/source_coding/all.py +2 -0
- sage/coding/source_coding/huffman.py +553 -0
- sage/coding/subfield_subcode.py +423 -0
- sage/coding/two_weight_db.py +399 -0
- sage/combinat/all__sagemath_modules.py +7 -0
- sage/combinat/cartesian_product.py +347 -0
- sage/combinat/family.py +11 -0
- sage/combinat/free_module.py +1977 -0
- sage/combinat/root_system/all.py +147 -0
- sage/combinat/root_system/ambient_space.py +527 -0
- sage/combinat/root_system/associahedron.py +471 -0
- sage/combinat/root_system/braid_move_calculator.py +143 -0
- sage/combinat/root_system/braid_orbit.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/combinat/root_system/braid_orbit.pyx +144 -0
- sage/combinat/root_system/branching_rules.py +2301 -0
- sage/combinat/root_system/cartan_matrix.py +1245 -0
- sage/combinat/root_system/cartan_type.py +3069 -0
- sage/combinat/root_system/coxeter_group.py +162 -0
- sage/combinat/root_system/coxeter_matrix.py +1261 -0
- sage/combinat/root_system/coxeter_type.py +681 -0
- sage/combinat/root_system/dynkin_diagram.py +900 -0
- sage/combinat/root_system/extended_affine_weyl_group.py +2993 -0
- sage/combinat/root_system/fundamental_group.py +795 -0
- sage/combinat/root_system/hecke_algebra_representation.py +1203 -0
- sage/combinat/root_system/integrable_representations.py +1227 -0
- sage/combinat/root_system/non_symmetric_macdonald_polynomials.py +1965 -0
- sage/combinat/root_system/pieri_factors.py +1147 -0
- sage/combinat/root_system/plot.py +1615 -0
- sage/combinat/root_system/root_lattice_realization_algebras.py +1214 -0
- sage/combinat/root_system/root_lattice_realizations.py +4628 -0
- sage/combinat/root_system/root_space.py +487 -0
- sage/combinat/root_system/root_system.py +882 -0
- sage/combinat/root_system/type_A.py +348 -0
- sage/combinat/root_system/type_A_affine.py +227 -0
- sage/combinat/root_system/type_A_infinity.py +241 -0
- sage/combinat/root_system/type_B.py +347 -0
- sage/combinat/root_system/type_BC_affine.py +287 -0
- sage/combinat/root_system/type_B_affine.py +216 -0
- sage/combinat/root_system/type_C.py +317 -0
- sage/combinat/root_system/type_C_affine.py +188 -0
- sage/combinat/root_system/type_D.py +357 -0
- sage/combinat/root_system/type_D_affine.py +208 -0
- sage/combinat/root_system/type_E.py +641 -0
- sage/combinat/root_system/type_E_affine.py +231 -0
- sage/combinat/root_system/type_F.py +387 -0
- sage/combinat/root_system/type_F_affine.py +137 -0
- sage/combinat/root_system/type_G.py +293 -0
- sage/combinat/root_system/type_G_affine.py +132 -0
- sage/combinat/root_system/type_H.py +105 -0
- sage/combinat/root_system/type_I.py +110 -0
- sage/combinat/root_system/type_Q.py +150 -0
- sage/combinat/root_system/type_affine.py +509 -0
- sage/combinat/root_system/type_dual.py +704 -0
- sage/combinat/root_system/type_folded.py +301 -0
- sage/combinat/root_system/type_marked.py +748 -0
- sage/combinat/root_system/type_reducible.py +601 -0
- sage/combinat/root_system/type_relabel.py +730 -0
- sage/combinat/root_system/type_super_A.py +837 -0
- sage/combinat/root_system/weight_lattice_realizations.py +1188 -0
- sage/combinat/root_system/weight_space.py +639 -0
- sage/combinat/root_system/weyl_characters.py +2238 -0
- sage/crypto/__init__.py +4 -0
- sage/crypto/all.py +28 -0
- sage/crypto/block_cipher/all.py +7 -0
- sage/crypto/block_cipher/des.py +1065 -0
- sage/crypto/block_cipher/miniaes.py +2171 -0
- sage/crypto/block_cipher/present.py +909 -0
- sage/crypto/block_cipher/sdes.py +1527 -0
- sage/crypto/boolean_function.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/crypto/boolean_function.pxd +10 -0
- sage/crypto/boolean_function.pyx +1487 -0
- sage/crypto/cipher.py +78 -0
- sage/crypto/classical.py +3668 -0
- sage/crypto/classical_cipher.py +569 -0
- sage/crypto/cryptosystem.py +387 -0
- sage/crypto/key_exchange/all.py +7 -0
- sage/crypto/key_exchange/catalog.py +24 -0
- sage/crypto/key_exchange/diffie_hellman.py +323 -0
- sage/crypto/key_exchange/key_exchange_scheme.py +107 -0
- sage/crypto/lattice.py +312 -0
- sage/crypto/lfsr.py +295 -0
- sage/crypto/lwe.py +840 -0
- sage/crypto/mq/__init__.py +4 -0
- sage/crypto/mq/mpolynomialsystemgenerator.py +204 -0
- sage/crypto/mq/rijndael_gf.py +2345 -0
- sage/crypto/mq/sbox.py +7 -0
- sage/crypto/mq/sr.py +3344 -0
- sage/crypto/public_key/all.py +5 -0
- sage/crypto/public_key/blum_goldwasser.py +776 -0
- sage/crypto/sbox.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/crypto/sbox.pyx +2090 -0
- sage/crypto/sboxes.py +2090 -0
- sage/crypto/stream.py +390 -0
- sage/crypto/stream_cipher.py +297 -0
- sage/crypto/util.py +519 -0
- sage/ext/all__sagemath_modules.py +1 -0
- sage/ext/interpreters/__init__.py +1 -0
- sage/ext/interpreters/all__sagemath_modules.py +2 -0
- sage/ext/interpreters/wrapper_cc.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/ext/interpreters/wrapper_cc.pxd +30 -0
- sage/ext/interpreters/wrapper_cc.pyx +252 -0
- sage/ext/interpreters/wrapper_cdf.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/ext/interpreters/wrapper_cdf.pxd +26 -0
- sage/ext/interpreters/wrapper_cdf.pyx +245 -0
- sage/ext/interpreters/wrapper_rdf.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/ext/interpreters/wrapper_rdf.pxd +23 -0
- sage/ext/interpreters/wrapper_rdf.pyx +221 -0
- sage/ext/interpreters/wrapper_rr.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/ext/interpreters/wrapper_rr.pxd +28 -0
- sage/ext/interpreters/wrapper_rr.pyx +335 -0
- sage/geometry/all__sagemath_modules.py +5 -0
- sage/geometry/toric_lattice.py +1745 -0
- sage/geometry/toric_lattice_element.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/geometry/toric_lattice_element.pyx +432 -0
- sage/groups/abelian_gps/abelian_group.py +1925 -0
- sage/groups/abelian_gps/abelian_group_element.py +164 -0
- sage/groups/abelian_gps/all__sagemath_modules.py +5 -0
- sage/groups/abelian_gps/dual_abelian_group.py +421 -0
- sage/groups/abelian_gps/dual_abelian_group_element.py +179 -0
- sage/groups/abelian_gps/element_base.py +341 -0
- sage/groups/abelian_gps/values.py +488 -0
- sage/groups/additive_abelian/additive_abelian_group.py +476 -0
- sage/groups/additive_abelian/additive_abelian_wrapper.py +857 -0
- sage/groups/additive_abelian/all.py +4 -0
- sage/groups/additive_abelian/qmodnz.py +231 -0
- sage/groups/additive_abelian/qmodnz_element.py +349 -0
- sage/groups/affine_gps/affine_group.py +535 -0
- sage/groups/affine_gps/all.py +1 -0
- sage/groups/affine_gps/catalog.py +17 -0
- sage/groups/affine_gps/euclidean_group.py +246 -0
- sage/groups/affine_gps/group_element.py +562 -0
- sage/groups/all__sagemath_modules.py +12 -0
- sage/groups/galois_group.py +479 -0
- sage/groups/matrix_gps/all.py +4 -0
- sage/groups/matrix_gps/all__sagemath_modules.py +13 -0
- sage/groups/matrix_gps/catalog.py +26 -0
- sage/groups/matrix_gps/coxeter_group.py +927 -0
- sage/groups/matrix_gps/finitely_generated.py +487 -0
- sage/groups/matrix_gps/group_element.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/groups/matrix_gps/group_element.pxd +11 -0
- sage/groups/matrix_gps/group_element.pyx +431 -0
- sage/groups/matrix_gps/linear.py +440 -0
- sage/groups/matrix_gps/matrix_group.py +617 -0
- sage/groups/matrix_gps/named_group.py +296 -0
- sage/groups/matrix_gps/orthogonal.py +544 -0
- sage/groups/matrix_gps/symplectic.py +251 -0
- sage/groups/matrix_gps/unitary.py +436 -0
- sage/groups/misc_gps/all__sagemath_modules.py +1 -0
- sage/groups/misc_gps/argument_groups.py +1905 -0
- sage/groups/misc_gps/imaginary_groups.py +479 -0
- sage/groups/perm_gps/all__sagemath_modules.py +1 -0
- sage/groups/perm_gps/partn_ref/all__sagemath_modules.py +1 -0
- sage/groups/perm_gps/partn_ref/refinement_binary.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/groups/perm_gps/partn_ref/refinement_binary.pxd +41 -0
- sage/groups/perm_gps/partn_ref/refinement_binary.pyx +1167 -0
- sage/groups/perm_gps/partn_ref/refinement_matrices.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/groups/perm_gps/partn_ref/refinement_matrices.pxd +31 -0
- sage/groups/perm_gps/partn_ref/refinement_matrices.pyx +385 -0
- sage/homology/algebraic_topological_model.py +595 -0
- sage/homology/all.py +2 -0
- sage/homology/all__sagemath_modules.py +8 -0
- sage/homology/chain_complex.py +2148 -0
- sage/homology/chain_complex_homspace.py +165 -0
- sage/homology/chain_complex_morphism.py +629 -0
- sage/homology/chain_homotopy.py +604 -0
- sage/homology/chains.py +653 -0
- sage/homology/free_resolution.py +923 -0
- sage/homology/graded_resolution.py +567 -0
- sage/homology/hochschild_complex.py +756 -0
- sage/homology/homology_group.py +188 -0
- sage/homology/homology_morphism.py +422 -0
- sage/homology/homology_vector_space_with_basis.py +1454 -0
- sage/homology/koszul_complex.py +169 -0
- sage/homology/matrix_utils.py +205 -0
- sage/libs/all__sagemath_modules.py +1 -0
- sage/libs/gsl/__init__.py +1 -0
- sage/libs/gsl/airy.pxd +56 -0
- sage/libs/gsl/all.pxd +66 -0
- sage/libs/gsl/array.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/libs/gsl/array.pxd +5 -0
- sage/libs/gsl/array.pyx +102 -0
- sage/libs/gsl/bessel.pxd +208 -0
- sage/libs/gsl/blas.pxd +116 -0
- sage/libs/gsl/blas_types.pxd +34 -0
- sage/libs/gsl/block.pxd +52 -0
- sage/libs/gsl/chebyshev.pxd +37 -0
- sage/libs/gsl/clausen.pxd +12 -0
- sage/libs/gsl/combination.pxd +47 -0
- sage/libs/gsl/complex.pxd +151 -0
- sage/libs/gsl/coulomb.pxd +30 -0
- sage/libs/gsl/coupling.pxd +21 -0
- sage/libs/gsl/dawson.pxd +12 -0
- sage/libs/gsl/debye.pxd +24 -0
- sage/libs/gsl/dilog.pxd +14 -0
- sage/libs/gsl/eigen.pxd +46 -0
- sage/libs/gsl/elementary.pxd +12 -0
- sage/libs/gsl/ellint.pxd +48 -0
- sage/libs/gsl/elljac.pxd +8 -0
- sage/libs/gsl/erf.pxd +32 -0
- sage/libs/gsl/errno.pxd +26 -0
- sage/libs/gsl/exp.pxd +44 -0
- sage/libs/gsl/expint.pxd +44 -0
- sage/libs/gsl/fermi_dirac.pxd +44 -0
- sage/libs/gsl/fft.pxd +121 -0
- sage/libs/gsl/fit.pxd +50 -0
- sage/libs/gsl/gamma.pxd +94 -0
- sage/libs/gsl/gegenbauer.pxd +26 -0
- sage/libs/gsl/histogram.pxd +176 -0
- sage/libs/gsl/hyperg.pxd +52 -0
- sage/libs/gsl/integration.pxd +69 -0
- sage/libs/gsl/interp.pxd +109 -0
- sage/libs/gsl/laguerre.pxd +24 -0
- sage/libs/gsl/lambert.pxd +16 -0
- sage/libs/gsl/legendre.pxd +90 -0
- sage/libs/gsl/linalg.pxd +185 -0
- sage/libs/gsl/log.pxd +26 -0
- sage/libs/gsl/math.pxd +43 -0
- sage/libs/gsl/matrix.pxd +143 -0
- sage/libs/gsl/matrix_complex.pxd +130 -0
- sage/libs/gsl/min.pxd +67 -0
- sage/libs/gsl/monte.pxd +56 -0
- sage/libs/gsl/ntuple.pxd +32 -0
- sage/libs/gsl/odeiv.pxd +70 -0
- sage/libs/gsl/permutation.pxd +78 -0
- sage/libs/gsl/poly.pxd +40 -0
- sage/libs/gsl/pow_int.pxd +12 -0
- sage/libs/gsl/psi.pxd +28 -0
- sage/libs/gsl/qrng.pxd +29 -0
- sage/libs/gsl/random.pxd +257 -0
- sage/libs/gsl/rng.pxd +100 -0
- sage/libs/gsl/roots.pxd +72 -0
- sage/libs/gsl/sort.pxd +36 -0
- sage/libs/gsl/statistics.pxd +59 -0
- sage/libs/gsl/sum.pxd +55 -0
- sage/libs/gsl/synchrotron.pxd +16 -0
- sage/libs/gsl/transport.pxd +24 -0
- sage/libs/gsl/trig.pxd +58 -0
- sage/libs/gsl/types.pxd +137 -0
- sage/libs/gsl/vector.pxd +101 -0
- sage/libs/gsl/vector_complex.pxd +83 -0
- sage/libs/gsl/wavelet.pxd +49 -0
- sage/libs/gsl/zeta.pxd +28 -0
- sage/libs/mpc/__init__.pxd +114 -0
- sage/libs/mpc/types.pxd +28 -0
- sage/libs/mpfr/__init__.pxd +299 -0
- sage/libs/mpfr/types.pxd +26 -0
- sage/libs/mpmath/__init__.py +1 -0
- sage/libs/mpmath/all.py +27 -0
- sage/libs/mpmath/all__sagemath_modules.py +1 -0
- sage/libs/mpmath/utils.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/libs/mpmath/utils.pxd +4 -0
- sage/libs/mpmath/utils.pyx +319 -0
- sage/matrix/action.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/matrix/action.pxd +26 -0
- sage/matrix/action.pyx +596 -0
- sage/matrix/all.py +9 -0
- sage/matrix/args.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/matrix/args.pxd +144 -0
- sage/matrix/args.pyx +1668 -0
- sage/matrix/benchmark.py +1258 -0
- sage/matrix/berlekamp_massey.py +95 -0
- sage/matrix/compute_J_ideal.py +926 -0
- sage/matrix/constructor.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/matrix/constructor.pyx +750 -0
- sage/matrix/docs.py +430 -0
- sage/matrix/echelon_matrix.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/matrix/echelon_matrix.pyx +155 -0
- sage/matrix/matrix.pxd +2 -0
- sage/matrix/matrix0.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/matrix/matrix0.pxd +68 -0
- sage/matrix/matrix0.pyx +6324 -0
- sage/matrix/matrix1.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/matrix/matrix1.pxd +8 -0
- sage/matrix/matrix1.pyx +2851 -0
- sage/matrix/matrix2.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/matrix/matrix2.pxd +25 -0
- sage/matrix/matrix2.pyx +20181 -0
- sage/matrix/matrix_cdv.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/matrix/matrix_cdv.pxd +4 -0
- sage/matrix/matrix_cdv.pyx +93 -0
- sage/matrix/matrix_complex_double_dense.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/matrix/matrix_complex_double_dense.pxd +5 -0
- sage/matrix/matrix_complex_double_dense.pyx +98 -0
- sage/matrix/matrix_dense.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/matrix/matrix_dense.pxd +5 -0
- sage/matrix/matrix_dense.pyx +343 -0
- sage/matrix/matrix_domain_dense.pxd +5 -0
- sage/matrix/matrix_domain_sparse.pxd +5 -0
- sage/matrix/matrix_double_dense.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/matrix/matrix_double_dense.pxd +7 -0
- sage/matrix/matrix_double_dense.pyx +3906 -0
- sage/matrix/matrix_double_sparse.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/matrix/matrix_double_sparse.pxd +6 -0
- sage/matrix/matrix_double_sparse.pyx +248 -0
- sage/matrix/matrix_generic_dense.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/matrix/matrix_generic_dense.pxd +7 -0
- sage/matrix/matrix_generic_dense.pyx +354 -0
- sage/matrix/matrix_generic_sparse.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/matrix/matrix_generic_sparse.pxd +7 -0
- sage/matrix/matrix_generic_sparse.pyx +461 -0
- sage/matrix/matrix_laurent_mpolynomial_dense.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/matrix/matrix_laurent_mpolynomial_dense.pxd +5 -0
- sage/matrix/matrix_laurent_mpolynomial_dense.pyx +115 -0
- sage/matrix/matrix_misc.py +313 -0
- sage/matrix/matrix_numpy_dense.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/matrix/matrix_numpy_dense.pxd +14 -0
- sage/matrix/matrix_numpy_dense.pyx +450 -0
- sage/matrix/matrix_numpy_integer_dense.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/matrix/matrix_numpy_integer_dense.pxd +7 -0
- sage/matrix/matrix_numpy_integer_dense.pyx +59 -0
- sage/matrix/matrix_polynomial_dense.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/matrix/matrix_polynomial_dense.pxd +5 -0
- sage/matrix/matrix_polynomial_dense.pyx +5341 -0
- sage/matrix/matrix_real_double_dense.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/matrix/matrix_real_double_dense.pxd +7 -0
- sage/matrix/matrix_real_double_dense.pyx +122 -0
- sage/matrix/matrix_space.py +2848 -0
- sage/matrix/matrix_sparse.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/matrix/matrix_sparse.pxd +5 -0
- sage/matrix/matrix_sparse.pyx +1222 -0
- sage/matrix/matrix_window.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/matrix/matrix_window.pxd +37 -0
- sage/matrix/matrix_window.pyx +242 -0
- sage/matrix/misc_mpfr.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/matrix/misc_mpfr.pyx +80 -0
- sage/matrix/operation_table.py +1182 -0
- sage/matrix/special.py +3666 -0
- sage/matrix/strassen.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/matrix/strassen.pyx +851 -0
- sage/matrix/symplectic_basis.py +541 -0
- sage/matrix/template.pxd +6 -0
- sage/matrix/tests.py +71 -0
- sage/matroids/advanced.py +77 -0
- sage/matroids/all.py +13 -0
- sage/matroids/basis_exchange_matroid.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/matroids/basis_exchange_matroid.pxd +96 -0
- sage/matroids/basis_exchange_matroid.pyx +2344 -0
- sage/matroids/basis_matroid.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/matroids/basis_matroid.pxd +45 -0
- sage/matroids/basis_matroid.pyx +1217 -0
- sage/matroids/catalog.py +44 -0
- sage/matroids/chow_ring.py +473 -0
- sage/matroids/chow_ring_ideal.py +849 -0
- sage/matroids/circuit_closures_matroid.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/matroids/circuit_closures_matroid.pxd +16 -0
- sage/matroids/circuit_closures_matroid.pyx +559 -0
- sage/matroids/circuits_matroid.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/matroids/circuits_matroid.pxd +38 -0
- sage/matroids/circuits_matroid.pyx +947 -0
- sage/matroids/constructor.py +1086 -0
- sage/matroids/database_collections.py +365 -0
- sage/matroids/database_matroids.py +5338 -0
- sage/matroids/dual_matroid.py +583 -0
- sage/matroids/extension.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/matroids/extension.pxd +34 -0
- sage/matroids/extension.pyx +519 -0
- sage/matroids/flats_matroid.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/matroids/flats_matroid.pxd +28 -0
- sage/matroids/flats_matroid.pyx +715 -0
- sage/matroids/gammoid.py +600 -0
- sage/matroids/graphic_matroid.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/matroids/graphic_matroid.pxd +39 -0
- sage/matroids/graphic_matroid.pyx +2024 -0
- sage/matroids/lean_matrix.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/matroids/lean_matrix.pxd +126 -0
- sage/matroids/lean_matrix.pyx +3667 -0
- sage/matroids/linear_matroid.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/matroids/linear_matroid.pxd +180 -0
- sage/matroids/linear_matroid.pyx +6649 -0
- sage/matroids/matroid.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/matroids/matroid.pxd +243 -0
- sage/matroids/matroid.pyx +8759 -0
- sage/matroids/matroids_catalog.py +190 -0
- sage/matroids/matroids_plot_helpers.py +890 -0
- sage/matroids/minor_matroid.py +480 -0
- sage/matroids/minorfix.h +9 -0
- sage/matroids/named_matroids.py +5 -0
- sage/matroids/rank_matroid.py +268 -0
- sage/matroids/set_system.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/matroids/set_system.pxd +38 -0
- sage/matroids/set_system.pyx +800 -0
- sage/matroids/transversal_matroid.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/matroids/transversal_matroid.pxd +14 -0
- sage/matroids/transversal_matroid.pyx +893 -0
- sage/matroids/union_matroid.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/matroids/union_matroid.pxd +20 -0
- sage/matroids/union_matroid.pyx +331 -0
- sage/matroids/unpickling.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/matroids/unpickling.pyx +843 -0
- sage/matroids/utilities.py +809 -0
- sage/misc/all__sagemath_modules.py +20 -0
- sage/misc/c3.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/misc/c3.pyx +238 -0
- sage/misc/compat.py +87 -0
- sage/misc/element_with_label.py +173 -0
- sage/misc/func_persist.py +79 -0
- sage/misc/pickle_old.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/misc/pickle_old.pyx +19 -0
- sage/misc/proof.py +7 -0
- sage/misc/replace_dot_all.py +472 -0
- sage/misc/sagedoc_conf.py +168 -0
- sage/misc/sphinxify.py +167 -0
- sage/misc/test_class_pickling.py +85 -0
- sage/modules/all.py +42 -0
- sage/modules/complex_double_vector.py +25 -0
- sage/modules/diamond_cutting.py +380 -0
- sage/modules/fg_pid/all.py +1 -0
- sage/modules/fg_pid/fgp_element.py +456 -0
- sage/modules/fg_pid/fgp_module.py +2091 -0
- sage/modules/fg_pid/fgp_morphism.py +550 -0
- sage/modules/filtered_vector_space.py +1271 -0
- sage/modules/finite_submodule_iter.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/modules/finite_submodule_iter.pxd +27 -0
- sage/modules/finite_submodule_iter.pyx +452 -0
- sage/modules/fp_graded/all.py +1 -0
- sage/modules/fp_graded/element.py +346 -0
- sage/modules/fp_graded/free_element.py +298 -0
- sage/modules/fp_graded/free_homspace.py +53 -0
- sage/modules/fp_graded/free_module.py +1060 -0
- sage/modules/fp_graded/free_morphism.py +217 -0
- sage/modules/fp_graded/homspace.py +563 -0
- sage/modules/fp_graded/module.py +1340 -0
- sage/modules/fp_graded/morphism.py +1990 -0
- sage/modules/fp_graded/steenrod/all.py +1 -0
- sage/modules/fp_graded/steenrod/homspace.py +65 -0
- sage/modules/fp_graded/steenrod/module.py +477 -0
- sage/modules/fp_graded/steenrod/morphism.py +404 -0
- sage/modules/fp_graded/steenrod/profile.py +241 -0
- sage/modules/free_module.py +8447 -0
- sage/modules/free_module_element.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/modules/free_module_element.pxd +22 -0
- sage/modules/free_module_element.pyx +5445 -0
- sage/modules/free_module_homspace.py +369 -0
- sage/modules/free_module_integer.py +896 -0
- sage/modules/free_module_morphism.py +823 -0
- sage/modules/free_module_pseudohomspace.py +352 -0
- sage/modules/free_module_pseudomorphism.py +578 -0
- sage/modules/free_quadratic_module.py +1706 -0
- sage/modules/free_quadratic_module_integer_symmetric.py +1790 -0
- sage/modules/matrix_morphism.py +1745 -0
- sage/modules/misc.py +103 -0
- sage/modules/module_functors.py +192 -0
- sage/modules/multi_filtered_vector_space.py +719 -0
- sage/modules/ore_module.py +2208 -0
- sage/modules/ore_module_element.py +178 -0
- sage/modules/ore_module_homspace.py +147 -0
- sage/modules/ore_module_morphism.py +968 -0
- sage/modules/quotient_module.py +699 -0
- sage/modules/real_double_vector.py +22 -0
- sage/modules/submodule.py +255 -0
- sage/modules/tensor_operations.py +567 -0
- sage/modules/torsion_quadratic_module.py +1352 -0
- sage/modules/tutorial_free_modules.py +248 -0
- sage/modules/vector_complex_double_dense.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/modules/vector_complex_double_dense.pxd +6 -0
- sage/modules/vector_complex_double_dense.pyx +117 -0
- sage/modules/vector_double_dense.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/modules/vector_double_dense.pxd +6 -0
- sage/modules/vector_double_dense.pyx +604 -0
- sage/modules/vector_integer_dense.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/modules/vector_integer_dense.pxd +15 -0
- sage/modules/vector_integer_dense.pyx +361 -0
- sage/modules/vector_integer_sparse.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/modules/vector_integer_sparse.pxd +29 -0
- sage/modules/vector_integer_sparse.pyx +406 -0
- sage/modules/vector_modn_dense.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/modules/vector_modn_dense.pxd +12 -0
- sage/modules/vector_modn_dense.pyx +394 -0
- sage/modules/vector_modn_sparse.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/modules/vector_modn_sparse.pxd +21 -0
- sage/modules/vector_modn_sparse.pyx +298 -0
- sage/modules/vector_numpy_dense.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/modules/vector_numpy_dense.pxd +15 -0
- sage/modules/vector_numpy_dense.pyx +304 -0
- sage/modules/vector_numpy_integer_dense.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/modules/vector_numpy_integer_dense.pxd +7 -0
- sage/modules/vector_numpy_integer_dense.pyx +54 -0
- sage/modules/vector_rational_dense.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/modules/vector_rational_dense.pxd +15 -0
- sage/modules/vector_rational_dense.pyx +387 -0
- sage/modules/vector_rational_sparse.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/modules/vector_rational_sparse.pxd +30 -0
- sage/modules/vector_rational_sparse.pyx +413 -0
- sage/modules/vector_real_double_dense.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/modules/vector_real_double_dense.pxd +6 -0
- sage/modules/vector_real_double_dense.pyx +126 -0
- sage/modules/vector_space_homspace.py +430 -0
- sage/modules/vector_space_morphism.py +989 -0
- sage/modules/with_basis/all.py +15 -0
- sage/modules/with_basis/cell_module.py +494 -0
- sage/modules/with_basis/indexed_element.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/modules/with_basis/indexed_element.pxd +13 -0
- sage/modules/with_basis/indexed_element.pyx +1058 -0
- sage/modules/with_basis/invariant.py +1075 -0
- sage/modules/with_basis/morphism.py +1636 -0
- sage/modules/with_basis/representation.py +2939 -0
- sage/modules/with_basis/subquotient.py +685 -0
- sage/numerical/all__sagemath_modules.py +6 -0
- sage/numerical/gauss_legendre.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/numerical/gauss_legendre.pyx +381 -0
- sage/numerical/optimize.py +910 -0
- sage/probability/all.py +10 -0
- sage/probability/probability_distribution.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/probability/probability_distribution.pyx +1242 -0
- sage/probability/random_variable.py +411 -0
- sage/quadratic_forms/all.py +4 -0
- sage/quadratic_forms/all__sagemath_modules.py +15 -0
- sage/quadratic_forms/binary_qf.py +2042 -0
- sage/quadratic_forms/bqf_class_group.py +748 -0
- sage/quadratic_forms/constructions.py +93 -0
- sage/quadratic_forms/count_local_2.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/quadratic_forms/count_local_2.pyx +365 -0
- sage/quadratic_forms/extras.py +195 -0
- sage/quadratic_forms/quadratic_form.py +1753 -0
- sage/quadratic_forms/quadratic_form__count_local_2.py +221 -0
- sage/quadratic_forms/quadratic_form__equivalence_testing.py +708 -0
- sage/quadratic_forms/quadratic_form__evaluate.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/quadratic_forms/quadratic_form__evaluate.pyx +139 -0
- sage/quadratic_forms/quadratic_form__local_density_congruence.py +977 -0
- sage/quadratic_forms/quadratic_form__local_field_invariants.py +1072 -0
- sage/quadratic_forms/quadratic_form__neighbors.py +424 -0
- sage/quadratic_forms/quadratic_form__reduction_theory.py +488 -0
- sage/quadratic_forms/quadratic_form__split_local_covering.py +416 -0
- sage/quadratic_forms/quadratic_form__ternary_Tornaria.py +657 -0
- sage/quadratic_forms/quadratic_form__theta.py +352 -0
- sage/quadratic_forms/quadratic_form__variable_substitutions.py +370 -0
- sage/quadratic_forms/random_quadraticform.py +209 -0
- sage/quadratic_forms/ternary.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/quadratic_forms/ternary.pyx +1154 -0
- sage/quadratic_forms/ternary_qf.py +2027 -0
- sage/rings/all__sagemath_modules.py +28 -0
- sage/rings/asymptotic/all__sagemath_modules.py +1 -0
- sage/rings/asymptotic/misc.py +1252 -0
- sage/rings/cc.py +4 -0
- sage/rings/cfinite_sequence.py +1306 -0
- sage/rings/complex_conversion.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/rings/complex_conversion.pxd +8 -0
- sage/rings/complex_conversion.pyx +23 -0
- sage/rings/complex_double.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/rings/complex_double.pxd +21 -0
- sage/rings/complex_double.pyx +2654 -0
- sage/rings/complex_mpc.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/rings/complex_mpc.pxd +21 -0
- sage/rings/complex_mpc.pyx +2576 -0
- sage/rings/complex_mpfr.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/rings/complex_mpfr.pxd +18 -0
- sage/rings/complex_mpfr.pyx +3602 -0
- sage/rings/derivation.py +2334 -0
- sage/rings/finite_rings/all__sagemath_modules.py +1 -0
- sage/rings/finite_rings/maps_finite_field.py +191 -0
- sage/rings/function_field/all__sagemath_modules.py +8 -0
- sage/rings/function_field/derivations.py +102 -0
- sage/rings/function_field/derivations_rational.py +132 -0
- sage/rings/function_field/differential.py +853 -0
- sage/rings/function_field/divisor.py +1107 -0
- sage/rings/function_field/drinfeld_modules/action.py +199 -0
- sage/rings/function_field/drinfeld_modules/all.py +1 -0
- sage/rings/function_field/drinfeld_modules/charzero_drinfeld_module.py +673 -0
- sage/rings/function_field/drinfeld_modules/drinfeld_module.py +2087 -0
- sage/rings/function_field/drinfeld_modules/finite_drinfeld_module.py +1131 -0
- sage/rings/function_field/drinfeld_modules/homset.py +420 -0
- sage/rings/function_field/drinfeld_modules/morphism.py +820 -0
- sage/rings/function_field/hermite_form_polynomial.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/rings/function_field/hermite_form_polynomial.pyx +188 -0
- sage/rings/function_field/khuri_makdisi.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/rings/function_field/khuri_makdisi.pyx +935 -0
- sage/rings/invariants/all.py +4 -0
- sage/rings/invariants/invariant_theory.py +4597 -0
- sage/rings/invariants/reconstruction.py +395 -0
- sage/rings/polynomial/all__sagemath_modules.py +17 -0
- sage/rings/polynomial/integer_valued_polynomials.py +1230 -0
- sage/rings/polynomial/laurent_polynomial_mpair.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/rings/polynomial/laurent_polynomial_mpair.pxd +15 -0
- sage/rings/polynomial/laurent_polynomial_mpair.pyx +2023 -0
- sage/rings/polynomial/ore_function_element.py +952 -0
- sage/rings/polynomial/ore_function_field.py +1028 -0
- sage/rings/polynomial/ore_polynomial_element.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/rings/polynomial/ore_polynomial_element.pxd +48 -0
- sage/rings/polynomial/ore_polynomial_element.pyx +3145 -0
- sage/rings/polynomial/ore_polynomial_ring.py +1334 -0
- sage/rings/polynomial/polynomial_real_mpfr_dense.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/rings/polynomial/polynomial_real_mpfr_dense.pyx +788 -0
- sage/rings/polynomial/q_integer_valued_polynomials.py +1264 -0
- sage/rings/polynomial/skew_polynomial_element.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/rings/polynomial/skew_polynomial_element.pxd +9 -0
- sage/rings/polynomial/skew_polynomial_element.pyx +684 -0
- sage/rings/polynomial/skew_polynomial_finite_field.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/rings/polynomial/skew_polynomial_finite_field.pxd +19 -0
- sage/rings/polynomial/skew_polynomial_finite_field.pyx +1093 -0
- sage/rings/polynomial/skew_polynomial_finite_order.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/rings/polynomial/skew_polynomial_finite_order.pxd +10 -0
- sage/rings/polynomial/skew_polynomial_finite_order.pyx +567 -0
- sage/rings/polynomial/skew_polynomial_ring.py +908 -0
- sage/rings/real_double_element_gsl.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/rings/real_double_element_gsl.pxd +8 -0
- sage/rings/real_double_element_gsl.pyx +794 -0
- sage/rings/real_field.py +58 -0
- sage/rings/real_mpfr.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/rings/real_mpfr.pxd +29 -0
- sage/rings/real_mpfr.pyx +6122 -0
- sage/rings/ring_extension.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/rings/ring_extension.pxd +42 -0
- sage/rings/ring_extension.pyx +2779 -0
- sage/rings/ring_extension_conversion.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/rings/ring_extension_conversion.pxd +16 -0
- sage/rings/ring_extension_conversion.pyx +462 -0
- sage/rings/ring_extension_element.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/rings/ring_extension_element.pxd +21 -0
- sage/rings/ring_extension_element.pyx +1635 -0
- sage/rings/ring_extension_homset.py +64 -0
- sage/rings/ring_extension_morphism.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/rings/ring_extension_morphism.pxd +35 -0
- sage/rings/ring_extension_morphism.pyx +920 -0
- sage/schemes/all__sagemath_modules.py +1 -0
- sage/schemes/projective/all__sagemath_modules.py +1 -0
- sage/schemes/projective/coherent_sheaf.py +300 -0
- sage/schemes/projective/cohomology.py +510 -0
- sage/stats/all.py +15 -0
- sage/stats/basic_stats.py +489 -0
- sage/stats/distributions/all.py +7 -0
- sage/stats/distributions/catalog.py +34 -0
- sage/stats/distributions/dgs.h +50 -0
- sage/stats/distributions/dgs.pxd +111 -0
- sage/stats/distributions/dgs_bern.h +400 -0
- sage/stats/distributions/dgs_gauss.h +614 -0
- sage/stats/distributions/dgs_misc.h +104 -0
- sage/stats/distributions/discrete_gaussian_integer.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/stats/distributions/discrete_gaussian_integer.pxd +14 -0
- sage/stats/distributions/discrete_gaussian_integer.pyx +498 -0
- sage/stats/distributions/discrete_gaussian_lattice.py +908 -0
- sage/stats/distributions/discrete_gaussian_polynomial.py +141 -0
- sage/stats/hmm/all.py +15 -0
- sage/stats/hmm/chmm.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/stats/hmm/chmm.pyx +1595 -0
- sage/stats/hmm/distributions.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/stats/hmm/distributions.pxd +29 -0
- sage/stats/hmm/distributions.pyx +531 -0
- sage/stats/hmm/hmm.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/stats/hmm/hmm.pxd +17 -0
- sage/stats/hmm/hmm.pyx +1388 -0
- sage/stats/hmm/util.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/stats/hmm/util.pxd +7 -0
- sage/stats/hmm/util.pyx +165 -0
- sage/stats/intlist.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/stats/intlist.pxd +14 -0
- sage/stats/intlist.pyx +588 -0
- sage/stats/r.py +49 -0
- sage/stats/time_series.cpython-314-aarch64-linux-gnu.so +0 -0
- sage/stats/time_series.pxd +6 -0
- sage/stats/time_series.pyx +2546 -0
- sage/tensor/all.py +2 -0
- sage/tensor/modules/all.py +8 -0
- sage/tensor/modules/alternating_contr_tensor.py +761 -0
- sage/tensor/modules/comp.py +5598 -0
- sage/tensor/modules/ext_pow_free_module.py +824 -0
- sage/tensor/modules/finite_rank_free_module.py +3589 -0
- sage/tensor/modules/format_utilities.py +333 -0
- sage/tensor/modules/free_module_alt_form.py +858 -0
- sage/tensor/modules/free_module_automorphism.py +1207 -0
- sage/tensor/modules/free_module_basis.py +1074 -0
- sage/tensor/modules/free_module_element.py +284 -0
- sage/tensor/modules/free_module_homset.py +652 -0
- sage/tensor/modules/free_module_linear_group.py +564 -0
- sage/tensor/modules/free_module_morphism.py +1581 -0
- sage/tensor/modules/free_module_tensor.py +3289 -0
- sage/tensor/modules/reflexive_module.py +386 -0
- sage/tensor/modules/tensor_free_module.py +780 -0
- sage/tensor/modules/tensor_free_submodule.py +538 -0
- sage/tensor/modules/tensor_free_submodule_basis.py +140 -0
- sage/tensor/modules/tensor_with_indices.py +1043 -0
|
@@ -0,0 +1,2576 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-modules
|
|
2
|
+
"""
|
|
3
|
+
Arbitrary precision floating point complex numbers using GNU MPC
|
|
4
|
+
|
|
5
|
+
This is a binding for the arbitrary-precision floating point library
|
|
6
|
+
:ref:`GNU MPC <spkg_mpc>`.
|
|
7
|
+
|
|
8
|
+
We define a class :class:`MPComplexField`, each instance of which
|
|
9
|
+
specifies a field of floating-point complex numbers with
|
|
10
|
+
a specified precision shared by the real and imaginary part and a rounding
|
|
11
|
+
mode stating the rounding mode directions specific to real and imaginary
|
|
12
|
+
parts.
|
|
13
|
+
|
|
14
|
+
Individual floating-point numbers are of class :class:`MPComplexNumber`.
|
|
15
|
+
|
|
16
|
+
For floating-point representation and rounding mode description see the
|
|
17
|
+
documentation for the :mod:`sage.rings.real_mpfr`.
|
|
18
|
+
|
|
19
|
+
AUTHORS:
|
|
20
|
+
|
|
21
|
+
- Philippe Theveny (2008-10-13): initial version, adapted from
|
|
22
|
+
:mod:`sage.rings.real_mpfr` and :mod:`sage.rings.complex_mpfr`.
|
|
23
|
+
|
|
24
|
+
- Alex Ghitza (2008-11): cache, generators, random element, and many doctests.
|
|
25
|
+
|
|
26
|
+
- Yann Laigle-Chapuy (2010-01): improves compatibility with CC, updates.
|
|
27
|
+
|
|
28
|
+
- Jeroen Demeyer (2012-02): reformat documentation, make MPC a standard
|
|
29
|
+
package.
|
|
30
|
+
|
|
31
|
+
- Travis Scrimshaw (2012-10-18): Added doctests for full coverage.
|
|
32
|
+
|
|
33
|
+
- Vincent Klein (2017-11-15) : add __mpc__() to class MPComplexNumber.
|
|
34
|
+
MPComplexNumber constructor support gmpy2.mpz, gmpy2.mpq, gmpy2.mpfr
|
|
35
|
+
and gmpy2.mpc parameters.
|
|
36
|
+
|
|
37
|
+
EXAMPLES::
|
|
38
|
+
|
|
39
|
+
sage: MPC = MPComplexField(42)
|
|
40
|
+
sage: a = MPC(12, '15.64E+32'); a
|
|
41
|
+
12.0000000000 + 1.56400000000e33*I
|
|
42
|
+
sage: a *a *a *a
|
|
43
|
+
5.98338564121e132 - 1.83633318912e101*I
|
|
44
|
+
sage: a + 1
|
|
45
|
+
13.0000000000 + 1.56400000000e33*I
|
|
46
|
+
sage: a / 3
|
|
47
|
+
4.00000000000 + 5.21333333333e32*I
|
|
48
|
+
sage: MPC("infinity + NaN *I")
|
|
49
|
+
+infinity + NaN*I
|
|
50
|
+
"""
|
|
51
|
+
# ****************************************************************************
|
|
52
|
+
# Copyright (C) 2008 Philippe Theveny <thevenyp@loria.fr>
|
|
53
|
+
# 2008 Alex Ghitza
|
|
54
|
+
# 2010 Yann Laigle-Chapuy
|
|
55
|
+
# 2012 Jeroen Demeyer <jdemeyer@cage.ugent.be>
|
|
56
|
+
#
|
|
57
|
+
# Distributed under the terms of the GNU General Public License (GPL)
|
|
58
|
+
# as published by the Free Software Foundation; either version 2 of
|
|
59
|
+
# the License, or (at your option) any later version.
|
|
60
|
+
# https://www.gnu.org/licenses/
|
|
61
|
+
# ****************************************************************************
|
|
62
|
+
|
|
63
|
+
import re
|
|
64
|
+
from sage.rings import real_mpfr
|
|
65
|
+
import weakref
|
|
66
|
+
from cpython.object cimport Py_NE
|
|
67
|
+
|
|
68
|
+
import sage
|
|
69
|
+
from sage.cpython.string cimport str_to_bytes
|
|
70
|
+
from sage.libs.mpfr cimport *
|
|
71
|
+
from sage.libs.mpc cimport *
|
|
72
|
+
from sage.structure.parent cimport Parent
|
|
73
|
+
from sage.structure.element cimport Element
|
|
74
|
+
from sage.structure.richcmp cimport rich_to_bool
|
|
75
|
+
from sage.categories.map cimport Map
|
|
76
|
+
|
|
77
|
+
try:
|
|
78
|
+
from sage.libs.pari import pari
|
|
79
|
+
from cypari2.handle_error import PariError
|
|
80
|
+
from cypari2.gen import Gen as pari_gen
|
|
81
|
+
except ImportError:
|
|
82
|
+
pari_gen = PariError = ()
|
|
83
|
+
|
|
84
|
+
from sage.rings.integer cimport Integer
|
|
85
|
+
from sage.rings.complex_mpfr cimport ComplexNumber
|
|
86
|
+
from sage.rings.complex_mpfr import ComplexField_class
|
|
87
|
+
|
|
88
|
+
from sage.misc.randstate cimport randstate, current_randstate
|
|
89
|
+
from sage.rings.real_mpfr cimport RealField_class, RealNumber
|
|
90
|
+
from sage.rings.real_mpfr import mpfr_prec_min, mpfr_prec_max
|
|
91
|
+
from sage.structure.richcmp cimport rich_to_bool, richcmp
|
|
92
|
+
from sage.categories.fields import Fields
|
|
93
|
+
from sage.structure.element import Expression
|
|
94
|
+
|
|
95
|
+
cimport gmpy2
|
|
96
|
+
gmpy2.import_gmpy2()
|
|
97
|
+
|
|
98
|
+
AA = None
|
|
99
|
+
QQbar = None
|
|
100
|
+
CDF = CLF = RLF = None
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def late_import():
|
|
104
|
+
"""
|
|
105
|
+
Import the objects/modules after build (when needed).
|
|
106
|
+
|
|
107
|
+
TESTS::
|
|
108
|
+
|
|
109
|
+
sage: sage.rings.complex_mpc.late_import()
|
|
110
|
+
"""
|
|
111
|
+
global AA, QQbar
|
|
112
|
+
global CLF, RLF, CDF
|
|
113
|
+
if CDF is None:
|
|
114
|
+
try:
|
|
115
|
+
from sage.rings.qqbar import AA, QQbar
|
|
116
|
+
except ImportError:
|
|
117
|
+
pass
|
|
118
|
+
from sage.rings.real_lazy import CLF, RLF
|
|
119
|
+
from sage.rings.complex_double import CDF
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
_mpfr_rounding_modes = ['RNDN', 'RNDZ', 'RNDU', 'RNDD']
|
|
123
|
+
|
|
124
|
+
_mpc_rounding_modes = [ 'RNDNN', 'RNDZN', 'RNDUN', 'RNDDN',
|
|
125
|
+
'', '', '', '', '', '', '', '', '', '', '', '',
|
|
126
|
+
'RNDNZ', 'RNDZZ', 'RNDUZ', 'RNDDZ',
|
|
127
|
+
'', '', '', '', '', '', '', '', '', '', '', '',
|
|
128
|
+
'RNDUN', 'RNDZU', 'RNDUU', 'RNDDU',
|
|
129
|
+
'', '', '', '', '', '', '', '', '', '', '', '',
|
|
130
|
+
'RNDDN', 'RNDZD', 'RNDUD', 'RNDDD' ]
|
|
131
|
+
|
|
132
|
+
cdef inline mpfr_rnd_t rnd_re(mpc_rnd_t rnd) noexcept:
|
|
133
|
+
"""
|
|
134
|
+
Return the numeric value of the real part rounding mode. This
|
|
135
|
+
is an internal function.
|
|
136
|
+
"""
|
|
137
|
+
return <mpfr_rnd_t>(rnd & 3)
|
|
138
|
+
|
|
139
|
+
cdef inline mpfr_rnd_t rnd_im(mpc_rnd_t rnd) noexcept:
|
|
140
|
+
"""
|
|
141
|
+
Return the numeric value of the imaginary part rounding mode.
|
|
142
|
+
This is an internal function.
|
|
143
|
+
"""
|
|
144
|
+
return <mpfr_rnd_t>(rnd >> 4)
|
|
145
|
+
|
|
146
|
+
sign = '[+-]'
|
|
147
|
+
digit_ten = '[0123456789]'
|
|
148
|
+
exponent_ten = '[e@]' + sign + '?[0123456789]+'
|
|
149
|
+
number_ten = r'inf(?:inity)?|@inf@|nan(?:\([0-9A-Z_]*\))?|@nan@(?:\([0-9A-Z_]*\))?'\
|
|
150
|
+
'|(?:' + digit_ten + r'*\.' + digit_ten + '+|' + digit_ten + r'+\.?)(?:' + exponent_ten + ')?'
|
|
151
|
+
imaginary_ten = r'i(?:\s*\*\s*(?:' + number_ten + '))?|(?:' + number_ten + r')\s*\*\s*i'
|
|
152
|
+
complex_ten = '(?P<im_first>(?P<im_first_im_sign>' + sign + r')?\s*(?P<im_first_im_abs>' + imaginary_ten + r')' \
|
|
153
|
+
r'(\s*(?P<im_first_re_sign>' + sign + r')\s*(?P<im_first_re_abs>' + number_ten + '))?)' \
|
|
154
|
+
'|' \
|
|
155
|
+
'(?P<re_first>(?P<re_first_re_sign>' + sign + r')?\s*(?P<re_first_re_abs>' + number_ten + r')' \
|
|
156
|
+
r'(\s*(?P<re_first_im_sign>' + sign + r')\s*(?P<re_first_im_abs>' + imaginary_ten + '))?)'
|
|
157
|
+
re_complex_ten = re.compile(r'^\s*(?:' + complex_ten + r')\s*$', re.I)
|
|
158
|
+
|
|
159
|
+
cpdef inline split_complex_string(string, int base=10):
|
|
160
|
+
"""
|
|
161
|
+
Split and return in that order the real and imaginary parts
|
|
162
|
+
of a complex in a string.
|
|
163
|
+
|
|
164
|
+
This is an internal function.
|
|
165
|
+
|
|
166
|
+
EXAMPLES::
|
|
167
|
+
|
|
168
|
+
sage: sage.rings.complex_mpc.split_complex_string('123.456e789')
|
|
169
|
+
('123.456e789', None)
|
|
170
|
+
sage: sage.rings.complex_mpc.split_complex_string('123.456e789*I')
|
|
171
|
+
(None, '123.456e789')
|
|
172
|
+
sage: sage.rings.complex_mpc.split_complex_string('123.+456e789*I')
|
|
173
|
+
('123.', '+456e789')
|
|
174
|
+
sage: sage.rings.complex_mpc.split_complex_string('123.456e789', base=2)
|
|
175
|
+
(None, None)
|
|
176
|
+
"""
|
|
177
|
+
if base == 10:
|
|
178
|
+
number = number_ten
|
|
179
|
+
z = re_complex_ten.match(string)
|
|
180
|
+
else:
|
|
181
|
+
all_digits = "0123456789abcdefghijklmnopqrstuvwxyz"
|
|
182
|
+
digit = '[' + all_digits[0:base] + ']'
|
|
183
|
+
|
|
184
|
+
# In MPFR, '1e42'-> 10^42, '1p42'->2^42, '1@42'->base^42
|
|
185
|
+
if base == 2:
|
|
186
|
+
exponent = '[e@p]'
|
|
187
|
+
elif base <= 10:
|
|
188
|
+
exponent = '[e@]'
|
|
189
|
+
elif base == 16:
|
|
190
|
+
exponent = '[@p]'
|
|
191
|
+
else:
|
|
192
|
+
exponent = '@'
|
|
193
|
+
exponent += sign + '?' + digit + '+'
|
|
194
|
+
|
|
195
|
+
# Warning: number, imaginary, and complex should be enclosed in parentheses
|
|
196
|
+
# when used as regexp because of alternatives '|'
|
|
197
|
+
number = r'@nan@(?:\([0-9A-Z_]*\))?|@inf@|(?:' + digit + r'*\.' + digit + '+|' + digit + r'+\.?)(?:' + exponent + ')?'
|
|
198
|
+
if base <= 10:
|
|
199
|
+
number = r'nan(?:\([0-9A-Z_]*\))?|inf(?:inity)?|' + number
|
|
200
|
+
imaginary = r'i(?:\s*\*\s*(?:' + number + '))?|(?:' + number + r')\s*\*\s*i'
|
|
201
|
+
complex = '(?P<im_first>(?P<im_first_im_sign>' + sign + r')?\s*(?P<im_first_im_abs>' + imaginary + r')' \
|
|
202
|
+
r'(\s*(?P<im_first_re_sign>' + sign + r')\s*(?P<im_first_re_abs>' + number + '))?)' \
|
|
203
|
+
'|' \
|
|
204
|
+
'(?P<re_first>(?P<re_first_re_sign>' + sign + r')?\s*(?P<re_first_re_abs>' + number + r')' \
|
|
205
|
+
r'(\s*(?P<re_first_im_sign>' + sign + r')\s*(?P<re_first_im_abs>' + imaginary + '))?)'
|
|
206
|
+
|
|
207
|
+
z = re.match(r'^\s*(?:' + complex + r')\s*$', string, re.I)
|
|
208
|
+
|
|
209
|
+
x, y = None, None
|
|
210
|
+
if z is not None:
|
|
211
|
+
if z.group('im_first') is not None:
|
|
212
|
+
prefix = 'im_first'
|
|
213
|
+
elif z.group('re_first') is not None:
|
|
214
|
+
prefix = 're_first'
|
|
215
|
+
else:
|
|
216
|
+
return None
|
|
217
|
+
|
|
218
|
+
if z.group(prefix + '_re_abs') is not None:
|
|
219
|
+
x = z.expand(r'\g<' + prefix + '_re_abs>')
|
|
220
|
+
if z.group(prefix + '_re_sign') is not None:
|
|
221
|
+
x = z.expand(r'\g<' + prefix + '_re_sign>') + x
|
|
222
|
+
|
|
223
|
+
if z.group(prefix + '_im_abs') is not None:
|
|
224
|
+
y = re.search('(?P<im_part>' + number + ')', z.expand(r'\g<' + prefix + '_im_abs>'), re.I)
|
|
225
|
+
if y is None:
|
|
226
|
+
y = '1'
|
|
227
|
+
else:
|
|
228
|
+
y = y.expand(r'\g<im_part>')
|
|
229
|
+
if z.group(prefix + '_im_sign') is not None:
|
|
230
|
+
y = z.expand(r'\g<' + prefix + '_im_sign>') + y
|
|
231
|
+
|
|
232
|
+
return x, y
|
|
233
|
+
|
|
234
|
+
#*****************************************************************************
|
|
235
|
+
#
|
|
236
|
+
# MPComplex Field
|
|
237
|
+
#
|
|
238
|
+
#*****************************************************************************
|
|
239
|
+
# The complex field is in Cython, so mpc elements will have access to
|
|
240
|
+
# their parent via direct C calls, which will be faster.
|
|
241
|
+
|
|
242
|
+
cache = {}
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
def MPComplexField(prec=53, rnd='RNDNN', names=None):
|
|
246
|
+
"""
|
|
247
|
+
Return the complex field with real and imaginary parts having
|
|
248
|
+
prec *bits* of precision.
|
|
249
|
+
|
|
250
|
+
EXAMPLES::
|
|
251
|
+
|
|
252
|
+
sage: MPComplexField()
|
|
253
|
+
Complex Field with 53 bits of precision
|
|
254
|
+
sage: MPComplexField(100)
|
|
255
|
+
Complex Field with 100 bits of precision
|
|
256
|
+
sage: MPComplexField(100).base_ring()
|
|
257
|
+
Real Field with 100 bits of precision
|
|
258
|
+
sage: i = MPComplexField(200).gen()
|
|
259
|
+
sage: i^2
|
|
260
|
+
-1.0000000000000000000000000000000000000000000000000000000000
|
|
261
|
+
"""
|
|
262
|
+
global cache
|
|
263
|
+
mykey = (prec, rnd)
|
|
264
|
+
if mykey in cache:
|
|
265
|
+
X = cache[mykey]
|
|
266
|
+
C = X()
|
|
267
|
+
if C is not None:
|
|
268
|
+
return C
|
|
269
|
+
C = MPComplexField_class(prec, rnd)
|
|
270
|
+
cache[mykey] = weakref.ref(C)
|
|
271
|
+
return C
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
cdef class MPComplexField_class(Field):
|
|
275
|
+
def __init__(self, int prec=53, rnd="RNDNN"):
|
|
276
|
+
"""
|
|
277
|
+
Initialize ``self``.
|
|
278
|
+
|
|
279
|
+
INPUT:
|
|
280
|
+
|
|
281
|
+
- ``prec`` -- integer (default: 53); precision
|
|
282
|
+
|
|
283
|
+
prec is the number of bits used to represent the mantissa of
|
|
284
|
+
both the real and imaginary part of complex floating-point number.
|
|
285
|
+
|
|
286
|
+
- ``rnd`` -- string (default: ``'RNDNN'``); the rounding mode
|
|
287
|
+
|
|
288
|
+
Rounding mode is of the form ``'RNDxy'`` where ``x`` and ``y`` are
|
|
289
|
+
the rounding mode for respectively the real and imaginary parts and
|
|
290
|
+
are one of:
|
|
291
|
+
|
|
292
|
+
- ``'N'`` for rounding to nearest
|
|
293
|
+
- ``'Z'`` for rounding towards zero
|
|
294
|
+
- ``'U'`` for rounding towards plus infinity
|
|
295
|
+
- ``'D'`` for rounding towards minus infinity
|
|
296
|
+
|
|
297
|
+
For example, ``'RNDZU'`` indicates to round the real part towards
|
|
298
|
+
zero, and the imaginary part towards plus infinity.
|
|
299
|
+
|
|
300
|
+
EXAMPLES::
|
|
301
|
+
|
|
302
|
+
sage: MPComplexField(17)
|
|
303
|
+
Complex Field with 17 bits of precision
|
|
304
|
+
sage: MPComplexField()
|
|
305
|
+
Complex Field with 53 bits of precision
|
|
306
|
+
sage: MPComplexField(1042,'RNDDZ')
|
|
307
|
+
Complex Field with 1042 bits of precision and rounding RNDDZ
|
|
308
|
+
|
|
309
|
+
ALGORITHMS: Computations are done using the MPC library.
|
|
310
|
+
|
|
311
|
+
TESTS::
|
|
312
|
+
|
|
313
|
+
sage: TestSuite(MPComplexField(17)).run()
|
|
314
|
+
|
|
315
|
+
sage: MPComplexField(17).is_finite()
|
|
316
|
+
False
|
|
317
|
+
"""
|
|
318
|
+
if prec < mpfr_prec_min() or prec > mpfr_prec_max():
|
|
319
|
+
raise ValueError("prec (=%s) must be >= %s and <= %s." % (
|
|
320
|
+
prec, mpfr_prec_min(), mpfr_prec_max()))
|
|
321
|
+
self._prec = prec
|
|
322
|
+
if not isinstance(rnd, str):
|
|
323
|
+
raise TypeError("rnd must be a string")
|
|
324
|
+
try:
|
|
325
|
+
n = _mpc_rounding_modes.index(rnd)
|
|
326
|
+
except ValueError:
|
|
327
|
+
raise ValueError("rnd (=%s) must be of the form RNDxy"
|
|
328
|
+
"where x and y are one of N, Z, U, D" % rnd)
|
|
329
|
+
self.__rnd = n
|
|
330
|
+
self.__rnd_str = rnd
|
|
331
|
+
|
|
332
|
+
self.__real_field = real_mpfr.RealField(prec, rnd=_mpfr_rounding_modes[rnd_re(n)])
|
|
333
|
+
self.__imag_field = real_mpfr.RealField(prec, rnd=_mpfr_rounding_modes[rnd_im(n)])
|
|
334
|
+
|
|
335
|
+
Parent.__init__(self, self._real_field(), names=('I',), normalize=False,
|
|
336
|
+
category=Fields().Infinite())
|
|
337
|
+
self._populate_coercion_lists_(coerce_list=[MPFRtoMPC(self._real_field(), self)])
|
|
338
|
+
|
|
339
|
+
cdef MPComplexNumber _new(self):
|
|
340
|
+
"""
|
|
341
|
+
Return a new complex number with parent ``self``.
|
|
342
|
+
"""
|
|
343
|
+
cdef MPComplexNumber z
|
|
344
|
+
z = MPComplexNumber.__new__(MPComplexNumber)
|
|
345
|
+
z._parent = self
|
|
346
|
+
mpc_init2(z.value, self._prec)
|
|
347
|
+
z.init = 1
|
|
348
|
+
return z
|
|
349
|
+
|
|
350
|
+
def _repr_ (self) -> str:
|
|
351
|
+
"""
|
|
352
|
+
Return a string representation of ``self``.
|
|
353
|
+
|
|
354
|
+
EXAMPLES::
|
|
355
|
+
|
|
356
|
+
sage: MPComplexField(200, 'RNDDU') # indirect doctest
|
|
357
|
+
Complex Field with 200 bits of precision and rounding RNDDU
|
|
358
|
+
"""
|
|
359
|
+
s = "Complex Field with %s bits of precision" % self._prec
|
|
360
|
+
if self.__rnd != MPC_RNDNN:
|
|
361
|
+
s = s + " and rounding %s" % (self.__rnd_str)
|
|
362
|
+
return s
|
|
363
|
+
|
|
364
|
+
def _latex_(self) -> str:
|
|
365
|
+
r"""
|
|
366
|
+
Return a latex representation of ``self``.
|
|
367
|
+
|
|
368
|
+
EXAMPLES::
|
|
369
|
+
|
|
370
|
+
sage: MPC = MPComplexField(10)
|
|
371
|
+
sage: latex(MPC) # indirect doctest
|
|
372
|
+
\C
|
|
373
|
+
"""
|
|
374
|
+
return "\\C"
|
|
375
|
+
|
|
376
|
+
def __call__(self, x, im=None):
|
|
377
|
+
"""
|
|
378
|
+
Create a floating-point complex using ``x`` and optionally an imaginary
|
|
379
|
+
part ``im``.
|
|
380
|
+
|
|
381
|
+
EXAMPLES::
|
|
382
|
+
|
|
383
|
+
sage: MPC = MPComplexField()
|
|
384
|
+
sage: MPC(2) # indirect doctest
|
|
385
|
+
2.00000000000000
|
|
386
|
+
sage: MPC(0, 1) # indirect doctest
|
|
387
|
+
1.00000000000000*I
|
|
388
|
+
sage: MPC(1, 1)
|
|
389
|
+
1.00000000000000 + 1.00000000000000*I
|
|
390
|
+
sage: MPC(2, 3)
|
|
391
|
+
2.00000000000000 + 3.00000000000000*I
|
|
392
|
+
"""
|
|
393
|
+
if x is None:
|
|
394
|
+
return self.zero()
|
|
395
|
+
# We implement __call__ to gracefully accept the second argument.
|
|
396
|
+
if im is not None:
|
|
397
|
+
x = x, im
|
|
398
|
+
return Parent.__call__(self, x)
|
|
399
|
+
|
|
400
|
+
def _element_constructor_(self, z):
|
|
401
|
+
"""
|
|
402
|
+
Coerce `z` into this complex field.
|
|
403
|
+
|
|
404
|
+
EXAMPLES::
|
|
405
|
+
|
|
406
|
+
sage: C20 = MPComplexField(20) # indirect doctest
|
|
407
|
+
|
|
408
|
+
The value can be set with a couple of reals::
|
|
409
|
+
|
|
410
|
+
sage: a = C20(1.5625, 17.42); a
|
|
411
|
+
1.5625 + 17.420*I
|
|
412
|
+
sage: a.str(2)
|
|
413
|
+
'1.1001000000000000000 + 10001.011010111000011*I'
|
|
414
|
+
sage: C20(0, 2)
|
|
415
|
+
2.0000*I
|
|
416
|
+
|
|
417
|
+
Complex number can be coerced into MPComplexNumber::
|
|
418
|
+
|
|
419
|
+
sage: C20(14.7 + 0.35*I) # needs sage.symbolic
|
|
420
|
+
14.700 + 0.35000*I
|
|
421
|
+
sage: C20(i*4, 7) # needs sage.symbolic
|
|
422
|
+
Traceback (most recent call last):
|
|
423
|
+
...
|
|
424
|
+
TypeError: unable to coerce to a ComplexNumber: <class 'sage.rings.number_field.number_field_element_quadratic.NumberFieldElement_gaussian'>
|
|
425
|
+
|
|
426
|
+
Each part can be set with strings (written in base ten)::
|
|
427
|
+
|
|
428
|
+
sage: C20('1.234', '56.789')
|
|
429
|
+
1.2340 + 56.789*I
|
|
430
|
+
|
|
431
|
+
The string can represent the whole complex value::
|
|
432
|
+
|
|
433
|
+
sage: C20('42 + I * 100')
|
|
434
|
+
42.000 + 100.00*I
|
|
435
|
+
sage: C20('-42 * I')
|
|
436
|
+
- 42.000*I
|
|
437
|
+
|
|
438
|
+
The imaginary part can be written first::
|
|
439
|
+
|
|
440
|
+
sage: C20('100*i+42')
|
|
441
|
+
42.000 + 100.00*I
|
|
442
|
+
|
|
443
|
+
Use ``'inf'`` for infinity and ``'nan'`` for Not a Number::
|
|
444
|
+
|
|
445
|
+
sage: C20('nan+inf*i')
|
|
446
|
+
NaN + +infinity*I
|
|
447
|
+
"""
|
|
448
|
+
cdef MPComplexNumber zz
|
|
449
|
+
zz = self._new()
|
|
450
|
+
zz._set(z)
|
|
451
|
+
return zz
|
|
452
|
+
|
|
453
|
+
cpdef _coerce_map_from_(self, S):
|
|
454
|
+
"""
|
|
455
|
+
Canonical coercion of `z` to this mpc complex field.
|
|
456
|
+
|
|
457
|
+
The rings that canonically coerce to this mpc complex field are:
|
|
458
|
+
|
|
459
|
+
- any mpc complex field with precision that is as large as this one
|
|
460
|
+
- anything that canonically coerces to the mpfr real
|
|
461
|
+
field with this prec and the rounding mode of real part.
|
|
462
|
+
|
|
463
|
+
EXAMPLES::
|
|
464
|
+
|
|
465
|
+
sage: MPComplexField(100)(17, '4.2') + MPComplexField(20)('6.0', -23) # indirect doctest
|
|
466
|
+
23.000 - 18.800*I
|
|
467
|
+
sage: a = MPComplexField(100)(17, '4.2') + MPComplexField(20)('6.0', -23)
|
|
468
|
+
sage: a.parent()
|
|
469
|
+
Complex Field with 20 bits of precision
|
|
470
|
+
"""
|
|
471
|
+
if isinstance(S, RealField_class):
|
|
472
|
+
return MPFRtoMPC(S, self)
|
|
473
|
+
if isinstance(S, sage.rings.integer_ring.IntegerRing_class):
|
|
474
|
+
return INTEGERtoMPC(S, self)
|
|
475
|
+
|
|
476
|
+
RR = self.__real_field
|
|
477
|
+
if RR.has_coerce_map_from(S):
|
|
478
|
+
return self._coerce_map_via([RR], S)
|
|
479
|
+
|
|
480
|
+
if isinstance(S, MPComplexField_class) and S.prec() >= self._prec:
|
|
481
|
+
#FIXME: What map when rounding modes differ but prec is the same ?
|
|
482
|
+
# How to provide commutativity of morphisms ?
|
|
483
|
+
# Change _cmp_ when done
|
|
484
|
+
return MPCtoMPC(S, self)
|
|
485
|
+
|
|
486
|
+
if isinstance(S, ComplexField_class) and S.prec() >= self._prec:
|
|
487
|
+
return CCtoMPC(S, self)
|
|
488
|
+
|
|
489
|
+
late_import()
|
|
490
|
+
if S in [AA, QQbar, CLF, RLF] or (S == CDF and self._prec <= 53):
|
|
491
|
+
return self._generic_coerce_map(S)
|
|
492
|
+
|
|
493
|
+
return self._coerce_map_via([CLF], S)
|
|
494
|
+
|
|
495
|
+
def __reduce__(self):
|
|
496
|
+
"""
|
|
497
|
+
For pickling.
|
|
498
|
+
|
|
499
|
+
EXAMPLES::
|
|
500
|
+
|
|
501
|
+
sage: C = MPComplexField(prec=200, rnd='RNDDZ')
|
|
502
|
+
sage: loads(dumps(C)) == C
|
|
503
|
+
True
|
|
504
|
+
"""
|
|
505
|
+
return __create__MPComplexField_version0, (self._prec, self.__rnd_str)
|
|
506
|
+
|
|
507
|
+
def __richcmp__(left, right, int op):
|
|
508
|
+
"""
|
|
509
|
+
Compare ``self`` and ``other``, ignoring the rounding mode.
|
|
510
|
+
|
|
511
|
+
EXAMPLES::
|
|
512
|
+
|
|
513
|
+
sage: MPComplexField(10) == MPComplexField(11) # indirect doctest
|
|
514
|
+
False
|
|
515
|
+
sage: MPComplexField(10) == MPComplexField(10)
|
|
516
|
+
True
|
|
517
|
+
sage: MPComplexField(10,rnd='RNDZN') == MPComplexField(10,rnd='RNDZU')
|
|
518
|
+
True
|
|
519
|
+
"""
|
|
520
|
+
if left is right:
|
|
521
|
+
return rich_to_bool(op, 0)
|
|
522
|
+
|
|
523
|
+
if not isinstance(right, MPComplexField_class):
|
|
524
|
+
return op == Py_NE
|
|
525
|
+
|
|
526
|
+
cdef MPComplexField_class s = <MPComplexField_class>left
|
|
527
|
+
cdef MPComplexField_class o = <MPComplexField_class>right
|
|
528
|
+
return richcmp(s._prec, o._prec, op)
|
|
529
|
+
|
|
530
|
+
def gen(self, n=0):
|
|
531
|
+
"""
|
|
532
|
+
Return the generator of this complex field over its real subfield.
|
|
533
|
+
|
|
534
|
+
EXAMPLES::
|
|
535
|
+
|
|
536
|
+
sage: MPComplexField(34).gen()
|
|
537
|
+
1.00000000*I
|
|
538
|
+
"""
|
|
539
|
+
if n != 0:
|
|
540
|
+
raise IndexError("n must be 0")
|
|
541
|
+
return self(0, 1)
|
|
542
|
+
|
|
543
|
+
def ngens(self):
|
|
544
|
+
"""
|
|
545
|
+
Return 1, the number of generators of this complex field over its real
|
|
546
|
+
subfield.
|
|
547
|
+
|
|
548
|
+
EXAMPLES::
|
|
549
|
+
|
|
550
|
+
sage: MPComplexField(34).ngens()
|
|
551
|
+
1
|
|
552
|
+
"""
|
|
553
|
+
return 1
|
|
554
|
+
|
|
555
|
+
cpdef _an_element_(self):
|
|
556
|
+
"""
|
|
557
|
+
Return an element of this complex field.
|
|
558
|
+
|
|
559
|
+
EXAMPLES::
|
|
560
|
+
|
|
561
|
+
sage: MPC = MPComplexField(20)
|
|
562
|
+
sage: MPC._an_element_()
|
|
563
|
+
1.0000*I
|
|
564
|
+
"""
|
|
565
|
+
return self(0, 1)
|
|
566
|
+
|
|
567
|
+
def random_element(self, min=0, max=1):
|
|
568
|
+
"""
|
|
569
|
+
Return a random complex number, uniformly distributed with
|
|
570
|
+
real and imaginary parts between min and max (default 0 to 1).
|
|
571
|
+
|
|
572
|
+
EXAMPLES::
|
|
573
|
+
|
|
574
|
+
sage: MPComplexField(100).random_element(-5, 10) # random
|
|
575
|
+
1.9305310520925994224072377281 + 0.94745292506956219710477444855*I
|
|
576
|
+
sage: MPComplexField(10).random_element() # random
|
|
577
|
+
0.12 + 0.23*I
|
|
578
|
+
"""
|
|
579
|
+
cdef MPComplexNumber z
|
|
580
|
+
z = self._new()
|
|
581
|
+
cdef randstate rstate = current_randstate()
|
|
582
|
+
mpc_urandom(z.value, rstate.gmp_state)
|
|
583
|
+
if min == 0 and max == 1:
|
|
584
|
+
return z
|
|
585
|
+
else:
|
|
586
|
+
return (max-min)*z + min*self(1,1)
|
|
587
|
+
|
|
588
|
+
cpdef bint is_exact(self) except -2:
|
|
589
|
+
"""
|
|
590
|
+
Return whether or not this field is exact, which is always ``False``.
|
|
591
|
+
|
|
592
|
+
EXAMPLES::
|
|
593
|
+
|
|
594
|
+
sage: MPComplexField(42).is_exact()
|
|
595
|
+
False
|
|
596
|
+
"""
|
|
597
|
+
return False
|
|
598
|
+
|
|
599
|
+
def characteristic(self):
|
|
600
|
+
"""
|
|
601
|
+
Return 0, since the field of complex numbers has characteristic 0.
|
|
602
|
+
|
|
603
|
+
EXAMPLES::
|
|
604
|
+
|
|
605
|
+
sage: MPComplexField(42).characteristic()
|
|
606
|
+
0
|
|
607
|
+
"""
|
|
608
|
+
return Integer(0)
|
|
609
|
+
|
|
610
|
+
def name(self):
|
|
611
|
+
"""
|
|
612
|
+
Return the name of the complex field.
|
|
613
|
+
|
|
614
|
+
EXAMPLES::
|
|
615
|
+
|
|
616
|
+
sage: C = MPComplexField(10, 'RNDNZ'); C.name()
|
|
617
|
+
'MPComplexField10_RNDNZ'
|
|
618
|
+
"""
|
|
619
|
+
return "MPComplexField%s_%s" % (self._prec, self.__rnd_str)
|
|
620
|
+
|
|
621
|
+
def __hash__(self):
|
|
622
|
+
"""
|
|
623
|
+
Return the hash of ``self``.
|
|
624
|
+
|
|
625
|
+
EXAMPLES::
|
|
626
|
+
|
|
627
|
+
sage: MPC = MPComplexField()
|
|
628
|
+
sage: hash(MPC) % 2^32 == hash(MPC.name()) % 2^32
|
|
629
|
+
True
|
|
630
|
+
"""
|
|
631
|
+
return hash(self.name())
|
|
632
|
+
|
|
633
|
+
def prec(self):
|
|
634
|
+
"""
|
|
635
|
+
Return the precision of this field of complex numbers.
|
|
636
|
+
|
|
637
|
+
EXAMPLES::
|
|
638
|
+
|
|
639
|
+
sage: MPComplexField().prec()
|
|
640
|
+
53
|
|
641
|
+
sage: MPComplexField(22).prec()
|
|
642
|
+
22
|
|
643
|
+
"""
|
|
644
|
+
return self._prec
|
|
645
|
+
|
|
646
|
+
def rounding_mode(self):
|
|
647
|
+
"""
|
|
648
|
+
Return rounding modes used for each part of a complex number.
|
|
649
|
+
|
|
650
|
+
EXAMPLES::
|
|
651
|
+
|
|
652
|
+
sage: MPComplexField().rounding_mode()
|
|
653
|
+
'RNDNN'
|
|
654
|
+
sage: MPComplexField(rnd='RNDZU').rounding_mode()
|
|
655
|
+
'RNDZU'
|
|
656
|
+
"""
|
|
657
|
+
return self.__rnd_str
|
|
658
|
+
|
|
659
|
+
def rounding_mode_real(self):
|
|
660
|
+
"""
|
|
661
|
+
Return rounding mode used for the real part of complex number.
|
|
662
|
+
|
|
663
|
+
EXAMPLES::
|
|
664
|
+
|
|
665
|
+
sage: MPComplexField(rnd='RNDZU').rounding_mode_real()
|
|
666
|
+
'RNDZ'
|
|
667
|
+
"""
|
|
668
|
+
return _mpfr_rounding_modes[rnd_re(self.__rnd)]
|
|
669
|
+
|
|
670
|
+
def rounding_mode_imag(self):
|
|
671
|
+
"""
|
|
672
|
+
Return rounding mode used for the imaginary part of complex number.
|
|
673
|
+
|
|
674
|
+
EXAMPLES::
|
|
675
|
+
|
|
676
|
+
sage: MPComplexField(rnd='RNDZU').rounding_mode_imag()
|
|
677
|
+
'RNDU'
|
|
678
|
+
"""
|
|
679
|
+
return _mpfr_rounding_modes[rnd_im(self.__rnd)]
|
|
680
|
+
|
|
681
|
+
def _real_field(self):
|
|
682
|
+
"""
|
|
683
|
+
Return real field for the real part.
|
|
684
|
+
|
|
685
|
+
EXAMPLES::
|
|
686
|
+
|
|
687
|
+
sage: MPComplexField()._real_field()
|
|
688
|
+
Real Field with 53 bits of precision
|
|
689
|
+
"""
|
|
690
|
+
return self.__real_field
|
|
691
|
+
|
|
692
|
+
def _imag_field(self):
|
|
693
|
+
"""
|
|
694
|
+
Return real field for the imaginary part.
|
|
695
|
+
|
|
696
|
+
EXAMPLES::
|
|
697
|
+
|
|
698
|
+
sage: MPComplexField(prec=100)._imag_field()
|
|
699
|
+
Real Field with 100 bits of precision
|
|
700
|
+
"""
|
|
701
|
+
return self.__imag_field
|
|
702
|
+
|
|
703
|
+
|
|
704
|
+
#*****************************************************************************
|
|
705
|
+
#
|
|
706
|
+
# MPComplex Number -- element of MPComplex Field
|
|
707
|
+
#
|
|
708
|
+
#*****************************************************************************
|
|
709
|
+
|
|
710
|
+
cdef class MPComplexNumber(sage.structure.element.FieldElement):
|
|
711
|
+
"""
|
|
712
|
+
A floating point approximation to a complex number using any specified
|
|
713
|
+
precision common to both real and imaginary part.
|
|
714
|
+
"""
|
|
715
|
+
cdef MPComplexNumber _new(self):
|
|
716
|
+
"""
|
|
717
|
+
Return a new complex number with same parent as ``self``.
|
|
718
|
+
"""
|
|
719
|
+
cdef MPComplexNumber z
|
|
720
|
+
z = MPComplexNumber.__new__(MPComplexNumber)
|
|
721
|
+
z._parent = self._parent
|
|
722
|
+
mpc_init2(z.value, (<MPComplexField_class>self._parent)._prec)
|
|
723
|
+
z.init = 1
|
|
724
|
+
return z
|
|
725
|
+
|
|
726
|
+
def __init__(self, MPComplexField_class parent, x, y=None, int base=10):
|
|
727
|
+
"""
|
|
728
|
+
Create a complex number.
|
|
729
|
+
|
|
730
|
+
INPUT:
|
|
731
|
+
|
|
732
|
+
- ``x`` -- real part or the complex value in a string
|
|
733
|
+
|
|
734
|
+
- ``y`` -- imaginary part
|
|
735
|
+
|
|
736
|
+
- ``base`` -- when ``x`` or ``y`` is a string, base in which the
|
|
737
|
+
number is written
|
|
738
|
+
|
|
739
|
+
A :class:`MPComplexNumber` should be called by first creating a
|
|
740
|
+
:class:`MPComplexField`, as illustrated in the examples.
|
|
741
|
+
|
|
742
|
+
EXAMPLES::
|
|
743
|
+
|
|
744
|
+
sage: C200 = MPComplexField(200)
|
|
745
|
+
sage: C200(1/3, '0.6789')
|
|
746
|
+
0.33333333333333333333333333333333333333333333333333333333333 + 0.67890000000000000000000000000000000000000000000000000000000*I
|
|
747
|
+
sage: C3 = MPComplexField(3)
|
|
748
|
+
sage: C3('1.2345', '0.6789')
|
|
749
|
+
1.2 + 0.62*I
|
|
750
|
+
sage: C3(3.14159)
|
|
751
|
+
3.0
|
|
752
|
+
|
|
753
|
+
Rounding modes::
|
|
754
|
+
|
|
755
|
+
sage: w = C3(5/2, 7/2); w.str(2)
|
|
756
|
+
'10.1 + 11.1*I'
|
|
757
|
+
sage: MPComplexField(2, rnd="RNDZN")(w).str(2)
|
|
758
|
+
'10. + 100.*I'
|
|
759
|
+
sage: MPComplexField(2, rnd="RNDDU")(w).str(2)
|
|
760
|
+
'10. + 100.*I'
|
|
761
|
+
sage: MPComplexField(2, rnd="RNDUD")(w).str(2)
|
|
762
|
+
'11. + 11.*I'
|
|
763
|
+
sage: MPComplexField(2, rnd="RNDNZ")(w).str(2)
|
|
764
|
+
'10. + 11.*I'
|
|
765
|
+
|
|
766
|
+
TESTS::
|
|
767
|
+
|
|
768
|
+
sage: MPComplexField(42)._repr_option('element_is_atomic')
|
|
769
|
+
False
|
|
770
|
+
"""
|
|
771
|
+
self.init = 0
|
|
772
|
+
if parent is None:
|
|
773
|
+
raise TypeError
|
|
774
|
+
self._parent = parent
|
|
775
|
+
mpc_init2(self.value, parent._prec)
|
|
776
|
+
self.init = 1
|
|
777
|
+
if x is None: return
|
|
778
|
+
self._set(x, y, base)
|
|
779
|
+
|
|
780
|
+
def _set(self, z, y=None, base=10):
|
|
781
|
+
"""
|
|
782
|
+
EXAMPLES::
|
|
783
|
+
|
|
784
|
+
sage: MPC = MPComplexField(100)
|
|
785
|
+
sage: r = RealField(100).pi()
|
|
786
|
+
sage: z = MPC(r); z # indirect doctest
|
|
787
|
+
3.1415926535897932384626433833
|
|
788
|
+
sage: MPComplexField(10, rnd='RNDDD')(z)
|
|
789
|
+
3.1
|
|
790
|
+
sage: c = ComplexField(53)(1, r)
|
|
791
|
+
sage: MPC(c)
|
|
792
|
+
1.0000000000000000000000000000 + 3.1415926535897931159979634685*I
|
|
793
|
+
sage: MPC(I) # needs sage.symbolic
|
|
794
|
+
1.0000000000000000000000000000*I
|
|
795
|
+
sage: MPC('-0 +i')
|
|
796
|
+
1.0000000000000000000000000000*I
|
|
797
|
+
sage: MPC(1+i) # needs sage.symbolic
|
|
798
|
+
1.0000000000000000000000000000 + 1.0000000000000000000000000000*I
|
|
799
|
+
sage: MPC(1/3)
|
|
800
|
+
0.33333333333333333333333333333
|
|
801
|
+
|
|
802
|
+
::
|
|
803
|
+
|
|
804
|
+
sage: MPC(1, r/3)
|
|
805
|
+
1.0000000000000000000000000000 + 1.0471975511965977461542144611*I
|
|
806
|
+
sage: MPC(3, 2)
|
|
807
|
+
3.0000000000000000000000000000 + 2.0000000000000000000000000000*I
|
|
808
|
+
sage: MPC(0, r)
|
|
809
|
+
3.1415926535897932384626433833*I
|
|
810
|
+
sage: MPC('0.625e-26', '0.0000001')
|
|
811
|
+
6.2500000000000000000000000000e-27 + 1.0000000000000000000000000000e-7*I
|
|
812
|
+
|
|
813
|
+
Conversion from gmpy2 numbers::
|
|
814
|
+
|
|
815
|
+
sage: from gmpy2 import *
|
|
816
|
+
sage: MPC(mpc(int(2),int(1)))
|
|
817
|
+
2.0000000000000000000000000000 + 1.0000000000000000000000000000*I
|
|
818
|
+
sage: MPC(mpfr(2.5))
|
|
819
|
+
2.5000000000000000000000000000
|
|
820
|
+
sage: MPC(mpq('3/2'))
|
|
821
|
+
1.5000000000000000000000000000
|
|
822
|
+
sage: MPC(mpz(int(5)))
|
|
823
|
+
5.0000000000000000000000000000
|
|
824
|
+
sage: re = mpfr('2.5')
|
|
825
|
+
sage: im = mpz(int(2))
|
|
826
|
+
sage: MPC(re, im)
|
|
827
|
+
2.5000000000000000000000000000 + 2.0000000000000000000000000000*I
|
|
828
|
+
"""
|
|
829
|
+
# This should not be called except when the number is being created.
|
|
830
|
+
# Complex Numbers are supposed to be immutable.
|
|
831
|
+
cdef mpc_rnd_t rnd
|
|
832
|
+
rnd =(<MPComplexField_class>self._parent).__rnd
|
|
833
|
+
if y is None:
|
|
834
|
+
if z is None: return
|
|
835
|
+
if isinstance(z, MPComplexNumber):
|
|
836
|
+
mpc_set(self.value, (<MPComplexNumber>z).value, rnd)
|
|
837
|
+
return
|
|
838
|
+
elif isinstance(z, str):
|
|
839
|
+
a, b = split_complex_string(z, base)
|
|
840
|
+
if a is None and b is None:
|
|
841
|
+
raise TypeError("unable to convert {!r} to a MPComplexNumber".format(z))
|
|
842
|
+
# set real part
|
|
843
|
+
if a is None:
|
|
844
|
+
mpfr_set_ui(self.value.re, 0, MPFR_RNDN)
|
|
845
|
+
else:
|
|
846
|
+
mpfr_set_str(self.value.re, str_to_bytes(a),
|
|
847
|
+
base, rnd_re(rnd))
|
|
848
|
+
# set imag part
|
|
849
|
+
if b is None:
|
|
850
|
+
mpfr_set_ui(self.value.im, 0, MPFR_RNDN)
|
|
851
|
+
else:
|
|
852
|
+
mpfr_set_str(self.value.im, str_to_bytes(b),
|
|
853
|
+
base, rnd_im(rnd))
|
|
854
|
+
return
|
|
855
|
+
elif isinstance(z, ComplexNumber):
|
|
856
|
+
mpc_set_fr_fr(self.value, (<ComplexNumber>z).__re, (<ComplexNumber>z).__im, rnd)
|
|
857
|
+
return
|
|
858
|
+
elif isinstance(z, pari_gen):
|
|
859
|
+
real, imag = z.real(), z.imag()
|
|
860
|
+
elif isinstance(z, (list, tuple)):
|
|
861
|
+
real, imag = z
|
|
862
|
+
elif isinstance(z, complex):
|
|
863
|
+
real, imag = z.real, z.imag
|
|
864
|
+
elif type(z) is gmpy2.mpc:
|
|
865
|
+
mpc_set(self.value, (<gmpy2.mpc>z).c, rnd)
|
|
866
|
+
return
|
|
867
|
+
elif type(z) is gmpy2.mpfr:
|
|
868
|
+
mpc_set_fr(self.value, (<gmpy2.mpfr>z).f, rnd)
|
|
869
|
+
return
|
|
870
|
+
elif type(z) is gmpy2.mpq:
|
|
871
|
+
mpc_set_q(self.value, (<gmpy2.mpq>z).q, rnd)
|
|
872
|
+
return
|
|
873
|
+
elif type(z) is gmpy2.mpz:
|
|
874
|
+
mpc_set_z(self.value, (<gmpy2.mpz>z).z, rnd)
|
|
875
|
+
return
|
|
876
|
+
elif isinstance(z, RealNumber):
|
|
877
|
+
zz = sage.rings.real_mpfr.RealField(self._parent.prec())(z)
|
|
878
|
+
mpc_set_fr(self.value, (<RealNumber>zz).value, rnd)
|
|
879
|
+
return
|
|
880
|
+
elif isinstance(z, Integer):
|
|
881
|
+
mpc_set_z(self.value, (<Integer>z).value, rnd)
|
|
882
|
+
return
|
|
883
|
+
elif isinstance(z, int):
|
|
884
|
+
mpc_set_si(self.value, z, rnd)
|
|
885
|
+
return
|
|
886
|
+
else:
|
|
887
|
+
C = sage.rings.complex_mpfr.ComplexField(self._parent.prec())
|
|
888
|
+
if C.has_coerce_map_from(z.parent()) or isinstance(z, Expression):
|
|
889
|
+
self._set(C(z))
|
|
890
|
+
return
|
|
891
|
+
else:
|
|
892
|
+
real = z
|
|
893
|
+
imag = 0
|
|
894
|
+
else:
|
|
895
|
+
real = z
|
|
896
|
+
imag = y
|
|
897
|
+
|
|
898
|
+
cdef RealField_class R = self._parent._real_field()
|
|
899
|
+
try:
|
|
900
|
+
rr = R(real)
|
|
901
|
+
ii = R(imag)
|
|
902
|
+
mpc_set_fr_fr(self.value, (<RealNumber>rr).value, (<RealNumber>ii).value, rnd)
|
|
903
|
+
|
|
904
|
+
except TypeError:
|
|
905
|
+
raise TypeError("unable to coerce to a ComplexNumber: %s" % type(real))
|
|
906
|
+
|
|
907
|
+
def __reduce__(self):
|
|
908
|
+
"""
|
|
909
|
+
For pickling.
|
|
910
|
+
|
|
911
|
+
EXAMPLES::
|
|
912
|
+
|
|
913
|
+
sage: C = MPComplexField(prec=200, rnd='RNDUU')
|
|
914
|
+
sage: b = C(393.39203845902384098234098230948209384028340)
|
|
915
|
+
sage: loads(dumps(b)) == b
|
|
916
|
+
True
|
|
917
|
+
sage: b = C(-1).sqrt(); b
|
|
918
|
+
1.0000000000000000000000000000000000000000000000000000000000*I
|
|
919
|
+
sage: loads(dumps(b)) == b
|
|
920
|
+
True
|
|
921
|
+
|
|
922
|
+
Some tests with ``NaN``, which cannot be compared to anything::
|
|
923
|
+
|
|
924
|
+
sage: b = C(1)/C(0); b
|
|
925
|
+
NaN + NaN*I
|
|
926
|
+
sage: loads(dumps(b))
|
|
927
|
+
NaN + NaN*I
|
|
928
|
+
sage: b = C(-1)/C(0.); b
|
|
929
|
+
NaN + NaN*I
|
|
930
|
+
sage: loads(dumps(b))
|
|
931
|
+
NaN + NaN*I
|
|
932
|
+
"""
|
|
933
|
+
s = self.str(32)
|
|
934
|
+
return (__create_MPComplexNumber_version0, (self._parent, s, 32))
|
|
935
|
+
|
|
936
|
+
def __dealloc__(self):
|
|
937
|
+
if self.init:
|
|
938
|
+
mpc_clear(self.value)
|
|
939
|
+
|
|
940
|
+
def _repr_(self):
|
|
941
|
+
"""
|
|
942
|
+
Return a string representation of ``self``.
|
|
943
|
+
|
|
944
|
+
EXAMPLES::
|
|
945
|
+
|
|
946
|
+
sage: MPComplexField()(2, -3) # indirect doctest
|
|
947
|
+
2.00000000000000 - 3.00000000000000*I
|
|
948
|
+
"""
|
|
949
|
+
return self.str(truncate=True)
|
|
950
|
+
|
|
951
|
+
def _latex_(self):
|
|
952
|
+
"""
|
|
953
|
+
Return a latex representation of ``self``.
|
|
954
|
+
|
|
955
|
+
EXAMPLES::
|
|
956
|
+
|
|
957
|
+
sage: latex(MPComplexField()(2, -3)) # indirect doctest
|
|
958
|
+
2.00000000000000 - 3.00000000000000i
|
|
959
|
+
"""
|
|
960
|
+
import re
|
|
961
|
+
s = repr(self).replace('*I', 'i')
|
|
962
|
+
return re.sub(r"e(-?\d+)", r" \\times 10^{\1}", s)
|
|
963
|
+
|
|
964
|
+
def __hash__(self):
|
|
965
|
+
"""
|
|
966
|
+
Return the hash of ``self``, which coincides with the python
|
|
967
|
+
complex and float (and often int) types.
|
|
968
|
+
|
|
969
|
+
This has the drawback that two very close high precision
|
|
970
|
+
numbers will have the same hash, but allows them to play
|
|
971
|
+
nicely with other real types.
|
|
972
|
+
|
|
973
|
+
EXAMPLES::
|
|
974
|
+
|
|
975
|
+
sage: hash(MPComplexField()('1.2', 33)) == hash(complex(1.2, 33))
|
|
976
|
+
True
|
|
977
|
+
"""
|
|
978
|
+
return hash(complex(self))
|
|
979
|
+
|
|
980
|
+
def __getitem__(self, i):
|
|
981
|
+
r"""
|
|
982
|
+
Return either the real or imaginary component of ``self``
|
|
983
|
+
depending on the choice of ``i``: real (``i``=0), imaginary (``i``=1).
|
|
984
|
+
|
|
985
|
+
INPUT:
|
|
986
|
+
|
|
987
|
+
- ``i`` -- 0 or 1
|
|
988
|
+
|
|
989
|
+
- ``0`` -- will return the real component of ``self``
|
|
990
|
+
- ``1`` -- will return the imaginary component of ``self``
|
|
991
|
+
|
|
992
|
+
EXAMPLES::
|
|
993
|
+
|
|
994
|
+
sage: MPC = MPComplexField()
|
|
995
|
+
sage: a = MPC(2,1)
|
|
996
|
+
sage: a.__getitem__(0)
|
|
997
|
+
2.00000000000000
|
|
998
|
+
sage: a.__getitem__(1)
|
|
999
|
+
1.00000000000000
|
|
1000
|
+
|
|
1001
|
+
::
|
|
1002
|
+
|
|
1003
|
+
sage: b = MPC(42,0)
|
|
1004
|
+
sage: b
|
|
1005
|
+
42.0000000000000
|
|
1006
|
+
sage: b.__getitem__(1)
|
|
1007
|
+
0.000000000000000
|
|
1008
|
+
"""
|
|
1009
|
+
if i == 0:
|
|
1010
|
+
return self.real()
|
|
1011
|
+
elif i == 1:
|
|
1012
|
+
return self.imag()
|
|
1013
|
+
raise IndexError("i must be between 0 and 1.")
|
|
1014
|
+
|
|
1015
|
+
def prec(self):
|
|
1016
|
+
"""
|
|
1017
|
+
Return precision of this complex number.
|
|
1018
|
+
|
|
1019
|
+
EXAMPLES::
|
|
1020
|
+
|
|
1021
|
+
sage: i = MPComplexField(2000).0
|
|
1022
|
+
sage: i.prec()
|
|
1023
|
+
2000
|
|
1024
|
+
"""
|
|
1025
|
+
return <MPComplexField_class>(self._parent)._prec
|
|
1026
|
+
|
|
1027
|
+
def real(self):
|
|
1028
|
+
"""
|
|
1029
|
+
Return the real part of ``self``.
|
|
1030
|
+
|
|
1031
|
+
EXAMPLES::
|
|
1032
|
+
|
|
1033
|
+
sage: C = MPComplexField(100)
|
|
1034
|
+
sage: z = C(2, 3)
|
|
1035
|
+
sage: x = z.real(); x
|
|
1036
|
+
2.0000000000000000000000000000
|
|
1037
|
+
sage: x.parent()
|
|
1038
|
+
Real Field with 100 bits of precision
|
|
1039
|
+
"""
|
|
1040
|
+
cdef RealNumber x
|
|
1041
|
+
x = RealNumber(self._parent._real_field())
|
|
1042
|
+
mpfr_set (x.value, self.value.re, (<RealField_class>x._parent).rnd)
|
|
1043
|
+
return x
|
|
1044
|
+
|
|
1045
|
+
def imag(self):
|
|
1046
|
+
"""
|
|
1047
|
+
Return imaginary part of ``self``.
|
|
1048
|
+
|
|
1049
|
+
EXAMPLES::
|
|
1050
|
+
|
|
1051
|
+
sage: C = MPComplexField(100)
|
|
1052
|
+
sage: z = C(2, 3)
|
|
1053
|
+
sage: x = z.imag(); x
|
|
1054
|
+
3.0000000000000000000000000000
|
|
1055
|
+
sage: x.parent()
|
|
1056
|
+
Real Field with 100 bits of precision
|
|
1057
|
+
"""
|
|
1058
|
+
cdef RealNumber y
|
|
1059
|
+
y = RealNumber(self._parent._imag_field())
|
|
1060
|
+
mpfr_set (y.value, self.value.im, (<RealField_class>y._parent).rnd)
|
|
1061
|
+
return y
|
|
1062
|
+
|
|
1063
|
+
def str(self, base=10, **kwds):
|
|
1064
|
+
"""
|
|
1065
|
+
Return a string of ``self``.
|
|
1066
|
+
|
|
1067
|
+
INPUT:
|
|
1068
|
+
|
|
1069
|
+
- ``base`` -- (default: 10) base for output
|
|
1070
|
+
|
|
1071
|
+
- ``**kwds`` -- other arguments to pass to the ``str()``
|
|
1072
|
+
method of the real numbers in the real and imaginary parts
|
|
1073
|
+
|
|
1074
|
+
EXAMPLES::
|
|
1075
|
+
|
|
1076
|
+
sage: MPC = MPComplexField(64)
|
|
1077
|
+
sage: z = MPC(-4, 3)/7
|
|
1078
|
+
sage: z.str()
|
|
1079
|
+
'-0.571428571428571428564 + 0.428571428571428571436*I'
|
|
1080
|
+
sage: z.str(16)
|
|
1081
|
+
'-0.92492492492492490 + 0.6db6db6db6db6db70*I'
|
|
1082
|
+
sage: z.str(truncate=True)
|
|
1083
|
+
'-0.571428571428571429 + 0.428571428571428571*I'
|
|
1084
|
+
sage: z.str(2)
|
|
1085
|
+
'-0.1001001001001001001001001001001001001001001001001001001001001001 + 0.01101101101101101101101101101101101101101101101101101101101101110*I'
|
|
1086
|
+
"""
|
|
1087
|
+
s = ""
|
|
1088
|
+
if self.real() != 0:
|
|
1089
|
+
s = self.real().str(base, **kwds)
|
|
1090
|
+
if self.imag() != 0:
|
|
1091
|
+
if mpfr_signbit(self.value.im):
|
|
1092
|
+
s += ' - ' + (-self.imag()).str(base, **kwds) + '*I'
|
|
1093
|
+
else:
|
|
1094
|
+
if s:
|
|
1095
|
+
s += ' + '
|
|
1096
|
+
s += self.imag().str(base, **kwds) + '*I'
|
|
1097
|
+
if not s:
|
|
1098
|
+
return "0"
|
|
1099
|
+
return s
|
|
1100
|
+
|
|
1101
|
+
def __copy__(self):
|
|
1102
|
+
"""
|
|
1103
|
+
Return copy of ``self``.
|
|
1104
|
+
|
|
1105
|
+
Since ``self`` is immutable, we just return ``self`` again.
|
|
1106
|
+
|
|
1107
|
+
EXAMPLES::
|
|
1108
|
+
|
|
1109
|
+
sage: a = MPComplexField()(3.5, 3)
|
|
1110
|
+
sage: copy(a) is a
|
|
1111
|
+
True
|
|
1112
|
+
"""
|
|
1113
|
+
return self # since object is immutable.
|
|
1114
|
+
|
|
1115
|
+
def __deepcopy__(self, memo):
|
|
1116
|
+
"""
|
|
1117
|
+
EXAMPLES::
|
|
1118
|
+
|
|
1119
|
+
sage: a = MPComplexField()(3.5, 3)
|
|
1120
|
+
sage: deepcopy(a) is a
|
|
1121
|
+
True
|
|
1122
|
+
"""
|
|
1123
|
+
return self # since object is immutable.
|
|
1124
|
+
|
|
1125
|
+
def __int__(self):
|
|
1126
|
+
r"""
|
|
1127
|
+
Method for converting ``self`` to type ``int``.
|
|
1128
|
+
|
|
1129
|
+
Called by the ``int`` function. Note that calling this method returns
|
|
1130
|
+
an error since, in general, complex numbers cannot be coerced into
|
|
1131
|
+
integers.
|
|
1132
|
+
|
|
1133
|
+
EXAMPLES::
|
|
1134
|
+
|
|
1135
|
+
sage: MPC = MPComplexField()
|
|
1136
|
+
sage: a = MPC(2,1)
|
|
1137
|
+
sage: int(a)
|
|
1138
|
+
Traceback (most recent call last):
|
|
1139
|
+
...
|
|
1140
|
+
TypeError: can...t convert complex to int; use int(abs(z))
|
|
1141
|
+
sage: a.__int__()
|
|
1142
|
+
Traceback (most recent call last):
|
|
1143
|
+
...
|
|
1144
|
+
TypeError: can...t convert complex to int; use int(abs(z))
|
|
1145
|
+
"""
|
|
1146
|
+
raise TypeError("can't convert complex to int; use int(abs(z))")
|
|
1147
|
+
|
|
1148
|
+
def __float__(self):
|
|
1149
|
+
r"""
|
|
1150
|
+
Method for converting ``self`` to type ``float``.
|
|
1151
|
+
|
|
1152
|
+
Called by the ``float`` function. Note that calling this method returns
|
|
1153
|
+
an error since if the imaginary part of the number is not zero.
|
|
1154
|
+
|
|
1155
|
+
EXAMPLES::
|
|
1156
|
+
|
|
1157
|
+
sage: MPC = MPComplexField()
|
|
1158
|
+
sage: a = MPC(1, 0)
|
|
1159
|
+
sage: float(a)
|
|
1160
|
+
1.0
|
|
1161
|
+
sage: a = MPC(2,1)
|
|
1162
|
+
sage: float(a)
|
|
1163
|
+
Traceback (most recent call last):
|
|
1164
|
+
...
|
|
1165
|
+
TypeError: can...t convert complex to float; use abs(z)
|
|
1166
|
+
sage: a.__float__()
|
|
1167
|
+
Traceback (most recent call last):
|
|
1168
|
+
...
|
|
1169
|
+
TypeError: can...t convert complex to float; use abs(z)
|
|
1170
|
+
"""
|
|
1171
|
+
if mpfr_zero_p(self.value.im):
|
|
1172
|
+
return mpfr_get_d(self.value.re,
|
|
1173
|
+
rnd_re((<MPComplexField_class>self._parent).__rnd))
|
|
1174
|
+
else:
|
|
1175
|
+
raise TypeError("can't convert complex to float; use abs(z)")
|
|
1176
|
+
|
|
1177
|
+
def __complex__(self):
|
|
1178
|
+
r"""
|
|
1179
|
+
Method for converting ``self`` to type ``complex``.
|
|
1180
|
+
|
|
1181
|
+
Called by the ``complex`` function.
|
|
1182
|
+
|
|
1183
|
+
EXAMPLES::
|
|
1184
|
+
|
|
1185
|
+
sage: MPC = MPComplexField()
|
|
1186
|
+
sage: a = MPC(2,1)
|
|
1187
|
+
sage: complex(a)
|
|
1188
|
+
(2+1j)
|
|
1189
|
+
sage: type(complex(a))
|
|
1190
|
+
<... 'complex'>
|
|
1191
|
+
sage: a.__complex__()
|
|
1192
|
+
(2+1j)
|
|
1193
|
+
"""
|
|
1194
|
+
# Fixme: is it the right choice for rounding modes ?
|
|
1195
|
+
cdef mpc_rnd_t rnd
|
|
1196
|
+
rnd = (<MPComplexField_class>self._parent).__rnd
|
|
1197
|
+
return complex(mpfr_get_d(self.value.re, rnd_re(rnd)), mpfr_get_d(self.value.im, rnd_im(rnd)))
|
|
1198
|
+
|
|
1199
|
+
def __pari__(self):
|
|
1200
|
+
r"""
|
|
1201
|
+
Convert ``self`` to a PARI object.
|
|
1202
|
+
|
|
1203
|
+
OUTPUT: a PARI ``t_COMPLEX`` object if the input is not purely
|
|
1204
|
+
real. If the input is real, a ``t_REAL`` is returned.
|
|
1205
|
+
|
|
1206
|
+
EXAMPLES::
|
|
1207
|
+
|
|
1208
|
+
sage: MPC = MPComplexField()
|
|
1209
|
+
sage: a = MPC(2,1)
|
|
1210
|
+
sage: a.__pari__() # needs sage.libs.pari
|
|
1211
|
+
2.00000000000000 + 1.00000000000000*I
|
|
1212
|
+
sage: pari(a) # needs sage.libs.pari
|
|
1213
|
+
2.00000000000000 + 1.00000000000000*I
|
|
1214
|
+
sage: pari(a).type() # needs sage.libs.pari
|
|
1215
|
+
't_COMPLEX'
|
|
1216
|
+
sage: a = MPC(pi) # needs sage.libs.pari sage.symbolic
|
|
1217
|
+
sage: pari(a) # needs sage.libs.pari sage.symbolic
|
|
1218
|
+
3.14159265358979
|
|
1219
|
+
sage: pari(a).type() # needs sage.libs.pari sage.symbolic
|
|
1220
|
+
't_REAL'
|
|
1221
|
+
sage: a = MPC(-2).sqrt()
|
|
1222
|
+
sage: pari(a) # needs sage.libs.pari
|
|
1223
|
+
1.41421356237310*I
|
|
1224
|
+
|
|
1225
|
+
The precision is preserved, rounded up to the wordsize::
|
|
1226
|
+
|
|
1227
|
+
sage: MPC = MPComplexField(250)
|
|
1228
|
+
sage: MPC(1,2).__pari__().bitprecision() # needs sage.libs.pari
|
|
1229
|
+
256
|
|
1230
|
+
sage: MPC(pi).__pari__().bitprecision() # needs sage.libs.pari sage.symbolic
|
|
1231
|
+
256
|
|
1232
|
+
"""
|
|
1233
|
+
if mpfr_zero_p(self.value.re):
|
|
1234
|
+
re = pari.PARI_ZERO
|
|
1235
|
+
else:
|
|
1236
|
+
re = self.real().__pari__()
|
|
1237
|
+
if mpfr_zero_p(self.value.im):
|
|
1238
|
+
return re
|
|
1239
|
+
im = self.imag().__pari__()
|
|
1240
|
+
return pari.complex(re, im)
|
|
1241
|
+
|
|
1242
|
+
def __mpc__(self):
|
|
1243
|
+
"""
|
|
1244
|
+
Convert Sage ``MPComplexNumber`` to gmpy2 ``mpc``.
|
|
1245
|
+
|
|
1246
|
+
EXAMPLES::
|
|
1247
|
+
|
|
1248
|
+
sage: MPC = MPComplexField()
|
|
1249
|
+
sage: c = MPC(2,1)
|
|
1250
|
+
sage: c.__mpc__()
|
|
1251
|
+
mpc('2.0+1.0j')
|
|
1252
|
+
sage: from gmpy2 import mpc
|
|
1253
|
+
sage: mpc(c)
|
|
1254
|
+
mpc('2.0+1.0j')
|
|
1255
|
+
sage: MPCF = MPComplexField(42)
|
|
1256
|
+
sage: mpc(MPCF(12, 12)).precision
|
|
1257
|
+
(42, 42)
|
|
1258
|
+
sage: MPCF = MPComplexField(236)
|
|
1259
|
+
sage: mpc(MPCF(12, 12)).precision
|
|
1260
|
+
(236, 236)
|
|
1261
|
+
sage: MPCF = MPComplexField(63)
|
|
1262
|
+
sage: x = MPCF('15.64E+128', '15.64E+128')
|
|
1263
|
+
sage: y = mpc(x)
|
|
1264
|
+
sage: y.precision
|
|
1265
|
+
(63, 63)
|
|
1266
|
+
sage: MPCF(y) == x
|
|
1267
|
+
True
|
|
1268
|
+
sage: x = mpc('1.324+4e50j', precision=(70,70))
|
|
1269
|
+
sage: y = MPComplexField(70)(x)
|
|
1270
|
+
sage: mpc(y) == x
|
|
1271
|
+
True
|
|
1272
|
+
"""
|
|
1273
|
+
return gmpy2.GMPy_MPC_From_mpfr(self.value.re, self.value.im)
|
|
1274
|
+
|
|
1275
|
+
cpdef _richcmp_(self, other, int op):
|
|
1276
|
+
r"""
|
|
1277
|
+
Compare ``self`` to ``other``.
|
|
1278
|
+
|
|
1279
|
+
EXAMPLES::
|
|
1280
|
+
|
|
1281
|
+
sage: MPC = MPComplexField()
|
|
1282
|
+
sage: a = MPC(2,1)
|
|
1283
|
+
sage: b = MPC(1,2)
|
|
1284
|
+
sage: a < b
|
|
1285
|
+
False
|
|
1286
|
+
sage: a > b
|
|
1287
|
+
True
|
|
1288
|
+
"""
|
|
1289
|
+
cdef MPComplexNumber z = <MPComplexNumber>other
|
|
1290
|
+
# NaN should compare to nothing
|
|
1291
|
+
if mpfr_nan_p(self.value.re) or mpfr_nan_p(self.value.im) or mpfr_nan_p(z.value.re) or mpfr_nan_p(z.value.im):
|
|
1292
|
+
return False
|
|
1293
|
+
cdef int c = mpc_cmp(self.value, z.value)
|
|
1294
|
+
cdef int cre = MPC_INEX_RE(c)
|
|
1295
|
+
cdef int cim
|
|
1296
|
+
if cre:
|
|
1297
|
+
return rich_to_bool(op, cre)
|
|
1298
|
+
else:
|
|
1299
|
+
cim = MPC_INEX_IM(c)
|
|
1300
|
+
return rich_to_bool(op, cim)
|
|
1301
|
+
|
|
1302
|
+
def __bool__(self):
|
|
1303
|
+
"""
|
|
1304
|
+
Return ``True`` if ``self`` is not zero.
|
|
1305
|
+
|
|
1306
|
+
This is an internal function; use :meth:`is_zero()` instead.
|
|
1307
|
+
|
|
1308
|
+
EXAMPLES::
|
|
1309
|
+
|
|
1310
|
+
sage: MPC = MPComplexField()
|
|
1311
|
+
sage: z = 1 + MPC(I) # needs sage.symbolic
|
|
1312
|
+
sage: z.is_zero() # needs sage.symbolic
|
|
1313
|
+
False
|
|
1314
|
+
"""
|
|
1315
|
+
return not (mpfr_zero_p(self.value.re) and mpfr_zero_p(self.value.im))
|
|
1316
|
+
|
|
1317
|
+
def is_square(self):
|
|
1318
|
+
r"""
|
|
1319
|
+
This function always returns true as `\CC` is algebraically closed.
|
|
1320
|
+
|
|
1321
|
+
EXAMPLES::
|
|
1322
|
+
|
|
1323
|
+
sage: C200 = MPComplexField(200)
|
|
1324
|
+
sage: a = C200(2,1)
|
|
1325
|
+
sage: a.is_square()
|
|
1326
|
+
True
|
|
1327
|
+
|
|
1328
|
+
`\CC` is algebraically closed, hence every element is a square::
|
|
1329
|
+
|
|
1330
|
+
sage: b = C200(5)
|
|
1331
|
+
sage: b.is_square()
|
|
1332
|
+
True
|
|
1333
|
+
"""
|
|
1334
|
+
return True
|
|
1335
|
+
|
|
1336
|
+
def is_real(self):
|
|
1337
|
+
"""
|
|
1338
|
+
Return ``True`` if ``self`` is real, i.e. has imaginary part zero.
|
|
1339
|
+
|
|
1340
|
+
EXAMPLES::
|
|
1341
|
+
|
|
1342
|
+
sage: C200 = MPComplexField(200)
|
|
1343
|
+
sage: C200(1.23).is_real()
|
|
1344
|
+
True
|
|
1345
|
+
sage: C200(1 + i).is_real() # needs sage.symbolic
|
|
1346
|
+
False
|
|
1347
|
+
"""
|
|
1348
|
+
return (mpfr_zero_p(self.value.im) != 0)
|
|
1349
|
+
|
|
1350
|
+
def is_imaginary(self):
|
|
1351
|
+
"""
|
|
1352
|
+
Return ``True`` if ``self`` is imaginary, i.e. has real part zero.
|
|
1353
|
+
|
|
1354
|
+
EXAMPLES::
|
|
1355
|
+
|
|
1356
|
+
sage: C200 = MPComplexField(200)
|
|
1357
|
+
sage: C200(1.23*i).is_imaginary() # needs sage.symbolic
|
|
1358
|
+
True
|
|
1359
|
+
sage: C200(1 + i).is_imaginary() # needs sage.symbolic
|
|
1360
|
+
False
|
|
1361
|
+
"""
|
|
1362
|
+
return (mpfr_zero_p(self.value.re) != 0)
|
|
1363
|
+
|
|
1364
|
+
def algebraic_dependency(self, n, **kwds):
|
|
1365
|
+
"""
|
|
1366
|
+
Return an irreducible polynomial of degree at most `n` which is
|
|
1367
|
+
approximately satisfied by this complex number.
|
|
1368
|
+
|
|
1369
|
+
ALGORITHM: Uses the PARI C-library :pari:`algdep` command.
|
|
1370
|
+
|
|
1371
|
+
INPUT: Type ``algebraic_dependency?`` at the top level prompt.
|
|
1372
|
+
|
|
1373
|
+
All additional parameters are passed onto the top-level
|
|
1374
|
+
``algebraic_dependency`` command.
|
|
1375
|
+
|
|
1376
|
+
EXAMPLES::
|
|
1377
|
+
|
|
1378
|
+
sage: # needs sage.libs.pari
|
|
1379
|
+
sage: MPC = MPComplexField()
|
|
1380
|
+
sage: z = (1/2)*(1 + sqrt(3.0) * MPC.0); z
|
|
1381
|
+
0.500000000000000 + 0.866025403784439*I
|
|
1382
|
+
sage: p = z.algebraic_dependency(5)
|
|
1383
|
+
sage: p
|
|
1384
|
+
x^2 - x + 1
|
|
1385
|
+
sage: p(z)
|
|
1386
|
+
1.11022302462516e-16
|
|
1387
|
+
"""
|
|
1388
|
+
from sage.arith.misc import algebraic_dependency
|
|
1389
|
+
return algebraic_dependency(self, n, **kwds)
|
|
1390
|
+
|
|
1391
|
+
algdep = algebraic_dependency
|
|
1392
|
+
|
|
1393
|
+
################################
|
|
1394
|
+
# Basic Arithmetic
|
|
1395
|
+
################################
|
|
1396
|
+
|
|
1397
|
+
cpdef _add_(self, right):
|
|
1398
|
+
"""
|
|
1399
|
+
Add two complex numbers with the same parent.
|
|
1400
|
+
|
|
1401
|
+
EXAMPLES::
|
|
1402
|
+
|
|
1403
|
+
sage: MPC = MPComplexField(30)
|
|
1404
|
+
sage: MPC(-1.5, 2) + MPC(0.2, 1) # indirect doctest
|
|
1405
|
+
-1.3000000 + 3.0000000*I
|
|
1406
|
+
"""
|
|
1407
|
+
cdef MPComplexNumber z
|
|
1408
|
+
z = self._new()
|
|
1409
|
+
mpc_add(z.value, self.value, (<MPComplexNumber>right).value, (<MPComplexField_class>self._parent).__rnd)
|
|
1410
|
+
return z
|
|
1411
|
+
|
|
1412
|
+
cpdef _sub_(self, right):
|
|
1413
|
+
"""
|
|
1414
|
+
Subtract two complex numbers with the same parent.
|
|
1415
|
+
|
|
1416
|
+
EXAMPLES::
|
|
1417
|
+
|
|
1418
|
+
sage: MPC = MPComplexField(30)
|
|
1419
|
+
sage: MPC(-1.5, 2) - MPC(0.2, 1) # indirect doctest
|
|
1420
|
+
-1.7000000 + 1.0000000*I
|
|
1421
|
+
"""
|
|
1422
|
+
cdef MPComplexNumber z
|
|
1423
|
+
z = self._new()
|
|
1424
|
+
mpc_sub(z.value, self.value, (<MPComplexNumber>right).value, (<MPComplexField_class>self._parent).__rnd)
|
|
1425
|
+
return z
|
|
1426
|
+
|
|
1427
|
+
cpdef _mul_(self, right):
|
|
1428
|
+
"""
|
|
1429
|
+
Multiply two complex numbers with the same parent.
|
|
1430
|
+
|
|
1431
|
+
EXAMPLES::
|
|
1432
|
+
|
|
1433
|
+
sage: MPC = MPComplexField(30)
|
|
1434
|
+
sage: MPC(-1.5, 2) * MPC(0.2, 1) # indirect doctest
|
|
1435
|
+
-2.3000000 - 1.1000000*I
|
|
1436
|
+
"""
|
|
1437
|
+
cdef MPComplexNumber z
|
|
1438
|
+
z = self._new()
|
|
1439
|
+
mpc_mul(z.value, self.value, (<MPComplexNumber>right).value, (<MPComplexField_class>self._parent).__rnd)
|
|
1440
|
+
return z
|
|
1441
|
+
|
|
1442
|
+
cpdef _div_(self, right):
|
|
1443
|
+
"""
|
|
1444
|
+
Divide two complex numbers with the same parent.
|
|
1445
|
+
|
|
1446
|
+
EXAMPLES::
|
|
1447
|
+
|
|
1448
|
+
sage: MPC = MPComplexField(30)
|
|
1449
|
+
sage: MPC(-1.5, 2) / MPC(0.2, 1) # indirect doctest
|
|
1450
|
+
1.6346154 + 1.8269231*I
|
|
1451
|
+
sage: MPC(-1, 1) / MPC(0)
|
|
1452
|
+
NaN + NaN*I
|
|
1453
|
+
"""
|
|
1454
|
+
cdef MPComplexNumber z, x
|
|
1455
|
+
z = self._new()
|
|
1456
|
+
x = <MPComplexNumber>right
|
|
1457
|
+
if not x.is_zero():
|
|
1458
|
+
mpc_div(z.value, self.value, x.value, (<MPComplexField_class>self._parent).__rnd)
|
|
1459
|
+
return z
|
|
1460
|
+
|
|
1461
|
+
cpdef _neg_(self):
|
|
1462
|
+
"""
|
|
1463
|
+
Return the negative of this complex number.
|
|
1464
|
+
|
|
1465
|
+
EXAMPLES::
|
|
1466
|
+
|
|
1467
|
+
sage: MPC = MPComplexField(30)
|
|
1468
|
+
sage: - MPC(-1.5, 2) # indirect doctest
|
|
1469
|
+
1.5000000 - 2.0000000*I
|
|
1470
|
+
sage: - MPC(0)
|
|
1471
|
+
0
|
|
1472
|
+
"""
|
|
1473
|
+
cdef MPComplexNumber z
|
|
1474
|
+
z = self._new()
|
|
1475
|
+
mpc_neg(z.value, self.value, (<MPComplexField_class>self._parent).__rnd)
|
|
1476
|
+
return z
|
|
1477
|
+
|
|
1478
|
+
def __invert__(self):
|
|
1479
|
+
"""
|
|
1480
|
+
Return the multiplicative inverse.
|
|
1481
|
+
|
|
1482
|
+
EXAMPLES::
|
|
1483
|
+
|
|
1484
|
+
sage: C = MPComplexField()
|
|
1485
|
+
sage: a = ~C(5, 1)
|
|
1486
|
+
sage: a * C(5, 1)
|
|
1487
|
+
1.00000000000000
|
|
1488
|
+
"""
|
|
1489
|
+
cdef MPComplexNumber z
|
|
1490
|
+
z = self._new()
|
|
1491
|
+
if not self.is_zero():
|
|
1492
|
+
mpc_ui_div (z.value, 1, self.value, (<MPComplexField_class>self._parent).__rnd)
|
|
1493
|
+
return z
|
|
1494
|
+
|
|
1495
|
+
def __neg__(self):
|
|
1496
|
+
r"""
|
|
1497
|
+
Return the negative of this complex number.
|
|
1498
|
+
|
|
1499
|
+
-(a + ib) = -a -i b
|
|
1500
|
+
|
|
1501
|
+
EXAMPLES::
|
|
1502
|
+
|
|
1503
|
+
sage: MPC = MPComplexField()
|
|
1504
|
+
sage: a = MPC(2,1)
|
|
1505
|
+
sage: -a
|
|
1506
|
+
-2.00000000000000 - 1.00000000000000*I
|
|
1507
|
+
sage: a.__neg__()
|
|
1508
|
+
-2.00000000000000 - 1.00000000000000*I
|
|
1509
|
+
"""
|
|
1510
|
+
cdef MPComplexNumber z
|
|
1511
|
+
z = self._new()
|
|
1512
|
+
mpc_neg(z.value, self.value, (<MPComplexField_class>self._parent).__rnd)
|
|
1513
|
+
return z
|
|
1514
|
+
|
|
1515
|
+
def __abs__(self):
|
|
1516
|
+
r"""
|
|
1517
|
+
Absolute value or modulus of this complex number,
|
|
1518
|
+
rounded with the rounding mode of the real part:
|
|
1519
|
+
|
|
1520
|
+
.. MATH::
|
|
1521
|
+
|
|
1522
|
+
|a + ib| = \sqrt(a^2 + b^2).
|
|
1523
|
+
|
|
1524
|
+
OUTPUT:
|
|
1525
|
+
|
|
1526
|
+
A floating-point number in the real field of the real part
|
|
1527
|
+
(same precision, same rounding mode).
|
|
1528
|
+
|
|
1529
|
+
EXAMPLES:
|
|
1530
|
+
|
|
1531
|
+
Note that the absolute value of a complex number with imaginary
|
|
1532
|
+
component equal to zero is the absolute value of the real component::
|
|
1533
|
+
|
|
1534
|
+
sage: MPC = MPComplexField()
|
|
1535
|
+
sage: a = MPC(2,1)
|
|
1536
|
+
sage: abs(a)
|
|
1537
|
+
2.23606797749979
|
|
1538
|
+
sage: a.__abs__()
|
|
1539
|
+
2.23606797749979
|
|
1540
|
+
sage: float(sqrt(2^2 + 1^1)) # needs sage.symbolic
|
|
1541
|
+
2.23606797749979
|
|
1542
|
+
|
|
1543
|
+
sage: b = MPC(42,0)
|
|
1544
|
+
sage: abs(b)
|
|
1545
|
+
42.0000000000000
|
|
1546
|
+
sage: b.__abs__()
|
|
1547
|
+
42.0000000000000
|
|
1548
|
+
sage: b
|
|
1549
|
+
42.0000000000000
|
|
1550
|
+
"""
|
|
1551
|
+
cdef RealNumber x
|
|
1552
|
+
x = RealNumber(self._parent._real_field())
|
|
1553
|
+
mpc_abs(x.value, self.value, (<RealField_class>x._parent).rnd)
|
|
1554
|
+
return x
|
|
1555
|
+
|
|
1556
|
+
def norm(self):
|
|
1557
|
+
r"""
|
|
1558
|
+
Return the norm of a complex number, rounded with the rounding
|
|
1559
|
+
mode of the real part. The norm is the square of the absolute
|
|
1560
|
+
value:
|
|
1561
|
+
|
|
1562
|
+
.. MATH::
|
|
1563
|
+
|
|
1564
|
+
\mathrm{norm}(a + ib) = a^2 + b^2.
|
|
1565
|
+
|
|
1566
|
+
OUTPUT:
|
|
1567
|
+
|
|
1568
|
+
A floating-point number in the real field of the real part
|
|
1569
|
+
(same precision, same rounding mode).
|
|
1570
|
+
|
|
1571
|
+
EXAMPLES:
|
|
1572
|
+
|
|
1573
|
+
This indeed acts as the square function when the imaginary
|
|
1574
|
+
component of ``self`` is equal to zero::
|
|
1575
|
+
|
|
1576
|
+
sage: MPC = MPComplexField()
|
|
1577
|
+
sage: a = MPC(2,1)
|
|
1578
|
+
sage: a.norm()
|
|
1579
|
+
5.00000000000000
|
|
1580
|
+
sage: b = MPC(4.2,0)
|
|
1581
|
+
sage: b.norm()
|
|
1582
|
+
17.6400000000000
|
|
1583
|
+
sage: b^2
|
|
1584
|
+
17.6400000000000
|
|
1585
|
+
"""
|
|
1586
|
+
cdef RealNumber x
|
|
1587
|
+
x = RealNumber(self._parent._real_field())
|
|
1588
|
+
mpc_norm(x.value, self.value, (<RealField_class>x._parent).rnd)
|
|
1589
|
+
return x
|
|
1590
|
+
|
|
1591
|
+
def __pow__(self, right, modulus):
|
|
1592
|
+
"""
|
|
1593
|
+
Compute ``self`` raised to the power of exponent, rounded in
|
|
1594
|
+
the direction specified by the parent of ``self``.
|
|
1595
|
+
|
|
1596
|
+
.. TODO::
|
|
1597
|
+
|
|
1598
|
+
FIXME: Branch cut
|
|
1599
|
+
|
|
1600
|
+
EXAMPLES::
|
|
1601
|
+
|
|
1602
|
+
sage: MPC.<i> = MPComplexField(20)
|
|
1603
|
+
sage: a = i^2; a
|
|
1604
|
+
-1.0000
|
|
1605
|
+
sage: a.parent()
|
|
1606
|
+
Complex Field with 20 bits of precision
|
|
1607
|
+
sage: a = (1+i)^i; a
|
|
1608
|
+
0.42883 + 0.15487*I
|
|
1609
|
+
sage: (1+i)^(1+i)
|
|
1610
|
+
0.27396 + 0.58370*I
|
|
1611
|
+
sage: a.parent()
|
|
1612
|
+
Complex Field with 20 bits of precision
|
|
1613
|
+
sage: i^i
|
|
1614
|
+
0.20788
|
|
1615
|
+
sage: (2+i)^(0.5)
|
|
1616
|
+
1.4553 + 0.34356*I
|
|
1617
|
+
"""
|
|
1618
|
+
cdef MPComplexNumber z, x, p
|
|
1619
|
+
x = <MPComplexNumber>self
|
|
1620
|
+
z = x._new()
|
|
1621
|
+
|
|
1622
|
+
if isinstance(right, int):
|
|
1623
|
+
mpc_pow_si(z.value, x.value, right, (<MPComplexField_class>x._parent).__rnd)
|
|
1624
|
+
elif isinstance(right, Integer):
|
|
1625
|
+
mpc_pow_z(z.value, x.value, (<Integer>right).value, (<MPComplexField_class>x._parent).__rnd)
|
|
1626
|
+
else:
|
|
1627
|
+
try:
|
|
1628
|
+
p = (<MPComplexField_class>x._parent)(right)
|
|
1629
|
+
except Exception:
|
|
1630
|
+
raise ValueError
|
|
1631
|
+
mpc_pow(z.value, x.value, p.value, (<MPComplexField_class>x._parent).__rnd)
|
|
1632
|
+
|
|
1633
|
+
return z
|
|
1634
|
+
|
|
1635
|
+
################################
|
|
1636
|
+
# Trigonometric & hyperbolic functions
|
|
1637
|
+
################################
|
|
1638
|
+
|
|
1639
|
+
def cos(self):
|
|
1640
|
+
r"""
|
|
1641
|
+
Return the cosine of this complex number:
|
|
1642
|
+
|
|
1643
|
+
.. MATH::
|
|
1644
|
+
|
|
1645
|
+
\cos(a + ib) = \cos a \cosh b -i \sin a \sinh b.
|
|
1646
|
+
|
|
1647
|
+
EXAMPLES::
|
|
1648
|
+
|
|
1649
|
+
sage: MPC = MPComplexField()
|
|
1650
|
+
sage: u = MPC(2, 4)
|
|
1651
|
+
sage: cos(u)
|
|
1652
|
+
-11.3642347064011 - 24.8146514856342*I
|
|
1653
|
+
"""
|
|
1654
|
+
cdef MPComplexNumber z
|
|
1655
|
+
z = self._new()
|
|
1656
|
+
mpc_cos(z.value, self.value, (<MPComplexField_class>self._parent).__rnd)
|
|
1657
|
+
return z
|
|
1658
|
+
|
|
1659
|
+
def sin(self):
|
|
1660
|
+
r"""
|
|
1661
|
+
Return the sine of this complex number:
|
|
1662
|
+
|
|
1663
|
+
.. MATH::
|
|
1664
|
+
|
|
1665
|
+
\sin(a + ib) = \sin a \cosh b + i \cos x \sinh b.
|
|
1666
|
+
|
|
1667
|
+
EXAMPLES::
|
|
1668
|
+
|
|
1669
|
+
sage: MPC = MPComplexField()
|
|
1670
|
+
sage: u = MPC(2, 4)
|
|
1671
|
+
sage: sin(u)
|
|
1672
|
+
24.8313058489464 - 11.3566127112182*I
|
|
1673
|
+
"""
|
|
1674
|
+
cdef MPComplexNumber z
|
|
1675
|
+
z = self._new()
|
|
1676
|
+
mpc_sin(z.value, self.value, (<MPComplexField_class>self._parent).__rnd)
|
|
1677
|
+
return z
|
|
1678
|
+
|
|
1679
|
+
def tan(self):
|
|
1680
|
+
r"""
|
|
1681
|
+
Return the tangent of this complex number:
|
|
1682
|
+
|
|
1683
|
+
.. MATH::
|
|
1684
|
+
|
|
1685
|
+
\tan(a + ib) = (\sin 2a + i \sinh 2b)/(\cos 2a + \cosh 2b).
|
|
1686
|
+
|
|
1687
|
+
EXAMPLES::
|
|
1688
|
+
|
|
1689
|
+
sage: MPC = MPComplexField()
|
|
1690
|
+
sage: u = MPC(-2, 4)
|
|
1691
|
+
sage: tan(u)
|
|
1692
|
+
0.000507980623470039 + 1.00043851320205*I
|
|
1693
|
+
"""
|
|
1694
|
+
cdef MPComplexNumber z
|
|
1695
|
+
z = self._new()
|
|
1696
|
+
mpc_tan(z.value, self.value, (<MPComplexField_class>self._parent).__rnd)
|
|
1697
|
+
return z
|
|
1698
|
+
|
|
1699
|
+
def cosh(self):
|
|
1700
|
+
r"""
|
|
1701
|
+
Return the hyperbolic cosine of this complex number:
|
|
1702
|
+
|
|
1703
|
+
.. MATH::
|
|
1704
|
+
|
|
1705
|
+
\cosh(a + ib) = \cosh a \cos b + i \sinh a \sin b.
|
|
1706
|
+
|
|
1707
|
+
EXAMPLES::
|
|
1708
|
+
|
|
1709
|
+
sage: MPC = MPComplexField()
|
|
1710
|
+
sage: u = MPC(2, 4)
|
|
1711
|
+
sage: cosh(u)
|
|
1712
|
+
-2.45913521391738 - 2.74481700679215*I
|
|
1713
|
+
"""
|
|
1714
|
+
cdef MPComplexNumber z
|
|
1715
|
+
z = self._new()
|
|
1716
|
+
mpc_cosh(z.value, self.value, (<MPComplexField_class>self._parent).__rnd)
|
|
1717
|
+
return z
|
|
1718
|
+
|
|
1719
|
+
def sinh(self):
|
|
1720
|
+
r"""
|
|
1721
|
+
Return the hyperbolic sine of this complex number:
|
|
1722
|
+
|
|
1723
|
+
.. MATH::
|
|
1724
|
+
|
|
1725
|
+
\sinh(a + ib) = \sinh a \cos b + i \cosh a \sin b.
|
|
1726
|
+
|
|
1727
|
+
EXAMPLES::
|
|
1728
|
+
|
|
1729
|
+
sage: MPC = MPComplexField()
|
|
1730
|
+
sage: u = MPC(2, 4)
|
|
1731
|
+
sage: sinh(u)
|
|
1732
|
+
-2.37067416935200 - 2.84723908684883*I
|
|
1733
|
+
"""
|
|
1734
|
+
cdef MPComplexNumber z
|
|
1735
|
+
z = self._new()
|
|
1736
|
+
mpc_sinh(z.value, self.value, (<MPComplexField_class>self._parent).__rnd)
|
|
1737
|
+
return z
|
|
1738
|
+
|
|
1739
|
+
def tanh(self):
|
|
1740
|
+
r"""
|
|
1741
|
+
Return the hyperbolic tangent of this complex number:
|
|
1742
|
+
|
|
1743
|
+
.. MATH::
|
|
1744
|
+
|
|
1745
|
+
\tanh(a + ib) = (\sinh 2a + i \sin 2b)/(\cosh 2a + \cos 2b).
|
|
1746
|
+
|
|
1747
|
+
EXAMPLES::
|
|
1748
|
+
|
|
1749
|
+
sage: MPC = MPComplexField()
|
|
1750
|
+
sage: u = MPC(2, 4)
|
|
1751
|
+
sage: tanh(u)
|
|
1752
|
+
1.00468231219024 + 0.0364233692474037*I
|
|
1753
|
+
"""
|
|
1754
|
+
cdef MPComplexNumber z
|
|
1755
|
+
z = self._new()
|
|
1756
|
+
mpc_tanh(z.value, self.value, (<MPComplexField_class>self._parent).__rnd)
|
|
1757
|
+
return z
|
|
1758
|
+
|
|
1759
|
+
def arccos(self):
|
|
1760
|
+
"""
|
|
1761
|
+
Return the arccosine of this complex number.
|
|
1762
|
+
|
|
1763
|
+
EXAMPLES::
|
|
1764
|
+
|
|
1765
|
+
sage: MPC = MPComplexField()
|
|
1766
|
+
sage: u = MPC(2, 4)
|
|
1767
|
+
sage: arccos(u)
|
|
1768
|
+
1.11692611683177 - 2.19857302792094*I
|
|
1769
|
+
"""
|
|
1770
|
+
cdef MPComplexNumber z
|
|
1771
|
+
z = self._new()
|
|
1772
|
+
mpc_acos(z.value, self.value, (<MPComplexField_class>self._parent).__rnd)
|
|
1773
|
+
return z
|
|
1774
|
+
|
|
1775
|
+
def arcsin(self):
|
|
1776
|
+
"""
|
|
1777
|
+
Return the arcsine of this complex number.
|
|
1778
|
+
|
|
1779
|
+
EXAMPLES::
|
|
1780
|
+
|
|
1781
|
+
sage: MPC = MPComplexField()
|
|
1782
|
+
sage: u = MPC(2, 4)
|
|
1783
|
+
sage: arcsin(u)
|
|
1784
|
+
0.453870209963122 + 2.19857302792094*I
|
|
1785
|
+
"""
|
|
1786
|
+
cdef MPComplexNumber z
|
|
1787
|
+
z = self._new()
|
|
1788
|
+
mpc_asin(z.value, self.value, (<MPComplexField_class>self._parent).__rnd)
|
|
1789
|
+
return z
|
|
1790
|
+
|
|
1791
|
+
def arctan(self):
|
|
1792
|
+
"""
|
|
1793
|
+
Return the arctangent of this complex number.
|
|
1794
|
+
|
|
1795
|
+
EXAMPLES::
|
|
1796
|
+
|
|
1797
|
+
sage: MPC = MPComplexField()
|
|
1798
|
+
sage: u = MPC(-2, 4)
|
|
1799
|
+
sage: arctan(u)
|
|
1800
|
+
-1.46704821357730 + 0.200586618131234*I
|
|
1801
|
+
"""
|
|
1802
|
+
cdef MPComplexNumber z
|
|
1803
|
+
z = self._new()
|
|
1804
|
+
mpc_atan(z.value, self.value, (<MPComplexField_class>self._parent).__rnd)
|
|
1805
|
+
return z
|
|
1806
|
+
|
|
1807
|
+
def arccosh(self):
|
|
1808
|
+
"""
|
|
1809
|
+
Return the hyperbolic arccos of this complex number.
|
|
1810
|
+
|
|
1811
|
+
EXAMPLES::
|
|
1812
|
+
|
|
1813
|
+
sage: MPC = MPComplexField()
|
|
1814
|
+
sage: u = MPC(2, 4)
|
|
1815
|
+
sage: arccosh(u)
|
|
1816
|
+
2.19857302792094 + 1.11692611683177*I
|
|
1817
|
+
"""
|
|
1818
|
+
cdef MPComplexNumber z
|
|
1819
|
+
z = self._new()
|
|
1820
|
+
mpc_acosh(z.value, self.value, (<MPComplexField_class>self._parent).__rnd)
|
|
1821
|
+
return z
|
|
1822
|
+
|
|
1823
|
+
def arcsinh(self):
|
|
1824
|
+
"""
|
|
1825
|
+
Return the hyperbolic arcsine of this complex number.
|
|
1826
|
+
|
|
1827
|
+
EXAMPLES::
|
|
1828
|
+
|
|
1829
|
+
sage: MPC = MPComplexField()
|
|
1830
|
+
sage: u = MPC(2, 4)
|
|
1831
|
+
sage: arcsinh(u)
|
|
1832
|
+
2.18358521656456 + 1.09692154883014*I
|
|
1833
|
+
"""
|
|
1834
|
+
cdef MPComplexNumber z
|
|
1835
|
+
z = self._new()
|
|
1836
|
+
mpc_asinh(z.value, self.value, (<MPComplexField_class>self._parent).__rnd)
|
|
1837
|
+
return z
|
|
1838
|
+
|
|
1839
|
+
def arctanh(self):
|
|
1840
|
+
"""
|
|
1841
|
+
Return the hyperbolic arctangent of this complex number.
|
|
1842
|
+
|
|
1843
|
+
EXAMPLES::
|
|
1844
|
+
|
|
1845
|
+
sage: MPC = MPComplexField()
|
|
1846
|
+
sage: u = MPC(2, 4)
|
|
1847
|
+
sage: arctanh(u)
|
|
1848
|
+
0.0964156202029962 + 1.37153510396169*I
|
|
1849
|
+
"""
|
|
1850
|
+
cdef MPComplexNumber z
|
|
1851
|
+
z = self._new()
|
|
1852
|
+
mpc_atanh(z.value, self.value, (<MPComplexField_class>self._parent).__rnd)
|
|
1853
|
+
return z
|
|
1854
|
+
|
|
1855
|
+
def coth(self):
|
|
1856
|
+
"""
|
|
1857
|
+
Return the hyperbolic cotangent of this complex number.
|
|
1858
|
+
|
|
1859
|
+
EXAMPLES::
|
|
1860
|
+
|
|
1861
|
+
sage: MPC = MPComplexField(100)
|
|
1862
|
+
sage: MPC(1,1).coth()
|
|
1863
|
+
0.86801414289592494863584920892 - 0.21762156185440268136513424361*I
|
|
1864
|
+
"""
|
|
1865
|
+
return ~(self.tanh())
|
|
1866
|
+
|
|
1867
|
+
def arccoth(self):
|
|
1868
|
+
"""
|
|
1869
|
+
Return the hyperbolic arccotangent of this complex number.
|
|
1870
|
+
|
|
1871
|
+
EXAMPLES::
|
|
1872
|
+
|
|
1873
|
+
sage: MPC = MPComplexField(100)
|
|
1874
|
+
sage: MPC(1,1).arccoth()
|
|
1875
|
+
0.40235947810852509365018983331 - 0.55357435889704525150853273009*I
|
|
1876
|
+
"""
|
|
1877
|
+
return (~self).arctanh()
|
|
1878
|
+
|
|
1879
|
+
def csc(self):
|
|
1880
|
+
"""
|
|
1881
|
+
Return the cosecant of this complex number.
|
|
1882
|
+
|
|
1883
|
+
EXAMPLES::
|
|
1884
|
+
|
|
1885
|
+
sage: MPC = MPComplexField(100)
|
|
1886
|
+
sage: MPC(1,1).csc()
|
|
1887
|
+
0.62151801717042842123490780586 - 0.30393100162842645033448560451*I
|
|
1888
|
+
"""
|
|
1889
|
+
return ~(self.sin())
|
|
1890
|
+
|
|
1891
|
+
def csch(self):
|
|
1892
|
+
"""
|
|
1893
|
+
Return the hyperbolic cosecant of this complex number.
|
|
1894
|
+
|
|
1895
|
+
EXAMPLES::
|
|
1896
|
+
|
|
1897
|
+
sage: MPC = MPComplexField(100)
|
|
1898
|
+
sage: MPC(1,1).csch()
|
|
1899
|
+
0.30393100162842645033448560451 - 0.62151801717042842123490780586*I
|
|
1900
|
+
"""
|
|
1901
|
+
return ~(self.sinh())
|
|
1902
|
+
|
|
1903
|
+
def arccsch(self):
|
|
1904
|
+
"""
|
|
1905
|
+
Return the hyperbolic arcsine of this complex number.
|
|
1906
|
+
|
|
1907
|
+
EXAMPLES::
|
|
1908
|
+
|
|
1909
|
+
sage: MPC = MPComplexField(100)
|
|
1910
|
+
sage: MPC(1,1).arccsch()
|
|
1911
|
+
0.53063753095251782601650945811 - 0.45227844715119068206365839783*I
|
|
1912
|
+
"""
|
|
1913
|
+
return (~self).arcsinh()
|
|
1914
|
+
|
|
1915
|
+
def sec(self):
|
|
1916
|
+
"""
|
|
1917
|
+
Return the secant of this complex number.
|
|
1918
|
+
|
|
1919
|
+
EXAMPLES::
|
|
1920
|
+
|
|
1921
|
+
sage: MPC = MPComplexField(100)
|
|
1922
|
+
sage: MPC(1,1).sec()
|
|
1923
|
+
0.49833703055518678521380589177 + 0.59108384172104504805039169297*I
|
|
1924
|
+
"""
|
|
1925
|
+
return ~(self.cos())
|
|
1926
|
+
|
|
1927
|
+
def sech(self):
|
|
1928
|
+
"""
|
|
1929
|
+
Return the hyperbolic secant of this complex number.
|
|
1930
|
+
|
|
1931
|
+
EXAMPLES::
|
|
1932
|
+
|
|
1933
|
+
sage: MPC = MPComplexField(100)
|
|
1934
|
+
sage: MPC(1,1).sech()
|
|
1935
|
+
0.49833703055518678521380589177 - 0.59108384172104504805039169297*I
|
|
1936
|
+
"""
|
|
1937
|
+
return ~(self.cosh())
|
|
1938
|
+
|
|
1939
|
+
def arcsech(self):
|
|
1940
|
+
"""
|
|
1941
|
+
Return the hyperbolic arcsecant of this complex number.
|
|
1942
|
+
|
|
1943
|
+
EXAMPLES::
|
|
1944
|
+
|
|
1945
|
+
sage: MPC = MPComplexField(100)
|
|
1946
|
+
sage: MPC(1,1).arcsech()
|
|
1947
|
+
0.53063753095251782601650945811 - 1.1185178796437059371676632938*I
|
|
1948
|
+
"""
|
|
1949
|
+
return (~self).arccosh()
|
|
1950
|
+
|
|
1951
|
+
def cot(self):
|
|
1952
|
+
"""
|
|
1953
|
+
Return the cotangent of this complex number.
|
|
1954
|
+
|
|
1955
|
+
EXAMPLES::
|
|
1956
|
+
|
|
1957
|
+
sage: MPC = MPComplexField(53)
|
|
1958
|
+
sage: (1+MPC(I)).cot() # needs sage.symbolic
|
|
1959
|
+
0.217621561854403 - 0.868014142895925*I
|
|
1960
|
+
sage: i = MPComplexField(200).0
|
|
1961
|
+
sage: (1+i).cot()
|
|
1962
|
+
0.21762156185440268136513424360523807352075436916785404091068 - 0.86801414289592494863584920891627388827343874994609327121115*I
|
|
1963
|
+
sage: i = MPComplexField(220).0
|
|
1964
|
+
sage: (1+i).cot()
|
|
1965
|
+
0.21762156185440268136513424360523807352075436916785404091068124239 - 0.86801414289592494863584920891627388827343874994609327121115071646*I
|
|
1966
|
+
"""
|
|
1967
|
+
return ~(self.tan())
|
|
1968
|
+
|
|
1969
|
+
################################
|
|
1970
|
+
# Other functions
|
|
1971
|
+
################################
|
|
1972
|
+
|
|
1973
|
+
def argument(self):
|
|
1974
|
+
r"""
|
|
1975
|
+
The argument (angle) of the complex number, normalized so that
|
|
1976
|
+
`-\pi < \theta \leq \pi`.
|
|
1977
|
+
|
|
1978
|
+
EXAMPLES::
|
|
1979
|
+
|
|
1980
|
+
sage: MPC = MPComplexField()
|
|
1981
|
+
sage: i = MPC.0
|
|
1982
|
+
sage: (i^2).argument()
|
|
1983
|
+
3.14159265358979
|
|
1984
|
+
sage: (1+i).argument()
|
|
1985
|
+
0.785398163397448
|
|
1986
|
+
sage: i.argument()
|
|
1987
|
+
1.57079632679490
|
|
1988
|
+
sage: (-i).argument()
|
|
1989
|
+
-1.57079632679490
|
|
1990
|
+
sage: (RR('-0.001') - i).argument()
|
|
1991
|
+
-1.57179632646156
|
|
1992
|
+
"""
|
|
1993
|
+
cdef RealNumber x
|
|
1994
|
+
x = RealNumber(self._parent._real_field())
|
|
1995
|
+
mpc_arg(x.value, self.value, (<RealField_class>x._parent).rnd)
|
|
1996
|
+
return x
|
|
1997
|
+
|
|
1998
|
+
def conjugate(self):
|
|
1999
|
+
r"""
|
|
2000
|
+
Return the complex conjugate of this complex number:
|
|
2001
|
+
|
|
2002
|
+
.. MATH::
|
|
2003
|
+
|
|
2004
|
+
\mathrm{conjugate}(a + ib) = a - ib.
|
|
2005
|
+
|
|
2006
|
+
EXAMPLES::
|
|
2007
|
+
|
|
2008
|
+
sage: MPC = MPComplexField()
|
|
2009
|
+
sage: i = MPC(0, 1)
|
|
2010
|
+
sage: (1+i).conjugate()
|
|
2011
|
+
1.00000000000000 - 1.00000000000000*I
|
|
2012
|
+
"""
|
|
2013
|
+
cdef MPComplexNumber z
|
|
2014
|
+
z = self._new()
|
|
2015
|
+
mpc_conj(z.value, self.value, (<MPComplexField_class>self._parent).__rnd)
|
|
2016
|
+
return z
|
|
2017
|
+
|
|
2018
|
+
def sqr(self):
|
|
2019
|
+
"""
|
|
2020
|
+
Return the square of a complex number:
|
|
2021
|
+
|
|
2022
|
+
.. MATH::
|
|
2023
|
+
|
|
2024
|
+
(a + ib)^2 = (a^2 - b^2) + 2iab.
|
|
2025
|
+
|
|
2026
|
+
EXAMPLES::
|
|
2027
|
+
|
|
2028
|
+
sage: C = MPComplexField()
|
|
2029
|
+
sage: a = C(5, 1)
|
|
2030
|
+
sage: a.sqr()
|
|
2031
|
+
24.0000000000000 + 10.0000000000000*I
|
|
2032
|
+
"""
|
|
2033
|
+
cdef MPComplexNumber z
|
|
2034
|
+
z = self._new()
|
|
2035
|
+
mpc_sqr(z.value, self.value, (<MPComplexField_class>self._parent).__rnd)
|
|
2036
|
+
return z
|
|
2037
|
+
|
|
2038
|
+
def sqrt(self):
|
|
2039
|
+
r"""
|
|
2040
|
+
Return the square root, taking the branch cut to be the negative real
|
|
2041
|
+
axis:
|
|
2042
|
+
|
|
2043
|
+
.. MATH::
|
|
2044
|
+
|
|
2045
|
+
\sqrt z = \sqrt{|z|}(\cos(\arg(z)/2) + i \sin(\arg(z)/2)).
|
|
2046
|
+
|
|
2047
|
+
EXAMPLES::
|
|
2048
|
+
|
|
2049
|
+
sage: C = MPComplexField()
|
|
2050
|
+
sage: a = C(24, 10)
|
|
2051
|
+
sage: a.sqrt()
|
|
2052
|
+
5.00000000000000 + 1.00000000000000*I
|
|
2053
|
+
"""
|
|
2054
|
+
cdef MPComplexNumber z
|
|
2055
|
+
z = self._new()
|
|
2056
|
+
mpc_sqrt(z.value, self.value, (<MPComplexField_class>self._parent).__rnd)
|
|
2057
|
+
return z
|
|
2058
|
+
|
|
2059
|
+
def exp(self):
|
|
2060
|
+
r"""
|
|
2061
|
+
Return the exponential of this complex number:
|
|
2062
|
+
|
|
2063
|
+
.. MATH::
|
|
2064
|
+
|
|
2065
|
+
\exp(a + ib) = \exp(a) (\cos b + i \sin b).
|
|
2066
|
+
|
|
2067
|
+
EXAMPLES::
|
|
2068
|
+
|
|
2069
|
+
sage: MPC = MPComplexField()
|
|
2070
|
+
sage: u = MPC(2, 4)
|
|
2071
|
+
sage: exp(u)
|
|
2072
|
+
-4.82980938326939 - 5.59205609364098*I
|
|
2073
|
+
"""
|
|
2074
|
+
cdef MPComplexNumber z
|
|
2075
|
+
z = self._new()
|
|
2076
|
+
mpc_exp(z.value, self.value, (<MPComplexField_class>self._parent).__rnd)
|
|
2077
|
+
return z
|
|
2078
|
+
|
|
2079
|
+
def log(self):
|
|
2080
|
+
r"""
|
|
2081
|
+
Return the logarithm of this complex number with the branch
|
|
2082
|
+
cut on the negative real axis:
|
|
2083
|
+
|
|
2084
|
+
.. MATH::
|
|
2085
|
+
|
|
2086
|
+
\log(z) = \log |z| + i \arg(z).
|
|
2087
|
+
|
|
2088
|
+
EXAMPLES::
|
|
2089
|
+
|
|
2090
|
+
sage: MPC = MPComplexField()
|
|
2091
|
+
sage: u = MPC(2, 4)
|
|
2092
|
+
sage: log(u)
|
|
2093
|
+
1.49786613677700 + 1.10714871779409*I
|
|
2094
|
+
"""
|
|
2095
|
+
cdef MPComplexNumber z
|
|
2096
|
+
z = self._new()
|
|
2097
|
+
mpc_log(z.value, self.value, (<MPComplexField_class>self._parent).__rnd)
|
|
2098
|
+
return z
|
|
2099
|
+
|
|
2100
|
+
def __lshift__(self, n):
|
|
2101
|
+
"""
|
|
2102
|
+
Fast multiplication by `2^n`.
|
|
2103
|
+
|
|
2104
|
+
EXAMPLES::
|
|
2105
|
+
|
|
2106
|
+
sage: MPC = MPComplexField()
|
|
2107
|
+
sage: u = MPC(2, 4)
|
|
2108
|
+
sage: u<<2
|
|
2109
|
+
8.00000000000000 + 16.0000000000000*I
|
|
2110
|
+
sage: u<<(-1)
|
|
2111
|
+
1.00000000000000 + 2.00000000000000*I
|
|
2112
|
+
"""
|
|
2113
|
+
cdef MPComplexNumber z, x
|
|
2114
|
+
x = <MPComplexNumber>self
|
|
2115
|
+
z = x._new()
|
|
2116
|
+
mpc_mul_2si(z.value, x.value, n, (<MPComplexField_class>x._parent).__rnd)
|
|
2117
|
+
return z
|
|
2118
|
+
|
|
2119
|
+
def __rshift__(self, n):
|
|
2120
|
+
"""
|
|
2121
|
+
Fast division by `2^n`.
|
|
2122
|
+
|
|
2123
|
+
EXAMPLES::
|
|
2124
|
+
|
|
2125
|
+
sage: MPC = MPComplexField()
|
|
2126
|
+
sage: u = MPC(2, 4)
|
|
2127
|
+
sage: u>>2
|
|
2128
|
+
0.500000000000000 + 1.00000000000000*I
|
|
2129
|
+
sage: u>>(-1)
|
|
2130
|
+
4.00000000000000 + 8.00000000000000*I
|
|
2131
|
+
"""
|
|
2132
|
+
cdef MPComplexNumber z, x
|
|
2133
|
+
x = <MPComplexNumber>self
|
|
2134
|
+
z = x._new()
|
|
2135
|
+
mpc_div_2si(z.value, x.value, n, (<MPComplexField_class>x._parent).__rnd)
|
|
2136
|
+
return z
|
|
2137
|
+
|
|
2138
|
+
def nth_root(self, n, all=False):
|
|
2139
|
+
"""
|
|
2140
|
+
The `n`-th root function.
|
|
2141
|
+
|
|
2142
|
+
INPUT:
|
|
2143
|
+
|
|
2144
|
+
- ``all`` -- boolean (default: ``False``); if ``True``, return a
|
|
2145
|
+
list of all `n`-th roots
|
|
2146
|
+
|
|
2147
|
+
EXAMPLES::
|
|
2148
|
+
|
|
2149
|
+
sage: MPC = MPComplexField()
|
|
2150
|
+
sage: a = MPC(27)
|
|
2151
|
+
sage: a.nth_root(3)
|
|
2152
|
+
3.00000000000000
|
|
2153
|
+
sage: a.nth_root(3, all=True)
|
|
2154
|
+
[3.00000000000000, -1.50000000000000 + 2.59807621135332*I, -1.50000000000000 - 2.59807621135332*I]
|
|
2155
|
+
"""
|
|
2156
|
+
if self.is_zero():
|
|
2157
|
+
return [self] if all else self
|
|
2158
|
+
|
|
2159
|
+
cdef RealField_class R = self._parent._real_field()
|
|
2160
|
+
cdef mpfr_rnd_t rrnd = R.rnd
|
|
2161
|
+
cdef mpc_rnd_t crnd = (<MPComplexField_class>(self._parent)).__rnd
|
|
2162
|
+
|
|
2163
|
+
cdef RealNumber a,r
|
|
2164
|
+
a = self.argument()/n
|
|
2165
|
+
r = self.abs()
|
|
2166
|
+
mpfr_rootn_ui(r.value, r.value, n, rrnd)
|
|
2167
|
+
|
|
2168
|
+
cdef MPComplexNumber z
|
|
2169
|
+
z = self._new()
|
|
2170
|
+
mpfr_sin_cos(z.value.im, z.value.re, a.value, rrnd)
|
|
2171
|
+
mpc_mul_fr(z.value, z.value, r.value, crnd)
|
|
2172
|
+
|
|
2173
|
+
if not all:
|
|
2174
|
+
return z
|
|
2175
|
+
|
|
2176
|
+
cdef RealNumber t, tt
|
|
2177
|
+
t = R.pi()*2/n
|
|
2178
|
+
tt= RealNumber(R)
|
|
2179
|
+
|
|
2180
|
+
cdef list zlist = [z]
|
|
2181
|
+
for i in range(1,n):
|
|
2182
|
+
z = self._new()
|
|
2183
|
+
mpfr_mul_ui(tt.value, t.value, i, rrnd)
|
|
2184
|
+
mpfr_add(tt.value, tt.value, a.value, rrnd)
|
|
2185
|
+
mpfr_sin_cos(z.value.im, z.value.re, tt.value, rrnd)
|
|
2186
|
+
mpc_mul_fr(z.value, z.value, r.value, crnd)
|
|
2187
|
+
zlist.append(z)
|
|
2188
|
+
|
|
2189
|
+
return zlist
|
|
2190
|
+
|
|
2191
|
+
def dilog(self):
|
|
2192
|
+
r"""
|
|
2193
|
+
Return the complex dilogarithm of ``self``.
|
|
2194
|
+
|
|
2195
|
+
The complex dilogarithm, or Spence's function, is defined by
|
|
2196
|
+
|
|
2197
|
+
.. MATH::
|
|
2198
|
+
|
|
2199
|
+
Li_2(z) = - \int_0^z \frac{\log|1-\zeta|}{\zeta} d(\zeta)
|
|
2200
|
+
= \sum_{k=1}^\infty \frac{z^k}{k^2}.
|
|
2201
|
+
|
|
2202
|
+
Note that the series definition can only be used for `|z| < 1`.
|
|
2203
|
+
|
|
2204
|
+
EXAMPLES::
|
|
2205
|
+
|
|
2206
|
+
sage: MPC = MPComplexField()
|
|
2207
|
+
sage: a = MPC(1,0)
|
|
2208
|
+
sage: a.dilog() # needs sage.libs.pari
|
|
2209
|
+
1.64493406684823
|
|
2210
|
+
sage: float(pi^2/6) # needs sage.symbolic
|
|
2211
|
+
1.6449340668482262
|
|
2212
|
+
|
|
2213
|
+
::
|
|
2214
|
+
|
|
2215
|
+
sage: b = MPC(0,1)
|
|
2216
|
+
sage: b.dilog() # needs sage.libs.pari
|
|
2217
|
+
-0.205616758356028 + 0.915965594177219*I
|
|
2218
|
+
|
|
2219
|
+
::
|
|
2220
|
+
|
|
2221
|
+
sage: c = MPC(0,0)
|
|
2222
|
+
sage: c.dilog() # needs sage.libs.pari
|
|
2223
|
+
0
|
|
2224
|
+
"""
|
|
2225
|
+
return self._parent(self.__pari__().dilog())
|
|
2226
|
+
|
|
2227
|
+
def eta(self, omit_frac=False):
|
|
2228
|
+
r"""
|
|
2229
|
+
Return the value of the Dedekind `\eta` function on ``self``,
|
|
2230
|
+
intelligently computed using `\mathbb{SL}(2,\ZZ)` transformations.
|
|
2231
|
+
|
|
2232
|
+
The `\eta` function is
|
|
2233
|
+
|
|
2234
|
+
.. MATH::
|
|
2235
|
+
|
|
2236
|
+
\eta(z) = e^{\pi i z / 12} \prod_{n=1}^{\infty}(1-e^{2\pi inz})
|
|
2237
|
+
|
|
2238
|
+
INPUT:
|
|
2239
|
+
|
|
2240
|
+
- ``self`` -- element of the upper half plane (if not,
|
|
2241
|
+
raises a :exc:`ValueError`)
|
|
2242
|
+
|
|
2243
|
+
- ``omit_frac`` -- -- boolean (default: ``False``); if ``True``,
|
|
2244
|
+
omit the `e^{\pi i z / 12}` factor
|
|
2245
|
+
|
|
2246
|
+
OUTPUT: a complex number
|
|
2247
|
+
|
|
2248
|
+
ALGORITHM: Uses the PARI C library.
|
|
2249
|
+
|
|
2250
|
+
EXAMPLES::
|
|
2251
|
+
|
|
2252
|
+
sage: MPC = MPComplexField()
|
|
2253
|
+
sage: i = MPC.0
|
|
2254
|
+
sage: z = 1+i; z.eta() # needs sage.libs.pari
|
|
2255
|
+
0.742048775836565 + 0.198831370229911*I
|
|
2256
|
+
"""
|
|
2257
|
+
try:
|
|
2258
|
+
return self._parent(self.__pari__().eta(not omit_frac))
|
|
2259
|
+
except PariError:
|
|
2260
|
+
raise ValueError("value must be in the upper half plane")
|
|
2261
|
+
|
|
2262
|
+
def gamma(self):
|
|
2263
|
+
"""
|
|
2264
|
+
Return the Gamma function evaluated at this complex number.
|
|
2265
|
+
|
|
2266
|
+
EXAMPLES::
|
|
2267
|
+
|
|
2268
|
+
sage: MPC = MPComplexField(30)
|
|
2269
|
+
sage: i = MPC.0
|
|
2270
|
+
sage: (1+i).gamma() # needs sage.libs.pari
|
|
2271
|
+
0.49801567 - 0.15494983*I
|
|
2272
|
+
|
|
2273
|
+
TESTS::
|
|
2274
|
+
|
|
2275
|
+
sage: MPC(0).gamma() # needs sage.libs.pari
|
|
2276
|
+
Infinity
|
|
2277
|
+
|
|
2278
|
+
::
|
|
2279
|
+
|
|
2280
|
+
sage: MPC(-1).gamma() # needs sage.libs.pari
|
|
2281
|
+
Infinity
|
|
2282
|
+
"""
|
|
2283
|
+
try:
|
|
2284
|
+
return self._parent(self.__pari__().gamma())
|
|
2285
|
+
except PariError:
|
|
2286
|
+
from sage.rings.infinity import UnsignedInfinityRing
|
|
2287
|
+
return UnsignedInfinityRing.gen()
|
|
2288
|
+
|
|
2289
|
+
def gamma_inc(self, t):
|
|
2290
|
+
"""
|
|
2291
|
+
Return the incomplete Gamma function evaluated at this complex number.
|
|
2292
|
+
|
|
2293
|
+
EXAMPLES::
|
|
2294
|
+
|
|
2295
|
+
sage: # needs sage.libs.pari
|
|
2296
|
+
sage: C, i = MPComplexField(30).objgen()
|
|
2297
|
+
sage: (1+i).gamma_inc(2 + 3*i) # abs tol 2e-10
|
|
2298
|
+
0.0020969149 - 0.059981914*I
|
|
2299
|
+
sage: (1+i).gamma_inc(5)
|
|
2300
|
+
-0.0013781309 + 0.0065198200*I
|
|
2301
|
+
sage: C(2).gamma_inc(1 + i)
|
|
2302
|
+
0.70709210 - 0.42035364*I
|
|
2303
|
+
"""
|
|
2304
|
+
return self._parent(self.__pari__().incgam(t, precision=self.prec()))
|
|
2305
|
+
|
|
2306
|
+
def zeta(self):
|
|
2307
|
+
"""
|
|
2308
|
+
Return the Riemann zeta function evaluated at this complex number.
|
|
2309
|
+
|
|
2310
|
+
EXAMPLES::
|
|
2311
|
+
|
|
2312
|
+
sage: i = MPComplexField(30).gen()
|
|
2313
|
+
sage: z = 1 + i
|
|
2314
|
+
sage: z.zeta() # needs sage.libs.pari
|
|
2315
|
+
0.58215806 - 0.92684856*I
|
|
2316
|
+
"""
|
|
2317
|
+
return self._parent(self.__pari__().zeta())
|
|
2318
|
+
|
|
2319
|
+
def agm(self, right, algorithm='optimal'):
|
|
2320
|
+
"""
|
|
2321
|
+
Return the algebro-geometric mean of ``self`` and ``right``.
|
|
2322
|
+
|
|
2323
|
+
EXAMPLES::
|
|
2324
|
+
|
|
2325
|
+
sage: MPC = MPComplexField()
|
|
2326
|
+
sage: u = MPC(1, 4)
|
|
2327
|
+
sage: v = MPC(-2,5)
|
|
2328
|
+
sage: u.agm(v, algorithm='pari') # needs sage.libs.pari
|
|
2329
|
+
-0.410522769709397 + 4.60061063922097*I
|
|
2330
|
+
sage: u.agm(v, algorithm='principal')
|
|
2331
|
+
1.24010691168158 - 0.472193567796433*I
|
|
2332
|
+
sage: u.agm(v, algorithm='optimal')
|
|
2333
|
+
-0.410522769709397 + 4.60061063922097*I
|
|
2334
|
+
"""
|
|
2335
|
+
if algorithm == "pari":
|
|
2336
|
+
t = self._parent(right).__pari__()
|
|
2337
|
+
return self._parent(self.__pari__().agm(t))
|
|
2338
|
+
|
|
2339
|
+
cdef MPComplexNumber a, b, d, s, res
|
|
2340
|
+
cdef mp_exp_t rel_prec
|
|
2341
|
+
cdef bint optimal = algorithm == "optimal"
|
|
2342
|
+
|
|
2343
|
+
cdef mpc_rnd_t rnd = (<MPComplexField_class>(self._parent)).__rnd
|
|
2344
|
+
|
|
2345
|
+
cdef int prec = self._parent._prec
|
|
2346
|
+
|
|
2347
|
+
if optimal or algorithm == "principal":
|
|
2348
|
+
if not isinstance(right, MPComplexNumber) or (<MPComplexNumber>right)._parent is not self._parent:
|
|
2349
|
+
right = self._parent(right)
|
|
2350
|
+
|
|
2351
|
+
res = self._new()
|
|
2352
|
+
|
|
2353
|
+
if self.is_zero():
|
|
2354
|
+
return self
|
|
2355
|
+
elif (<MPComplexNumber>right).is_zero():
|
|
2356
|
+
return right
|
|
2357
|
+
elif (mpfr_cmpabs(self.value.re, (<MPComplexNumber>right).value.re) == 0 and
|
|
2358
|
+
mpfr_cmpabs(self.value.im, (<MPComplexNumber>right).value.im) == 0 and
|
|
2359
|
+
mpfr_cmp(self.value.re, (<MPComplexNumber>right).value.re) != 0 and
|
|
2360
|
+
mpfr_cmp(self.value.im, (<MPComplexNumber>right).value.im) != 0):
|
|
2361
|
+
# self = -right
|
|
2362
|
+
mpc_set_ui(res.value, 0, rnd)
|
|
2363
|
+
return res
|
|
2364
|
+
# Do the computations to a bit higher precision so rounding error
|
|
2365
|
+
# won't obscure the termination condition.
|
|
2366
|
+
a = MPComplexNumber(MPComplexField(prec+5), None)
|
|
2367
|
+
b = a._new()
|
|
2368
|
+
d = a._new()
|
|
2369
|
+
s = a._new()
|
|
2370
|
+
|
|
2371
|
+
# Make copies so we don't mutate self or right.
|
|
2372
|
+
mpc_set(a.value, self.value, rnd)
|
|
2373
|
+
mpc_set(b.value, (<MPComplexNumber>right).value, rnd)
|
|
2374
|
+
|
|
2375
|
+
if optimal:
|
|
2376
|
+
mpc_add(s.value, a.value, b.value, rnd)
|
|
2377
|
+
|
|
2378
|
+
while True:
|
|
2379
|
+
# s = a+b
|
|
2380
|
+
if not optimal:
|
|
2381
|
+
mpc_add(s.value, a.value, b.value, rnd)
|
|
2382
|
+
|
|
2383
|
+
# b = sqrt(a*b)
|
|
2384
|
+
mpc_mul(d.value, a.value, b.value, rnd)
|
|
2385
|
+
mpc_sqrt(b.value, d.value, rnd)
|
|
2386
|
+
|
|
2387
|
+
# a = s/2
|
|
2388
|
+
mpc_div_2ui(a.value, s.value, 1, rnd)
|
|
2389
|
+
|
|
2390
|
+
# d = a - b
|
|
2391
|
+
mpc_sub(d.value, a.value, b.value, rnd)
|
|
2392
|
+
if d.is_zero():
|
|
2393
|
+
mpc_set(res.value, a.value, rnd)
|
|
2394
|
+
return res
|
|
2395
|
+
|
|
2396
|
+
if optimal:
|
|
2397
|
+
# s = a+b
|
|
2398
|
+
mpc_add(s.value, a.value, b.value, rnd)
|
|
2399
|
+
if s.is_zero():
|
|
2400
|
+
mpc_set(res.value, a.value, rnd)
|
|
2401
|
+
return res
|
|
2402
|
+
|
|
2403
|
+
# |s| < |d|
|
|
2404
|
+
if s.norm() < d.norm():
|
|
2405
|
+
mpc_swap(d.value, s.value)
|
|
2406
|
+
mpc_neg(b.value, b.value, rnd)
|
|
2407
|
+
|
|
2408
|
+
rel_prec = min_exp_t(max_exp(a), max_exp(b)) - max_exp(d)
|
|
2409
|
+
if rel_prec > prec:
|
|
2410
|
+
mpc_set(res.value, a.value, rnd)
|
|
2411
|
+
return res
|
|
2412
|
+
|
|
2413
|
+
cdef inline mp_exp_t min_exp_t(mp_exp_t a, mp_exp_t b) noexcept:
|
|
2414
|
+
return a if a < b else b
|
|
2415
|
+
cdef inline mp_exp_t max_exp_t(mp_exp_t a, mp_exp_t b) noexcept:
|
|
2416
|
+
return a if a > b else b
|
|
2417
|
+
|
|
2418
|
+
cdef inline mp_exp_t max_exp(MPComplexNumber z) noexcept:
|
|
2419
|
+
"""
|
|
2420
|
+
Quickly return the maximum exponent of the real and complex parts of ``z``,
|
|
2421
|
+
which is useful for estimating its magnitude.
|
|
2422
|
+
"""
|
|
2423
|
+
if mpfr_zero_p(z.value.im):
|
|
2424
|
+
return mpfr_get_exp(z.value.re)
|
|
2425
|
+
elif mpfr_zero_p(z.value.re):
|
|
2426
|
+
return mpfr_get_exp(z.value.im)
|
|
2427
|
+
return max_exp_t(mpfr_get_exp(z.value.re), mpfr_get_exp(z.value.im))
|
|
2428
|
+
|
|
2429
|
+
|
|
2430
|
+
def __create__MPComplexField_version0 (prec, rnd):
|
|
2431
|
+
"""
|
|
2432
|
+
Create a :class:`MPComplexField`.
|
|
2433
|
+
|
|
2434
|
+
EXAMPLES::
|
|
2435
|
+
|
|
2436
|
+
sage: sage.rings.complex_mpc.__create__MPComplexField_version0(200, 'RNDDZ')
|
|
2437
|
+
Complex Field with 200 bits of precision and rounding RNDDZ
|
|
2438
|
+
"""
|
|
2439
|
+
return MPComplexField(prec, rnd)
|
|
2440
|
+
|
|
2441
|
+
|
|
2442
|
+
def __create__MPComplexNumber_version0 (parent, s, base=10):
|
|
2443
|
+
"""
|
|
2444
|
+
Create a :class:`MPComplexNumber`.
|
|
2445
|
+
|
|
2446
|
+
EXAMPLES::
|
|
2447
|
+
|
|
2448
|
+
sage: C = MPComplexField(prec=20, rnd='RNDUU')
|
|
2449
|
+
sage: sage.rings.complex_mpc.__create__MPComplexNumber_version0(C, 3.2+2*i) # needs sage.symbolic
|
|
2450
|
+
3.2001 + 2.0000*I
|
|
2451
|
+
sage: C = MPComplexField(prec=20, rnd='RNDUU')
|
|
2452
|
+
sage: sage.rings.complex_mpc.__create__MPComplexNumber_version0(C,"33.",10)
|
|
2453
|
+
33.000
|
|
2454
|
+
"""
|
|
2455
|
+
return MPComplexNumber(parent, s, base=base)
|
|
2456
|
+
|
|
2457
|
+
|
|
2458
|
+
# original version of the file had this with only 1 underscore - TCS
|
|
2459
|
+
__create_MPComplexNumber_version0 = __create__MPComplexNumber_version0
|
|
2460
|
+
|
|
2461
|
+
#*****************************************************************************
|
|
2462
|
+
#
|
|
2463
|
+
# Morphisms
|
|
2464
|
+
#
|
|
2465
|
+
#*****************************************************************************
|
|
2466
|
+
|
|
2467
|
+
cdef class MPCtoMPC(Map):
|
|
2468
|
+
cpdef Element _call_(self, z):
|
|
2469
|
+
"""
|
|
2470
|
+
EXAMPLES::
|
|
2471
|
+
|
|
2472
|
+
sage: from sage.rings.complex_mpc import *
|
|
2473
|
+
sage: C10 = MPComplexField(10)
|
|
2474
|
+
sage: C100 = MPComplexField(100)
|
|
2475
|
+
sage: f = MPCtoMPC(C100, C10) # indirect doctest
|
|
2476
|
+
sage: a = C100(1.2, 24)
|
|
2477
|
+
sage: f(a)
|
|
2478
|
+
1.2 + 24.*I
|
|
2479
|
+
sage: f
|
|
2480
|
+
Generic map:
|
|
2481
|
+
From: Complex Field with 100 bits of precision
|
|
2482
|
+
To: Complex Field with 10 bits of precision
|
|
2483
|
+
"""
|
|
2484
|
+
cdef MPComplexNumber y
|
|
2485
|
+
y = (<MPComplexField_class>self.codomain())._new()
|
|
2486
|
+
y._set(z)
|
|
2487
|
+
return y
|
|
2488
|
+
|
|
2489
|
+
def section(self):
|
|
2490
|
+
"""
|
|
2491
|
+
EXAMPLES::
|
|
2492
|
+
|
|
2493
|
+
sage: from sage.rings.complex_mpc import *
|
|
2494
|
+
sage: C10 = MPComplexField(10)
|
|
2495
|
+
sage: C100 = MPComplexField(100)
|
|
2496
|
+
sage: f = MPCtoMPC(C100, C10)
|
|
2497
|
+
sage: f.section()
|
|
2498
|
+
Generic map:
|
|
2499
|
+
From: Complex Field with 10 bits of precision
|
|
2500
|
+
To: Complex Field with 100 bits of precision
|
|
2501
|
+
"""
|
|
2502
|
+
return MPCtoMPC(self.codomain(), self.domain())
|
|
2503
|
+
|
|
2504
|
+
cdef class INTEGERtoMPC(Map):
|
|
2505
|
+
cpdef Element _call_(self, x):
|
|
2506
|
+
"""
|
|
2507
|
+
EXAMPLES::
|
|
2508
|
+
|
|
2509
|
+
sage: from sage.rings.complex_mpc import *
|
|
2510
|
+
sage: I = IntegerRing()
|
|
2511
|
+
sage: C100 = MPComplexField(100)
|
|
2512
|
+
sage: f = MPFRtoMPC(I, C100); f # indirect doctest
|
|
2513
|
+
Generic map:
|
|
2514
|
+
From: Integer Ring
|
|
2515
|
+
To: Complex Field with 100 bits of precision
|
|
2516
|
+
sage: a = I(625)
|
|
2517
|
+
sage: f(a)
|
|
2518
|
+
625.00000000000000000000000000
|
|
2519
|
+
"""
|
|
2520
|
+
cdef MPComplexNumber y
|
|
2521
|
+
cdef mpc_rnd_t rnd
|
|
2522
|
+
rnd =(<MPComplexField_class>self._parent).__rnd
|
|
2523
|
+
y = (<MPComplexField_class>self.codomain())._new()
|
|
2524
|
+
mpc_set_z(y.value, (<Integer>x).value, rnd)
|
|
2525
|
+
return y
|
|
2526
|
+
|
|
2527
|
+
cdef class MPFRtoMPC(Map):
|
|
2528
|
+
cpdef Element _call_(self, x):
|
|
2529
|
+
"""
|
|
2530
|
+
EXAMPLES::
|
|
2531
|
+
|
|
2532
|
+
sage: from sage.rings.complex_mpc import *
|
|
2533
|
+
sage: R10 = RealField(10)
|
|
2534
|
+
sage: C100 = MPComplexField(100)
|
|
2535
|
+
sage: f = MPFRtoMPC(R10, C100); f # indirect doctest
|
|
2536
|
+
Generic map:
|
|
2537
|
+
From: Real Field with 10 bits of precision
|
|
2538
|
+
To: Complex Field with 100 bits of precision
|
|
2539
|
+
sage: a = R10(1.625)
|
|
2540
|
+
sage: f(a)
|
|
2541
|
+
1.6250000000000000000000000000
|
|
2542
|
+
"""
|
|
2543
|
+
cdef MPComplexNumber y
|
|
2544
|
+
# cdef mpc_rnd_t rnd
|
|
2545
|
+
# rnd =(<MPComplexField_class>self._parent).__rnd
|
|
2546
|
+
y = (<MPComplexField_class>self.codomain())._new()
|
|
2547
|
+
# mpc_set_fr(y.value, (<RealNumber>x).value, rnd)
|
|
2548
|
+
y._set(x)
|
|
2549
|
+
return y
|
|
2550
|
+
|
|
2551
|
+
cdef class CCtoMPC(Map):
|
|
2552
|
+
cpdef Element _call_(self, z):
|
|
2553
|
+
"""
|
|
2554
|
+
EXAMPLES::
|
|
2555
|
+
|
|
2556
|
+
sage: from sage.rings.complex_mpc import *
|
|
2557
|
+
sage: C10 = ComplexField(10)
|
|
2558
|
+
sage: MPC100 = MPComplexField(100)
|
|
2559
|
+
sage: f = CCtoMPC(C10, MPC100); f # indirect doctest
|
|
2560
|
+
Generic map:
|
|
2561
|
+
From: Complex Field with 10 bits of precision
|
|
2562
|
+
To: Complex Field with 100 bits of precision
|
|
2563
|
+
sage: a = C10(1.625, 42)
|
|
2564
|
+
sage: f(a)
|
|
2565
|
+
1.6250000000000000000000000000 + 42.000000000000000000000000000*I
|
|
2566
|
+
"""
|
|
2567
|
+
cdef MPComplexNumber y
|
|
2568
|
+
cdef mpc_rnd_t rnd
|
|
2569
|
+
rnd =(<MPComplexField_class>self._parent).__rnd
|
|
2570
|
+
y = (<MPComplexField_class>self.codomain())._new()
|
|
2571
|
+
mpc_set_fr_fr(y.value, (<ComplexNumber>z).__re, (<ComplexNumber>z).__im, rnd)
|
|
2572
|
+
return y
|
|
2573
|
+
|
|
2574
|
+
|
|
2575
|
+
# Support Python's numbers abstract base class
|
|
2576
|
+
# import numbers
|