passagemath-modules 10.6.31rc3__cp314-cp314-musllinux_1_2_x86_64.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 +808 -0
- passagemath_modules-10.6.31rc3.dist-info/WHEEL +5 -0
- passagemath_modules-10.6.31rc3.dist-info/top_level.txt +2 -0
- passagemath_modules.libs/libgcc_s-0cd532bd.so.1 +0 -0
- passagemath_modules.libs/libgfortran-2c33b284.so.5.0.0 +0 -0
- passagemath_modules.libs/libgmp-0e7fc84e.so.10.5.0 +0 -0
- passagemath_modules.libs/libgsl-42cda06f.so.28.0.0 +0 -0
- passagemath_modules.libs/libmpc-d8ebe4b5.so.3.3.1 +0 -0
- passagemath_modules.libs/libmpfr-aaecbfc0.so.6.2.1 +0 -0
- passagemath_modules.libs/libopenblasp-r0-905cb27d.3.29.so +0 -0
- passagemath_modules.libs/libquadmath-bb76a5fc.so.0.0.0 +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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.so +0 -0
- sage/calculus/integration.pyx +698 -0
- sage/calculus/interpolation.cpython-314-x86_64-linux-musl.so +0 -0
- sage/calculus/interpolation.pxd +13 -0
- sage/calculus/interpolation.pyx +387 -0
- sage/calculus/interpolators.cpython-314-x86_64-linux-musl.so +0 -0
- sage/calculus/interpolators.pyx +326 -0
- sage/calculus/ode.cpython-314-x86_64-linux-musl.so +0 -0
- sage/calculus/ode.pxd +5 -0
- sage/calculus/ode.pyx +610 -0
- sage/calculus/riemann.cpython-314-x86_64-linux-musl.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-x86_64-linux-musl.so +0 -0
- sage/calculus/transforms/dwt.pxd +7 -0
- sage/calculus/transforms/dwt.pyx +160 -0
- sage/calculus/transforms/fft.cpython-314-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.so +0 -0
- sage/libs/mpmath/utils.pxd +4 -0
- sage/libs/mpmath/utils.pyx +319 -0
- sage/matrix/action.cpython-314-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.so +0 -0
- sage/matrix/constructor.pyx +750 -0
- sage/matrix/docs.py +430 -0
- sage/matrix/echelon_matrix.cpython-314-x86_64-linux-musl.so +0 -0
- sage/matrix/echelon_matrix.pyx +155 -0
- sage/matrix/matrix.pxd +2 -0
- sage/matrix/matrix0.cpython-314-x86_64-linux-musl.so +0 -0
- sage/matrix/matrix0.pxd +68 -0
- sage/matrix/matrix0.pyx +6324 -0
- sage/matrix/matrix1.cpython-314-x86_64-linux-musl.so +0 -0
- sage/matrix/matrix1.pxd +8 -0
- sage/matrix/matrix1.pyx +2851 -0
- sage/matrix/matrix2.cpython-314-x86_64-linux-musl.so +0 -0
- sage/matrix/matrix2.pxd +25 -0
- sage/matrix/matrix2.pyx +20181 -0
- sage/matrix/matrix_cdv.cpython-314-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.so +0 -0
- sage/matrix/matrix_sparse.pxd +5 -0
- sage/matrix/matrix_sparse.pyx +1222 -0
- sage/matrix/matrix_window.cpython-314-x86_64-linux-musl.so +0 -0
- sage/matrix/matrix_window.pxd +37 -0
- sage/matrix/matrix_window.pyx +242 -0
- sage/matrix/misc_mpfr.cpython-314-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.so +0 -0
- sage/matroids/extension.pxd +34 -0
- sage/matroids/extension.pyx +519 -0
- sage/matroids/flats_matroid.cpython-314-x86_64-linux-musl.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-x86_64-linux-musl.so +0 -0
- sage/matroids/graphic_matroid.pxd +39 -0
- sage/matroids/graphic_matroid.pyx +2024 -0
- sage/matroids/lean_matrix.cpython-314-x86_64-linux-musl.so +0 -0
- sage/matroids/lean_matrix.pxd +126 -0
- sage/matroids/lean_matrix.pyx +3667 -0
- sage/matroids/linear_matroid.cpython-314-x86_64-linux-musl.so +0 -0
- sage/matroids/linear_matroid.pxd +180 -0
- sage/matroids/linear_matroid.pyx +6649 -0
- sage/matroids/matroid.cpython-314-x86_64-linux-musl.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-x86_64-linux-musl.so +0 -0
- sage/matroids/set_system.pxd +38 -0
- sage/matroids/set_system.pyx +800 -0
- sage/matroids/transversal_matroid.cpython-314-x86_64-linux-musl.so +0 -0
- sage/matroids/transversal_matroid.pxd +14 -0
- sage/matroids/transversal_matroid.pyx +893 -0
- sage/matroids/union_matroid.cpython-314-x86_64-linux-musl.so +0 -0
- sage/matroids/union_matroid.pxd +20 -0
- sage/matroids/union_matroid.pyx +331 -0
- sage/matroids/unpickling.cpython-314-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.so +0 -0
- sage/rings/complex_conversion.pxd +8 -0
- sage/rings/complex_conversion.pyx +23 -0
- sage/rings/complex_double.cpython-314-x86_64-linux-musl.so +0 -0
- sage/rings/complex_double.pxd +21 -0
- sage/rings/complex_double.pyx +2654 -0
- sage/rings/complex_mpc.cpython-314-x86_64-linux-musl.so +0 -0
- sage/rings/complex_mpc.pxd +21 -0
- sage/rings/complex_mpc.pyx +2576 -0
- sage/rings/complex_mpfr.cpython-314-x86_64-linux-musl.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-x86_64-linux-musl.so +0 -0
- sage/rings/function_field/hermite_form_polynomial.pyx +188 -0
- sage/rings/function_field/khuri_makdisi.cpython-314-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.so +0 -0
- sage/rings/real_mpfr.pxd +29 -0
- sage/rings/real_mpfr.pyx +6122 -0
- sage/rings/ring_extension.cpython-314-x86_64-linux-musl.so +0 -0
- sage/rings/ring_extension.pxd +42 -0
- sage/rings/ring_extension.pyx +2779 -0
- sage/rings/ring_extension_conversion.cpython-314-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.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-x86_64-linux-musl.so +0 -0
- sage/stats/hmm/chmm.pyx +1595 -0
- sage/stats/hmm/distributions.cpython-314-x86_64-linux-musl.so +0 -0
- sage/stats/hmm/distributions.pxd +29 -0
- sage/stats/hmm/distributions.pyx +531 -0
- sage/stats/hmm/hmm.cpython-314-x86_64-linux-musl.so +0 -0
- sage/stats/hmm/hmm.pxd +17 -0
- sage/stats/hmm/hmm.pyx +1388 -0
- sage/stats/hmm/util.cpython-314-x86_64-linux-musl.so +0 -0
- sage/stats/hmm/util.pxd +7 -0
- sage/stats/hmm/util.pyx +165 -0
- sage/stats/intlist.cpython-314-x86_64-linux-musl.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-x86_64-linux-musl.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,2654 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-modules
|
|
2
|
+
# distutils: extra_compile_args = -D_XPG6
|
|
3
|
+
# distutils: libraries = M_LIBRARIES
|
|
4
|
+
# distutils: language = c++
|
|
5
|
+
# distutils: extra_compile_args = -std=c++11
|
|
6
|
+
r"""
|
|
7
|
+
Double precision floating point complex numbers
|
|
8
|
+
|
|
9
|
+
Sage supports arithmetic using double-precision complex numbers. A
|
|
10
|
+
double-precision complex number is a complex number ``x + I*y`` with
|
|
11
|
+
`x`, `y` 64-bit (8 byte) floating point numbers (double precision).
|
|
12
|
+
|
|
13
|
+
The field :class:`ComplexDoubleField` implements the field
|
|
14
|
+
of all double-precision complex numbers. You can refer to this
|
|
15
|
+
field by the shorthand ``CDF``. Elements of this field are of type
|
|
16
|
+
:class:`ComplexDoubleElement`. If `x` and `y` are coercible to
|
|
17
|
+
doubles, you can create a complex double element using
|
|
18
|
+
``ComplexDoubleElement(x,y)``. You can coerce more
|
|
19
|
+
general objects `z` to complex doubles by typing either
|
|
20
|
+
``ComplexDoubleField(x)`` or ``CDF(x)``.
|
|
21
|
+
|
|
22
|
+
EXAMPLES::
|
|
23
|
+
|
|
24
|
+
sage: ComplexDoubleField()
|
|
25
|
+
Complex Double Field
|
|
26
|
+
sage: CDF
|
|
27
|
+
Complex Double Field
|
|
28
|
+
sage: type(CDF.0)
|
|
29
|
+
<class 'sage.rings.complex_double.ComplexDoubleElement'>
|
|
30
|
+
sage: ComplexDoubleElement(sqrt(2), 3) # needs sage.symbolic
|
|
31
|
+
1.4142135623730951 + 3.0*I
|
|
32
|
+
sage: parent(CDF(-2))
|
|
33
|
+
Complex Double Field
|
|
34
|
+
|
|
35
|
+
::
|
|
36
|
+
|
|
37
|
+
sage: CC == CDF
|
|
38
|
+
False
|
|
39
|
+
sage: CDF is ComplexDoubleField() # CDF is the shorthand
|
|
40
|
+
True
|
|
41
|
+
sage: CDF == ComplexDoubleField()
|
|
42
|
+
True
|
|
43
|
+
|
|
44
|
+
The underlying arithmetic of complex numbers is implemented using
|
|
45
|
+
functions and macros in :ref:`GSL <spkg_gsl>` (the GNU Scientific Library), and
|
|
46
|
+
should be very fast. Also, all standard complex trig functions,
|
|
47
|
+
log, exponents, etc., are implemented using GSL, and are also
|
|
48
|
+
robust and fast. Several other special functions, e.g. eta, gamma,
|
|
49
|
+
incomplete gamma, etc., are implemented using the :ref:`PARI <spkg_pari>`
|
|
50
|
+
C library.
|
|
51
|
+
|
|
52
|
+
AUTHORS:
|
|
53
|
+
|
|
54
|
+
- William Stein (2006-09): first version
|
|
55
|
+
|
|
56
|
+
- Travis Scrimshaw (2012-10-18): Added doctests to get full coverage
|
|
57
|
+
|
|
58
|
+
- Jeroen Demeyer (2013-02-27): fixed all PARI calls (:issue:`14082`)
|
|
59
|
+
|
|
60
|
+
- Vincent Klein (2017-11-15) : add __mpc__() to class ComplexDoubleElement.
|
|
61
|
+
ComplexDoubleElement constructor support and gmpy2.mpc parameter.
|
|
62
|
+
"""
|
|
63
|
+
|
|
64
|
+
# ****************************************************************************
|
|
65
|
+
# Copyright (C) 2006 William Stein <wstein@gmail.com>
|
|
66
|
+
# Copyright (C) 2013 Jeroen Demeyer <jdemeyer@cage.ugent.be>
|
|
67
|
+
#
|
|
68
|
+
# Distributed under the terms of the GNU General Public License (GPL)
|
|
69
|
+
# as published by the Free Software Foundation; either version 2 of
|
|
70
|
+
# the License, or (at your option) any later version.
|
|
71
|
+
# https://www.gnu.org/licenses/
|
|
72
|
+
# ****************************************************************************
|
|
73
|
+
|
|
74
|
+
from cpython.object cimport Py_NE
|
|
75
|
+
|
|
76
|
+
from sage.misc.randstate cimport randstate, current_randstate
|
|
77
|
+
|
|
78
|
+
from sage.libs.gsl.complex cimport *
|
|
79
|
+
|
|
80
|
+
cimport libcpp.complex
|
|
81
|
+
from libcpp.complex cimport abs, sqrt
|
|
82
|
+
|
|
83
|
+
import sage.rings.abc
|
|
84
|
+
cimport sage.rings.integer
|
|
85
|
+
|
|
86
|
+
from sage.structure.element cimport Element, FieldElement
|
|
87
|
+
from sage.structure.parent cimport Parent
|
|
88
|
+
from sage.structure.richcmp cimport rich_to_bool
|
|
89
|
+
from sage.categories.morphism cimport Morphism
|
|
90
|
+
from sage.structure.coerce cimport is_numpy_type
|
|
91
|
+
|
|
92
|
+
try:
|
|
93
|
+
from cypari2.gen import Gen as pari_gen
|
|
94
|
+
from sage.libs.pari.convert_sage_complex_double import pari_to_cdf
|
|
95
|
+
|
|
96
|
+
except ImportError:
|
|
97
|
+
pari_gen = ()
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
new_gen_from_complex_double_element = None
|
|
101
|
+
complex_double_element_eta = None
|
|
102
|
+
complex_double_element_agm = None
|
|
103
|
+
complex_double_element_dilog = None
|
|
104
|
+
complex_double_element_gamma = None
|
|
105
|
+
complex_double_element_gamma_inc = None
|
|
106
|
+
complex_double_element_zeta = None
|
|
107
|
+
|
|
108
|
+
from sage.rings.complex_conversion cimport CCtoCDF
|
|
109
|
+
|
|
110
|
+
from sage.rings.real_double cimport RealDoubleElement, double_repr
|
|
111
|
+
from sage.rings.real_double import RDF
|
|
112
|
+
from sage.rings.integer_ring import ZZ
|
|
113
|
+
from sage.structure.richcmp cimport rich_to_bool
|
|
114
|
+
|
|
115
|
+
cimport gmpy2
|
|
116
|
+
gmpy2.import_gmpy2()
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
cdef class ComplexDoubleField_class(sage.rings.abc.ComplexDoubleField):
|
|
120
|
+
"""
|
|
121
|
+
An approximation to the field of complex numbers using double
|
|
122
|
+
precision floating point numbers. Answers derived from calculations
|
|
123
|
+
in this approximation may differ from what they would be if those
|
|
124
|
+
calculations were performed in the true field of complex numbers.
|
|
125
|
+
This is due to the rounding errors inherent to finite precision
|
|
126
|
+
calculations.
|
|
127
|
+
|
|
128
|
+
ALGORITHM:
|
|
129
|
+
|
|
130
|
+
Arithmetic is done using GSL (the GNU Scientific Library).
|
|
131
|
+
"""
|
|
132
|
+
def __init__(self):
|
|
133
|
+
r"""
|
|
134
|
+
Construct field of complex double precision numbers.
|
|
135
|
+
|
|
136
|
+
EXAMPLES::
|
|
137
|
+
|
|
138
|
+
sage: from sage.rings.complex_double import ComplexDoubleField_class
|
|
139
|
+
sage: CDF == ComplexDoubleField_class()
|
|
140
|
+
True
|
|
141
|
+
sage: TestSuite(CDF).run(skip = ["_test_prod"])
|
|
142
|
+
|
|
143
|
+
.. WARNING:: due to rounding errors, one can have `x^2 != x*x`::
|
|
144
|
+
|
|
145
|
+
sage: x = CDF.an_element()
|
|
146
|
+
sage: x
|
|
147
|
+
1.0*I
|
|
148
|
+
sage: x*x, x**2, x*x == x**2
|
|
149
|
+
(-1.0, -1.0 + 1.2246...e-16*I, False)
|
|
150
|
+
"""
|
|
151
|
+
from sage.categories.fields import Fields
|
|
152
|
+
Parent.__init__(self, self, names=('I',), normalize=False,
|
|
153
|
+
category=Fields().Infinite().Metric().Complete())
|
|
154
|
+
self._populate_coercion_lists_()
|
|
155
|
+
|
|
156
|
+
def __reduce__(self):
|
|
157
|
+
"""
|
|
158
|
+
For pickling.
|
|
159
|
+
|
|
160
|
+
EXAMPLES::
|
|
161
|
+
|
|
162
|
+
sage: loads(dumps(CDF)) is CDF
|
|
163
|
+
True
|
|
164
|
+
"""
|
|
165
|
+
return ComplexDoubleField, ()
|
|
166
|
+
|
|
167
|
+
cpdef bint is_exact(self) except -2:
|
|
168
|
+
"""
|
|
169
|
+
Return whether or not this field is exact, which is always ``False``.
|
|
170
|
+
|
|
171
|
+
EXAMPLES::
|
|
172
|
+
|
|
173
|
+
sage: CDF.is_exact()
|
|
174
|
+
False
|
|
175
|
+
"""
|
|
176
|
+
return False
|
|
177
|
+
|
|
178
|
+
def __richcmp__(left, right, int op):
|
|
179
|
+
"""
|
|
180
|
+
Rich comparison of ``left`` against ``right``.
|
|
181
|
+
|
|
182
|
+
EXAMPLES::
|
|
183
|
+
|
|
184
|
+
sage: CDF == CDF
|
|
185
|
+
True
|
|
186
|
+
"""
|
|
187
|
+
if left is right:
|
|
188
|
+
return rich_to_bool(op, 0)
|
|
189
|
+
if isinstance(right, ComplexDoubleField_class):
|
|
190
|
+
return rich_to_bool(op, 0)
|
|
191
|
+
return op == Py_NE
|
|
192
|
+
|
|
193
|
+
def __hash__(self):
|
|
194
|
+
"""
|
|
195
|
+
Return the hash for ``self``.
|
|
196
|
+
|
|
197
|
+
This class is intended for use as a singleton so any instance
|
|
198
|
+
of it should be equivalent from a hashing perspective.
|
|
199
|
+
|
|
200
|
+
TESTS::
|
|
201
|
+
|
|
202
|
+
sage: from sage.rings.complex_double import ComplexDoubleField_class
|
|
203
|
+
sage: hash(CDF) == hash(ComplexDoubleField_class())
|
|
204
|
+
True
|
|
205
|
+
"""
|
|
206
|
+
return 561162115
|
|
207
|
+
|
|
208
|
+
def characteristic(self):
|
|
209
|
+
"""
|
|
210
|
+
Return the characteristic of the complex double field, which is 0.
|
|
211
|
+
|
|
212
|
+
EXAMPLES::
|
|
213
|
+
|
|
214
|
+
sage: CDF.characteristic()
|
|
215
|
+
0
|
|
216
|
+
"""
|
|
217
|
+
from sage.rings.integer import Integer
|
|
218
|
+
return Integer(0)
|
|
219
|
+
|
|
220
|
+
def random_element(self, double xmin=-1, double xmax=1, double ymin=-1, double ymax=1):
|
|
221
|
+
"""
|
|
222
|
+
Return a random element of this complex double field with real and
|
|
223
|
+
imaginary part bounded by ``xmin``, ``xmax``, ``ymin``, ``ymax``.
|
|
224
|
+
|
|
225
|
+
EXAMPLES::
|
|
226
|
+
|
|
227
|
+
sage: CDF.random_element().parent() is CDF
|
|
228
|
+
True
|
|
229
|
+
sage: re, im = CDF.random_element()
|
|
230
|
+
sage: -1 <= re <= 1, -1 <= im <= 1
|
|
231
|
+
(True, True)
|
|
232
|
+
sage: re, im = CDF.random_element(-10,10,-10,10)
|
|
233
|
+
sage: -10 <= re <= 10, -10 <= im <= 10
|
|
234
|
+
(True, True)
|
|
235
|
+
sage: re, im = CDF.random_element(-10^20,10^20,-2,2)
|
|
236
|
+
sage: -10^20 <= re <= 10^20, -2 <= im <= 2
|
|
237
|
+
(True, True)
|
|
238
|
+
"""
|
|
239
|
+
cdef randstate rstate = current_randstate()
|
|
240
|
+
global _CDF
|
|
241
|
+
cdef ComplexDoubleElement z
|
|
242
|
+
cdef double imag = (ymax-ymin)*rstate.c_rand_double() + ymin
|
|
243
|
+
cdef double real = (xmax-xmin)*rstate.c_rand_double() + xmin
|
|
244
|
+
z = ComplexDoubleElement.__new__(ComplexDoubleElement)
|
|
245
|
+
z._complex = gsl_complex_rect(real, imag)
|
|
246
|
+
return z
|
|
247
|
+
|
|
248
|
+
def _repr_(self):
|
|
249
|
+
"""
|
|
250
|
+
Print out this complex double field.
|
|
251
|
+
|
|
252
|
+
EXAMPLES::
|
|
253
|
+
|
|
254
|
+
sage: ComplexDoubleField() # indirect doctest
|
|
255
|
+
Complex Double Field
|
|
256
|
+
sage: CDF # indirect doctest
|
|
257
|
+
Complex Double Field
|
|
258
|
+
"""
|
|
259
|
+
return "Complex Double Field"
|
|
260
|
+
|
|
261
|
+
def _latex_(self):
|
|
262
|
+
r"""
|
|
263
|
+
Return a LaTeX representation of ``self``.
|
|
264
|
+
|
|
265
|
+
OUTPUT: string
|
|
266
|
+
|
|
267
|
+
TESTS::
|
|
268
|
+
|
|
269
|
+
sage: print(CDF._latex_())
|
|
270
|
+
\Bold{C}
|
|
271
|
+
"""
|
|
272
|
+
return r"\Bold{C}"
|
|
273
|
+
|
|
274
|
+
def __call__(self, x=None, im=None):
|
|
275
|
+
"""
|
|
276
|
+
Create a complex double using ``x`` and optionally an imaginary part
|
|
277
|
+
``im``.
|
|
278
|
+
|
|
279
|
+
EXAMPLES::
|
|
280
|
+
|
|
281
|
+
sage: CDF(0,1) # indirect doctest
|
|
282
|
+
1.0*I
|
|
283
|
+
sage: CDF(2/3) # indirect doctest
|
|
284
|
+
0.6666666666666666
|
|
285
|
+
sage: CDF(5) # indirect doctest
|
|
286
|
+
5.0
|
|
287
|
+
sage: CDF('i') # indirect doctest
|
|
288
|
+
1.0*I
|
|
289
|
+
sage: CDF(complex(2,-3)) # indirect doctest
|
|
290
|
+
2.0 - 3.0*I
|
|
291
|
+
sage: CDF(4.5) # indirect doctest
|
|
292
|
+
4.5
|
|
293
|
+
sage: CDF(1+I) # indirect doctest # needs sage.symbolic
|
|
294
|
+
1.0 + 1.0*I
|
|
295
|
+
sage: CDF(pari(1)) # needs sage.libs.pari
|
|
296
|
+
1.0
|
|
297
|
+
sage: CDF(pari("I")) # needs sage.libs.pari
|
|
298
|
+
1.0*I
|
|
299
|
+
sage: CDF(pari("x^2 + x + 1").polroots()[0]) # needs sage.libs.pari
|
|
300
|
+
-0.5 - 0.8660254037844386*I
|
|
301
|
+
sage: from gmpy2 import mpc
|
|
302
|
+
sage: CDF(mpc('2.0+1.0j'))
|
|
303
|
+
2.0 + 1.0*I
|
|
304
|
+
|
|
305
|
+
A :exc:`TypeError` is raised if the coercion doesn't make sense::
|
|
306
|
+
|
|
307
|
+
sage: CDF(QQ['x'].0)
|
|
308
|
+
Traceback (most recent call last):
|
|
309
|
+
...
|
|
310
|
+
TypeError: cannot convert nonconstant polynomial
|
|
311
|
+
|
|
312
|
+
One can convert back and forth between double precision complex
|
|
313
|
+
numbers and higher-precision ones, though of course there may be
|
|
314
|
+
loss of precision::
|
|
315
|
+
|
|
316
|
+
sage: # needs sage.rings.real_mpfr
|
|
317
|
+
sage: a = ComplexField(200)(-2).sqrt(); a
|
|
318
|
+
1.4142135623730950488016887242096980785696718753769480731767*I
|
|
319
|
+
sage: b = CDF(a); b
|
|
320
|
+
1.4142135623730951*I
|
|
321
|
+
sage: a.parent()(b)
|
|
322
|
+
1.4142135623730951454746218587388284504413604736328125000000*I
|
|
323
|
+
sage: a.parent()(b) == b
|
|
324
|
+
True
|
|
325
|
+
sage: b == CC(a)
|
|
326
|
+
True
|
|
327
|
+
|
|
328
|
+
TESTS:
|
|
329
|
+
|
|
330
|
+
Check that :issue:`31836` is fixed::
|
|
331
|
+
|
|
332
|
+
sage: a = CDF(); a
|
|
333
|
+
0.0
|
|
334
|
+
sage: a.parent()
|
|
335
|
+
Complex Double Field
|
|
336
|
+
"""
|
|
337
|
+
# We implement __call__ to gracefully accept the second argument.
|
|
338
|
+
if x is None:
|
|
339
|
+
return self.zero()
|
|
340
|
+
if im is not None:
|
|
341
|
+
x = x, im
|
|
342
|
+
return Parent.__call__(self, x)
|
|
343
|
+
|
|
344
|
+
def _element_constructor_(self, x):
|
|
345
|
+
"""
|
|
346
|
+
See ``__call__()``.
|
|
347
|
+
|
|
348
|
+
EXAMPLES::
|
|
349
|
+
|
|
350
|
+
sage: CDF((1,2)) # indirect doctest
|
|
351
|
+
1.0 + 2.0*I
|
|
352
|
+
"""
|
|
353
|
+
from sage.rings import complex_mpfr
|
|
354
|
+
if isinstance(x, ComplexDoubleElement):
|
|
355
|
+
return x
|
|
356
|
+
elif isinstance(x, tuple):
|
|
357
|
+
return ComplexDoubleElement(x[0], x[1])
|
|
358
|
+
elif isinstance(x, (float, int)):
|
|
359
|
+
return ComplexDoubleElement(x, 0)
|
|
360
|
+
elif isinstance(x, complex):
|
|
361
|
+
return ComplexDoubleElement(x.real, x.imag)
|
|
362
|
+
elif isinstance(x, complex_mpfr.ComplexNumber):
|
|
363
|
+
return ComplexDoubleElement(x.real(), x.imag())
|
|
364
|
+
elif isinstance(x, pari_gen):
|
|
365
|
+
return pari_to_cdf(x)
|
|
366
|
+
elif type(x) is gmpy2.mpc:
|
|
367
|
+
return ComplexDoubleElement((<gmpy2.mpc>x).real, (<gmpy2.mpc>x).imag)
|
|
368
|
+
elif isinstance(x, str):
|
|
369
|
+
t = cdf_parser.parse_expression(x)
|
|
370
|
+
if isinstance(t, float):
|
|
371
|
+
return ComplexDoubleElement(t, 0)
|
|
372
|
+
else:
|
|
373
|
+
return t
|
|
374
|
+
elif hasattr(x, '_complex_double_'):
|
|
375
|
+
return x._complex_double_(self)
|
|
376
|
+
else:
|
|
377
|
+
return ComplexDoubleElement(x, 0)
|
|
378
|
+
|
|
379
|
+
cpdef _coerce_map_from_(self, S):
|
|
380
|
+
"""
|
|
381
|
+
Return the canonical coerce of `x` into the complex double field, if
|
|
382
|
+
it is defined, otherwise raise a :exc:`TypeError`.
|
|
383
|
+
|
|
384
|
+
The rings that canonically coerce to the complex double field are:
|
|
385
|
+
|
|
386
|
+
- the complex double field itself
|
|
387
|
+
- anything that canonically coerces to real double field.
|
|
388
|
+
- mathematical constants
|
|
389
|
+
- the 53-bit mpfr complex field
|
|
390
|
+
|
|
391
|
+
EXAMPLES::
|
|
392
|
+
|
|
393
|
+
sage: CDF.coerce(5) # indirect doctest
|
|
394
|
+
5.0
|
|
395
|
+
sage: CDF.coerce(RDF(3.4))
|
|
396
|
+
3.4
|
|
397
|
+
|
|
398
|
+
Thus the sum of a CDF and a symbolic object is symbolic::
|
|
399
|
+
|
|
400
|
+
sage: a = pi + CDF.0; a # needs sage.symbolic
|
|
401
|
+
pi + 1.0*I
|
|
402
|
+
sage: parent(a) # needs sage.symbolic
|
|
403
|
+
Symbolic Ring
|
|
404
|
+
|
|
405
|
+
TESTS::
|
|
406
|
+
|
|
407
|
+
sage: # needs sage.rings.real_mpfr
|
|
408
|
+
sage: CDF(1) + RR(1)
|
|
409
|
+
2.0
|
|
410
|
+
sage: CDF.0 - CC(1) - int(1) - RR(1) - QQbar(1) # needs sage.rings.number_field
|
|
411
|
+
-4.0 + 1.0*I
|
|
412
|
+
sage: CDF.has_coerce_map_from(ComplexField(20))
|
|
413
|
+
False
|
|
414
|
+
sage: CDF.has_coerce_map_from(complex)
|
|
415
|
+
True
|
|
416
|
+
"""
|
|
417
|
+
if S is int or S is float:
|
|
418
|
+
return FloatToCDF(S)
|
|
419
|
+
from sage.rings.rational_field import QQ
|
|
420
|
+
from sage.rings.real_lazy import RLF
|
|
421
|
+
from sage.rings.real_mpfr import RR
|
|
422
|
+
from sage.rings.cc import CC
|
|
423
|
+
|
|
424
|
+
if S is ZZ or S is QQ or S is RDF or S is RLF:
|
|
425
|
+
return FloatToCDF(S)
|
|
426
|
+
if isinstance(S, sage.rings.abc.RealField):
|
|
427
|
+
if S.prec() >= 53:
|
|
428
|
+
return FloatToCDF(S)
|
|
429
|
+
else:
|
|
430
|
+
return None
|
|
431
|
+
elif is_numpy_type(S):
|
|
432
|
+
import numpy
|
|
433
|
+
if issubclass(S, numpy.integer) or issubclass(S, numpy.floating):
|
|
434
|
+
return FloatToCDF(S)
|
|
435
|
+
elif issubclass(S, numpy.complexfloating):
|
|
436
|
+
return ComplexToCDF(S)
|
|
437
|
+
else:
|
|
438
|
+
return None
|
|
439
|
+
elif RR.has_coerce_map_from(S):
|
|
440
|
+
return FloatToCDF(RR) * RR._internal_coerce_map_from(S)
|
|
441
|
+
elif isinstance(S, sage.rings.abc.ComplexField) and S.prec() >= 53:
|
|
442
|
+
return CCtoCDF(S, self)
|
|
443
|
+
elif CC.has_coerce_map_from(S):
|
|
444
|
+
return CCtoCDF(CC, self) * CC._internal_coerce_map_from(S)
|
|
445
|
+
|
|
446
|
+
def _magma_init_(self, magma):
|
|
447
|
+
r"""
|
|
448
|
+
Return a string representation of ``self`` in the Magma language.
|
|
449
|
+
|
|
450
|
+
EXAMPLES::
|
|
451
|
+
|
|
452
|
+
sage: CDF._magma_init_(magma) # optional - magma
|
|
453
|
+
'ComplexField(53 : Bits := true)'
|
|
454
|
+
sage: magma(CDF) # optional - magma
|
|
455
|
+
Complex field of precision 15
|
|
456
|
+
sage: floor(RR(log(2**53, 10))) # needs sage.symbolic
|
|
457
|
+
15
|
|
458
|
+
sage: magma(CDF).sage() # optional - magma
|
|
459
|
+
Complex Field with 53 bits of precision
|
|
460
|
+
"""
|
|
461
|
+
return "ComplexField(%s : Bits := true)" % self.prec()
|
|
462
|
+
|
|
463
|
+
def _fricas_init_(self):
|
|
464
|
+
r"""
|
|
465
|
+
Return a string representation of ``self`` in the FriCAS language.
|
|
466
|
+
|
|
467
|
+
EXAMPLES::
|
|
468
|
+
|
|
469
|
+
sage: fricas(CDF) # indirect doctest, optional - fricas
|
|
470
|
+
Complex(DoubleFloat)
|
|
471
|
+
"""
|
|
472
|
+
return "Complex DoubleFloat"
|
|
473
|
+
|
|
474
|
+
def prec(self):
|
|
475
|
+
"""
|
|
476
|
+
Return the precision of this complex double field (to be more
|
|
477
|
+
similar to :class:`ComplexField`). Always returns 53.
|
|
478
|
+
|
|
479
|
+
EXAMPLES::
|
|
480
|
+
|
|
481
|
+
sage: CDF.prec()
|
|
482
|
+
53
|
|
483
|
+
"""
|
|
484
|
+
return 53
|
|
485
|
+
|
|
486
|
+
precision=prec
|
|
487
|
+
|
|
488
|
+
def to_prec(self, prec):
|
|
489
|
+
"""
|
|
490
|
+
Return the complex field to the specified precision. As doubles
|
|
491
|
+
have fixed precision, this will only return a complex double field
|
|
492
|
+
if prec is exactly 53.
|
|
493
|
+
|
|
494
|
+
EXAMPLES::
|
|
495
|
+
|
|
496
|
+
sage: CDF.to_prec(53)
|
|
497
|
+
Complex Double Field
|
|
498
|
+
sage: CDF.to_prec(250)
|
|
499
|
+
Complex Field with 250 bits of precision
|
|
500
|
+
"""
|
|
501
|
+
if prec == 53:
|
|
502
|
+
return self
|
|
503
|
+
else:
|
|
504
|
+
from sage.rings.complex_mpfr import ComplexField
|
|
505
|
+
return ComplexField(prec)
|
|
506
|
+
|
|
507
|
+
def gen(self, n=0):
|
|
508
|
+
"""
|
|
509
|
+
Return the generator of the complex double field.
|
|
510
|
+
|
|
511
|
+
EXAMPLES::
|
|
512
|
+
|
|
513
|
+
sage: CDF.0
|
|
514
|
+
1.0*I
|
|
515
|
+
sage: CDF.gen(0)
|
|
516
|
+
1.0*I
|
|
517
|
+
"""
|
|
518
|
+
if n != 0:
|
|
519
|
+
raise ValueError("only 1 generator")
|
|
520
|
+
return I
|
|
521
|
+
|
|
522
|
+
def ngens(self):
|
|
523
|
+
r"""
|
|
524
|
+
The number of generators of this complex field as an `\RR`-algebra.
|
|
525
|
+
|
|
526
|
+
There is one generator, namely ``sqrt(-1)``.
|
|
527
|
+
|
|
528
|
+
EXAMPLES::
|
|
529
|
+
|
|
530
|
+
sage: CDF.ngens()
|
|
531
|
+
1
|
|
532
|
+
"""
|
|
533
|
+
return 1
|
|
534
|
+
|
|
535
|
+
def algebraic_closure(self):
|
|
536
|
+
r"""
|
|
537
|
+
Return the algebraic closure of ``self``, i.e., the complex double
|
|
538
|
+
field.
|
|
539
|
+
|
|
540
|
+
EXAMPLES::
|
|
541
|
+
|
|
542
|
+
sage: CDF.algebraic_closure()
|
|
543
|
+
Complex Double Field
|
|
544
|
+
"""
|
|
545
|
+
return self
|
|
546
|
+
|
|
547
|
+
def real_double_field(self):
|
|
548
|
+
"""
|
|
549
|
+
The real double field, which you may view as a subfield of this
|
|
550
|
+
complex double field.
|
|
551
|
+
|
|
552
|
+
EXAMPLES::
|
|
553
|
+
|
|
554
|
+
sage: CDF.real_double_field()
|
|
555
|
+
Real Double Field
|
|
556
|
+
"""
|
|
557
|
+
return RDF
|
|
558
|
+
|
|
559
|
+
def pi(self):
|
|
560
|
+
r"""
|
|
561
|
+
Return `\pi` as a double precision complex number.
|
|
562
|
+
|
|
563
|
+
EXAMPLES::
|
|
564
|
+
|
|
565
|
+
sage: CDF.pi()
|
|
566
|
+
3.141592653589793
|
|
567
|
+
"""
|
|
568
|
+
return self(3.1415926535897932384626433832)
|
|
569
|
+
|
|
570
|
+
def construction(self):
|
|
571
|
+
"""
|
|
572
|
+
Return the functorial construction of ``self``, namely, algebraic
|
|
573
|
+
closure of the real double field.
|
|
574
|
+
|
|
575
|
+
EXAMPLES::
|
|
576
|
+
|
|
577
|
+
sage: c, S = CDF.construction(); S
|
|
578
|
+
Real Double Field
|
|
579
|
+
sage: CDF == c(S)
|
|
580
|
+
True
|
|
581
|
+
"""
|
|
582
|
+
from sage.categories.pushout import AlgebraicClosureFunctor
|
|
583
|
+
return (AlgebraicClosureFunctor(), self.real_double_field())
|
|
584
|
+
|
|
585
|
+
def zeta(self, n=2):
|
|
586
|
+
r"""
|
|
587
|
+
Return a primitive `n`-th root of unity in this CDF, for
|
|
588
|
+
`n \geq 1`.
|
|
589
|
+
|
|
590
|
+
INPUT:
|
|
591
|
+
|
|
592
|
+
- ``n`` -- positive integer (default: 2)
|
|
593
|
+
|
|
594
|
+
OUTPUT: a complex `n`-th root of unity
|
|
595
|
+
|
|
596
|
+
EXAMPLES::
|
|
597
|
+
|
|
598
|
+
sage: CDF.zeta(7) # rel tol 1e-15
|
|
599
|
+
0.6234898018587336 + 0.7818314824680298*I
|
|
600
|
+
sage: CDF.zeta(1)
|
|
601
|
+
1.0
|
|
602
|
+
sage: CDF.zeta()
|
|
603
|
+
-1.0
|
|
604
|
+
sage: CDF.zeta() == CDF.zeta(2)
|
|
605
|
+
True
|
|
606
|
+
|
|
607
|
+
::
|
|
608
|
+
|
|
609
|
+
sage: CDF.zeta(0.5)
|
|
610
|
+
Traceback (most recent call last):
|
|
611
|
+
...
|
|
612
|
+
ValueError: n must be a positive integer
|
|
613
|
+
sage: CDF.zeta(0)
|
|
614
|
+
Traceback (most recent call last):
|
|
615
|
+
...
|
|
616
|
+
ValueError: n must be a positive integer
|
|
617
|
+
sage: CDF.zeta(-1)
|
|
618
|
+
Traceback (most recent call last):
|
|
619
|
+
...
|
|
620
|
+
ValueError: n must be a positive integer
|
|
621
|
+
"""
|
|
622
|
+
from sage.rings.integer import Integer
|
|
623
|
+
try:
|
|
624
|
+
n = Integer(n)
|
|
625
|
+
except TypeError:
|
|
626
|
+
raise ValueError("n must be a positive integer")
|
|
627
|
+
|
|
628
|
+
if n<1:
|
|
629
|
+
raise ValueError("n must be a positive integer")
|
|
630
|
+
|
|
631
|
+
if n == 1:
|
|
632
|
+
x = self(1)
|
|
633
|
+
elif n == 2:
|
|
634
|
+
x = self(-1)
|
|
635
|
+
elif n >= 3:
|
|
636
|
+
# Use De Moivre
|
|
637
|
+
# e^(2*pi*i/n) = cos(2pi/n) + i *sin(2pi/n)
|
|
638
|
+
pi = RDF.pi()
|
|
639
|
+
z = 2*pi/n
|
|
640
|
+
x = CDF(z.cos(), z.sin())
|
|
641
|
+
# x._set_multiplicative_order( n ) # not implemented for CDF
|
|
642
|
+
return x
|
|
643
|
+
|
|
644
|
+
def _factor_univariate_polynomial(self, f):
|
|
645
|
+
"""
|
|
646
|
+
Factor the univariate polynomial ``f``.
|
|
647
|
+
|
|
648
|
+
INPUT:
|
|
649
|
+
|
|
650
|
+
- ``f`` -- a univariate polynomial defined over the double precision
|
|
651
|
+
complex numbers
|
|
652
|
+
|
|
653
|
+
OUTPUT:
|
|
654
|
+
|
|
655
|
+
- A factorization of ``f`` over the double precision complex numbers
|
|
656
|
+
into a unit and monic irreducible factors
|
|
657
|
+
|
|
658
|
+
.. NOTE::
|
|
659
|
+
|
|
660
|
+
This is a helper method for
|
|
661
|
+
:meth:`sage.rings.polynomial.polynomial_element.Polynomial.factor`.
|
|
662
|
+
|
|
663
|
+
TESTS::
|
|
664
|
+
|
|
665
|
+
sage: # needs numpy
|
|
666
|
+
sage: R.<x> = CDF[]
|
|
667
|
+
sage: CDF._factor_univariate_polynomial(x)
|
|
668
|
+
x
|
|
669
|
+
sage: CDF._factor_univariate_polynomial(2*x)
|
|
670
|
+
(2.0) * x
|
|
671
|
+
sage: CDF._factor_univariate_polynomial(x^2)
|
|
672
|
+
x^2
|
|
673
|
+
sage: f = x^2 + 1
|
|
674
|
+
sage: F = CDF._factor_univariate_polynomial(f)
|
|
675
|
+
sage: [f(t[0][0]).abs() for t in F] # abs tol 1e-9
|
|
676
|
+
[5.55111512313e-17, 6.66133814775e-16]
|
|
677
|
+
sage: f = (x^2 + 2*R(I))^3
|
|
678
|
+
sage: F = f.factor()
|
|
679
|
+
sage: [f(t[0][0]).abs() for t in F] # abs tol 1e-9
|
|
680
|
+
[1.979365054e-14, 1.97936298566e-14, 1.97936990747e-14, 3.6812407475e-14, 3.65211563729e-14, 3.65220890052e-14]
|
|
681
|
+
"""
|
|
682
|
+
unit = f.leading_coefficient()
|
|
683
|
+
f *= ~unit
|
|
684
|
+
roots = f.roots()
|
|
685
|
+
from sage.misc.flatten import flatten
|
|
686
|
+
roots = flatten([[r]*m for r, m in roots])
|
|
687
|
+
from sage.structure.factorization import Factorization
|
|
688
|
+
x = f.parent().gen()
|
|
689
|
+
return Factorization([(x - a, 1) for a in roots], unit)
|
|
690
|
+
|
|
691
|
+
|
|
692
|
+
cdef ComplexDoubleElement new_ComplexDoubleElement():
|
|
693
|
+
"""
|
|
694
|
+
Create a new (empty) :class:`ComplexDoubleElement`.
|
|
695
|
+
"""
|
|
696
|
+
cdef ComplexDoubleElement z
|
|
697
|
+
z = ComplexDoubleElement.__new__(ComplexDoubleElement)
|
|
698
|
+
return z
|
|
699
|
+
|
|
700
|
+
|
|
701
|
+
def is_ComplexDoubleElement(x):
|
|
702
|
+
"""
|
|
703
|
+
Return ``True`` if ``x`` is a :class:`ComplexDoubleElement`.
|
|
704
|
+
|
|
705
|
+
EXAMPLES::
|
|
706
|
+
|
|
707
|
+
sage: from sage.rings.complex_double import is_ComplexDoubleElement
|
|
708
|
+
sage: is_ComplexDoubleElement(0)
|
|
709
|
+
doctest:warning...
|
|
710
|
+
DeprecationWarning: The function is_ComplexDoubleElement is deprecated;
|
|
711
|
+
use 'isinstance(..., ComplexDoubleElement)' instead.
|
|
712
|
+
See https://github.com/sagemath/sage/issues/38128 for details.
|
|
713
|
+
False
|
|
714
|
+
sage: is_ComplexDoubleElement(CDF(0))
|
|
715
|
+
True
|
|
716
|
+
"""
|
|
717
|
+
from sage.misc.superseded import deprecation_cython
|
|
718
|
+
deprecation_cython(38128,
|
|
719
|
+
"The function is_ComplexDoubleElement is deprecated; "
|
|
720
|
+
"use 'isinstance(..., ComplexDoubleElement)' instead.")
|
|
721
|
+
return isinstance(x, ComplexDoubleElement)
|
|
722
|
+
|
|
723
|
+
|
|
724
|
+
cdef class ComplexDoubleElement(FieldElement):
|
|
725
|
+
"""
|
|
726
|
+
An approximation to a complex number using double precision
|
|
727
|
+
floating point numbers. Answers derived from calculations with such
|
|
728
|
+
approximations may differ from what they would be if those
|
|
729
|
+
calculations were performed with true complex numbers. This is due
|
|
730
|
+
to the rounding errors inherent to finite precision calculations.
|
|
731
|
+
"""
|
|
732
|
+
|
|
733
|
+
__array_interface__ = {'typestr': '=c16'}
|
|
734
|
+
|
|
735
|
+
def __cinit__(self):
|
|
736
|
+
r"""
|
|
737
|
+
Initialize ``self`` as an element of `\CC`.
|
|
738
|
+
|
|
739
|
+
EXAMPLES::
|
|
740
|
+
|
|
741
|
+
sage: ComplexDoubleElement(1,-2) # indirect doctest
|
|
742
|
+
1.0 - 2.0*I
|
|
743
|
+
"""
|
|
744
|
+
self._parent = _CDF
|
|
745
|
+
|
|
746
|
+
def __init__(self, real, imag):
|
|
747
|
+
"""
|
|
748
|
+
Construct an element of a complex double field with specified real
|
|
749
|
+
and imaginary values.
|
|
750
|
+
|
|
751
|
+
EXAMPLES::
|
|
752
|
+
|
|
753
|
+
sage: ComplexDoubleElement(1,-2)
|
|
754
|
+
1.0 - 2.0*I
|
|
755
|
+
"""
|
|
756
|
+
self._complex = gsl_complex_rect(real, imag)
|
|
757
|
+
|
|
758
|
+
def __reduce__(self):
|
|
759
|
+
"""
|
|
760
|
+
For pickling.
|
|
761
|
+
|
|
762
|
+
EXAMPLES::
|
|
763
|
+
|
|
764
|
+
sage: a = CDF(-2.7, -3)
|
|
765
|
+
sage: loads(dumps(a)) == a
|
|
766
|
+
True
|
|
767
|
+
"""
|
|
768
|
+
return (ComplexDoubleElement,
|
|
769
|
+
(GSL_REAL(self._complex), GSL_IMAG(self._complex)))
|
|
770
|
+
|
|
771
|
+
cdef ComplexDoubleElement _new_c(self, gsl_complex x):
|
|
772
|
+
"""
|
|
773
|
+
C-level code for creating a :class:`ComplexDoubleElement` from a
|
|
774
|
+
``gsl_complex``.
|
|
775
|
+
"""
|
|
776
|
+
cdef ComplexDoubleElement z = <ComplexDoubleElement>ComplexDoubleElement.__new__(ComplexDoubleElement)
|
|
777
|
+
z._complex = x
|
|
778
|
+
return z
|
|
779
|
+
|
|
780
|
+
def __hash__(self):
|
|
781
|
+
"""
|
|
782
|
+
Return the hash of ``self``, which coincides with the python ``float``
|
|
783
|
+
and ``complex`` (and often ``int``) types for ``self``.
|
|
784
|
+
|
|
785
|
+
EXAMPLES::
|
|
786
|
+
|
|
787
|
+
sage: hash(CDF(1.2)) == hash(1.2r)
|
|
788
|
+
True
|
|
789
|
+
sage: hash(CDF(-1))
|
|
790
|
+
-2
|
|
791
|
+
sage: hash(CDF(1.2, 1.3)) == hash(complex(1.2r, 1.3r))
|
|
792
|
+
True
|
|
793
|
+
"""
|
|
794
|
+
return hash(complex(self))
|
|
795
|
+
|
|
796
|
+
cpdef _richcmp_(left, right, int op):
|
|
797
|
+
"""
|
|
798
|
+
We order the complex numbers in dictionary order by real parts then
|
|
799
|
+
imaginary parts.
|
|
800
|
+
|
|
801
|
+
This order, of course, does not respect the field structure, though
|
|
802
|
+
it agrees with the usual order on the real numbers.
|
|
803
|
+
|
|
804
|
+
EXAMPLES::
|
|
805
|
+
|
|
806
|
+
sage: CDF(1.2) > CDF(i) # needs sage.symbolic
|
|
807
|
+
True
|
|
808
|
+
sage: CDF(1) < CDF(2)
|
|
809
|
+
True
|
|
810
|
+
sage: CDF(1 + i) > CDF(-1 - i) # needs sage.symbolic
|
|
811
|
+
True
|
|
812
|
+
|
|
813
|
+
::
|
|
814
|
+
|
|
815
|
+
sage: CDF(2,3) < CDF(3,1)
|
|
816
|
+
True
|
|
817
|
+
sage: CDF(2,3) > CDF(3,1)
|
|
818
|
+
False
|
|
819
|
+
sage: CDF(2,-1) < CDF(2,3)
|
|
820
|
+
True
|
|
821
|
+
|
|
822
|
+
It's dictionary order, not absolute value::
|
|
823
|
+
|
|
824
|
+
sage: CDF(-1,3) < CDF(-1,-20)
|
|
825
|
+
False
|
|
826
|
+
|
|
827
|
+
Numbers are coerced before comparison::
|
|
828
|
+
|
|
829
|
+
sage: CDF(3,5) < 7
|
|
830
|
+
True
|
|
831
|
+
sage: 4.3 > CDF(5,1)
|
|
832
|
+
False
|
|
833
|
+
"""
|
|
834
|
+
if GSL_REAL(left._complex) < GSL_REAL((<ComplexDoubleElement>right)._complex):
|
|
835
|
+
return rich_to_bool(op, -1)
|
|
836
|
+
if GSL_REAL(left._complex) > GSL_REAL((<ComplexDoubleElement>right)._complex):
|
|
837
|
+
return rich_to_bool(op, 1)
|
|
838
|
+
if GSL_IMAG(left._complex) < GSL_IMAG((<ComplexDoubleElement>right)._complex):
|
|
839
|
+
return rich_to_bool(op, -1)
|
|
840
|
+
if GSL_IMAG(left._complex) > GSL_IMAG((<ComplexDoubleElement>right)._complex):
|
|
841
|
+
return rich_to_bool(op, 1)
|
|
842
|
+
return rich_to_bool(op, 0)
|
|
843
|
+
|
|
844
|
+
def __getitem__(self, n):
|
|
845
|
+
"""
|
|
846
|
+
Return the real or imaginary part of ``self``.
|
|
847
|
+
|
|
848
|
+
INPUT:
|
|
849
|
+
|
|
850
|
+
- ``n`` -- integer (either 0 or 1)
|
|
851
|
+
|
|
852
|
+
Raises an :exc:`IndexError` if ``n`` is not 0 or 1.
|
|
853
|
+
|
|
854
|
+
EXAMPLES::
|
|
855
|
+
|
|
856
|
+
sage: P = CDF(2,3)
|
|
857
|
+
sage: P[0]
|
|
858
|
+
2.0
|
|
859
|
+
sage: P[1]
|
|
860
|
+
3.0
|
|
861
|
+
sage: P[3]
|
|
862
|
+
Traceback (most recent call last):
|
|
863
|
+
...
|
|
864
|
+
IndexError: index n must be 0 or 1
|
|
865
|
+
"""
|
|
866
|
+
if n == 0:
|
|
867
|
+
return GSL_REAL(self._complex)
|
|
868
|
+
if n == 1:
|
|
869
|
+
return GSL_IMAG(self._complex)
|
|
870
|
+
raise IndexError("index n must be 0 or 1")
|
|
871
|
+
|
|
872
|
+
def _magma_init_(self, magma):
|
|
873
|
+
r"""
|
|
874
|
+
Return the magma representation of ``self``.
|
|
875
|
+
|
|
876
|
+
EXAMPLES::
|
|
877
|
+
|
|
878
|
+
sage: # optional - magma
|
|
879
|
+
sage: CDF((1.2, 0.3))._magma_init_(magma)
|
|
880
|
+
'ComplexField(53 : Bits := true)![1.2, 0.3]'
|
|
881
|
+
sage: magma(CDF(1.2, 0.3)) # indirect doctest
|
|
882
|
+
1.20000000000000 + 0.300000000000000*$.1
|
|
883
|
+
sage: s = magma(CDF(1.2, 0.3)).sage(); s # indirect doctest
|
|
884
|
+
1.20000000000000 + 0.300000000000000*I
|
|
885
|
+
sage: s.parent()
|
|
886
|
+
Complex Field with 53 bits of precision
|
|
887
|
+
"""
|
|
888
|
+
return "%s![%s, %s]" % (self.parent()._magma_init_(magma), self.real(), self.imag())
|
|
889
|
+
|
|
890
|
+
def prec(self):
|
|
891
|
+
"""
|
|
892
|
+
Return the precision of this number (to be more similar to
|
|
893
|
+
:class:`ComplexNumber`). Always returns 53.
|
|
894
|
+
|
|
895
|
+
EXAMPLES::
|
|
896
|
+
|
|
897
|
+
sage: CDF(0).prec()
|
|
898
|
+
53
|
|
899
|
+
"""
|
|
900
|
+
return 53
|
|
901
|
+
|
|
902
|
+
#######################################################################
|
|
903
|
+
# Coercions
|
|
904
|
+
#######################################################################
|
|
905
|
+
|
|
906
|
+
def __int__(self):
|
|
907
|
+
"""
|
|
908
|
+
Convert ``self`` to an ``int``.
|
|
909
|
+
|
|
910
|
+
EXAMPLES::
|
|
911
|
+
|
|
912
|
+
sage: int(CDF(1,1))
|
|
913
|
+
Traceback (most recent call last):
|
|
914
|
+
...
|
|
915
|
+
TypeError: can...t convert complex to int; use int(abs(z))
|
|
916
|
+
sage: int(abs(CDF(1,1)))
|
|
917
|
+
1
|
|
918
|
+
"""
|
|
919
|
+
raise TypeError("can't convert complex to int; use int(abs(z))")
|
|
920
|
+
|
|
921
|
+
def __float__(self):
|
|
922
|
+
"""
|
|
923
|
+
Method for converting ``self`` to type ``float``. Called by the
|
|
924
|
+
``float`` function. This conversion will throw an error if
|
|
925
|
+
the number has a nonzero imaginary part.
|
|
926
|
+
|
|
927
|
+
EXAMPLES::
|
|
928
|
+
|
|
929
|
+
sage: a = CDF(1, 0)
|
|
930
|
+
sage: float(a)
|
|
931
|
+
1.0
|
|
932
|
+
sage: a = CDF(2,1)
|
|
933
|
+
sage: float(a)
|
|
934
|
+
Traceback (most recent call last):
|
|
935
|
+
...
|
|
936
|
+
TypeError: unable to convert 2.0 + 1.0*I to float; use abs() or real_part() as desired
|
|
937
|
+
sage: a.__float__()
|
|
938
|
+
Traceback (most recent call last):
|
|
939
|
+
...
|
|
940
|
+
TypeError: unable to convert 2.0 + 1.0*I to float; use abs() or real_part() as desired
|
|
941
|
+
sage: float(abs(CDF(1,1)))
|
|
942
|
+
1.4142135623730951
|
|
943
|
+
"""
|
|
944
|
+
if GSL_IMAG(self._complex):
|
|
945
|
+
raise TypeError(f"unable to convert {self} to float; use abs() or real_part() as desired")
|
|
946
|
+
return GSL_REAL(self._complex)
|
|
947
|
+
|
|
948
|
+
def __complex__(self):
|
|
949
|
+
"""
|
|
950
|
+
Convert ``self`` to python's ``complex`` object.
|
|
951
|
+
|
|
952
|
+
EXAMPLES::
|
|
953
|
+
|
|
954
|
+
sage: a = complex(2303,-3939)
|
|
955
|
+
sage: CDF(a)
|
|
956
|
+
2303.0 - 3939.0*I
|
|
957
|
+
sage: complex(CDF(a))
|
|
958
|
+
(2303-3939j)
|
|
959
|
+
"""
|
|
960
|
+
return complex(GSL_REAL(self._complex), GSL_IMAG(self._complex))
|
|
961
|
+
|
|
962
|
+
def _interface_init_(self, I=None):
|
|
963
|
+
"""
|
|
964
|
+
Return ``self`` formatted as a string, suitable as input to another
|
|
965
|
+
computer algebra system. (This is the default function used for
|
|
966
|
+
exporting to other computer algebra systems.)
|
|
967
|
+
|
|
968
|
+
EXAMPLES::
|
|
969
|
+
|
|
970
|
+
sage: s1 = CDF(exp(I)); s1 # needs sage.symbolic
|
|
971
|
+
0.5403023058681398 + 0.8414709848078965*I
|
|
972
|
+
sage: s1._interface_init_() # needs sage.symbolic
|
|
973
|
+
'0.54030230586813977 + 0.84147098480789650*I'
|
|
974
|
+
sage: s1 == CDF(gp(s1)) # needs sage.symbolic
|
|
975
|
+
True
|
|
976
|
+
"""
|
|
977
|
+
# Sending to another computer algebra system is slow anyway, right?
|
|
978
|
+
from sage.rings.complex_mpfr import ComplexField
|
|
979
|
+
return ComplexField()(self)._interface_init_(I)
|
|
980
|
+
|
|
981
|
+
def _mathematica_init_(self):
|
|
982
|
+
"""
|
|
983
|
+
TESTS:
|
|
984
|
+
|
|
985
|
+
Check that :issue:`28814` is fixed::
|
|
986
|
+
|
|
987
|
+
sage: mathematica(CDF(1e-25, 1e25)) # optional - mathematica
|
|
988
|
+
1.*^-25 + 1.*^25*I
|
|
989
|
+
"""
|
|
990
|
+
from sage.rings.complex_mpfr import ComplexField
|
|
991
|
+
return ComplexField()(self)._mathematica_init_()
|
|
992
|
+
|
|
993
|
+
def _maxima_init_(self, I=None):
|
|
994
|
+
"""
|
|
995
|
+
Return a string representation of this complex number in the syntax of
|
|
996
|
+
Maxima. That is, use ``%i`` to represent the complex unit.
|
|
997
|
+
|
|
998
|
+
EXAMPLES::
|
|
999
|
+
|
|
1000
|
+
sage: CDF.0._maxima_init_()
|
|
1001
|
+
'1.0000000000000000*%i'
|
|
1002
|
+
sage: CDF(.5 + I)._maxima_init_() # needs sage.symbolic
|
|
1003
|
+
'0.50000000000000000 + 1.0000000000000000*%i'
|
|
1004
|
+
"""
|
|
1005
|
+
from sage.rings.complex_mpfr import ComplexField
|
|
1006
|
+
return ComplexField()(self)._maxima_init_(I)
|
|
1007
|
+
|
|
1008
|
+
def _sympy_(self):
|
|
1009
|
+
"""
|
|
1010
|
+
Convert this complex number to Sympy.
|
|
1011
|
+
|
|
1012
|
+
EXAMPLES::
|
|
1013
|
+
|
|
1014
|
+
sage: CDF(1, 0)._sympy_() # needs sympy
|
|
1015
|
+
1.00000000000000
|
|
1016
|
+
sage: CDF(1/3, 1)._sympy_() # needs sympy
|
|
1017
|
+
0.333333333333333 + 1.0*I
|
|
1018
|
+
sage: type(_) # needs sympy
|
|
1019
|
+
<class 'sympy.core.add.Add'>
|
|
1020
|
+
"""
|
|
1021
|
+
x = GSL_REAL(self._complex)
|
|
1022
|
+
y = GSL_IMAG(self._complex)
|
|
1023
|
+
import sympy
|
|
1024
|
+
return sympy.Float(x) + sympy.Float(y) * sympy.I
|
|
1025
|
+
|
|
1026
|
+
def _repr_(self):
|
|
1027
|
+
"""
|
|
1028
|
+
Return the string representation of ``self``.
|
|
1029
|
+
|
|
1030
|
+
EXAMPLES::
|
|
1031
|
+
|
|
1032
|
+
sage: CDF(0, 2/3)
|
|
1033
|
+
0.6666666666666666*I
|
|
1034
|
+
sage: a = CDF(2,-3); a # indirect doctest
|
|
1035
|
+
2.0 - 3.0*I
|
|
1036
|
+
sage: a^2 # abs tol 4e-15
|
|
1037
|
+
-5.0 - 12.0*I
|
|
1038
|
+
sage: (1/CDF(0,0)).__repr__()
|
|
1039
|
+
'NaN + NaN*I'
|
|
1040
|
+
sage: CDF(oo,1)
|
|
1041
|
+
+infinity + 1.0*I
|
|
1042
|
+
sage: CDF(1,oo)
|
|
1043
|
+
1.0 + +infinity*I
|
|
1044
|
+
sage: CDF(1,-oo)
|
|
1045
|
+
1.0 - +infinity*I
|
|
1046
|
+
sage: CC(CDF(1,-oo))
|
|
1047
|
+
1.00000000000000 - +infinity*I
|
|
1048
|
+
sage: CDF(oo,oo)
|
|
1049
|
+
+infinity + +infinity*I
|
|
1050
|
+
sage: CC(CDF(oo,oo))
|
|
1051
|
+
+infinity + +infinity*I
|
|
1052
|
+
sage: CDF(0)
|
|
1053
|
+
0.0
|
|
1054
|
+
"""
|
|
1055
|
+
x = GSL_REAL(self._complex)
|
|
1056
|
+
y = GSL_IMAG(self._complex)
|
|
1057
|
+
if x == 0:
|
|
1058
|
+
if y == 0:
|
|
1059
|
+
# Not sure what to do with the signs of the real and
|
|
1060
|
+
# imaginary zeros, let's not print any sign.
|
|
1061
|
+
return "0.0"
|
|
1062
|
+
s = ''
|
|
1063
|
+
else:
|
|
1064
|
+
s = double_repr(x)
|
|
1065
|
+
if y == 0:
|
|
1066
|
+
return s
|
|
1067
|
+
elif y < 0:
|
|
1068
|
+
s += " - "
|
|
1069
|
+
y = -y
|
|
1070
|
+
else:
|
|
1071
|
+
s += " + "
|
|
1072
|
+
|
|
1073
|
+
return s + double_repr(y) + "*I"
|
|
1074
|
+
|
|
1075
|
+
def __format__(self, format_spec):
|
|
1076
|
+
"""
|
|
1077
|
+
Return a formatted string representation of this complex number.
|
|
1078
|
+
|
|
1079
|
+
INPUT:
|
|
1080
|
+
|
|
1081
|
+
- ``format_spec`` -- string; a floating point format specifier as
|
|
1082
|
+
defined by :python:`the format specification mini-language
|
|
1083
|
+
<library/string.html#formatspec>` in Python
|
|
1084
|
+
|
|
1085
|
+
EXAMPLES::
|
|
1086
|
+
|
|
1087
|
+
sage: format(CDF(32/3, 0), ' .4f')
|
|
1088
|
+
' 10.6667 + 0.0000*I'
|
|
1089
|
+
sage: format(CDF(-2/3, -2/3), '.4e')
|
|
1090
|
+
'-6.6667e-01 - 6.6667e-01*I'
|
|
1091
|
+
sage: format(CDF(3, 0), '.4g')
|
|
1092
|
+
'3 + 0*I'
|
|
1093
|
+
sage: format(CDF(3, 0), '#.4g')
|
|
1094
|
+
'3.000 + 0.000*I'
|
|
1095
|
+
|
|
1096
|
+
If the representation type character is absent, the output matches the
|
|
1097
|
+
string representation of the complex number. This has the effect that
|
|
1098
|
+
real and imaginary part are only shown if they are not zero::
|
|
1099
|
+
|
|
1100
|
+
sage: format(CDF(0, 2/3), '.4')
|
|
1101
|
+
'0.6667*I'
|
|
1102
|
+
sage: format(CDF(2, 0), '.4')
|
|
1103
|
+
'2.0'
|
|
1104
|
+
sage: format(CDF(0, 0), '+#.4')
|
|
1105
|
+
'+0.000'
|
|
1106
|
+
"""
|
|
1107
|
+
from sage.rings.complex_mpfr import _format_complex_number
|
|
1108
|
+
return _format_complex_number(GSL_REAL(self._complex),
|
|
1109
|
+
GSL_IMAG(self._complex),
|
|
1110
|
+
format_spec)
|
|
1111
|
+
|
|
1112
|
+
def _latex_(self):
|
|
1113
|
+
"""
|
|
1114
|
+
Return a latex representation of ``self``.
|
|
1115
|
+
|
|
1116
|
+
EXAMPLES::
|
|
1117
|
+
|
|
1118
|
+
sage: CDF(1, 2)._latex_()
|
|
1119
|
+
'1.0 + 2.0i'
|
|
1120
|
+
sage: z = CDF(1,2)^100
|
|
1121
|
+
sage: z._latex_()
|
|
1122
|
+
'-6.443164690985956 \\times 10^{34} - 6.113241307762409 \\times 10^{34}i'
|
|
1123
|
+
"""
|
|
1124
|
+
import re
|
|
1125
|
+
s = str(self).replace('*I', 'i')
|
|
1126
|
+
return re.sub(r"e\+?(-?\d+)", r" \\times 10^{\1}", s)
|
|
1127
|
+
|
|
1128
|
+
def __pari__(self):
|
|
1129
|
+
"""
|
|
1130
|
+
Return PARI version of ``self``, as ``t_COMPLEX`` or ``t_REAL``.
|
|
1131
|
+
|
|
1132
|
+
EXAMPLES::
|
|
1133
|
+
|
|
1134
|
+
sage: # needs sage.libs.pari
|
|
1135
|
+
sage: CDF(1,2).__pari__()
|
|
1136
|
+
1.00000000000000 + 2.00000000000000*I
|
|
1137
|
+
sage: pari(CDF(1,2))
|
|
1138
|
+
1.00000000000000 + 2.00000000000000*I
|
|
1139
|
+
sage: pari(CDF(2.0))
|
|
1140
|
+
2.00000000000000
|
|
1141
|
+
sage: pari(CDF(I))
|
|
1142
|
+
1.00000000000000*I
|
|
1143
|
+
"""
|
|
1144
|
+
global new_gen_from_complex_double_element
|
|
1145
|
+
if new_gen_from_complex_double_element is None:
|
|
1146
|
+
from sage.libs.pari.convert_sage_complex_double import new_gen_from_complex_double_element
|
|
1147
|
+
return new_gen_from_complex_double_element(self)
|
|
1148
|
+
|
|
1149
|
+
def __mpc__(self):
|
|
1150
|
+
"""
|
|
1151
|
+
Convert Sage ``ComplexDoubleElement`` to gmpy2 ``mpc``.
|
|
1152
|
+
|
|
1153
|
+
EXAMPLES::
|
|
1154
|
+
|
|
1155
|
+
sage: c = CDF(2,1)
|
|
1156
|
+
sage: c.__mpc__()
|
|
1157
|
+
mpc('2.0+1.0j')
|
|
1158
|
+
sage: from gmpy2 import mpc
|
|
1159
|
+
sage: mpc(c)
|
|
1160
|
+
mpc('2.0+1.0j')
|
|
1161
|
+
"""
|
|
1162
|
+
return gmpy2.mpc(GSL_REAL(self._complex), GSL_IMAG(self._complex))
|
|
1163
|
+
|
|
1164
|
+
#######################################################################
|
|
1165
|
+
# Arithmetic
|
|
1166
|
+
#######################################################################
|
|
1167
|
+
|
|
1168
|
+
cpdef _add_(self, right):
|
|
1169
|
+
"""
|
|
1170
|
+
Add ``self`` and ``right``.
|
|
1171
|
+
|
|
1172
|
+
EXAMPLES::
|
|
1173
|
+
|
|
1174
|
+
sage: CDF(2,-3)._add_(CDF(1,-2))
|
|
1175
|
+
3.0 - 5.0*I
|
|
1176
|
+
"""
|
|
1177
|
+
return self._new_c(gsl_complex_add(self._complex,
|
|
1178
|
+
(<ComplexDoubleElement>right)._complex))
|
|
1179
|
+
|
|
1180
|
+
cpdef _sub_(self, right):
|
|
1181
|
+
"""
|
|
1182
|
+
Subtract ``self`` and ``right``.
|
|
1183
|
+
|
|
1184
|
+
EXAMPLES::
|
|
1185
|
+
|
|
1186
|
+
sage: CDF(2,-3)._sub_(CDF(1,-2))
|
|
1187
|
+
1.0 - 1.0*I
|
|
1188
|
+
"""
|
|
1189
|
+
return self._new_c(gsl_complex_sub(self._complex,
|
|
1190
|
+
(<ComplexDoubleElement>right)._complex))
|
|
1191
|
+
|
|
1192
|
+
cpdef _mul_(self, right):
|
|
1193
|
+
"""
|
|
1194
|
+
Multiply ``self`` and ``right``.
|
|
1195
|
+
|
|
1196
|
+
EXAMPLES::
|
|
1197
|
+
|
|
1198
|
+
sage: CDF(2,-3)._mul_(CDF(1,-2))
|
|
1199
|
+
-4.0 - 7.0*I
|
|
1200
|
+
"""
|
|
1201
|
+
return self._new_c(gsl_complex_mul(self._complex,
|
|
1202
|
+
(<ComplexDoubleElement>right)._complex))
|
|
1203
|
+
|
|
1204
|
+
cpdef _div_(self, right):
|
|
1205
|
+
"""
|
|
1206
|
+
Divide ``self`` by ``right``.
|
|
1207
|
+
|
|
1208
|
+
EXAMPLES::
|
|
1209
|
+
|
|
1210
|
+
sage: CDF(2,-3)._div_(CDF(1,-2)) # rel tol 1e-15
|
|
1211
|
+
1.5999999999999999 + 0.19999999999999998*I
|
|
1212
|
+
"""
|
|
1213
|
+
return self._new_c(gsl_complex_div(self._complex, (<ComplexDoubleElement>right)._complex))
|
|
1214
|
+
|
|
1215
|
+
def __invert__(self):
|
|
1216
|
+
r"""
|
|
1217
|
+
This function returns the inverse, or reciprocal, of the complex
|
|
1218
|
+
number `z`:
|
|
1219
|
+
|
|
1220
|
+
.. MATH::
|
|
1221
|
+
|
|
1222
|
+
1/z = (x - i y)/(x^2 + y^2).
|
|
1223
|
+
|
|
1224
|
+
EXAMPLES::
|
|
1225
|
+
|
|
1226
|
+
sage: ~CDF(2,1)
|
|
1227
|
+
0.39999999999999997 - 0.19999999999999998*I
|
|
1228
|
+
sage: 1/CDF(2,1)
|
|
1229
|
+
0.39999999999999997 - 0.19999999999999998*I
|
|
1230
|
+
|
|
1231
|
+
The inverse of 0 is ``NaN`` (it doesn't raise an exception)::
|
|
1232
|
+
|
|
1233
|
+
sage: ~(0*CDF(0,1))
|
|
1234
|
+
NaN + NaN*I
|
|
1235
|
+
"""
|
|
1236
|
+
return self._new_c(gsl_complex_inverse(self._complex))
|
|
1237
|
+
|
|
1238
|
+
cpdef _neg_(self):
|
|
1239
|
+
"""
|
|
1240
|
+
This function returns the negative of the complex number `z`:
|
|
1241
|
+
|
|
1242
|
+
.. MATH::
|
|
1243
|
+
|
|
1244
|
+
-z = (-x) + i(-y).
|
|
1245
|
+
|
|
1246
|
+
EXAMPLES::
|
|
1247
|
+
|
|
1248
|
+
sage: -CDF(2,1) # indirect doctest
|
|
1249
|
+
-2.0 - 1.0*I
|
|
1250
|
+
"""
|
|
1251
|
+
return self._new_c(gsl_complex_negative(self._complex))
|
|
1252
|
+
|
|
1253
|
+
def conjugate(self):
|
|
1254
|
+
r"""
|
|
1255
|
+
This function returns the complex conjugate of the complex number `z`:
|
|
1256
|
+
|
|
1257
|
+
.. MATH::
|
|
1258
|
+
|
|
1259
|
+
\overline{z} = x - i y.
|
|
1260
|
+
|
|
1261
|
+
EXAMPLES::
|
|
1262
|
+
|
|
1263
|
+
sage: z = CDF(2,3); z.conjugate()
|
|
1264
|
+
2.0 - 3.0*I
|
|
1265
|
+
"""
|
|
1266
|
+
return self._new_c(gsl_complex_conjugate(self._complex))
|
|
1267
|
+
|
|
1268
|
+
def conj(self):
|
|
1269
|
+
r"""
|
|
1270
|
+
This function returns the complex conjugate of the complex number `z`:
|
|
1271
|
+
|
|
1272
|
+
.. MATH::
|
|
1273
|
+
|
|
1274
|
+
\overline{z} = x - i y.
|
|
1275
|
+
|
|
1276
|
+
EXAMPLES::
|
|
1277
|
+
|
|
1278
|
+
sage: z = CDF(2,3); z.conj()
|
|
1279
|
+
2.0 - 3.0*I
|
|
1280
|
+
"""
|
|
1281
|
+
return self._new_c(gsl_complex_conjugate(self._complex))
|
|
1282
|
+
|
|
1283
|
+
#######################################################################
|
|
1284
|
+
# Properties of Complex Numbers
|
|
1285
|
+
#######################################################################
|
|
1286
|
+
|
|
1287
|
+
def arg(self):
|
|
1288
|
+
r"""
|
|
1289
|
+
This function returns the argument of ``self``, the complex number
|
|
1290
|
+
`z`, denoted by `\arg(z)`, where `-\pi < \arg(z) <= \pi`.
|
|
1291
|
+
|
|
1292
|
+
EXAMPLES::
|
|
1293
|
+
|
|
1294
|
+
sage: CDF(1,0).arg()
|
|
1295
|
+
0.0
|
|
1296
|
+
sage: CDF(0,1).arg()
|
|
1297
|
+
1.5707963267948966
|
|
1298
|
+
sage: CDF(0,-1).arg()
|
|
1299
|
+
-1.5707963267948966
|
|
1300
|
+
sage: CDF(-1,0).arg()
|
|
1301
|
+
3.141592653589793
|
|
1302
|
+
"""
|
|
1303
|
+
return RealDoubleElement(gsl_complex_arg(self._complex))
|
|
1304
|
+
|
|
1305
|
+
def __abs__(self):
|
|
1306
|
+
"""
|
|
1307
|
+
This function returns the magnitude of the complex number `z`, `|z|`.
|
|
1308
|
+
|
|
1309
|
+
EXAMPLES::
|
|
1310
|
+
|
|
1311
|
+
sage: abs(CDF(1,2)) # indirect doctest
|
|
1312
|
+
2.23606797749979
|
|
1313
|
+
sage: abs(CDF(1,0)) # indirect doctest
|
|
1314
|
+
1.0
|
|
1315
|
+
sage: abs(CDF(-2,3))
|
|
1316
|
+
3.605551275463989
|
|
1317
|
+
"""
|
|
1318
|
+
return RealDoubleElement(gsl_complex_abs(self._complex))
|
|
1319
|
+
|
|
1320
|
+
def abs(self):
|
|
1321
|
+
"""
|
|
1322
|
+
This function returns the magnitude `|z|` of the complex number `z`.
|
|
1323
|
+
|
|
1324
|
+
.. SEEALSO::
|
|
1325
|
+
|
|
1326
|
+
- :meth:`norm`
|
|
1327
|
+
|
|
1328
|
+
EXAMPLES::
|
|
1329
|
+
|
|
1330
|
+
sage: CDF(2,3).abs()
|
|
1331
|
+
3.605551275463989
|
|
1332
|
+
"""
|
|
1333
|
+
return RealDoubleElement(gsl_complex_abs(self._complex))
|
|
1334
|
+
|
|
1335
|
+
def argument(self):
|
|
1336
|
+
r"""
|
|
1337
|
+
This function returns the argument of the ``self``, the complex number
|
|
1338
|
+
`z`, in the interval `-\pi < arg(z) \leq \pi`.
|
|
1339
|
+
|
|
1340
|
+
EXAMPLES::
|
|
1341
|
+
|
|
1342
|
+
sage: CDF(6).argument()
|
|
1343
|
+
0.0
|
|
1344
|
+
sage: CDF(i).argument() # needs sage.symbolic
|
|
1345
|
+
1.5707963267948966
|
|
1346
|
+
sage: CDF(-1).argument()
|
|
1347
|
+
3.141592653589793
|
|
1348
|
+
sage: CDF(-1 - 0.000001*i).argument() # needs sage.symbolic
|
|
1349
|
+
-3.1415916535897934
|
|
1350
|
+
"""
|
|
1351
|
+
return RealDoubleElement(gsl_complex_arg(self._complex))
|
|
1352
|
+
|
|
1353
|
+
def abs2(self):
|
|
1354
|
+
"""
|
|
1355
|
+
This function returns the squared magnitude `|z|^2` of the complex
|
|
1356
|
+
number `z`, otherwise known as the complex norm.
|
|
1357
|
+
|
|
1358
|
+
.. SEEALSO::
|
|
1359
|
+
|
|
1360
|
+
- :meth:`norm`
|
|
1361
|
+
|
|
1362
|
+
EXAMPLES::
|
|
1363
|
+
|
|
1364
|
+
sage: CDF(2,3).abs2()
|
|
1365
|
+
13.0
|
|
1366
|
+
"""
|
|
1367
|
+
return RealDoubleElement(gsl_complex_abs2(self._complex))
|
|
1368
|
+
|
|
1369
|
+
def norm(self):
|
|
1370
|
+
r"""
|
|
1371
|
+
This function returns the squared magnitude `|z|^2` of the complex
|
|
1372
|
+
number `z`, otherwise known as the complex norm. If `c = a + bi`
|
|
1373
|
+
is a complex number, then the norm of `c` is defined as the product of
|
|
1374
|
+
`c` and its complex conjugate:
|
|
1375
|
+
|
|
1376
|
+
.. MATH::
|
|
1377
|
+
|
|
1378
|
+
\text{norm}(c)
|
|
1379
|
+
=
|
|
1380
|
+
\text{norm}(a + bi)
|
|
1381
|
+
=
|
|
1382
|
+
c \cdot \overline{c}
|
|
1383
|
+
=
|
|
1384
|
+
a^2 + b^2.
|
|
1385
|
+
|
|
1386
|
+
The norm of a complex number is different from its absolute value.
|
|
1387
|
+
The absolute value of a complex number is defined to be the square
|
|
1388
|
+
root of its norm. A typical use of the complex norm is in the
|
|
1389
|
+
integral domain `\ZZ[i]` of Gaussian integers, where the norm of
|
|
1390
|
+
each Gaussian integer `c = a + bi` is defined as its complex norm.
|
|
1391
|
+
|
|
1392
|
+
.. SEEALSO::
|
|
1393
|
+
|
|
1394
|
+
- :meth:`abs`
|
|
1395
|
+
|
|
1396
|
+
- :meth:`abs2`
|
|
1397
|
+
|
|
1398
|
+
- :func:`sage.misc.functional.norm`
|
|
1399
|
+
|
|
1400
|
+
- :meth:`sage.rings.complex_mpfr.ComplexNumber.norm`
|
|
1401
|
+
|
|
1402
|
+
EXAMPLES::
|
|
1403
|
+
|
|
1404
|
+
sage: CDF(2,3).norm()
|
|
1405
|
+
13.0
|
|
1406
|
+
"""
|
|
1407
|
+
return RealDoubleElement(gsl_complex_abs2(self._complex))
|
|
1408
|
+
|
|
1409
|
+
def logabs(self):
|
|
1410
|
+
r"""
|
|
1411
|
+
This function returns the natural logarithm of the magnitude of the
|
|
1412
|
+
complex number `z`, `\log|z|`.
|
|
1413
|
+
|
|
1414
|
+
This allows for an accurate evaluation of `\log|z|` when `|z|` is
|
|
1415
|
+
close to `1`. The direct evaluation of ``log(abs(z))`` would lead
|
|
1416
|
+
to a loss of precision in this case.
|
|
1417
|
+
|
|
1418
|
+
EXAMPLES::
|
|
1419
|
+
|
|
1420
|
+
sage: CDF(1.1,0.1).logabs()
|
|
1421
|
+
0.09942542937258267
|
|
1422
|
+
sage: log(abs(CDF(1.1,0.1)))
|
|
1423
|
+
0.09942542937258259
|
|
1424
|
+
|
|
1425
|
+
::
|
|
1426
|
+
|
|
1427
|
+
sage: log(abs(ComplexField(200)(1.1,0.1)))
|
|
1428
|
+
0.099425429372582595066319157757531449594489450091985182495705
|
|
1429
|
+
"""
|
|
1430
|
+
return RealDoubleElement(gsl_complex_logabs(self._complex))
|
|
1431
|
+
|
|
1432
|
+
def real(self):
|
|
1433
|
+
"""
|
|
1434
|
+
Return the real part of this complex double.
|
|
1435
|
+
|
|
1436
|
+
EXAMPLES::
|
|
1437
|
+
|
|
1438
|
+
sage: a = CDF(3,-2)
|
|
1439
|
+
sage: a.real()
|
|
1440
|
+
3.0
|
|
1441
|
+
sage: a.real_part()
|
|
1442
|
+
3.0
|
|
1443
|
+
"""
|
|
1444
|
+
return RealDoubleElement(GSL_REAL(self._complex))
|
|
1445
|
+
|
|
1446
|
+
real_part = real
|
|
1447
|
+
|
|
1448
|
+
def imag(self):
|
|
1449
|
+
"""
|
|
1450
|
+
Return the imaginary part of this complex double.
|
|
1451
|
+
|
|
1452
|
+
EXAMPLES::
|
|
1453
|
+
|
|
1454
|
+
sage: a = CDF(3,-2)
|
|
1455
|
+
sage: a.imag()
|
|
1456
|
+
-2.0
|
|
1457
|
+
sage: a.imag_part()
|
|
1458
|
+
-2.0
|
|
1459
|
+
"""
|
|
1460
|
+
return RealDoubleElement(GSL_IMAG(self._complex))
|
|
1461
|
+
|
|
1462
|
+
imag_part = imag
|
|
1463
|
+
|
|
1464
|
+
#######################################################################
|
|
1465
|
+
# Elementary Complex Functions
|
|
1466
|
+
#######################################################################
|
|
1467
|
+
def sqrt(self, all=False, **kwds):
|
|
1468
|
+
r"""
|
|
1469
|
+
The square root function.
|
|
1470
|
+
|
|
1471
|
+
INPUT:
|
|
1472
|
+
|
|
1473
|
+
- ``all`` -- boolean (default: ``False``); if ``True``, return a
|
|
1474
|
+
list of all square roots
|
|
1475
|
+
|
|
1476
|
+
If all is ``False``, the branch cut is the negative real axis. The
|
|
1477
|
+
result always lies in the right half of the complex plane.
|
|
1478
|
+
|
|
1479
|
+
EXAMPLES:
|
|
1480
|
+
|
|
1481
|
+
We compute several square roots::
|
|
1482
|
+
|
|
1483
|
+
sage: a = CDF(2,3)
|
|
1484
|
+
sage: b = a.sqrt(); b # rel tol 1e-15
|
|
1485
|
+
1.6741492280355401 + 0.8959774761298381*I
|
|
1486
|
+
sage: b^2 # rel tol 1e-15
|
|
1487
|
+
2.0 + 3.0*I
|
|
1488
|
+
sage: a^(1/2) # abs tol 1e-16
|
|
1489
|
+
1.6741492280355401 + 0.895977476129838*I
|
|
1490
|
+
|
|
1491
|
+
We compute the square root of -1::
|
|
1492
|
+
|
|
1493
|
+
sage: a = CDF(-1)
|
|
1494
|
+
sage: a.sqrt()
|
|
1495
|
+
1.0*I
|
|
1496
|
+
|
|
1497
|
+
We compute all square roots::
|
|
1498
|
+
|
|
1499
|
+
sage: CDF(-2).sqrt(all=True)
|
|
1500
|
+
[1.4142135623730951*I, -1.4142135623730951*I]
|
|
1501
|
+
sage: CDF(0).sqrt(all=True)
|
|
1502
|
+
[0.0]
|
|
1503
|
+
"""
|
|
1504
|
+
z = self._new_c(gsl_complex_sqrt(self._complex))
|
|
1505
|
+
if all:
|
|
1506
|
+
return [z] if z.is_zero() else [z, -z]
|
|
1507
|
+
return z
|
|
1508
|
+
|
|
1509
|
+
def nth_root(self, n, all=False):
|
|
1510
|
+
"""
|
|
1511
|
+
The ``n``-th root function.
|
|
1512
|
+
|
|
1513
|
+
INPUT:
|
|
1514
|
+
|
|
1515
|
+
- ``all`` -- boolean (default: ``False``); if ``True``, return a
|
|
1516
|
+
list of all ``n``-th roots
|
|
1517
|
+
|
|
1518
|
+
EXAMPLES::
|
|
1519
|
+
|
|
1520
|
+
sage: a = CDF(125)
|
|
1521
|
+
sage: a.nth_root(3)
|
|
1522
|
+
5.000000000000001
|
|
1523
|
+
sage: a = CDF(10, 2)
|
|
1524
|
+
sage: [r^5 for r in a.nth_root(5, all=True)] # rel tol 1e-14
|
|
1525
|
+
[9.999999999999998 + 2.0*I, 9.999999999999993 + 2.000000000000002*I, 9.999999999999996 + 1.9999999999999907*I, 9.999999999999993 + 2.0000000000000004*I, 9.999999999999998 + 1.9999999999999802*I]
|
|
1526
|
+
sage: abs(sum(a.nth_root(111, all=True))) # rel tol 0.1
|
|
1527
|
+
1.1057313523818259e-13
|
|
1528
|
+
"""
|
|
1529
|
+
if not self:
|
|
1530
|
+
return [self] if all else self
|
|
1531
|
+
arg = self.argument() / n
|
|
1532
|
+
abs = self.abs().nth_root(n)
|
|
1533
|
+
z = ComplexDoubleElement(abs * arg.cos(), abs*arg.sin())
|
|
1534
|
+
if all:
|
|
1535
|
+
zeta = self._parent.zeta(n)
|
|
1536
|
+
return [z * zeta**k for k in range(n)]
|
|
1537
|
+
else:
|
|
1538
|
+
return z
|
|
1539
|
+
|
|
1540
|
+
def is_square(self):
|
|
1541
|
+
r"""
|
|
1542
|
+
This function always returns ``True`` as `\CC` is algebraically closed.
|
|
1543
|
+
|
|
1544
|
+
EXAMPLES::
|
|
1545
|
+
|
|
1546
|
+
sage: CDF(-1).is_square()
|
|
1547
|
+
True
|
|
1548
|
+
"""
|
|
1549
|
+
return True
|
|
1550
|
+
|
|
1551
|
+
def is_integer(self):
|
|
1552
|
+
"""
|
|
1553
|
+
Return ``True`` if this number is a integer.
|
|
1554
|
+
|
|
1555
|
+
EXAMPLES::
|
|
1556
|
+
|
|
1557
|
+
sage: CDF(0.5).is_integer()
|
|
1558
|
+
False
|
|
1559
|
+
sage: CDF(I).is_integer() # needs sage.symbolic
|
|
1560
|
+
False
|
|
1561
|
+
sage: CDF(2).is_integer()
|
|
1562
|
+
True
|
|
1563
|
+
"""
|
|
1564
|
+
return (self.real() in ZZ) and (self.imag()==0)
|
|
1565
|
+
|
|
1566
|
+
def is_positive_infinity(self):
|
|
1567
|
+
r"""
|
|
1568
|
+
Check if ``self`` is `+\infty`.
|
|
1569
|
+
|
|
1570
|
+
EXAMPLES::
|
|
1571
|
+
|
|
1572
|
+
sage: CDF(1, 2).is_positive_infinity()
|
|
1573
|
+
False
|
|
1574
|
+
sage: CDF(oo, 0).is_positive_infinity()
|
|
1575
|
+
True
|
|
1576
|
+
sage: CDF(0, oo).is_positive_infinity()
|
|
1577
|
+
False
|
|
1578
|
+
"""
|
|
1579
|
+
return self.real().is_positive_infinity() and self.imag().is_zero()
|
|
1580
|
+
|
|
1581
|
+
def is_negative_infinity(self):
|
|
1582
|
+
r"""
|
|
1583
|
+
Check if ``self`` is `-\infty`.
|
|
1584
|
+
|
|
1585
|
+
EXAMPLES::
|
|
1586
|
+
|
|
1587
|
+
sage: CDF(1, 2).is_negative_infinity()
|
|
1588
|
+
False
|
|
1589
|
+
sage: CDF(-oo, 0).is_negative_infinity()
|
|
1590
|
+
True
|
|
1591
|
+
sage: CDF(0, -oo).is_negative_infinity()
|
|
1592
|
+
False
|
|
1593
|
+
"""
|
|
1594
|
+
return self.real().is_negative_infinity() and self.imag().is_zero()
|
|
1595
|
+
|
|
1596
|
+
def is_infinity(self):
|
|
1597
|
+
r"""
|
|
1598
|
+
Check if ``self`` is `\infty`.
|
|
1599
|
+
|
|
1600
|
+
EXAMPLES::
|
|
1601
|
+
|
|
1602
|
+
sage: CDF(1, 2).is_infinity()
|
|
1603
|
+
False
|
|
1604
|
+
sage: CDF(0, oo).is_infinity()
|
|
1605
|
+
True
|
|
1606
|
+
"""
|
|
1607
|
+
return self.real().is_infinity() or self.imag().is_infinity()
|
|
1608
|
+
|
|
1609
|
+
def is_NaN(self):
|
|
1610
|
+
r"""
|
|
1611
|
+
Check if ``self`` is not-a-number.
|
|
1612
|
+
|
|
1613
|
+
EXAMPLES::
|
|
1614
|
+
|
|
1615
|
+
sage: CDF(1, 2).is_NaN()
|
|
1616
|
+
False
|
|
1617
|
+
sage: CDF(NaN).is_NaN() # needs sage.symbolic
|
|
1618
|
+
True
|
|
1619
|
+
sage: (1/CDF(0, 0)).is_NaN()
|
|
1620
|
+
True
|
|
1621
|
+
"""
|
|
1622
|
+
return self.real().is_NaN() or self.imag().is_NaN()
|
|
1623
|
+
|
|
1624
|
+
cpdef _pow_(self, other):
|
|
1625
|
+
r"""
|
|
1626
|
+
The complex number ``self`` raised to the power ``other``.
|
|
1627
|
+
|
|
1628
|
+
This is computed using complex logarithms and exponentials
|
|
1629
|
+
as `z ^ a = \exp(a \log(z))`, unless ``self`` is real and
|
|
1630
|
+
``other`` is an exact integer: in that case, only real
|
|
1631
|
+
arithmetic is used.
|
|
1632
|
+
|
|
1633
|
+
EXAMPLES::
|
|
1634
|
+
|
|
1635
|
+
sage: a = CDF(1,1)
|
|
1636
|
+
sage: b = CDF(2,3)
|
|
1637
|
+
sage: c = a ^ b; c # rel tol 5e-16
|
|
1638
|
+
-0.163450932107355 + 0.09600498360894891*I
|
|
1639
|
+
sage: c ^ (1/b) # rel tol 2e-16
|
|
1640
|
+
1.0 + 1.0*I
|
|
1641
|
+
|
|
1642
|
+
We compute the cube root of `-1` then cube it and observe a
|
|
1643
|
+
rounding error::
|
|
1644
|
+
|
|
1645
|
+
sage: a = CDF(-1)^(1/3); a
|
|
1646
|
+
0.5000000000000001 + 0.8660254037844386*I
|
|
1647
|
+
sage: a^3 # rel tol 1e-4
|
|
1648
|
+
-1.0 + 1.2246467991473532e-16*I
|
|
1649
|
+
|
|
1650
|
+
We raise to symbolic powers::
|
|
1651
|
+
|
|
1652
|
+
sage: var('x, n') # needs sage.symbolic
|
|
1653
|
+
(x, n)
|
|
1654
|
+
sage: CDF(1.2)^x # needs sage.symbolic
|
|
1655
|
+
1.2^x
|
|
1656
|
+
sage: CDF(1.2)^(x^n + n^x) # needs sage.symbolic
|
|
1657
|
+
1.2^(n^x + x^n)
|
|
1658
|
+
|
|
1659
|
+
A real number powered to an exact integer always yields a real
|
|
1660
|
+
number::
|
|
1661
|
+
|
|
1662
|
+
sage: CDF(-0.26319743704743886) ^ 1
|
|
1663
|
+
-0.26319743704743886
|
|
1664
|
+
sage: CDF(-0.26319743704743886) ^ 0
|
|
1665
|
+
1.0
|
|
1666
|
+
sage: CDF(-0.26319743704743886) ^ -1
|
|
1667
|
+
-3.7994290948196405
|
|
1668
|
+
sage: CDF(-0.26319743704743886) ^ 2
|
|
1669
|
+
0.06927289086834054
|
|
1670
|
+
sage: CDF(-0.26319743704743886) ^ -2
|
|
1671
|
+
14.435661446561994
|
|
1672
|
+
sage: CDF(-1) ^ (2^100)
|
|
1673
|
+
1.0
|
|
1674
|
+
|
|
1675
|
+
Note the difference with ::
|
|
1676
|
+
|
|
1677
|
+
sage: CDF(-0.26319743704743886) ^ QQ(2)
|
|
1678
|
+
0.06927289086834053 - 1.6966964813919428e-17*I
|
|
1679
|
+
sage: CDF(-0.26319743704743886) ^ RDF(2)
|
|
1680
|
+
0.06927289086834053 - 1.6966964813919428e-17*I
|
|
1681
|
+
|
|
1682
|
+
TESTS::
|
|
1683
|
+
|
|
1684
|
+
sage: (-2) ^ CDF(-0.5) # abs tol 1e-16
|
|
1685
|
+
4.329780281177467e-17 - 0.7071067811865476*I
|
|
1686
|
+
"""
|
|
1687
|
+
z = <ComplexDoubleElement>other
|
|
1688
|
+
return self._new_c(gsl_complex_pow(self._complex, z._complex))
|
|
1689
|
+
|
|
1690
|
+
cdef _pow_long(self, long other):
|
|
1691
|
+
if other == 1:
|
|
1692
|
+
return self
|
|
1693
|
+
elif other == 0:
|
|
1694
|
+
res = gsl_complex_rect(1, 0)
|
|
1695
|
+
elif other == -1:
|
|
1696
|
+
res = gsl_complex_inverse(self._complex)
|
|
1697
|
+
elif not GSL_IMAG(self._complex):
|
|
1698
|
+
# If self is real, the result should be real too
|
|
1699
|
+
real = GSL_REAL(self._complex) ** <double>other
|
|
1700
|
+
res = gsl_complex_rect(real, 0)
|
|
1701
|
+
else:
|
|
1702
|
+
# General case
|
|
1703
|
+
res = gsl_complex_pow_real(self._complex, other)
|
|
1704
|
+
return self._new_c(res)
|
|
1705
|
+
|
|
1706
|
+
cpdef _pow_int(self, other):
|
|
1707
|
+
if not GSL_IMAG(self._complex):
|
|
1708
|
+
# If self is real, the result should be real too
|
|
1709
|
+
real = GSL_REAL(self._complex) ** <double>other
|
|
1710
|
+
res = gsl_complex_rect(real, 0)
|
|
1711
|
+
else:
|
|
1712
|
+
# General case
|
|
1713
|
+
res = gsl_complex_pow_real(self._complex, other)
|
|
1714
|
+
return self._new_c(res)
|
|
1715
|
+
|
|
1716
|
+
def exp(self):
|
|
1717
|
+
r"""
|
|
1718
|
+
This function returns the complex exponential of the complex number
|
|
1719
|
+
`z`, `\exp(z)`.
|
|
1720
|
+
|
|
1721
|
+
EXAMPLES::
|
|
1722
|
+
|
|
1723
|
+
sage: CDF(1,1).exp() # abs tol 4e-16
|
|
1724
|
+
1.4686939399158851 + 2.2873552871788423*I
|
|
1725
|
+
|
|
1726
|
+
We numerically verify a famous identity to the precision of a double::
|
|
1727
|
+
|
|
1728
|
+
sage: z = CDF(0, 2*pi); z # needs sage.symbolic
|
|
1729
|
+
6.283185307179586*I
|
|
1730
|
+
sage: exp(z) # rel tol 1e-4 # needs sage.symbolic
|
|
1731
|
+
1.0 - 2.4492935982947064e-16*I
|
|
1732
|
+
"""
|
|
1733
|
+
return self._new_c(gsl_complex_exp(self._complex))
|
|
1734
|
+
|
|
1735
|
+
def log(self, base=None):
|
|
1736
|
+
r"""
|
|
1737
|
+
This function returns the complex natural logarithm to the given
|
|
1738
|
+
base of the complex number `z`, `\log(z)`. The
|
|
1739
|
+
branch cut is the negative real axis.
|
|
1740
|
+
|
|
1741
|
+
INPUT:
|
|
1742
|
+
|
|
1743
|
+
- ``base`` -- (default: `e`) the base of the natural logarithm
|
|
1744
|
+
|
|
1745
|
+
EXAMPLES::
|
|
1746
|
+
|
|
1747
|
+
sage: CDF(1,1).log()
|
|
1748
|
+
0.34657359027997264 + 0.7853981633974483*I
|
|
1749
|
+
|
|
1750
|
+
This is the only example different from the GSL::
|
|
1751
|
+
|
|
1752
|
+
sage: CDF(0,0).log()
|
|
1753
|
+
-infinity
|
|
1754
|
+
"""
|
|
1755
|
+
if self == 0:
|
|
1756
|
+
return RDF(0).log()
|
|
1757
|
+
if base is None:
|
|
1758
|
+
return self._new_c(gsl_complex_log(self._complex))
|
|
1759
|
+
cdef ComplexDoubleElement z
|
|
1760
|
+
try:
|
|
1761
|
+
z = base
|
|
1762
|
+
except TypeError:
|
|
1763
|
+
z = CDF(base)
|
|
1764
|
+
return self._new_c(gsl_complex_log_b(self._complex, z._complex))
|
|
1765
|
+
|
|
1766
|
+
def log10(self):
|
|
1767
|
+
r"""
|
|
1768
|
+
This function returns the complex base-10 logarithm of the complex
|
|
1769
|
+
number `z`, `\log_{10}(z)`.
|
|
1770
|
+
|
|
1771
|
+
The branch cut is the negative real axis.
|
|
1772
|
+
|
|
1773
|
+
EXAMPLES::
|
|
1774
|
+
|
|
1775
|
+
sage: CDF(1,1).log10()
|
|
1776
|
+
0.15051499783199057 + 0.3410940884604603*I
|
|
1777
|
+
"""
|
|
1778
|
+
if self == 0:
|
|
1779
|
+
return RDF(0).log()
|
|
1780
|
+
return self._new_c(gsl_complex_log10(self._complex))
|
|
1781
|
+
|
|
1782
|
+
def log_b(self, b):
|
|
1783
|
+
r"""
|
|
1784
|
+
This function returns the complex base-`b` logarithm of the
|
|
1785
|
+
complex number `z`, `\log_b(z)`. This quantity is
|
|
1786
|
+
computed as the ratio `\log(z)/\log(b)`.
|
|
1787
|
+
|
|
1788
|
+
The branch cut is the negative real axis.
|
|
1789
|
+
|
|
1790
|
+
EXAMPLES::
|
|
1791
|
+
|
|
1792
|
+
sage: CDF(1,1).log_b(10) # rel tol 1e-15
|
|
1793
|
+
0.15051499783199057 + 0.3410940884604603*I
|
|
1794
|
+
"""
|
|
1795
|
+
cdef ComplexDoubleElement _b
|
|
1796
|
+
if self == 0:
|
|
1797
|
+
return RDF(0).log()
|
|
1798
|
+
try:
|
|
1799
|
+
_b = b
|
|
1800
|
+
except TypeError:
|
|
1801
|
+
_b = CDF(b)
|
|
1802
|
+
return self._new_c(gsl_complex_log_b(self._complex, _b._complex))
|
|
1803
|
+
|
|
1804
|
+
#######################################################################
|
|
1805
|
+
# Complex Trigonometric Functions
|
|
1806
|
+
#######################################################################
|
|
1807
|
+
def sin(self):
|
|
1808
|
+
r"""
|
|
1809
|
+
This function returns the complex sine of the complex number `z`:
|
|
1810
|
+
|
|
1811
|
+
.. MATH::
|
|
1812
|
+
|
|
1813
|
+
\sin(z) = \frac{e^{iz} - e^{-iz}}{2i}.
|
|
1814
|
+
|
|
1815
|
+
EXAMPLES::
|
|
1816
|
+
|
|
1817
|
+
sage: CDF(1,1).sin()
|
|
1818
|
+
1.2984575814159773 + 0.6349639147847361*I
|
|
1819
|
+
"""
|
|
1820
|
+
return self._new_c(gsl_complex_sin(self._complex))
|
|
1821
|
+
|
|
1822
|
+
def cos(self):
|
|
1823
|
+
r"""
|
|
1824
|
+
This function returns the complex cosine of the complex number `z`:
|
|
1825
|
+
|
|
1826
|
+
.. MATH::
|
|
1827
|
+
|
|
1828
|
+
\cos(z) = \frac{e^{iz} + e^{-iz}}{2}
|
|
1829
|
+
|
|
1830
|
+
EXAMPLES::
|
|
1831
|
+
|
|
1832
|
+
sage: CDF(1,1).cos() # abs tol 1e-16
|
|
1833
|
+
0.8337300251311491 - 0.9888977057628651*I
|
|
1834
|
+
"""
|
|
1835
|
+
return self._new_c(gsl_complex_cos(self._complex))
|
|
1836
|
+
|
|
1837
|
+
def tan(self):
|
|
1838
|
+
r"""
|
|
1839
|
+
This function returns the complex tangent of the complex number `z`:
|
|
1840
|
+
|
|
1841
|
+
.. MATH::
|
|
1842
|
+
|
|
1843
|
+
\tan(z) = \frac{\sin(z)}{\cos(z)}.
|
|
1844
|
+
|
|
1845
|
+
EXAMPLES::
|
|
1846
|
+
|
|
1847
|
+
sage: CDF(1,1).tan()
|
|
1848
|
+
0.27175258531951174 + 1.0839233273386946*I
|
|
1849
|
+
"""
|
|
1850
|
+
return self._new_c(gsl_complex_tan(self._complex))
|
|
1851
|
+
|
|
1852
|
+
def sec(self):
|
|
1853
|
+
r"""
|
|
1854
|
+
This function returns the complex secant of the complex number `z`:
|
|
1855
|
+
|
|
1856
|
+
.. MATH::
|
|
1857
|
+
|
|
1858
|
+
{\rm sec}(z) = \frac{1}{\cos(z)}.
|
|
1859
|
+
|
|
1860
|
+
EXAMPLES::
|
|
1861
|
+
|
|
1862
|
+
sage: CDF(1,1).sec() # rel tol 1e-15
|
|
1863
|
+
0.4983370305551868 + 0.591083841721045*I
|
|
1864
|
+
"""
|
|
1865
|
+
return self._new_c(gsl_complex_sec(self._complex))
|
|
1866
|
+
|
|
1867
|
+
def csc(self):
|
|
1868
|
+
r"""
|
|
1869
|
+
This function returns the complex cosecant of the complex number `z`:
|
|
1870
|
+
|
|
1871
|
+
.. MATH::
|
|
1872
|
+
|
|
1873
|
+
\csc(z) = \frac{1}{\sin(z)}.
|
|
1874
|
+
|
|
1875
|
+
EXAMPLES::
|
|
1876
|
+
|
|
1877
|
+
sage: CDF(1,1).csc() # rel tol 1e-15
|
|
1878
|
+
0.6215180171704284 - 0.30393100162842646*I
|
|
1879
|
+
"""
|
|
1880
|
+
return self._new_c(gsl_complex_csc(self._complex))
|
|
1881
|
+
|
|
1882
|
+
def cot(self):
|
|
1883
|
+
r"""
|
|
1884
|
+
This function returns the complex cotangent of the complex number `z`:
|
|
1885
|
+
|
|
1886
|
+
.. MATH::
|
|
1887
|
+
|
|
1888
|
+
\cot(z) = \frac{1}{\tan(z)}.
|
|
1889
|
+
|
|
1890
|
+
EXAMPLES::
|
|
1891
|
+
|
|
1892
|
+
sage: CDF(1,1).cot() # rel tol 1e-15
|
|
1893
|
+
0.21762156185440268 - 0.8680141428959249*I
|
|
1894
|
+
"""
|
|
1895
|
+
return self._new_c(gsl_complex_cot(self._complex))
|
|
1896
|
+
|
|
1897
|
+
#######################################################################
|
|
1898
|
+
# Inverse Complex Trigonometric Functions
|
|
1899
|
+
#######################################################################
|
|
1900
|
+
def arcsin(self):
|
|
1901
|
+
r"""
|
|
1902
|
+
This function returns the complex arcsine of the complex number
|
|
1903
|
+
`z`, `{\rm arcsin}(z)`. The branch cuts are on the
|
|
1904
|
+
real axis, less than -1 and greater than 1.
|
|
1905
|
+
|
|
1906
|
+
EXAMPLES::
|
|
1907
|
+
|
|
1908
|
+
sage: CDF(1,1).arcsin()
|
|
1909
|
+
0.6662394324925152 + 1.0612750619050357*I
|
|
1910
|
+
"""
|
|
1911
|
+
return self._new_c(gsl_complex_arcsin(self._complex))
|
|
1912
|
+
|
|
1913
|
+
def arccos(self):
|
|
1914
|
+
r"""
|
|
1915
|
+
This function returns the complex arccosine of the complex number
|
|
1916
|
+
`z`, `{\rm arccos}(z)`. The branch cuts are on the
|
|
1917
|
+
real axis, less than -1 and greater than 1.
|
|
1918
|
+
|
|
1919
|
+
EXAMPLES::
|
|
1920
|
+
|
|
1921
|
+
sage: CDF(1,1).arccos()
|
|
1922
|
+
0.9045568943023814 - 1.0612750619050357*I
|
|
1923
|
+
"""
|
|
1924
|
+
return self._new_c(gsl_complex_arccos(self._complex))
|
|
1925
|
+
|
|
1926
|
+
def arctan(self):
|
|
1927
|
+
r"""
|
|
1928
|
+
This function returns the complex arctangent of the complex number
|
|
1929
|
+
`z`, `{\rm arctan}(z)`. The branch cuts are on the
|
|
1930
|
+
imaginary axis, below `-i` and above `i`.
|
|
1931
|
+
|
|
1932
|
+
EXAMPLES::
|
|
1933
|
+
|
|
1934
|
+
sage: CDF(1,1).arctan()
|
|
1935
|
+
1.0172219678978514 + 0.4023594781085251*I
|
|
1936
|
+
"""
|
|
1937
|
+
return self._new_c(gsl_complex_arctan(self._complex))
|
|
1938
|
+
|
|
1939
|
+
def arccsc(self):
|
|
1940
|
+
r"""
|
|
1941
|
+
This function returns the complex arccosecant of the complex number
|
|
1942
|
+
`z`, `{\rm arccsc}(z) = {\rm arcsin}(1/z)`.
|
|
1943
|
+
|
|
1944
|
+
EXAMPLES::
|
|
1945
|
+
|
|
1946
|
+
sage: CDF(1,1).arccsc() # rel tol 1e-15
|
|
1947
|
+
0.45227844715119064 - 0.5306375309525178*I
|
|
1948
|
+
"""
|
|
1949
|
+
return self._new_c(gsl_complex_arccsc(self._complex))
|
|
1950
|
+
|
|
1951
|
+
def arccot(self):
|
|
1952
|
+
r"""
|
|
1953
|
+
This function returns the complex arccotangent of the complex
|
|
1954
|
+
number `z`, `{\rm arccot}(z) = {\rm arctan}(1/z).`
|
|
1955
|
+
|
|
1956
|
+
EXAMPLES::
|
|
1957
|
+
|
|
1958
|
+
sage: CDF(1,1).arccot() # rel tol 1e-15
|
|
1959
|
+
0.5535743588970452 - 0.4023594781085251*I
|
|
1960
|
+
"""
|
|
1961
|
+
return self._new_c(gsl_complex_arccot(self._complex))
|
|
1962
|
+
|
|
1963
|
+
def arcsec(self):
|
|
1964
|
+
r"""
|
|
1965
|
+
This function returns the complex arcsecant of the complex number
|
|
1966
|
+
`z`, `{\rm arcsec}(z) = {\rm arccos}(1/z)`.
|
|
1967
|
+
|
|
1968
|
+
EXAMPLES::
|
|
1969
|
+
|
|
1970
|
+
sage: CDF(1,1).arcsec() # rel tol 1e-15
|
|
1971
|
+
1.118517879643706 + 0.5306375309525178*I
|
|
1972
|
+
"""
|
|
1973
|
+
return self._new_c(gsl_complex_arcsec(self._complex))
|
|
1974
|
+
|
|
1975
|
+
#######################################################################
|
|
1976
|
+
# Complex Hyperbolic Functions
|
|
1977
|
+
#######################################################################
|
|
1978
|
+
|
|
1979
|
+
def sinh(self):
|
|
1980
|
+
r"""
|
|
1981
|
+
This function returns the complex hyperbolic sine of the complex
|
|
1982
|
+
number `z`:
|
|
1983
|
+
|
|
1984
|
+
.. MATH::
|
|
1985
|
+
|
|
1986
|
+
\sinh(z) = \frac{e^z - e^{-z}}{2}.
|
|
1987
|
+
|
|
1988
|
+
EXAMPLES::
|
|
1989
|
+
|
|
1990
|
+
sage: CDF(1,1).sinh()
|
|
1991
|
+
0.6349639147847361 + 1.2984575814159773*I
|
|
1992
|
+
"""
|
|
1993
|
+
return self._new_c(gsl_complex_sinh(self._complex))
|
|
1994
|
+
|
|
1995
|
+
def cosh(self):
|
|
1996
|
+
r"""
|
|
1997
|
+
This function returns the complex hyperbolic cosine of the complex
|
|
1998
|
+
number `z`:
|
|
1999
|
+
|
|
2000
|
+
.. MATH::
|
|
2001
|
+
|
|
2002
|
+
\cosh(z) = \frac{e^z + e^{-z}}{2}.
|
|
2003
|
+
|
|
2004
|
+
EXAMPLES::
|
|
2005
|
+
|
|
2006
|
+
sage: CDF(1,1).cosh() # abs tol 1e-16
|
|
2007
|
+
0.8337300251311491 + 0.9888977057628651*I
|
|
2008
|
+
"""
|
|
2009
|
+
return self._new_c(gsl_complex_cosh(self._complex))
|
|
2010
|
+
|
|
2011
|
+
def tanh(self):
|
|
2012
|
+
r"""
|
|
2013
|
+
This function returns the complex hyperbolic tangent of the complex
|
|
2014
|
+
number `z`:
|
|
2015
|
+
|
|
2016
|
+
.. MATH::
|
|
2017
|
+
|
|
2018
|
+
\tanh(z) = \frac{\sinh(z)}{\cosh(z)}.
|
|
2019
|
+
|
|
2020
|
+
EXAMPLES::
|
|
2021
|
+
|
|
2022
|
+
sage: CDF(1,1).tanh()
|
|
2023
|
+
1.0839233273386946 + 0.27175258531951174*I
|
|
2024
|
+
"""
|
|
2025
|
+
return self._new_c(gsl_complex_tanh(self._complex))
|
|
2026
|
+
|
|
2027
|
+
def sech(self):
|
|
2028
|
+
r"""
|
|
2029
|
+
This function returns the complex hyperbolic secant of the complex
|
|
2030
|
+
number `z`:
|
|
2031
|
+
|
|
2032
|
+
.. MATH::
|
|
2033
|
+
|
|
2034
|
+
{\rm sech}(z) = \frac{1}{{\rm cosh}(z)}.
|
|
2035
|
+
|
|
2036
|
+
EXAMPLES::
|
|
2037
|
+
|
|
2038
|
+
sage: CDF(1,1).sech() # rel tol 1e-15
|
|
2039
|
+
0.4983370305551868 - 0.591083841721045*I
|
|
2040
|
+
"""
|
|
2041
|
+
return self._new_c(gsl_complex_sech(self._complex))
|
|
2042
|
+
|
|
2043
|
+
def csch(self):
|
|
2044
|
+
r"""
|
|
2045
|
+
This function returns the complex hyperbolic cosecant of the
|
|
2046
|
+
complex number `z`:
|
|
2047
|
+
|
|
2048
|
+
.. MATH::
|
|
2049
|
+
|
|
2050
|
+
{\rm csch}(z) = \frac{1}{{\rm sinh}(z)}.
|
|
2051
|
+
|
|
2052
|
+
EXAMPLES::
|
|
2053
|
+
|
|
2054
|
+
sage: CDF(1,1).csch() # rel tol 1e-15
|
|
2055
|
+
0.30393100162842646 - 0.6215180171704284*I
|
|
2056
|
+
"""
|
|
2057
|
+
return self._new_c(gsl_complex_csch(self._complex))
|
|
2058
|
+
|
|
2059
|
+
def coth(self):
|
|
2060
|
+
r"""
|
|
2061
|
+
This function returns the complex hyperbolic cotangent of the
|
|
2062
|
+
complex number `z`:
|
|
2063
|
+
|
|
2064
|
+
.. MATH::
|
|
2065
|
+
|
|
2066
|
+
\coth(z) = \frac{1}{\tanh(z)}.
|
|
2067
|
+
|
|
2068
|
+
EXAMPLES::
|
|
2069
|
+
|
|
2070
|
+
sage: CDF(1,1).coth() # rel tol 1e-15
|
|
2071
|
+
0.8680141428959249 - 0.21762156185440268*I
|
|
2072
|
+
"""
|
|
2073
|
+
return self._new_c(gsl_complex_coth(self._complex))
|
|
2074
|
+
|
|
2075
|
+
#######################################################################
|
|
2076
|
+
# Inverse Complex Hyperbolic Functions
|
|
2077
|
+
#######################################################################
|
|
2078
|
+
def arcsinh(self):
|
|
2079
|
+
r"""
|
|
2080
|
+
This function returns the complex hyperbolic arcsine of the complex
|
|
2081
|
+
number `z`, `{\rm arcsinh}(z)`. The branch cuts are
|
|
2082
|
+
on the imaginary axis, below `-i` and above `i`.
|
|
2083
|
+
|
|
2084
|
+
EXAMPLES::
|
|
2085
|
+
|
|
2086
|
+
sage: CDF(1,1).arcsinh()
|
|
2087
|
+
1.0612750619050357 + 0.6662394324925152*I
|
|
2088
|
+
"""
|
|
2089
|
+
return self._new_c(gsl_complex_arcsinh(self._complex))
|
|
2090
|
+
|
|
2091
|
+
def arccosh(self):
|
|
2092
|
+
r"""
|
|
2093
|
+
This function returns the complex hyperbolic arccosine of the
|
|
2094
|
+
complex number `z`, `{\rm arccosh}(z)`. The branch
|
|
2095
|
+
cut is on the real axis, less than 1.
|
|
2096
|
+
|
|
2097
|
+
EXAMPLES::
|
|
2098
|
+
|
|
2099
|
+
sage: CDF(1,1).arccosh()
|
|
2100
|
+
1.0612750619050357 + 0.9045568943023814*I
|
|
2101
|
+
"""
|
|
2102
|
+
return self._new_c(gsl_complex_arccosh(self._complex))
|
|
2103
|
+
|
|
2104
|
+
def arctanh(self):
|
|
2105
|
+
r"""
|
|
2106
|
+
This function returns the complex hyperbolic arctangent of the
|
|
2107
|
+
complex number `z`, `{\rm arctanh} (z)`. The branch
|
|
2108
|
+
cuts are on the real axis, less than -1 and greater than 1.
|
|
2109
|
+
|
|
2110
|
+
EXAMPLES::
|
|
2111
|
+
|
|
2112
|
+
sage: CDF(1,1).arctanh()
|
|
2113
|
+
0.4023594781085251 + 1.0172219678978514*I
|
|
2114
|
+
"""
|
|
2115
|
+
return self._new_c(gsl_complex_arctanh(self._complex))
|
|
2116
|
+
|
|
2117
|
+
def arcsech(self):
|
|
2118
|
+
r"""
|
|
2119
|
+
This function returns the complex hyperbolic arcsecant of the
|
|
2120
|
+
complex number `z`, `{\rm arcsech}(z) = {\rm arccosh}(1/z)`.
|
|
2121
|
+
|
|
2122
|
+
EXAMPLES::
|
|
2123
|
+
|
|
2124
|
+
sage: CDF(1,1).arcsech() # rel tol 1e-15
|
|
2125
|
+
0.5306375309525176 - 1.118517879643706*I
|
|
2126
|
+
"""
|
|
2127
|
+
return self._new_c(gsl_complex_arcsech(self._complex))
|
|
2128
|
+
|
|
2129
|
+
def arccsch(self):
|
|
2130
|
+
r"""
|
|
2131
|
+
This function returns the complex hyperbolic arccosecant of the
|
|
2132
|
+
complex number `z`, `{\rm arccsch}(z) = {\rm arcsin}(1/z)`.
|
|
2133
|
+
|
|
2134
|
+
EXAMPLES::
|
|
2135
|
+
|
|
2136
|
+
sage: CDF(1,1).arccsch() # rel tol 1e-15
|
|
2137
|
+
0.5306375309525178 - 0.45227844715119064*I
|
|
2138
|
+
"""
|
|
2139
|
+
return self._new_c(gsl_complex_arccsch(self._complex))
|
|
2140
|
+
|
|
2141
|
+
def arccoth(self):
|
|
2142
|
+
r"""
|
|
2143
|
+
This function returns the complex hyperbolic arccotangent of the
|
|
2144
|
+
complex number `z`, `{\rm arccoth}(z) = {\rm arctanh(1/z)}`.
|
|
2145
|
+
|
|
2146
|
+
EXAMPLES::
|
|
2147
|
+
|
|
2148
|
+
sage: CDF(1,1).arccoth() # rel tol 1e-15
|
|
2149
|
+
0.4023594781085251 - 0.5535743588970452*I
|
|
2150
|
+
"""
|
|
2151
|
+
return self._new_c(gsl_complex_arccoth(self._complex))
|
|
2152
|
+
|
|
2153
|
+
#######################################################################
|
|
2154
|
+
# Special Functions (from PARI)
|
|
2155
|
+
#######################################################################
|
|
2156
|
+
def eta(self, int omit_frac=0):
|
|
2157
|
+
r"""
|
|
2158
|
+
Return the value of the Dedekind `\eta` function on ``self``.
|
|
2159
|
+
|
|
2160
|
+
INPUT:
|
|
2161
|
+
|
|
2162
|
+
- ``self`` -- element of the upper half plane (if not,
|
|
2163
|
+
raises a ValueError)
|
|
2164
|
+
|
|
2165
|
+
- ``omit_frac`` -- boolean (default: ``False``); if ``True``,
|
|
2166
|
+
omit the `e^{\pi i z / 12}` factor
|
|
2167
|
+
|
|
2168
|
+
OUTPUT: a complex double number
|
|
2169
|
+
|
|
2170
|
+
ALGORITHM: Uses the PARI C library.
|
|
2171
|
+
|
|
2172
|
+
The `\eta` function is
|
|
2173
|
+
|
|
2174
|
+
.. MATH::
|
|
2175
|
+
|
|
2176
|
+
\eta(z) = e^{\pi i z / 12} \prod_{n=1}^{\infty} (1 - e^{2\pi inz})
|
|
2177
|
+
|
|
2178
|
+
EXAMPLES:
|
|
2179
|
+
|
|
2180
|
+
We compute a few values of :meth:`eta()`::
|
|
2181
|
+
|
|
2182
|
+
sage: CDF(0,1).eta() # needs sage.libs.pari
|
|
2183
|
+
0.7682254223260566
|
|
2184
|
+
sage: CDF(1,1).eta() # needs sage.libs.pari
|
|
2185
|
+
0.7420487758365647 + 0.1988313702299107*I
|
|
2186
|
+
sage: CDF(25,1).eta() # needs sage.libs.pari
|
|
2187
|
+
0.7420487758365647 + 0.1988313702299107*I
|
|
2188
|
+
|
|
2189
|
+
:meth:`eta()` works even if the inputs are large::
|
|
2190
|
+
|
|
2191
|
+
sage: CDF(0, 10^15).eta()
|
|
2192
|
+
0.0
|
|
2193
|
+
sage: CDF(10^15, 0.1).eta() # abs tol 1e-10 # needs sage.libs.pari
|
|
2194
|
+
-0.115342592727 - 0.19977923088*I
|
|
2195
|
+
|
|
2196
|
+
We compute a few values of :meth:`eta()`, but with the fractional power
|
|
2197
|
+
of `e` omitted::
|
|
2198
|
+
|
|
2199
|
+
sage: CDF(0,1).eta(True) # needs sage.libs.pari
|
|
2200
|
+
0.9981290699259585
|
|
2201
|
+
|
|
2202
|
+
We compute :meth:`eta()` to low precision directly from the
|
|
2203
|
+
definition::
|
|
2204
|
+
|
|
2205
|
+
sage: z = CDF(1,1); z.eta() # needs sage.libs.pari
|
|
2206
|
+
0.7420487758365647 + 0.1988313702299107*I
|
|
2207
|
+
sage: i = CDF(0,1); pi = CDF(pi) # needs sage.symbolic
|
|
2208
|
+
sage: exp(pi * i * z / 12) * prod(1 - exp(2*pi*i*n*z) # needs sage.libs.pari sage.symbolic
|
|
2209
|
+
....: for n in range(1, 10))
|
|
2210
|
+
0.7420487758365647 + 0.19883137022991068*I
|
|
2211
|
+
|
|
2212
|
+
The optional argument allows us to omit the fractional part::
|
|
2213
|
+
|
|
2214
|
+
sage: z.eta(omit_frac=True) # needs sage.libs.pari
|
|
2215
|
+
0.9981290699259585
|
|
2216
|
+
sage: pi = CDF(pi) # needs sage.symbolic
|
|
2217
|
+
sage: prod(1 - exp(2*pi*i*n*z) for n in range(1,10)) # abs tol 1e-12 # needs sage.libs.pari sage.symbolic
|
|
2218
|
+
0.998129069926 + 4.59084695545e-19*I
|
|
2219
|
+
|
|
2220
|
+
We illustrate what happens when `z` is not in the upper half plane::
|
|
2221
|
+
|
|
2222
|
+
sage: z = CDF(1)
|
|
2223
|
+
sage: z.eta()
|
|
2224
|
+
Traceback (most recent call last):
|
|
2225
|
+
...
|
|
2226
|
+
ValueError: value must be in the upper half plane
|
|
2227
|
+
|
|
2228
|
+
You can also use functional notation::
|
|
2229
|
+
|
|
2230
|
+
sage: z = CDF(1,1)
|
|
2231
|
+
sage: eta(z) # needs sage.libs.pari
|
|
2232
|
+
0.7420487758365647 + 0.1988313702299107*I
|
|
2233
|
+
"""
|
|
2234
|
+
if GSL_IMAG(self._complex) <= 0:
|
|
2235
|
+
raise ValueError("value must be in the upper half plane")
|
|
2236
|
+
|
|
2237
|
+
if GSL_IMAG(self._complex) > 100000 and not omit_frac:
|
|
2238
|
+
# To the precision of doubles for such large imaginary
|
|
2239
|
+
# part, the answer is automatically 0. If we don't do
|
|
2240
|
+
# this, PARI can easily underflow.
|
|
2241
|
+
return ComplexDoubleElement(0,0)
|
|
2242
|
+
|
|
2243
|
+
global complex_double_element_eta
|
|
2244
|
+
if complex_double_element_eta is None:
|
|
2245
|
+
from sage.libs.pari.convert_sage_complex_double import complex_double_element_eta
|
|
2246
|
+
|
|
2247
|
+
cdef int flag = 0 if omit_frac else 1
|
|
2248
|
+
return complex_double_element_eta(self, flag)
|
|
2249
|
+
|
|
2250
|
+
def agm(self, right, algorithm='optimal'):
|
|
2251
|
+
r"""
|
|
2252
|
+
Return the Arithmetic-Geometric Mean (AGM) of ``self`` and ``right``.
|
|
2253
|
+
|
|
2254
|
+
INPUT:
|
|
2255
|
+
|
|
2256
|
+
- ``right`` -- complex; another complex number
|
|
2257
|
+
|
|
2258
|
+
- ``algorithm`` -- string (default: ``'optimal'``); the algorithm to
|
|
2259
|
+
use (see below)
|
|
2260
|
+
|
|
2261
|
+
OUTPUT:
|
|
2262
|
+
|
|
2263
|
+
(complex) A value of the AGM of ``self`` and ``right``. Note that
|
|
2264
|
+
this is a multi-valued function, and the algorithm used
|
|
2265
|
+
affects the value returned, as follows:
|
|
2266
|
+
|
|
2267
|
+
- ``'pari'``: Call the :pari:`agm` function from the pari library.
|
|
2268
|
+
|
|
2269
|
+
- ``'optimal'``: Use the AGM sequence such that at each stage
|
|
2270
|
+
`(a,b)` is replaced by `(a_1,b_1)=((a+b)/2,\pm\sqrt{ab})`
|
|
2271
|
+
where the sign is chosen so that `|a_1-b_1| \leq |a_1+b_1|`, or
|
|
2272
|
+
equivalently `\Re(b_1/a_1) \geq 0`. The resulting limit is
|
|
2273
|
+
maximal among all possible values.
|
|
2274
|
+
|
|
2275
|
+
- ``'principal'``: Use the AGM sequence such that at each stage
|
|
2276
|
+
`(a,b)` is replaced by `(a_1,b_1)=((a+b)/2,\pm\sqrt{ab})`
|
|
2277
|
+
where the sign is chosen so that `\Re(b_1/a_1) \geq 0` (the
|
|
2278
|
+
so-called principal branch of the square root).
|
|
2279
|
+
|
|
2280
|
+
See :wikipedia:`Arithmetic-geometric mean`
|
|
2281
|
+
|
|
2282
|
+
EXAMPLES::
|
|
2283
|
+
|
|
2284
|
+
sage: i = CDF(I) # needs sage.symbolic
|
|
2285
|
+
sage: (1+i).agm(2-i) # rel tol 1e-15 # needs sage.symbolic
|
|
2286
|
+
1.6278054848727064 + 0.1368275483973686*I
|
|
2287
|
+
|
|
2288
|
+
An example to show that the returned value depends on the algorithm
|
|
2289
|
+
parameter::
|
|
2290
|
+
|
|
2291
|
+
sage: a = CDF(-0.95,-0.65)
|
|
2292
|
+
sage: b = CDF(0.683,0.747)
|
|
2293
|
+
sage: a.agm(b, algorithm='optimal') # rel tol 1e-15
|
|
2294
|
+
-0.3715916523517613 + 0.31989466020683005*I
|
|
2295
|
+
sage: a.agm(b, algorithm='principal') # rel tol 2e-15
|
|
2296
|
+
0.33817546298618006 - 0.013532696956540483*I
|
|
2297
|
+
sage: a.agm(b, algorithm='pari') # needs sage.libs.pari
|
|
2298
|
+
-0.37159165235176134 + 0.31989466020683005*I
|
|
2299
|
+
|
|
2300
|
+
Some degenerate cases::
|
|
2301
|
+
|
|
2302
|
+
sage: CDF(0).agm(a)
|
|
2303
|
+
0.0
|
|
2304
|
+
sage: a.agm(0)
|
|
2305
|
+
0.0
|
|
2306
|
+
sage: a.agm(-a)
|
|
2307
|
+
0.0
|
|
2308
|
+
"""
|
|
2309
|
+
cdef libcpp.complex.complex[double] a, b, a1, b1, r
|
|
2310
|
+
cdef double d, e, eps = 2.0**-51
|
|
2311
|
+
|
|
2312
|
+
if algorithm == "pari":
|
|
2313
|
+
global complex_double_element_agm
|
|
2314
|
+
if complex_double_element_agm is None:
|
|
2315
|
+
from sage.libs.pari.convert_sage_complex_double import complex_double_element_agm
|
|
2316
|
+
return complex_double_element_agm(self, right)
|
|
2317
|
+
|
|
2318
|
+
if not isinstance(right, ComplexDoubleElement):
|
|
2319
|
+
right = CDF(right)
|
|
2320
|
+
|
|
2321
|
+
a = extract_double_complex(self)
|
|
2322
|
+
b = extract_double_complex(<ComplexDoubleElement>right)
|
|
2323
|
+
|
|
2324
|
+
if a == 0 or b == 0 or a == -b:
|
|
2325
|
+
return ComplexDoubleElement(0, 0)
|
|
2326
|
+
|
|
2327
|
+
if algorithm=="optimal":
|
|
2328
|
+
while True:
|
|
2329
|
+
a1 = (a+b)/2
|
|
2330
|
+
b1 = sqrt(a*b)
|
|
2331
|
+
r = b1/a1
|
|
2332
|
+
d = abs(r-1)
|
|
2333
|
+
e = abs(r+1)
|
|
2334
|
+
if e < d:
|
|
2335
|
+
b1=-b1
|
|
2336
|
+
d = e
|
|
2337
|
+
if d < eps: return ComplexDoubleElement_from_doubles(a1.real(), a1.imag())
|
|
2338
|
+
a, b = a1, b1
|
|
2339
|
+
|
|
2340
|
+
elif algorithm=="principal":
|
|
2341
|
+
while True:
|
|
2342
|
+
a1 = (a+b)/2
|
|
2343
|
+
b1 = sqrt(a*b)
|
|
2344
|
+
if abs((b1/a1)-1) < eps: return ComplexDoubleElement_from_doubles(a1.real(), a1.imag())
|
|
2345
|
+
a, b = a1, b1
|
|
2346
|
+
|
|
2347
|
+
else:
|
|
2348
|
+
raise ValueError("agm algorithm must be one of 'pari', 'optimal', 'principal'")
|
|
2349
|
+
|
|
2350
|
+
def dilog(self):
|
|
2351
|
+
r"""
|
|
2352
|
+
Return the principal branch of the dilogarithm of `x`, i.e., analytic
|
|
2353
|
+
continuation of the power series
|
|
2354
|
+
|
|
2355
|
+
.. MATH::
|
|
2356
|
+
|
|
2357
|
+
\log_2(x) = \sum_{n \ge 1} x^n / n^2.
|
|
2358
|
+
|
|
2359
|
+
EXAMPLES::
|
|
2360
|
+
|
|
2361
|
+
sage: CDF(1,2).dilog() # needs sage.libs.pari
|
|
2362
|
+
-0.059474798673809476 + 2.0726479717747566*I
|
|
2363
|
+
sage: CDF(10000000,10000000).dilog() # needs sage.libs.pari
|
|
2364
|
+
-134.411774490731 + 38.79396299904504*I
|
|
2365
|
+
"""
|
|
2366
|
+
global complex_double_element_dilog
|
|
2367
|
+
if complex_double_element_dilog is None:
|
|
2368
|
+
from sage.libs.pari.convert_sage_complex_double import complex_double_element_dilog
|
|
2369
|
+
return complex_double_element_dilog(self)
|
|
2370
|
+
|
|
2371
|
+
def gamma(self):
|
|
2372
|
+
r"""
|
|
2373
|
+
Return the gamma function `\Gamma(z)` evaluated at ``self``, the
|
|
2374
|
+
complex number `z`.
|
|
2375
|
+
|
|
2376
|
+
EXAMPLES::
|
|
2377
|
+
|
|
2378
|
+
sage: # needs sage.libs.pari
|
|
2379
|
+
sage: CDF(5,0).gamma()
|
|
2380
|
+
24.0
|
|
2381
|
+
sage: CDF(1,1).gamma()
|
|
2382
|
+
0.49801566811835607 - 0.15494982830181067*I
|
|
2383
|
+
sage: CDF(0).gamma()
|
|
2384
|
+
Infinity
|
|
2385
|
+
sage: CDF(-1,0).gamma()
|
|
2386
|
+
Infinity
|
|
2387
|
+
"""
|
|
2388
|
+
if not GSL_IMAG(self._complex):
|
|
2389
|
+
if GSL_REAL(self._complex) == 0:
|
|
2390
|
+
from sage.rings.infinity import unsigned_infinity
|
|
2391
|
+
return unsigned_infinity
|
|
2392
|
+
try:
|
|
2393
|
+
from sage.rings.integer import Integer
|
|
2394
|
+
if Integer(GSL_REAL(self._complex)) < 0:
|
|
2395
|
+
from sage.rings.cc import CC
|
|
2396
|
+
return CC(self).gamma()
|
|
2397
|
+
except TypeError:
|
|
2398
|
+
pass
|
|
2399
|
+
global complex_double_element_gamma
|
|
2400
|
+
if complex_double_element_gamma is None:
|
|
2401
|
+
from sage.libs.pari.convert_sage_complex_double import complex_double_element_gamma
|
|
2402
|
+
return complex_double_element_gamma(self)
|
|
2403
|
+
|
|
2404
|
+
def gamma_inc(self, t):
|
|
2405
|
+
r"""
|
|
2406
|
+
Return the incomplete gamma function evaluated at this complex number.
|
|
2407
|
+
|
|
2408
|
+
EXAMPLES::
|
|
2409
|
+
|
|
2410
|
+
sage: CDF(1,1).gamma_inc(CDF(2,3)) # needs sage.libs.pari
|
|
2411
|
+
0.0020969148636468277 - 0.059981913655449706*I
|
|
2412
|
+
sage: CDF(1,1).gamma_inc(5) # needs sage.libs.pari
|
|
2413
|
+
-0.001378130936215849 + 0.006519820023119819*I
|
|
2414
|
+
sage: CDF(2,0).gamma_inc(CDF(1,1)) # needs sage.libs.pari
|
|
2415
|
+
0.7070920963459381 - 0.4203536409598115*I
|
|
2416
|
+
"""
|
|
2417
|
+
global complex_double_element_gamma_inc
|
|
2418
|
+
if complex_double_element_gamma_inc is None:
|
|
2419
|
+
from sage.libs.pari.convert_sage_complex_double import complex_double_element_gamma_inc
|
|
2420
|
+
return complex_double_element_gamma_inc(self, t)
|
|
2421
|
+
|
|
2422
|
+
def zeta(self):
|
|
2423
|
+
"""
|
|
2424
|
+
Return the Riemann zeta function evaluated at this complex number.
|
|
2425
|
+
|
|
2426
|
+
EXAMPLES::
|
|
2427
|
+
|
|
2428
|
+
sage: z = CDF(1, 1)
|
|
2429
|
+
sage: z.zeta() # needs sage.libs.pari
|
|
2430
|
+
0.5821580597520036 - 0.9268485643308071*I
|
|
2431
|
+
sage: zeta(z) # needs sage.libs.pari
|
|
2432
|
+
0.5821580597520036 - 0.9268485643308071*I
|
|
2433
|
+
sage: zeta(CDF(1)) # needs sage.libs.pari
|
|
2434
|
+
Infinity
|
|
2435
|
+
"""
|
|
2436
|
+
if GSL_REAL(self._complex) == 1 and GSL_IMAG(self._complex) == 0:
|
|
2437
|
+
from sage.rings.infinity import unsigned_infinity
|
|
2438
|
+
return unsigned_infinity
|
|
2439
|
+
|
|
2440
|
+
global complex_double_element_zeta
|
|
2441
|
+
if complex_double_element_zeta is None:
|
|
2442
|
+
from sage.libs.pari.convert_sage_complex_double import complex_double_element_zeta
|
|
2443
|
+
return complex_double_element_zeta(self)
|
|
2444
|
+
|
|
2445
|
+
def algebraic_dependency(self, long n):
|
|
2446
|
+
"""
|
|
2447
|
+
Return a polynomial of degree at most `n` which is
|
|
2448
|
+
approximately satisfied by this complex number.
|
|
2449
|
+
|
|
2450
|
+
Note that the returned polynomial need not be irreducible, and
|
|
2451
|
+
indeed usually will not be if `z` is a good approximation to an
|
|
2452
|
+
algebraic number of degree less than `n`.
|
|
2453
|
+
|
|
2454
|
+
ALGORITHM: Uses the PARI C-library :pari:`algdep` command.
|
|
2455
|
+
|
|
2456
|
+
EXAMPLES::
|
|
2457
|
+
|
|
2458
|
+
sage: z = (1/2)*(1 + RDF(sqrt(3)) * CDF.0); z # abs tol 1e-16 # needs sage.symbolic
|
|
2459
|
+
0.5 + 0.8660254037844387*I
|
|
2460
|
+
sage: p = z.algebraic_dependency(5); p # needs sage.libs.pari sage.symbolic
|
|
2461
|
+
x^2 - x + 1
|
|
2462
|
+
sage: abs(z^2 - z + 1) < 1e-14 # needs sage.symbolic
|
|
2463
|
+
True
|
|
2464
|
+
|
|
2465
|
+
::
|
|
2466
|
+
|
|
2467
|
+
sage: CDF(0,2).algebraic_dependency(10) # needs sage.libs.pari
|
|
2468
|
+
x^2 + 4
|
|
2469
|
+
sage: CDF(1,5).algebraic_dependency(2) # needs sage.libs.pari
|
|
2470
|
+
x^2 - 2*x + 26
|
|
2471
|
+
"""
|
|
2472
|
+
from sage.arith.misc import algebraic_dependency
|
|
2473
|
+
return algebraic_dependency(self, n)
|
|
2474
|
+
|
|
2475
|
+
algdep = algebraic_dependency
|
|
2476
|
+
|
|
2477
|
+
|
|
2478
|
+
cdef class FloatToCDF(Morphism):
|
|
2479
|
+
"""
|
|
2480
|
+
Fast morphism from anything with a ``__float__`` method to a CDF element.
|
|
2481
|
+
|
|
2482
|
+
EXAMPLES::
|
|
2483
|
+
|
|
2484
|
+
sage: f = CDF.coerce_map_from(ZZ); f
|
|
2485
|
+
Native morphism:
|
|
2486
|
+
From: Integer Ring
|
|
2487
|
+
To: Complex Double Field
|
|
2488
|
+
sage: f(4)
|
|
2489
|
+
4.0
|
|
2490
|
+
sage: f = CDF.coerce_map_from(QQ); f
|
|
2491
|
+
Native morphism:
|
|
2492
|
+
From: Rational Field
|
|
2493
|
+
To: Complex Double Field
|
|
2494
|
+
sage: f(1/2)
|
|
2495
|
+
0.5
|
|
2496
|
+
sage: f = CDF.coerce_map_from(int); f
|
|
2497
|
+
Native morphism:
|
|
2498
|
+
From: Set of Python objects of class 'int'
|
|
2499
|
+
To: Complex Double Field
|
|
2500
|
+
sage: f(3r)
|
|
2501
|
+
3.0
|
|
2502
|
+
sage: f = CDF.coerce_map_from(float); f
|
|
2503
|
+
Native morphism:
|
|
2504
|
+
From: Set of Python objects of class 'float'
|
|
2505
|
+
To: Complex Double Field
|
|
2506
|
+
sage: f(3.5)
|
|
2507
|
+
3.5
|
|
2508
|
+
"""
|
|
2509
|
+
def __init__(self, R):
|
|
2510
|
+
"""
|
|
2511
|
+
Initialize ``self``.
|
|
2512
|
+
|
|
2513
|
+
EXAMPLES::
|
|
2514
|
+
|
|
2515
|
+
sage: f = CDF.coerce_map_from(ZZ); f
|
|
2516
|
+
Native morphism:
|
|
2517
|
+
From: Integer Ring
|
|
2518
|
+
To: Complex Double Field
|
|
2519
|
+
"""
|
|
2520
|
+
from sage.categories.homset import Hom
|
|
2521
|
+
if isinstance(R, type):
|
|
2522
|
+
from sage.sets.pythonclass import Set_PythonType
|
|
2523
|
+
R = Set_PythonType(R)
|
|
2524
|
+
Morphism.__init__(self, Hom(R, CDF))
|
|
2525
|
+
|
|
2526
|
+
cpdef Element _call_(self, x):
|
|
2527
|
+
"""
|
|
2528
|
+
Create an :class:`ComplexDoubleElement`.
|
|
2529
|
+
|
|
2530
|
+
EXAMPLES::
|
|
2531
|
+
|
|
2532
|
+
sage: CDF((1,2)) # indirect doctest
|
|
2533
|
+
1.0 + 2.0*I
|
|
2534
|
+
sage: CDF('i') # indirect doctest
|
|
2535
|
+
1.0*I
|
|
2536
|
+
sage: CDF(2+i) # indirect doctest # needs sage.symbolic
|
|
2537
|
+
2.0 + 1.0*I
|
|
2538
|
+
"""
|
|
2539
|
+
cdef ComplexDoubleElement z = <ComplexDoubleElement>ComplexDoubleElement.__new__(ComplexDoubleElement)
|
|
2540
|
+
z._complex = gsl_complex_rect(x, 0)
|
|
2541
|
+
return z
|
|
2542
|
+
|
|
2543
|
+
def _repr_type(self):
|
|
2544
|
+
"""
|
|
2545
|
+
Return string that describes the type of morphism.
|
|
2546
|
+
|
|
2547
|
+
EXAMPLES::
|
|
2548
|
+
|
|
2549
|
+
sage: sage.rings.complex_double.FloatToCDF(QQ)._repr_type()
|
|
2550
|
+
'Native'
|
|
2551
|
+
"""
|
|
2552
|
+
return "Native"
|
|
2553
|
+
|
|
2554
|
+
|
|
2555
|
+
cdef class ComplexToCDF(Morphism):
|
|
2556
|
+
r"""
|
|
2557
|
+
Fast morphism for anything such that the elements have attributes ``.real``
|
|
2558
|
+
and ``.imag`` (e.g. numpy complex types).
|
|
2559
|
+
|
|
2560
|
+
EXAMPLES::
|
|
2561
|
+
|
|
2562
|
+
sage: # needs numpy sage.symbolic
|
|
2563
|
+
sage: import numpy
|
|
2564
|
+
sage: f = CDF.coerce_map_from(numpy.complex128)
|
|
2565
|
+
sage: f(numpy.complex128(I))
|
|
2566
|
+
1.0*I
|
|
2567
|
+
sage: f(numpy.complex128(I)).parent()
|
|
2568
|
+
Complex Double Field
|
|
2569
|
+
"""
|
|
2570
|
+
def __init__(self, R):
|
|
2571
|
+
from sage.categories.homset import Hom
|
|
2572
|
+
if isinstance(R, type):
|
|
2573
|
+
from sage.sets.pythonclass import Set_PythonType
|
|
2574
|
+
R = Set_PythonType(R)
|
|
2575
|
+
Morphism.__init__(self, Hom(R, CDF))
|
|
2576
|
+
|
|
2577
|
+
cpdef Element _call_(self, x):
|
|
2578
|
+
"""
|
|
2579
|
+
Create an :class:`ComplexDoubleElement`.
|
|
2580
|
+
|
|
2581
|
+
EXAMPLES::
|
|
2582
|
+
|
|
2583
|
+
sage: # needs numpy sage.symbolic
|
|
2584
|
+
sage: import numpy
|
|
2585
|
+
sage: CDF(numpy.complex128(I)) # indirect doctest
|
|
2586
|
+
1.0*I
|
|
2587
|
+
"""
|
|
2588
|
+
cdef ComplexDoubleElement z = <ComplexDoubleElement>ComplexDoubleElement.__new__(ComplexDoubleElement)
|
|
2589
|
+
z._complex = gsl_complex_rect(x.real, x.imag)
|
|
2590
|
+
return z
|
|
2591
|
+
|
|
2592
|
+
def _repr_type(self):
|
|
2593
|
+
"""
|
|
2594
|
+
Return string that describes the type of morphism.
|
|
2595
|
+
|
|
2596
|
+
EXAMPLES::
|
|
2597
|
+
|
|
2598
|
+
sage: import numpy # needs numpy
|
|
2599
|
+
sage: f = sage.rings.complex_double.ComplexToCDF(numpy.complex128) # needs numpy
|
|
2600
|
+
sage: f._repr_type() # needs numpy
|
|
2601
|
+
'Native'
|
|
2602
|
+
"""
|
|
2603
|
+
return "Native"
|
|
2604
|
+
|
|
2605
|
+
|
|
2606
|
+
#####################################################
|
|
2607
|
+
# unique objects
|
|
2608
|
+
#####################################################
|
|
2609
|
+
cdef ComplexDoubleField_class _CDF
|
|
2610
|
+
_CDF = ComplexDoubleField_class()
|
|
2611
|
+
CDF = _CDF # external interface
|
|
2612
|
+
cdef ComplexDoubleElement I = ComplexDoubleElement(0, 1)
|
|
2613
|
+
|
|
2614
|
+
|
|
2615
|
+
def ComplexDoubleField():
|
|
2616
|
+
"""
|
|
2617
|
+
Return the field of double precision complex numbers.
|
|
2618
|
+
|
|
2619
|
+
EXAMPLES::
|
|
2620
|
+
|
|
2621
|
+
sage: ComplexDoubleField()
|
|
2622
|
+
Complex Double Field
|
|
2623
|
+
sage: ComplexDoubleField() is CDF
|
|
2624
|
+
True
|
|
2625
|
+
"""
|
|
2626
|
+
return _CDF
|
|
2627
|
+
|
|
2628
|
+
|
|
2629
|
+
from sage.misc.parser import Parser
|
|
2630
|
+
cdef cdf_parser = Parser(float, float, {"I": _CDF.gen(), "i": _CDF.gen()})
|
|
2631
|
+
|
|
2632
|
+
cdef inline libcpp.complex.complex[double] extract_double_complex(ComplexDoubleElement x) noexcept:
|
|
2633
|
+
"""
|
|
2634
|
+
Return the value of ``x`` as a C++ complex<double>
|
|
2635
|
+
"""
|
|
2636
|
+
cdef libcpp.complex.complex[double] z
|
|
2637
|
+
z.real(GSL_REAL(x._complex))
|
|
2638
|
+
z.imag(GSL_IMAG(x._complex))
|
|
2639
|
+
return z
|
|
2640
|
+
|
|
2641
|
+
|
|
2642
|
+
cdef inline ComplexDoubleElement ComplexDoubleElement_from_doubles(double re, double im):
|
|
2643
|
+
"""
|
|
2644
|
+
Create a new :class:`ComplexDoubleElement` with the specified real and
|
|
2645
|
+
imaginary parts.
|
|
2646
|
+
"""
|
|
2647
|
+
z = <ComplexDoubleElement>ComplexDoubleElement.__new__(ComplexDoubleElement)
|
|
2648
|
+
GSL_SET_COMPLEX(&z._complex, re, im)
|
|
2649
|
+
return z
|
|
2650
|
+
|
|
2651
|
+
|
|
2652
|
+
# Support Python's numbers abstract base class
|
|
2653
|
+
import numbers
|
|
2654
|
+
numbers.Complex.register(ComplexDoubleElement)
|