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
sage/matrix/args.pyx
ADDED
|
@@ -0,0 +1,1668 @@
|
|
|
1
|
+
# sage_setup: distribution = sagemath-modules
|
|
2
|
+
# cython: wraparound=False
|
|
3
|
+
# cython: boundscheck=False
|
|
4
|
+
"""
|
|
5
|
+
Helpers for creating matrices
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
#*****************************************************************************
|
|
9
|
+
# Copyright (C) 2018 Jeroen Demeyer <J.Demeyer@UGent.be>
|
|
10
|
+
#
|
|
11
|
+
# This program is free software: you can redistribute it and/or modify
|
|
12
|
+
# it under the terms of the GNU General Public License as published by
|
|
13
|
+
# the Free Software Foundation, either version 2 of the License, or
|
|
14
|
+
# (at your option) any later version.
|
|
15
|
+
# http://www.gnu.org/licenses/
|
|
16
|
+
#*****************************************************************************
|
|
17
|
+
|
|
18
|
+
cimport cython
|
|
19
|
+
from cpython.sequence cimport PySequence_Fast
|
|
20
|
+
from cysignals.signals cimport sig_check
|
|
21
|
+
|
|
22
|
+
MatrixSpace = None
|
|
23
|
+
|
|
24
|
+
from sage.rings.integer_ring import ZZ
|
|
25
|
+
from sage.rings.integer cimport Integer
|
|
26
|
+
from sage.structure.coerce cimport (coercion_model,
|
|
27
|
+
is_numpy_type, py_scalar_parent)
|
|
28
|
+
from sage.structure.element cimport Element, RingElement, Vector
|
|
29
|
+
from sage.arith.long cimport pyobject_to_long
|
|
30
|
+
from sage.misc.misc_c import sized_iter
|
|
31
|
+
from sage.categories import monoids
|
|
32
|
+
from sage.misc.superseded import deprecation_cython
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
try:
|
|
36
|
+
from cypari2.gen import Gen
|
|
37
|
+
except ImportError:
|
|
38
|
+
Gen = ()
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
CommutativeMonoids = monoids.Monoids().Commutative()
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
cdef inline bint element_is_scalar(Element x) noexcept:
|
|
45
|
+
"""
|
|
46
|
+
Should this element be considered a scalar (as opposed to a vector)?
|
|
47
|
+
"""
|
|
48
|
+
# This is mostly guesswork, but after some experimentation the
|
|
49
|
+
# checks below turned out to work well in practice...
|
|
50
|
+
if isinstance(x, RingElement):
|
|
51
|
+
return True
|
|
52
|
+
if x._parent in CommutativeMonoids:
|
|
53
|
+
return True
|
|
54
|
+
return False
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
# We disable cyclic garbage collection and subclassing for efficiency.
|
|
58
|
+
# This class is mainly meant to be used internally by MatrixArgs and
|
|
59
|
+
# typically not in user code.
|
|
60
|
+
@cython.final
|
|
61
|
+
@cython.no_gc
|
|
62
|
+
cdef class SparseEntry:
|
|
63
|
+
"""
|
|
64
|
+
Specialized class for dealing with sparse input in
|
|
65
|
+
:class:`MatrixArgs`. An instance of ``SparseEntry`` represents
|
|
66
|
+
one position in a matrix to be constructed. To construct a sparse
|
|
67
|
+
matrix, one would typically make a list of such.
|
|
68
|
+
|
|
69
|
+
Previous versions of Sage used a ``dict`` as data structure for
|
|
70
|
+
sparse input, but that is not so suitable because the keys are not
|
|
71
|
+
guaranteed to be of the correct format. There is also the
|
|
72
|
+
performance cost of creating tuples of Python integers.
|
|
73
|
+
|
|
74
|
+
Users of this class are expected to know what they are doing, so
|
|
75
|
+
the indices are not checked when constructing a matrix.
|
|
76
|
+
|
|
77
|
+
INPUT:
|
|
78
|
+
|
|
79
|
+
- ``i``, ``j`` -- row and column index
|
|
80
|
+
|
|
81
|
+
- ``entry`` -- value to be put at position `(i,j)`
|
|
82
|
+
|
|
83
|
+
EXAMPLES::
|
|
84
|
+
|
|
85
|
+
sage: from sage.matrix.args import SparseEntry
|
|
86
|
+
sage: SparseEntry(123, 456, "abc")
|
|
87
|
+
SparseEntry(123, 456, 'abc')
|
|
88
|
+
sage: SparseEntry(1/3, 2/3, x) # needs sage.symbolic
|
|
89
|
+
Traceback (most recent call last):
|
|
90
|
+
...
|
|
91
|
+
TypeError: unable to convert rational 1/3 to an integer
|
|
92
|
+
"""
|
|
93
|
+
|
|
94
|
+
def __init__(self, i, j, entry):
|
|
95
|
+
self.i = pyobject_to_long(i)
|
|
96
|
+
self.j = pyobject_to_long(j)
|
|
97
|
+
self.entry = entry
|
|
98
|
+
|
|
99
|
+
def __iter__(self):
|
|
100
|
+
"""
|
|
101
|
+
Iteration for convenience, such as converting to a tuple.
|
|
102
|
+
|
|
103
|
+
EXAMPLES::
|
|
104
|
+
|
|
105
|
+
sage: from sage.matrix.args import SparseEntry
|
|
106
|
+
sage: e = SparseEntry(123, 456, "abc")
|
|
107
|
+
sage: tuple(e)
|
|
108
|
+
(123, 456, 'abc')
|
|
109
|
+
"""
|
|
110
|
+
yield self.i
|
|
111
|
+
yield self.j
|
|
112
|
+
yield self.entry
|
|
113
|
+
|
|
114
|
+
def __repr__(self):
|
|
115
|
+
return f"{type(self).__name__}({self.i}, {self.j}, {self.entry!r})"
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
# We disable cyclic garbage collection for efficiency. This is not a
|
|
119
|
+
# problem because instances should exist only for a short time.
|
|
120
|
+
@cython.no_gc
|
|
121
|
+
cdef class MatrixArgs:
|
|
122
|
+
"""
|
|
123
|
+
Collect arguments for constructing a matrix.
|
|
124
|
+
|
|
125
|
+
This class is meant to pass around arguments, for example from the
|
|
126
|
+
global :func:`matrix` constructor to the matrix space or to the
|
|
127
|
+
element class constructor.
|
|
128
|
+
|
|
129
|
+
A typical use case is first creating a ``MatrixArgs`` instance,
|
|
130
|
+
possibly adjusting the attributes. This instance can then be passed
|
|
131
|
+
around and a matrix can be constructed from it using the
|
|
132
|
+
:meth:`matrix` method. Also, a flat list can be constructed using
|
|
133
|
+
:meth:`list` or a sparse dict using :meth:`dict`. It is safe to
|
|
134
|
+
construct multiple objects (of the same or a different kind) from
|
|
135
|
+
the same ``MatrixArgs`` instance.
|
|
136
|
+
|
|
137
|
+
``MatrixArgs`` also supports iteration using the :meth:`iter`
|
|
138
|
+
method. This is a more low-level interface.
|
|
139
|
+
|
|
140
|
+
When ``MatrixArgs`` produces output, it is first *finalized*. This
|
|
141
|
+
means that all missing attributes are derived or guessed. After
|
|
142
|
+
finalization, you should no longer change the attributes or it will
|
|
143
|
+
end up in an inconsistent state. You can also finalize explicitly by
|
|
144
|
+
calling the :meth:`finalized` method.
|
|
145
|
+
|
|
146
|
+
A ``MatrixArgs`` can contain invalid input. This is not checked when
|
|
147
|
+
constructing the ``MatrixArgs`` instance, but it is checked either
|
|
148
|
+
when finalizing or when constructing an object from it.
|
|
149
|
+
|
|
150
|
+
.. WARNING::
|
|
151
|
+
|
|
152
|
+
Instances of this class should only be temporary, they are not
|
|
153
|
+
meant to be stored long-term.
|
|
154
|
+
|
|
155
|
+
EXAMPLES::
|
|
156
|
+
|
|
157
|
+
sage: from sage.matrix.args import MatrixArgs
|
|
158
|
+
sage: ma = MatrixArgs(2, 2, (x for x in range(4))); ma
|
|
159
|
+
<MatrixArgs for None; typ=UNKNOWN; entries=<generator ...>>
|
|
160
|
+
sage: ma.finalized()
|
|
161
|
+
<MatrixArgs for Full MatrixSpace of 2 by 2 dense matrices
|
|
162
|
+
over Integer Ring; typ=SEQ_FLAT; entries=[0, 1, 2, 3]>
|
|
163
|
+
|
|
164
|
+
Many types of input are possible::
|
|
165
|
+
|
|
166
|
+
sage: ma = MatrixArgs(2, 2, entries=None); ma.finalized()
|
|
167
|
+
<MatrixArgs for Full MatrixSpace of 2 by 2 dense matrices
|
|
168
|
+
over Integer Ring; typ=ZERO; entries=None>
|
|
169
|
+
sage: ma.matrix()
|
|
170
|
+
[0 0]
|
|
171
|
+
[0 0]
|
|
172
|
+
sage: ma = MatrixArgs(2, 2, entries={}); ma.finalized()
|
|
173
|
+
<MatrixArgs for Full MatrixSpace of 2 by 2 sparse matrices
|
|
174
|
+
over Integer Ring; typ=SEQ_SPARSE; entries=[]>
|
|
175
|
+
sage: ma.matrix()
|
|
176
|
+
[0 0]
|
|
177
|
+
[0 0]
|
|
178
|
+
sage: ma = MatrixArgs(2, 2, entries=[1,2,3,4]); ma.finalized()
|
|
179
|
+
<MatrixArgs for Full MatrixSpace of 2 by 2 dense matrices
|
|
180
|
+
over Integer Ring; typ=SEQ_FLAT; entries=[1, 2, 3, 4]>
|
|
181
|
+
sage: ma.matrix()
|
|
182
|
+
[1 2]
|
|
183
|
+
[3 4]
|
|
184
|
+
sage: ma = MatrixArgs(2, 2, entries=math.pi); ma.finalized()
|
|
185
|
+
<MatrixArgs for Full MatrixSpace of 2 by 2 dense matrices
|
|
186
|
+
over Real Double Field; typ=SCALAR; entries=3.141592653589793>
|
|
187
|
+
sage: ma.matrix()
|
|
188
|
+
[3.141592653589793 0.0]
|
|
189
|
+
[ 0.0 3.141592653589793]
|
|
190
|
+
sage: ma = MatrixArgs(2, 2, entries=pi); ma.finalized() # needs sage.symbolic
|
|
191
|
+
<MatrixArgs for Full MatrixSpace of 2 by 2 dense matrices
|
|
192
|
+
over Symbolic Ring; typ=SCALAR; entries=pi>
|
|
193
|
+
sage: ma.matrix() # needs sage.symbolic
|
|
194
|
+
[pi 0]
|
|
195
|
+
[ 0 pi]
|
|
196
|
+
sage: ma = MatrixArgs(ZZ, 2, 2, entries={(0,0): 7}); ma.finalized()
|
|
197
|
+
<MatrixArgs for Full MatrixSpace of 2 by 2 sparse matrices
|
|
198
|
+
over Integer Ring; typ=SEQ_SPARSE; entries=[SparseEntry(0, 0, 7)]>
|
|
199
|
+
sage: ma.matrix()
|
|
200
|
+
[7 0]
|
|
201
|
+
[0 0]
|
|
202
|
+
sage: ma = MatrixArgs(ZZ, 2, 2, entries=((1,2), (3,4))); ma.finalized()
|
|
203
|
+
<MatrixArgs for Full MatrixSpace of 2 by 2 dense matrices
|
|
204
|
+
over Integer Ring; typ=SEQ_SEQ; entries=((1, 2), (3, 4))>
|
|
205
|
+
sage: ma.matrix()
|
|
206
|
+
[1 2]
|
|
207
|
+
[3 4]
|
|
208
|
+
sage: ma = MatrixArgs(ZZ, 2, 2, entries=(1,2,3,4)); ma.finalized()
|
|
209
|
+
<MatrixArgs for Full MatrixSpace of 2 by 2 dense matrices
|
|
210
|
+
over Integer Ring; typ=SEQ_FLAT; entries=(1, 2, 3, 4)>
|
|
211
|
+
sage: ma.matrix()
|
|
212
|
+
[1 2]
|
|
213
|
+
[3 4]
|
|
214
|
+
|
|
215
|
+
sage: # needs sage.libs.pari
|
|
216
|
+
sage: ma = MatrixArgs(QQ, entries=pari("[1,2;3,4]")); ma.finalized()
|
|
217
|
+
<MatrixArgs for Full MatrixSpace of 2 by 2 dense matrices
|
|
218
|
+
over Rational Field; typ=SEQ_FLAT; entries=[1, 2, 3, 4]>
|
|
219
|
+
sage: ma.matrix()
|
|
220
|
+
[1 2]
|
|
221
|
+
[3 4]
|
|
222
|
+
sage: ma = MatrixArgs(QQ, 2, 2, entries=pari("[1,2,3,4]")); ma.finalized()
|
|
223
|
+
<MatrixArgs for Full MatrixSpace of 2 by 2 dense matrices
|
|
224
|
+
over Rational Field; typ=SEQ_FLAT; entries=[1, 2, 3, 4]>
|
|
225
|
+
sage: ma.matrix()
|
|
226
|
+
[1 2]
|
|
227
|
+
[3 4]
|
|
228
|
+
sage: ma = MatrixArgs(QQ, 2, 2, entries=pari("3/5")); ma.finalized()
|
|
229
|
+
<MatrixArgs for Full MatrixSpace of 2 by 2 dense matrices
|
|
230
|
+
over Rational Field; typ=SCALAR; entries=3/5>
|
|
231
|
+
sage: ma.matrix()
|
|
232
|
+
[3/5 0]
|
|
233
|
+
[ 0 3/5]
|
|
234
|
+
|
|
235
|
+
sage: ma = MatrixArgs(entries=matrix(2,2)); ma.finalized()
|
|
236
|
+
<MatrixArgs for Full MatrixSpace of 2 by 2 dense matrices
|
|
237
|
+
over Integer Ring; typ=MATRIX; entries=[0 0]
|
|
238
|
+
[0 0]>
|
|
239
|
+
sage: ma.matrix()
|
|
240
|
+
[0 0]
|
|
241
|
+
[0 0]
|
|
242
|
+
sage: ma = MatrixArgs(2, 2, entries=lambda i,j: 1+2*i+j); ma.finalized()
|
|
243
|
+
<MatrixArgs for Full MatrixSpace of 2 by 2 dense matrices
|
|
244
|
+
over Integer Ring; typ=SEQ_FLAT; entries=[1, 2, 3, 4]>
|
|
245
|
+
sage: ma.matrix()
|
|
246
|
+
[1 2]
|
|
247
|
+
[3 4]
|
|
248
|
+
sage: ma = MatrixArgs(ZZ, 2, 2, entries=lambda i,j: 1+2*i+j); ma.finalized()
|
|
249
|
+
<MatrixArgs for Full MatrixSpace of 2 by 2 dense matrices
|
|
250
|
+
over Integer Ring; typ=CALLABLE; entries=<function ...>>
|
|
251
|
+
sage: ma.matrix()
|
|
252
|
+
[1 2]
|
|
253
|
+
[3 4]
|
|
254
|
+
|
|
255
|
+
sage: # needs numpy
|
|
256
|
+
sage: from numpy import array
|
|
257
|
+
sage: ma = MatrixArgs(array([[1,2],[3,4]])); ma.finalized()
|
|
258
|
+
<MatrixArgs for Full MatrixSpace of 2 by 2 dense matrices
|
|
259
|
+
over Integer Ring; typ=SEQ_SEQ; entries=array([[1, 2], [3, 4]])>
|
|
260
|
+
sage: ma.matrix()
|
|
261
|
+
[1 2]
|
|
262
|
+
[3 4]
|
|
263
|
+
sage: ma = MatrixArgs(array([[1.,2.],[3.,4.]])); ma.finalized()
|
|
264
|
+
<MatrixArgs for Full MatrixSpace of 2 by 2 dense matrices
|
|
265
|
+
over Real Double Field; typ=MATRIX; entries=[1.0 2.0]
|
|
266
|
+
[3.0 4.0]>
|
|
267
|
+
sage: ma.matrix()
|
|
268
|
+
[1.0 2.0]
|
|
269
|
+
[3.0 4.0]
|
|
270
|
+
sage: ma = MatrixArgs(RealField(20), array([[1.,2.],[3.,4.]])); ma.finalized()
|
|
271
|
+
<MatrixArgs for Full MatrixSpace of 2 by 2 dense matrices over Real Field
|
|
272
|
+
with 20 bits of precision; typ=MATRIX; entries=[1.0 2.0]
|
|
273
|
+
[3.0 4.0]>
|
|
274
|
+
sage: ma.matrix()
|
|
275
|
+
[1.0000 2.0000]
|
|
276
|
+
[3.0000 4.0000]
|
|
277
|
+
|
|
278
|
+
sage: # needs sage.graphs
|
|
279
|
+
sage: ma = MatrixArgs(graphs.CycleGraph(3)); ma.finalized()
|
|
280
|
+
<MatrixArgs for Full MatrixSpace of 3 by 3 dense matrices
|
|
281
|
+
over Integer Ring; typ=MATRIX; entries=[0 1 1]
|
|
282
|
+
[1 0 1]
|
|
283
|
+
[1 1 0]>
|
|
284
|
+
sage: ma.matrix()
|
|
285
|
+
[0 1 1]
|
|
286
|
+
[1 0 1]
|
|
287
|
+
[1 1 0]
|
|
288
|
+
|
|
289
|
+
sage: ma = MatrixArgs([vector([0,1], sparse=True),
|
|
290
|
+
....: vector([0,0], sparse=True)], sparse=True)
|
|
291
|
+
sage: ma.finalized()
|
|
292
|
+
<MatrixArgs for Full MatrixSpace of 2 by 2 sparse matrices over
|
|
293
|
+
Integer Ring; typ=SEQ_SPARSE; entries=[SparseEntry(0, 1, 1)]>
|
|
294
|
+
sage: ma.matrix()
|
|
295
|
+
[0 1]
|
|
296
|
+
[0 0]
|
|
297
|
+
|
|
298
|
+
Test invalid input::
|
|
299
|
+
|
|
300
|
+
sage: MatrixArgs(ZZ, 2, 2, entries='abcd').finalized()
|
|
301
|
+
<MatrixArgs for Full MatrixSpace of 2 by 2 dense matrices
|
|
302
|
+
over Integer Ring; typ=SCALAR; entries='abcd'>
|
|
303
|
+
sage: matrix(ZZ, 2, 2, entries='abcd')
|
|
304
|
+
Traceback (most recent call last):
|
|
305
|
+
...
|
|
306
|
+
TypeError: unable to convert 'abcd' to an integer
|
|
307
|
+
sage: MatrixArgs(ZZ, 2, 2, entries=MatrixArgs()).finalized()
|
|
308
|
+
Traceback (most recent call last):
|
|
309
|
+
...
|
|
310
|
+
TypeError: unable to convert <MatrixArgs for None; typ=UNKNOWN; entries=None> to a matrix
|
|
311
|
+
"""
|
|
312
|
+
|
|
313
|
+
def __cinit__(self):
|
|
314
|
+
self.nrows = -1
|
|
315
|
+
self.ncols = -1
|
|
316
|
+
self.sparse = -1
|
|
317
|
+
self.kwds = {}
|
|
318
|
+
|
|
319
|
+
def __init__(self, *args, base_ring=None, nrows=None, ncols=None, entries=None,
|
|
320
|
+
sparse=None, row_keys=None, column_keys=None, space=None, **kwds):
|
|
321
|
+
"""
|
|
322
|
+
Parse arguments for creating a new matrix.
|
|
323
|
+
|
|
324
|
+
See :func:`matrix` for documentation.
|
|
325
|
+
|
|
326
|
+
This typically does not raise errors for invalid input, except
|
|
327
|
+
when the arguments cannot be parsed.
|
|
328
|
+
|
|
329
|
+
EXAMPLES::
|
|
330
|
+
|
|
331
|
+
sage: from sage.matrix.args import MatrixArgs
|
|
332
|
+
sage: MatrixArgs().finalized()
|
|
333
|
+
<MatrixArgs for Full MatrixSpace of 0 by 0 dense matrices over
|
|
334
|
+
Integer Ring; typ=ZERO; entries=None>
|
|
335
|
+
sage: MatrixArgs(1).finalized()
|
|
336
|
+
<MatrixArgs for Full MatrixSpace of 1 by 1 dense matrices over
|
|
337
|
+
Integer Ring; typ=ZERO; entries=None>
|
|
338
|
+
sage: MatrixArgs(1, 1, 3).finalized()
|
|
339
|
+
<MatrixArgs for Full MatrixSpace of 1 by 1 dense matrices over
|
|
340
|
+
Integer Ring; typ=SCALAR; entries=3>
|
|
341
|
+
sage: MatrixArgs(1, 1, 1, 1).finalized()
|
|
342
|
+
Traceback (most recent call last):
|
|
343
|
+
...
|
|
344
|
+
TypeError: too many arguments in matrix constructor
|
|
345
|
+
sage: MatrixArgs(3, nrows=1, ncols=1).finalized()
|
|
346
|
+
<MatrixArgs for Full MatrixSpace of 1 by 1 dense matrices over
|
|
347
|
+
Integer Ring; typ=SCALAR; entries=3>
|
|
348
|
+
sage: MatrixArgs(3, nrows=1).finalized()
|
|
349
|
+
<MatrixArgs for Full MatrixSpace of 1 by 1 dense matrices over
|
|
350
|
+
Integer Ring; typ=SCALAR; entries=3>
|
|
351
|
+
sage: MatrixArgs(3, ncols=1).finalized()
|
|
352
|
+
<MatrixArgs for Full MatrixSpace of 1 by 1 dense matrices over
|
|
353
|
+
Integer Ring; typ=SCALAR; entries=3>
|
|
354
|
+
"""
|
|
355
|
+
if "ring" in kwds.keys():
|
|
356
|
+
deprecation_cython(issue_number=33380, message="ring is deprecated (keyword will be removed in the future). Use base_ring instead", stacklevel=3)
|
|
357
|
+
self.base = kwds.pop("ring")
|
|
358
|
+
else:
|
|
359
|
+
self.base = base_ring
|
|
360
|
+
|
|
361
|
+
if nrows is not None:
|
|
362
|
+
self.set_nrows(pyobject_to_long(nrows))
|
|
363
|
+
if ncols is not None:
|
|
364
|
+
self.set_ncols(pyobject_to_long(ncols))
|
|
365
|
+
self.entries = entries
|
|
366
|
+
if sparse is not None:
|
|
367
|
+
self.sparse = sparse
|
|
368
|
+
if row_keys is not None:
|
|
369
|
+
self.set_row_keys(row_keys)
|
|
370
|
+
if column_keys is not None:
|
|
371
|
+
self.set_column_keys(column_keys)
|
|
372
|
+
if space is not None:
|
|
373
|
+
self.set_space(space)
|
|
374
|
+
self.kwds.update(kwds)
|
|
375
|
+
|
|
376
|
+
# Parse positional arguments (base, nrows, ncols, entries)
|
|
377
|
+
# where each of them is optional.
|
|
378
|
+
cdef Py_ssize_t argi = 0, argc = len(args)
|
|
379
|
+
if argi == argc: return
|
|
380
|
+
|
|
381
|
+
# fast check for certain types of entries which cannot be
|
|
382
|
+
# confused with a base ring or a number.
|
|
383
|
+
arg = args[argc - 1]
|
|
384
|
+
if self.entries is None and isinstance(arg, (list, tuple, dict)):
|
|
385
|
+
self.entries = arg
|
|
386
|
+
argc -= 1
|
|
387
|
+
if argi == argc:
|
|
388
|
+
return
|
|
389
|
+
|
|
390
|
+
# check for base ring argument
|
|
391
|
+
if self.base is None and isinstance(args[argi], Parent):
|
|
392
|
+
self.base = args[argi]
|
|
393
|
+
argi += 1
|
|
394
|
+
if argi == argc:
|
|
395
|
+
return
|
|
396
|
+
|
|
397
|
+
# check positional nrows and ncols argument
|
|
398
|
+
# even if redundant with row_keys, column_keys given as keywords;
|
|
399
|
+
# but do not check for positional row_keys, column_keys arguments
|
|
400
|
+
# -- we do not allow those, as they would be too easy to
|
|
401
|
+
# confuse with entries
|
|
402
|
+
cdef Py_ssize_t k
|
|
403
|
+
cdef long v
|
|
404
|
+
if self.nrows == -1 and self.ncols == -1:
|
|
405
|
+
for k in range(2):
|
|
406
|
+
arg = args[argi]
|
|
407
|
+
if is_numpy_type(type(arg)):
|
|
408
|
+
import numpy
|
|
409
|
+
if isinstance(arg, numpy.ndarray):
|
|
410
|
+
break
|
|
411
|
+
try:
|
|
412
|
+
v = pyobject_to_long(arg)
|
|
413
|
+
except TypeError:
|
|
414
|
+
break
|
|
415
|
+
else:
|
|
416
|
+
if k == 0:
|
|
417
|
+
self.set_nrows(v)
|
|
418
|
+
else:
|
|
419
|
+
self.set_ncols(v)
|
|
420
|
+
argi += 1
|
|
421
|
+
if argi == argc:
|
|
422
|
+
return
|
|
423
|
+
|
|
424
|
+
# check for entries argument
|
|
425
|
+
if self.entries is None:
|
|
426
|
+
self.entries = args[argi]
|
|
427
|
+
argi += 1
|
|
428
|
+
if argi == argc: return
|
|
429
|
+
|
|
430
|
+
raise TypeError("too many arguments in matrix constructor")
|
|
431
|
+
|
|
432
|
+
def __repr__(self):
|
|
433
|
+
"""Print representation for debugging"""
|
|
434
|
+
t = "(invalid)"
|
|
435
|
+
if self.typ == MA_ENTRIES_UNKNOWN:
|
|
436
|
+
t = "UNKNOWN"
|
|
437
|
+
elif self.typ == MA_ENTRIES_ZERO:
|
|
438
|
+
t = "ZERO"
|
|
439
|
+
elif self.typ == MA_ENTRIES_SCALAR:
|
|
440
|
+
t = "SCALAR"
|
|
441
|
+
elif self.typ == MA_ENTRIES_SEQ_SEQ:
|
|
442
|
+
t = "SEQ_SEQ"
|
|
443
|
+
elif self.typ == MA_ENTRIES_SEQ_FLAT:
|
|
444
|
+
t = "SEQ_FLAT"
|
|
445
|
+
elif self.typ == MA_ENTRIES_SEQ_SPARSE:
|
|
446
|
+
t = "SEQ_SPARSE"
|
|
447
|
+
elif self.typ == MA_ENTRIES_CALLABLE:
|
|
448
|
+
t = "CALLABLE"
|
|
449
|
+
elif self.typ == MA_ENTRIES_MATRIX:
|
|
450
|
+
t = "MATRIX"
|
|
451
|
+
elif self.typ == MA_ENTRIES_MAPPING:
|
|
452
|
+
t = "MAPPING"
|
|
453
|
+
elif self.typ == MA_ENTRIES_METHOD:
|
|
454
|
+
t = "METHOD"
|
|
455
|
+
elif self.typ == MA_ENTRIES_NDARRAY:
|
|
456
|
+
t = "NDARRAY"
|
|
457
|
+
return f"<{type(self).__name__} for {self.space}; typ={t}; entries={self.entries!r}>"
|
|
458
|
+
|
|
459
|
+
def __reduce__(self):
|
|
460
|
+
"""
|
|
461
|
+
We intentionally do not support pickling because there should
|
|
462
|
+
not be any use case for it.
|
|
463
|
+
|
|
464
|
+
TESTS::
|
|
465
|
+
|
|
466
|
+
sage: from sage.matrix.args import MatrixArgs
|
|
467
|
+
sage: dumps(MatrixArgs())
|
|
468
|
+
Traceback (most recent call last):
|
|
469
|
+
...
|
|
470
|
+
RuntimeError: pickling MatrixArgs instances is not allowed
|
|
471
|
+
sage: copy(MatrixArgs())
|
|
472
|
+
Traceback (most recent call last):
|
|
473
|
+
...
|
|
474
|
+
RuntimeError: pickling MatrixArgs instances is not allowed
|
|
475
|
+
"""
|
|
476
|
+
raise RuntimeError(f"pickling {type(self).__name__} instances is not allowed")
|
|
477
|
+
|
|
478
|
+
def __iter__(self):
|
|
479
|
+
"""
|
|
480
|
+
Default iteration (dense with conversion).
|
|
481
|
+
|
|
482
|
+
EXAMPLES::
|
|
483
|
+
|
|
484
|
+
sage: from sage.matrix.args import SparseEntry, MatrixArgs
|
|
485
|
+
sage: ma = MatrixArgs(ZZ, 2, 3, iter(range(6)))
|
|
486
|
+
sage: list(ma)
|
|
487
|
+
[0, 1, 2, 3, 4, 5]
|
|
488
|
+
"""
|
|
489
|
+
return self.iter()
|
|
490
|
+
|
|
491
|
+
def iter(self, bint convert=True, bint sparse=False):
|
|
492
|
+
"""
|
|
493
|
+
Iteration over the entries in the matrix.
|
|
494
|
+
|
|
495
|
+
INPUT:
|
|
496
|
+
|
|
497
|
+
- ``convert`` -- if ``True``, the entries are converted to the
|
|
498
|
+
base right; if ``False``, the entries are returned as given
|
|
499
|
+
|
|
500
|
+
- ``sparse`` -- see OUTPUT below
|
|
501
|
+
|
|
502
|
+
OUTPUT: iterator
|
|
503
|
+
|
|
504
|
+
- If ``sparse`` is False: yield all entries of the matrix in
|
|
505
|
+
the following order::
|
|
506
|
+
|
|
507
|
+
[1 2 3]
|
|
508
|
+
[4 5 6]
|
|
509
|
+
|
|
510
|
+
- If ``sparse`` is True: yield instances of
|
|
511
|
+
:class:`SparseEntry`. The indices ``(i, j)`` are guaranteed to
|
|
512
|
+
lie within the matrix. Zero entries in the input are *not*
|
|
513
|
+
skipped.
|
|
514
|
+
|
|
515
|
+
.. WARNING::
|
|
516
|
+
|
|
517
|
+
If an iterator is given as input to :class:`MatrixArgs`, it
|
|
518
|
+
may be exhausted breaking any further usage. Otherwise, it
|
|
519
|
+
is safe to iterate multiple times.
|
|
520
|
+
|
|
521
|
+
EXAMPLES::
|
|
522
|
+
|
|
523
|
+
sage: from sage.matrix.args import SparseEntry, MatrixArgs
|
|
524
|
+
sage: ma = MatrixArgs(ZZ, 2, 3, iter(range(6)))
|
|
525
|
+
sage: list(ma.iter())
|
|
526
|
+
[0, 1, 2, 3, 4, 5]
|
|
527
|
+
sage: ma = MatrixArgs(ZZ, 3, 3, [SparseEntry(0, 0, 0)])
|
|
528
|
+
sage: list(ma.iter())
|
|
529
|
+
Traceback (most recent call last):
|
|
530
|
+
...
|
|
531
|
+
TypeError: dense iteration is not supported for sparse input
|
|
532
|
+
|
|
533
|
+
Sparse examples::
|
|
534
|
+
|
|
535
|
+
sage: ma = MatrixArgs(3, 3, pi) # needs sage.symbolic
|
|
536
|
+
sage: list(ma.iter(sparse=True)) # needs sage.symbolic
|
|
537
|
+
[SparseEntry(0, 0, pi), SparseEntry(1, 1, pi), SparseEntry(2, 2, pi)]
|
|
538
|
+
sage: ma = MatrixArgs(2, 3)
|
|
539
|
+
sage: list(ma.iter(sparse=True))
|
|
540
|
+
[]
|
|
541
|
+
sage: ma = MatrixArgs(2, 2, lambda i, j: i > j)
|
|
542
|
+
sage: list(ma.iter(convert=False, sparse=True))
|
|
543
|
+
[SparseEntry(0, 0, False),
|
|
544
|
+
SparseEntry(0, 1, False),
|
|
545
|
+
SparseEntry(1, 0, True),
|
|
546
|
+
SparseEntry(1, 1, False)]
|
|
547
|
+
sage: ma = MatrixArgs(2, 2, {(1,0):88, (0,1):89})
|
|
548
|
+
sage: sorted(tuple(x) for x in ma.iter(sparse=True))
|
|
549
|
+
[(0, 1, 89), (1, 0, 88)]
|
|
550
|
+
sage: ma = MatrixArgs(QQ, 2, 1, {(1,0):88, (0,1):89})
|
|
551
|
+
sage: ma.finalized()
|
|
552
|
+
Traceback (most recent call last):
|
|
553
|
+
...
|
|
554
|
+
IndexError: invalid column index 1
|
|
555
|
+
sage: ma = MatrixArgs(QQ, 1, 2, {(1,0):88, (0,1):89})
|
|
556
|
+
sage: ma.finalized()
|
|
557
|
+
Traceback (most recent call last):
|
|
558
|
+
...
|
|
559
|
+
IndexError: invalid row index 1
|
|
560
|
+
"""
|
|
561
|
+
self.finalize()
|
|
562
|
+
|
|
563
|
+
cdef long i, j
|
|
564
|
+
cdef SparseEntry se
|
|
565
|
+
if self.typ == MA_ENTRIES_ZERO:
|
|
566
|
+
if sparse:
|
|
567
|
+
pass
|
|
568
|
+
else:
|
|
569
|
+
self._ensure_nrows_ncols()
|
|
570
|
+
zero = self.base.zero()
|
|
571
|
+
for i in range(self.nrows):
|
|
572
|
+
for j in range(self.ncols):
|
|
573
|
+
sig_check()
|
|
574
|
+
yield zero
|
|
575
|
+
elif self.typ == MA_ENTRIES_SCALAR:
|
|
576
|
+
self._ensure_nrows_ncols()
|
|
577
|
+
diag = self.entries
|
|
578
|
+
if convert and self.need_to_convert(diag):
|
|
579
|
+
diag = self.base(diag)
|
|
580
|
+
if sparse:
|
|
581
|
+
for i in range(self.nrows):
|
|
582
|
+
sig_check()
|
|
583
|
+
yield make_SparseEntry(i, i, diag)
|
|
584
|
+
else:
|
|
585
|
+
zero = self.base.zero()
|
|
586
|
+
for i in range(self.nrows):
|
|
587
|
+
for j in range(self.ncols):
|
|
588
|
+
sig_check()
|
|
589
|
+
yield diag if (i == j) else zero
|
|
590
|
+
elif self.typ == MA_ENTRIES_SEQ_SEQ:
|
|
591
|
+
self._ensure_nrows_ncols()
|
|
592
|
+
row_iter = sized_iter(self.entries, self.nrows)
|
|
593
|
+
for i in range(self.nrows):
|
|
594
|
+
row = sized_iter(next(row_iter), self.ncols)
|
|
595
|
+
for j in range(self.ncols):
|
|
596
|
+
sig_check()
|
|
597
|
+
x = next(row)
|
|
598
|
+
if convert and self.need_to_convert(x):
|
|
599
|
+
x = self.base(x)
|
|
600
|
+
if sparse:
|
|
601
|
+
yield make_SparseEntry(i, j, x)
|
|
602
|
+
else:
|
|
603
|
+
yield x
|
|
604
|
+
elif self.typ == MA_ENTRIES_SEQ_FLAT:
|
|
605
|
+
self._ensure_nrows_ncols()
|
|
606
|
+
it = sized_iter(self.entries, self.nrows * self.ncols)
|
|
607
|
+
for i in range(self.nrows):
|
|
608
|
+
for j in range(self.ncols):
|
|
609
|
+
sig_check()
|
|
610
|
+
x = next(it)
|
|
611
|
+
if convert and self.need_to_convert(x):
|
|
612
|
+
x = self.base(x)
|
|
613
|
+
if sparse:
|
|
614
|
+
yield make_SparseEntry(i, j, x)
|
|
615
|
+
else:
|
|
616
|
+
yield x
|
|
617
|
+
elif self.typ == MA_ENTRIES_SEQ_SPARSE:
|
|
618
|
+
if sparse:
|
|
619
|
+
for t in self.entries:
|
|
620
|
+
sig_check()
|
|
621
|
+
se = <SparseEntry>t
|
|
622
|
+
if convert and self.need_to_convert(se.entry):
|
|
623
|
+
se = make_SparseEntry(se.i, se.j, self.base(se.entry))
|
|
624
|
+
yield se
|
|
625
|
+
else:
|
|
626
|
+
raise TypeError("dense iteration is not supported for sparse input")
|
|
627
|
+
elif self.typ == MA_ENTRIES_CALLABLE:
|
|
628
|
+
f = self.entries
|
|
629
|
+
row_keys = self.row_keys
|
|
630
|
+
if row_keys is None:
|
|
631
|
+
row_keys = range(self.nrows)
|
|
632
|
+
column_keys = self.column_keys
|
|
633
|
+
if column_keys is None:
|
|
634
|
+
column_keys = range(self.ncols)
|
|
635
|
+
for i in row_keys:
|
|
636
|
+
for j in column_keys:
|
|
637
|
+
sig_check()
|
|
638
|
+
x = f(i, j)
|
|
639
|
+
if convert and self.need_to_convert(x):
|
|
640
|
+
x = self.base(x)
|
|
641
|
+
if sparse:
|
|
642
|
+
yield make_SparseEntry(i, j, x)
|
|
643
|
+
else:
|
|
644
|
+
yield x
|
|
645
|
+
elif self.typ == MA_ENTRIES_MATRIX:
|
|
646
|
+
m = self.entries
|
|
647
|
+
for i in range(self.nrows):
|
|
648
|
+
for j in range(self.ncols):
|
|
649
|
+
sig_check()
|
|
650
|
+
x = m[i, j]
|
|
651
|
+
if convert and self.need_to_convert(x):
|
|
652
|
+
x = self.base(x)
|
|
653
|
+
if sparse:
|
|
654
|
+
yield make_SparseEntry(i, j, x)
|
|
655
|
+
else:
|
|
656
|
+
yield x
|
|
657
|
+
else:
|
|
658
|
+
raise AssertionError(f"unknown MatrixArgs type {self.typ}")
|
|
659
|
+
|
|
660
|
+
def __len__(self):
|
|
661
|
+
"""
|
|
662
|
+
EXAMPLES::
|
|
663
|
+
|
|
664
|
+
sage: from sage.matrix.args import MatrixArgs
|
|
665
|
+
sage: len(MatrixArgs(3, 14))
|
|
666
|
+
42
|
|
667
|
+
"""
|
|
668
|
+
self.finalize()
|
|
669
|
+
self._ensure_nrows_ncols()
|
|
670
|
+
return self.nrows * self.ncols
|
|
671
|
+
|
|
672
|
+
cpdef Matrix matrix(self, bint convert=True):
|
|
673
|
+
"""
|
|
674
|
+
Return the entries of the matrix as a Sage Matrix.
|
|
675
|
+
|
|
676
|
+
If possible, this returns a direct reference to
|
|
677
|
+
``self.entries`` without copying.
|
|
678
|
+
|
|
679
|
+
INPUT:
|
|
680
|
+
|
|
681
|
+
- ``convert`` -- if ``True``, the matrix is guaranteed to have
|
|
682
|
+
the correct parent matrix space. If ``False``, the input matrix
|
|
683
|
+
may be returned even if it lies in the wrong space.
|
|
684
|
+
|
|
685
|
+
.. NOTE::
|
|
686
|
+
|
|
687
|
+
This changes ``self.entries`` to the returned matrix. This
|
|
688
|
+
means that it is unsafe to access the ``self.entries``
|
|
689
|
+
attribute after calling this method.
|
|
690
|
+
|
|
691
|
+
EXAMPLES::
|
|
692
|
+
|
|
693
|
+
sage: from sage.matrix.args import MatrixArgs
|
|
694
|
+
sage: M = matrix(2, 3, range(6), sparse=True)
|
|
695
|
+
|
|
696
|
+
::
|
|
697
|
+
|
|
698
|
+
sage: ma = MatrixArgs(M); ma.finalized()
|
|
699
|
+
<MatrixArgs for Full MatrixSpace of 2 by 3 sparse matrices
|
|
700
|
+
over Integer Ring; typ=MATRIX; entries=[0 1 2]
|
|
701
|
+
[3 4 5]>
|
|
702
|
+
sage: ma.matrix()
|
|
703
|
+
[0 1 2]
|
|
704
|
+
[3 4 5]
|
|
705
|
+
|
|
706
|
+
::
|
|
707
|
+
|
|
708
|
+
sage: ma = MatrixArgs(M, sparse=False); ma.finalized()
|
|
709
|
+
<MatrixArgs for Full MatrixSpace of 2 by 3 dense matrices
|
|
710
|
+
over Integer Ring; typ=MATRIX; entries=[0 1 2]
|
|
711
|
+
[3 4 5]>
|
|
712
|
+
sage: ma.matrix()
|
|
713
|
+
[0 1 2]
|
|
714
|
+
[3 4 5]
|
|
715
|
+
|
|
716
|
+
::
|
|
717
|
+
|
|
718
|
+
sage: ma = MatrixArgs(RDF, M); ma.finalized()
|
|
719
|
+
<MatrixArgs for Full MatrixSpace of 2 by 3 sparse matrices
|
|
720
|
+
over Real Double Field; typ=MATRIX; entries=[0 1 2]
|
|
721
|
+
[3 4 5]>
|
|
722
|
+
sage: ma.matrix(convert=False)
|
|
723
|
+
[0 1 2]
|
|
724
|
+
[3 4 5]
|
|
725
|
+
sage: ma.matrix()
|
|
726
|
+
[0.0 1.0 2.0]
|
|
727
|
+
[3.0 4.0 5.0]
|
|
728
|
+
|
|
729
|
+
If we remove our reference to the input ``M``, no copy is made::
|
|
730
|
+
|
|
731
|
+
sage: idM = id(M)
|
|
732
|
+
sage: ma = MatrixArgs(M)
|
|
733
|
+
sage: del M
|
|
734
|
+
sage: M = ma.matrix()
|
|
735
|
+
sage: id(M) == idM
|
|
736
|
+
True
|
|
737
|
+
|
|
738
|
+
Immutable matrices are never copied::
|
|
739
|
+
|
|
740
|
+
sage: M.set_immutable()
|
|
741
|
+
sage: matrix(M) is M
|
|
742
|
+
True
|
|
743
|
+
"""
|
|
744
|
+
self.finalize()
|
|
745
|
+
|
|
746
|
+
cdef Matrix M
|
|
747
|
+
for _ in range(1):
|
|
748
|
+
if self.typ == MA_ENTRIES_MATRIX:
|
|
749
|
+
safe = self.ref_safe() # Check this before assigning M
|
|
750
|
+
M = <Matrix>self.entries
|
|
751
|
+
if M._parent is self.space or not convert:
|
|
752
|
+
if not (safe or M.is_immutable()):
|
|
753
|
+
M = M.__copy__()
|
|
754
|
+
break
|
|
755
|
+
else:
|
|
756
|
+
space = self.space
|
|
757
|
+
global MatrixSpace
|
|
758
|
+
if MatrixSpace is None:
|
|
759
|
+
from sage.matrix.matrix_space import MatrixSpace
|
|
760
|
+
if not isinstance(space, MatrixSpace):
|
|
761
|
+
space = space.zero().matrix(side='left').parent()
|
|
762
|
+
M = space(self, coerce=convert)
|
|
763
|
+
|
|
764
|
+
# Also store the matrix to support multiple calls of matrix()
|
|
765
|
+
self.entries = M
|
|
766
|
+
self.typ = MA_ENTRIES_MATRIX
|
|
767
|
+
return M
|
|
768
|
+
|
|
769
|
+
cpdef element(self, bint immutable=False):
|
|
770
|
+
r"""
|
|
771
|
+
Return the matrix or morphism.
|
|
772
|
+
|
|
773
|
+
INPUT:
|
|
774
|
+
|
|
775
|
+
- ``immutable`` -- boolean; if ``True``, the result will be immutable
|
|
776
|
+
|
|
777
|
+
OUTPUT: an element of ``self.space``
|
|
778
|
+
|
|
779
|
+
.. NOTE::
|
|
780
|
+
|
|
781
|
+
This may change ``self.entries``, making it unsafe to access the
|
|
782
|
+
``self.entries`` attribute after calling this method.
|
|
783
|
+
|
|
784
|
+
EXAMPLES::
|
|
785
|
+
|
|
786
|
+
sage: from sage.matrix.args import MatrixArgs
|
|
787
|
+
sage: M = matrix(2, 3, range(6), sparse=True)
|
|
788
|
+
sage: ma = MatrixArgs(M); ma.finalized()
|
|
789
|
+
<MatrixArgs for
|
|
790
|
+
Full MatrixSpace of 2 by 3 sparse matrices over Integer Ring;
|
|
791
|
+
typ=MATRIX; entries=[0 1 2]
|
|
792
|
+
[3 4 5]>
|
|
793
|
+
sage: M2 = ma.element(immutable=True); M2.parent()
|
|
794
|
+
Full MatrixSpace of 2 by 3 sparse matrices over Integer Ring
|
|
795
|
+
sage: M2.is_immutable()
|
|
796
|
+
True
|
|
797
|
+
|
|
798
|
+
sage: ma = MatrixArgs(M, row_keys=['u','v'], column_keys=['a','b','c'])
|
|
799
|
+
sage: ma.finalized()
|
|
800
|
+
<MatrixArgs for
|
|
801
|
+
Set of Morphisms
|
|
802
|
+
from Free module generated by {'a', 'b', 'c'} over Integer Ring
|
|
803
|
+
to Free module generated by {'u', 'v'} over Integer Ring
|
|
804
|
+
in Category of finite dimensional modules with basis over Integer Ring;
|
|
805
|
+
typ=MATRIX; entries=[0 1 2]
|
|
806
|
+
[3 4 5]>
|
|
807
|
+
sage: phi = ma.element(); phi
|
|
808
|
+
Generic morphism:
|
|
809
|
+
From: Free module generated by {'a', 'b', 'c'} over Integer Ring
|
|
810
|
+
To: Free module generated by {'u', 'v'} over Integer Ring
|
|
811
|
+
"""
|
|
812
|
+
self.finalize()
|
|
813
|
+
cdef Matrix M = self.matrix(convert=True)
|
|
814
|
+
if immutable:
|
|
815
|
+
M.set_immutable()
|
|
816
|
+
global MatrixSpace
|
|
817
|
+
if MatrixSpace is None:
|
|
818
|
+
from sage.matrix.matrix_space import MatrixSpace
|
|
819
|
+
if isinstance(self.space, MatrixSpace):
|
|
820
|
+
return M
|
|
821
|
+
return self.space(matrix=M, side='left')
|
|
822
|
+
|
|
823
|
+
cpdef list list(self, bint convert=True):
|
|
824
|
+
"""
|
|
825
|
+
Return the entries of the matrix as a flat list of scalars.
|
|
826
|
+
|
|
827
|
+
If possible and ``convert=False``, this returns a direct
|
|
828
|
+
reference to ``self.entries`` without copying.
|
|
829
|
+
|
|
830
|
+
INPUT:
|
|
831
|
+
|
|
832
|
+
- ``convert`` -- if ``True``, the entries are converted to the base
|
|
833
|
+
ring; otherwise, the entries are returned as given
|
|
834
|
+
|
|
835
|
+
.. NOTE::
|
|
836
|
+
|
|
837
|
+
This changes ``self.entries`` to the returned list. This
|
|
838
|
+
means that it is unsafe to access the ``self.entries``
|
|
839
|
+
attribute after calling this method.
|
|
840
|
+
|
|
841
|
+
EXAMPLES::
|
|
842
|
+
|
|
843
|
+
sage: from sage.matrix.args import MatrixArgs
|
|
844
|
+
sage: L = list(range(6))
|
|
845
|
+
sage: MatrixArgs(2, 3, L).list()
|
|
846
|
+
[0, 1, 2, 3, 4, 5]
|
|
847
|
+
|
|
848
|
+
::
|
|
849
|
+
|
|
850
|
+
sage: ma = MatrixArgs(RDF, 2, 3, L)
|
|
851
|
+
sage: ma.list(convert=False)
|
|
852
|
+
[0, 1, 2, 3, 4, 5]
|
|
853
|
+
sage: ma.list()
|
|
854
|
+
[0.0, 1.0, 2.0, 3.0, 4.0, 5.0]
|
|
855
|
+
|
|
856
|
+
If we remove our reference to the input ``L`` and
|
|
857
|
+
``convert=False``, no copy is made::
|
|
858
|
+
|
|
859
|
+
sage: idL = id(L)
|
|
860
|
+
sage: ma = MatrixArgs(2, 3, L)
|
|
861
|
+
sage: del L
|
|
862
|
+
sage: L = ma.list(convert=False)
|
|
863
|
+
sage: id(L) == idL
|
|
864
|
+
True
|
|
865
|
+
"""
|
|
866
|
+
self.finalize()
|
|
867
|
+
|
|
868
|
+
cdef list L
|
|
869
|
+
if self.typ == MA_ENTRIES_SEQ_FLAT and not convert:
|
|
870
|
+
# Try to reuse existing list
|
|
871
|
+
if type(self.entries) is not list:
|
|
872
|
+
L = list(self.entries)
|
|
873
|
+
else:
|
|
874
|
+
safe = self.ref_safe() # Check this before assigning L
|
|
875
|
+
L = <list>self.entries
|
|
876
|
+
if not safe:
|
|
877
|
+
L = L[:]
|
|
878
|
+
else:
|
|
879
|
+
L = list(self.iter(convert))
|
|
880
|
+
|
|
881
|
+
cdef long N = self.nrows * self.ncols
|
|
882
|
+
if len(L) != N:
|
|
883
|
+
raise ValueError(f"entries has the wrong length (expected {N}, got {len(L)})")
|
|
884
|
+
|
|
885
|
+
# Also store the list to support multiple calls of list()
|
|
886
|
+
self.entries = L
|
|
887
|
+
self.typ = MA_ENTRIES_SEQ_FLAT
|
|
888
|
+
return L
|
|
889
|
+
|
|
890
|
+
cpdef dict dict(self, bint convert=True):
|
|
891
|
+
"""
|
|
892
|
+
Return the entries of the matrix as a :class:`dict`.
|
|
893
|
+
|
|
894
|
+
The keys of this :class:`dict` are the nonzero positions ``(i,j)``. The
|
|
895
|
+
corresponding value is the entry at that position. Zero values are skipped.
|
|
896
|
+
|
|
897
|
+
If ``convert`` is ``True``, the entries are converted to the base
|
|
898
|
+
ring. Otherwise, the entries are returned as given.
|
|
899
|
+
|
|
900
|
+
EXAMPLES::
|
|
901
|
+
|
|
902
|
+
sage: from sage.matrix.args import MatrixArgs
|
|
903
|
+
sage: L = list(range(6))
|
|
904
|
+
sage: MatrixArgs(2, 3, L).dict()
|
|
905
|
+
{(0, 1): 1, (0, 2): 2, (1, 0): 3, (1, 1): 4, (1, 2): 5}
|
|
906
|
+
|
|
907
|
+
::
|
|
908
|
+
|
|
909
|
+
sage: ma = MatrixArgs(GF(2), 2, 3, L)
|
|
910
|
+
sage: ma.dict(convert=False)
|
|
911
|
+
{(0, 1): 1, (0, 2): 2, (1, 0): 3, (1, 1): 4, (1, 2): 5}
|
|
912
|
+
sage: ma.dict()
|
|
913
|
+
{(0, 1): 1, (1, 0): 1, (1, 2): 1}
|
|
914
|
+
"""
|
|
915
|
+
self.finalize()
|
|
916
|
+
|
|
917
|
+
cdef dict D = {}
|
|
918
|
+
for t in self.iter(convert, True):
|
|
919
|
+
se = <SparseEntry>t
|
|
920
|
+
x = se.entry
|
|
921
|
+
if x:
|
|
922
|
+
D[se.i, se.j] = x
|
|
923
|
+
return D
|
|
924
|
+
|
|
925
|
+
cpdef int set_column_keys(self, column_keys) except -1:
|
|
926
|
+
"""
|
|
927
|
+
Set the column keys with consistency checking.
|
|
928
|
+
|
|
929
|
+
If the value was previously set, it must remain the same.
|
|
930
|
+
|
|
931
|
+
EXAMPLES::
|
|
932
|
+
|
|
933
|
+
sage: from sage.matrix.args import MatrixArgs
|
|
934
|
+
sage: ma = MatrixArgs(2, 4)
|
|
935
|
+
sage: ma.set_column_keys('xyz')
|
|
936
|
+
Traceback (most recent call last):
|
|
937
|
+
...
|
|
938
|
+
ValueError: inconsistent column keys: should be of cardinality 4 but got xyz
|
|
939
|
+
sage: ma.set_column_keys('abcd')
|
|
940
|
+
0
|
|
941
|
+
sage: ma.finalized()
|
|
942
|
+
<MatrixArgs for
|
|
943
|
+
Set of Morphisms
|
|
944
|
+
from Free module generated by {'a', 'b', 'c', 'd'} over Integer Ring
|
|
945
|
+
to Ambient free module of rank 2 over the principal ideal domain
|
|
946
|
+
Integer Ring
|
|
947
|
+
in Category of finite dimensional modules with basis over
|
|
948
|
+
(Dedekind domains and euclidean domains
|
|
949
|
+
and noetherian rings and infinite enumerated sets
|
|
950
|
+
and metric spaces);
|
|
951
|
+
typ=ZERO; entries=None>
|
|
952
|
+
"""
|
|
953
|
+
if self.column_keys is not None and self.column_keys != column_keys:
|
|
954
|
+
raise ValueError(f"inconsistent column keys: should be {self.column_keys} "
|
|
955
|
+
f"but got {column_keys}")
|
|
956
|
+
cdef long p = self.ncols
|
|
957
|
+
if p != -1 and p != len(column_keys):
|
|
958
|
+
raise ValueError(f"inconsistent column keys: should be of cardinality {self.ncols} "
|
|
959
|
+
f"but got {column_keys}")
|
|
960
|
+
self.column_keys = column_keys
|
|
961
|
+
|
|
962
|
+
cpdef int set_row_keys(self, row_keys) except -1:
|
|
963
|
+
"""
|
|
964
|
+
Set the row keys with consistency checking.
|
|
965
|
+
|
|
966
|
+
If the value was previously set, it must remain the same.
|
|
967
|
+
|
|
968
|
+
EXAMPLES::
|
|
969
|
+
|
|
970
|
+
sage: from sage.matrix.args import MatrixArgs
|
|
971
|
+
sage: ma = MatrixArgs(2, 4)
|
|
972
|
+
sage: ma.set_row_keys('xyz')
|
|
973
|
+
Traceback (most recent call last):
|
|
974
|
+
...
|
|
975
|
+
ValueError: inconsistent row keys: should be of cardinality 2 but got xyz
|
|
976
|
+
sage: ma.set_row_keys(['u', 'v'])
|
|
977
|
+
0
|
|
978
|
+
sage: ma.finalized()
|
|
979
|
+
<MatrixArgs for
|
|
980
|
+
Set of Morphisms
|
|
981
|
+
from Ambient free module of rank 4 over the principal ideal domain
|
|
982
|
+
Integer Ring
|
|
983
|
+
to Free module generated by {'u', 'v'} over Integer Ring
|
|
984
|
+
in Category of finite dimensional modules with basis over
|
|
985
|
+
(Dedekind domains and euclidean domains
|
|
986
|
+
and noetherian rings and infinite enumerated sets
|
|
987
|
+
and metric spaces);
|
|
988
|
+
typ=ZERO; entries=None>
|
|
989
|
+
"""
|
|
990
|
+
if self.row_keys is not None and self.row_keys != row_keys:
|
|
991
|
+
raise ValueError(f"inconsistent row keys: should be {self.row_keys} "
|
|
992
|
+
f"but got {row_keys}")
|
|
993
|
+
if self.nrows != -1 and self.nrows != len(row_keys):
|
|
994
|
+
raise ValueError(f"inconsistent row keys: should be of cardinality {self.nrows} "
|
|
995
|
+
f"but got {row_keys}")
|
|
996
|
+
self.row_keys = row_keys
|
|
997
|
+
|
|
998
|
+
cpdef int set_space(self, space) except -1:
|
|
999
|
+
"""
|
|
1000
|
+
Set inputs from a given matrix space.
|
|
1001
|
+
|
|
1002
|
+
INPUT:
|
|
1003
|
+
|
|
1004
|
+
- ``space`` -- a :class:`MatrixSpace` or a homset of modules with basis
|
|
1005
|
+
|
|
1006
|
+
EXAMPLES::
|
|
1007
|
+
|
|
1008
|
+
sage: from sage.matrix.args import MatrixArgs
|
|
1009
|
+
sage: ma = MatrixArgs()
|
|
1010
|
+
sage: S = MatrixSpace(QQ, 3, 2, sparse=True)
|
|
1011
|
+
sage: _ = ma.set_space(S)
|
|
1012
|
+
sage: ma.finalized()
|
|
1013
|
+
<MatrixArgs for Full MatrixSpace of 3 by 2 sparse matrices
|
|
1014
|
+
over Rational Field; typ=ZERO; entries=None>
|
|
1015
|
+
sage: M = ma.matrix(); M
|
|
1016
|
+
[0 0]
|
|
1017
|
+
[0 0]
|
|
1018
|
+
[0 0]
|
|
1019
|
+
sage: M.parent() is S
|
|
1020
|
+
True
|
|
1021
|
+
|
|
1022
|
+
From a homset::
|
|
1023
|
+
|
|
1024
|
+
sage: C = CombinatorialFreeModule(ZZ, ['a', 'b', 'c'])
|
|
1025
|
+
sage: R = CombinatorialFreeModule(ZZ, ['u', 'v'])
|
|
1026
|
+
sage: S = Hom(C, R); S
|
|
1027
|
+
Set of Morphisms
|
|
1028
|
+
from Free module generated by {'a', 'b', 'c'} over Integer Ring
|
|
1029
|
+
to Free module generated by {'u', 'v'} over Integer Ring
|
|
1030
|
+
in Category of finite dimensional modules with basis over Integer Ring
|
|
1031
|
+
sage: ma = MatrixArgs()
|
|
1032
|
+
sage: _ = ma.set_space(S)
|
|
1033
|
+
sage: ma.finalized()
|
|
1034
|
+
<MatrixArgs for Set of Morphisms
|
|
1035
|
+
from Free module generated by {'a', 'b', 'c'} over Integer Ring
|
|
1036
|
+
to Free module generated by {'u', 'v'} over Integer Ring
|
|
1037
|
+
in Category of finite dimensional modules with basis over Integer Ring;
|
|
1038
|
+
typ=ZERO; entries=None>
|
|
1039
|
+
"""
|
|
1040
|
+
if self.space is not None:
|
|
1041
|
+
return 0 # TODO: ??????
|
|
1042
|
+
self.space = <Parent?>space
|
|
1043
|
+
try:
|
|
1044
|
+
self.set_nrows(space.nrows())
|
|
1045
|
+
self.set_ncols(space.ncols())
|
|
1046
|
+
self.base = space._base
|
|
1047
|
+
self.sparse = space.is_sparse()
|
|
1048
|
+
except AttributeError:
|
|
1049
|
+
self.set_row_keys(space.codomain().basis().keys())
|
|
1050
|
+
self.set_column_keys(space.domain().basis().keys())
|
|
1051
|
+
self.base = space.base_ring()
|
|
1052
|
+
|
|
1053
|
+
def finalized(self):
|
|
1054
|
+
"""
|
|
1055
|
+
Determine all missing values.
|
|
1056
|
+
|
|
1057
|
+
Depending on the input, this might be a non-trivial operation.
|
|
1058
|
+
In some cases, this will do most of the work of constructing the
|
|
1059
|
+
matrix. That is actually not a problem since we eventually want
|
|
1060
|
+
to construct the matrix anyway. However, care is taken to avoid
|
|
1061
|
+
double work or needless checking or copying.
|
|
1062
|
+
|
|
1063
|
+
OUTPUT: ``self``
|
|
1064
|
+
|
|
1065
|
+
EXAMPLES::
|
|
1066
|
+
|
|
1067
|
+
sage: from sage.matrix.args import MatrixArgs
|
|
1068
|
+
sage: MatrixArgs(pi).finalized() # needs sage.symbolic
|
|
1069
|
+
Traceback (most recent call last):
|
|
1070
|
+
...
|
|
1071
|
+
TypeError: the dimensions of the matrix must be specified
|
|
1072
|
+
sage: MatrixArgs(RR, pi).finalized() # needs sage.symbolic
|
|
1073
|
+
Traceback (most recent call last):
|
|
1074
|
+
...
|
|
1075
|
+
TypeError: the dimensions of the matrix must be specified
|
|
1076
|
+
sage: MatrixArgs(2, 3, 0.0).finalized()
|
|
1077
|
+
<MatrixArgs for Full MatrixSpace of 2 by 3 dense matrices over Real
|
|
1078
|
+
Field with 53 bits of precision; typ=ZERO; entries=0.000000000000000>
|
|
1079
|
+
sage: MatrixArgs(RR, 2, 3, 1.0).finalized()
|
|
1080
|
+
Traceback (most recent call last):
|
|
1081
|
+
...
|
|
1082
|
+
TypeError: nonzero scalar matrix must be square
|
|
1083
|
+
|
|
1084
|
+
Check :issue:`19134`::
|
|
1085
|
+
|
|
1086
|
+
sage: matrix(2, 3, [])
|
|
1087
|
+
Traceback (most recent call last):
|
|
1088
|
+
...
|
|
1089
|
+
ValueError: sequence too short (expected length 6, got 0)
|
|
1090
|
+
sage: matrix(ZZ, 2, 3, [])
|
|
1091
|
+
Traceback (most recent call last):
|
|
1092
|
+
...
|
|
1093
|
+
ValueError: sequence too short (expected length 6, got 0)
|
|
1094
|
+
sage: matrix(2, 3, [1])
|
|
1095
|
+
Traceback (most recent call last):
|
|
1096
|
+
...
|
|
1097
|
+
ValueError: sequence too short (expected length 6, got 1)
|
|
1098
|
+
|
|
1099
|
+
Check github issue #36065:
|
|
1100
|
+
|
|
1101
|
+
sage: # needs sage.rings.number_field
|
|
1102
|
+
sage: class MyAlgebraicNumber(sage.rings.qqbar.AlgebraicNumber):
|
|
1103
|
+
....: def __bool__(self):
|
|
1104
|
+
....: raise ValueError
|
|
1105
|
+
sage: matrix(1, 1, MyAlgebraicNumber(0))
|
|
1106
|
+
[0]
|
|
1107
|
+
sage: matrix(1, 1, MyAlgebraicNumber(3))
|
|
1108
|
+
[3]
|
|
1109
|
+
sage: matrix(1, 2, MyAlgebraicNumber(0))
|
|
1110
|
+
Traceback (most recent call last):
|
|
1111
|
+
...
|
|
1112
|
+
TypeError: scalar matrix must be square if the value cannot be determined to be zero
|
|
1113
|
+
sage: matrix(1, 2, MyAlgebraicNumber(3))
|
|
1114
|
+
Traceback (most recent call last):
|
|
1115
|
+
...
|
|
1116
|
+
TypeError: scalar matrix must be square if the value cannot be determined to be zero
|
|
1117
|
+
"""
|
|
1118
|
+
self.finalize()
|
|
1119
|
+
return self
|
|
1120
|
+
|
|
1121
|
+
cdef int finalize(self) except -1:
|
|
1122
|
+
# See finalized() for doc
|
|
1123
|
+
if self.is_finalized:
|
|
1124
|
+
return 0
|
|
1125
|
+
|
|
1126
|
+
if self.typ == MA_ENTRIES_UNKNOWN:
|
|
1127
|
+
self.typ = self.get_type()
|
|
1128
|
+
if self.typ == MA_ENTRIES_UNKNOWN:
|
|
1129
|
+
raise TypeError(f"unable to convert {self.entries!r} to a matrix")
|
|
1130
|
+
|
|
1131
|
+
# Can we assume a square matrix?
|
|
1132
|
+
if self.typ & MA_FLAG_ASSUME_SQUARE:
|
|
1133
|
+
# TODO: Handle column_keys/row_keys
|
|
1134
|
+
if self.ncols == -1:
|
|
1135
|
+
if self.nrows != -1:
|
|
1136
|
+
self.ncols = self.nrows
|
|
1137
|
+
elif self.typ == MA_ENTRIES_ZERO:
|
|
1138
|
+
# Special case for the zero matrix:
|
|
1139
|
+
# assume zero rows and columns
|
|
1140
|
+
self.nrows = self.ncols = 0
|
|
1141
|
+
elif self.nrows == -1:
|
|
1142
|
+
self.nrows = self.ncols
|
|
1143
|
+
|
|
1144
|
+
# Process some types to other types
|
|
1145
|
+
if not self.typ & MA_FLAG_FINAL:
|
|
1146
|
+
if self.typ == MA_ENTRIES_MAPPING:
|
|
1147
|
+
self.process_mapping()
|
|
1148
|
+
elif self.typ == MA_ENTRIES_METHOD:
|
|
1149
|
+
self.process_method()
|
|
1150
|
+
elif self.typ == MA_ENTRIES_NDARRAY:
|
|
1151
|
+
self.process_ndarray()
|
|
1152
|
+
else:
|
|
1153
|
+
raise AssertionError(f"unhandled MatrixArgs type {self.typ}")
|
|
1154
|
+
|
|
1155
|
+
# Handle trivial MATRIX type
|
|
1156
|
+
if self.typ == MA_ENTRIES_MATRIX:
|
|
1157
|
+
m = <Matrix>self.entries
|
|
1158
|
+
self.set_nrows(m._nrows)
|
|
1159
|
+
self.set_ncols(m._ncols)
|
|
1160
|
+
self.setdefault_base(m._parent._base)
|
|
1161
|
+
if self.sparse == -1:
|
|
1162
|
+
self.sparse = m.is_sparse()
|
|
1163
|
+
|
|
1164
|
+
# Error if size is required
|
|
1165
|
+
if self.typ & MA_FLAG_DIM_REQUIRED:
|
|
1166
|
+
if (self.nrows == -1 and self.row_keys is None) or (self.ncols == -1 and self.column_keys is None):
|
|
1167
|
+
raise TypeError("the dimensions of the matrix must be specified")
|
|
1168
|
+
|
|
1169
|
+
# Determine base in easy cases
|
|
1170
|
+
if self.base is None and self.typ & MA_FLAG_BASE_REQUIRED:
|
|
1171
|
+
if self.typ == MA_ENTRIES_ZERO:
|
|
1172
|
+
self.base = ZZ
|
|
1173
|
+
elif self.typ == MA_ENTRIES_SCALAR:
|
|
1174
|
+
if isinstance(self.entries, Element):
|
|
1175
|
+
self.base = (<Element>self.entries)._parent
|
|
1176
|
+
else:
|
|
1177
|
+
# Can be None if input is bogus
|
|
1178
|
+
self.base = py_scalar_parent(type(self.entries))
|
|
1179
|
+
if self.base is None:
|
|
1180
|
+
raise TypeError(f"unable to determine base of {self.entries!r}")
|
|
1181
|
+
|
|
1182
|
+
if ((self.nrows == -1 and self.row_keys is None)
|
|
1183
|
+
or (self.ncols == -1 and self.column_keys is None)
|
|
1184
|
+
or self.base is None):
|
|
1185
|
+
# Determine dimensions or base in the cases where we
|
|
1186
|
+
# really need to look at the entries.
|
|
1187
|
+
if self.typ == MA_ENTRIES_SEQ_SEQ:
|
|
1188
|
+
self.finalize_seq_seq()
|
|
1189
|
+
elif self.typ == MA_ENTRIES_SEQ_FLAT:
|
|
1190
|
+
self.finalize_seq_scalar()
|
|
1191
|
+
elif self.typ == MA_ENTRIES_CALLABLE:
|
|
1192
|
+
self.finalize_callable()
|
|
1193
|
+
else:
|
|
1194
|
+
raise AssertionError(f"nrows={self.nrows} ncols={self.ncols} base={self.base} type={self.typ}")
|
|
1195
|
+
|
|
1196
|
+
# Non-zero scalar matrices must be square
|
|
1197
|
+
# also ensure type is MA_ENTRIES_ZERO for scalar zero matrices
|
|
1198
|
+
if self.typ == MA_ENTRIES_SCALAR:
|
|
1199
|
+
try:
|
|
1200
|
+
if not self.entries:
|
|
1201
|
+
self.typ = MA_ENTRIES_ZERO
|
|
1202
|
+
except Exception:
|
|
1203
|
+
# "not self.entries" has failed, self.entries cannot be determined to be zero
|
|
1204
|
+
if self.nrows != self.ncols or self.row_keys != self.column_keys:
|
|
1205
|
+
raise TypeError("scalar matrix must be square if the value cannot be determined to be zero")
|
|
1206
|
+
if self.typ == MA_ENTRIES_SCALAR and (self.nrows != self.ncols or self.row_keys != self.column_keys):
|
|
1207
|
+
# self.typ is still SCALAR -> "not self.entries" has successfully evaluated, to False
|
|
1208
|
+
raise TypeError("nonzero scalar matrix must be square")
|
|
1209
|
+
|
|
1210
|
+
if self.sparse == -1:
|
|
1211
|
+
self.sparse = (self.typ & MA_FLAG_SPARSE) != 0
|
|
1212
|
+
|
|
1213
|
+
if self.space is None:
|
|
1214
|
+
global MatrixSpace
|
|
1215
|
+
if MatrixSpace is None:
|
|
1216
|
+
from sage.matrix.matrix_space import MatrixSpace
|
|
1217
|
+
nrows = self.nrows
|
|
1218
|
+
if nrows == -1:
|
|
1219
|
+
nrows = None
|
|
1220
|
+
ncols = self.ncols
|
|
1221
|
+
if ncols == -1:
|
|
1222
|
+
ncols = None
|
|
1223
|
+
self.space = MatrixSpace(self.base, nrows, ncols,
|
|
1224
|
+
sparse=self.sparse,
|
|
1225
|
+
row_keys=self.row_keys,
|
|
1226
|
+
column_keys=self.column_keys,
|
|
1227
|
+
**self.kwds)
|
|
1228
|
+
|
|
1229
|
+
self.is_finalized = True
|
|
1230
|
+
|
|
1231
|
+
cdef int set_base_from_entries(self, entries) except -1:
|
|
1232
|
+
"""
|
|
1233
|
+
Set base ring from the given list of entries.
|
|
1234
|
+
"""
|
|
1235
|
+
if entries:
|
|
1236
|
+
B = coercion_model.common_parent(*entries)
|
|
1237
|
+
if isinstance(B, type):
|
|
1238
|
+
B = py_scalar_parent(B)
|
|
1239
|
+
self.base = <Parent?>B
|
|
1240
|
+
else:
|
|
1241
|
+
self.base = ZZ
|
|
1242
|
+
|
|
1243
|
+
cdef int set_seq_flat(self, entries) except -1:
|
|
1244
|
+
"""
|
|
1245
|
+
Set ``self.entries`` to ``entries``, which should be a flat
|
|
1246
|
+
list of entries. Also determine base ring if unknown.
|
|
1247
|
+
"""
|
|
1248
|
+
if self.base is None:
|
|
1249
|
+
self.set_base_from_entries(entries)
|
|
1250
|
+
self.entries = entries
|
|
1251
|
+
self.typ = MA_ENTRIES_SEQ_FLAT
|
|
1252
|
+
|
|
1253
|
+
cdef int process_mapping(self) except -1:
|
|
1254
|
+
"""
|
|
1255
|
+
Convert type ``MAPPING`` to ``SEQ_SPARSE`` or ``SEQ_FLAT``
|
|
1256
|
+
(the latter if ``sparse`` is ``False``). This also does the rest
|
|
1257
|
+
of finalization, such as determining dimensions and base ring.
|
|
1258
|
+
|
|
1259
|
+
EXAMPLES::
|
|
1260
|
+
|
|
1261
|
+
sage: from sage.matrix.args import MatrixArgs
|
|
1262
|
+
sage: ma = MatrixArgs({(2,5): 1/2, (4,-3): 1/3})
|
|
1263
|
+
sage: ma = MatrixArgs(2, 2, {(-1,0): 2, (0,-1): 1}, sparse=True)
|
|
1264
|
+
sage: ma.finalized()
|
|
1265
|
+
<MatrixArgs for Full MatrixSpace of 2 by 2 sparse matrices over
|
|
1266
|
+
Integer Ring; typ=SEQ_SPARSE; entries=[SparseEntry(...), SparseEntry(...)]>
|
|
1267
|
+
sage: ma = MatrixArgs(2, 2, {(-1,0): 2, (0,-1): 1}, sparse=False)
|
|
1268
|
+
sage: ma.finalized()
|
|
1269
|
+
<MatrixArgs for Full MatrixSpace of 2 by 2 dense matrices over
|
|
1270
|
+
Integer Ring; typ=SEQ_FLAT; entries=[0, 1, 2, 0]>
|
|
1271
|
+
sage: ma = MatrixArgs(2, 1, {(1,0): 88, (0,1): 89})
|
|
1272
|
+
sage: ma.finalized()
|
|
1273
|
+
Traceback (most recent call last):
|
|
1274
|
+
...
|
|
1275
|
+
IndexError: invalid column index 1
|
|
1276
|
+
sage: ma = MatrixArgs(1, 2, {(1,0): 88, (0,1): 89})
|
|
1277
|
+
sage: ma.finalized()
|
|
1278
|
+
Traceback (most recent call last):
|
|
1279
|
+
...
|
|
1280
|
+
IndexError: invalid row index 1
|
|
1281
|
+
"""
|
|
1282
|
+
cdef list seqsparse = []
|
|
1283
|
+
cdef list values = []
|
|
1284
|
+
cdef long maxrow = -1, maxcol = -1 # Maximum occurring value for indices
|
|
1285
|
+
cdef long i, j
|
|
1286
|
+
for (i0, j0), x in self.entries.items():
|
|
1287
|
+
sig_check()
|
|
1288
|
+
i = pyobject_to_long(i0)
|
|
1289
|
+
j = pyobject_to_long(j0)
|
|
1290
|
+
if i > maxrow:
|
|
1291
|
+
maxrow = i
|
|
1292
|
+
elif i < 0: # Negative indices to index from the end
|
|
1293
|
+
if self.nrows > 0:
|
|
1294
|
+
i += self.nrows
|
|
1295
|
+
if i < 0:
|
|
1296
|
+
raise IndexError(f"invalid row index {i0}")
|
|
1297
|
+
if j > maxcol:
|
|
1298
|
+
maxcol = j
|
|
1299
|
+
elif j < 0: # Negative indices to index from the end
|
|
1300
|
+
if self.ncols > 0:
|
|
1301
|
+
j += self.ncols
|
|
1302
|
+
if j < 0:
|
|
1303
|
+
raise IndexError(f"invalid column index {j0}")
|
|
1304
|
+
seqsparse.append(make_SparseEntry(i, j, x))
|
|
1305
|
+
values.append(x)
|
|
1306
|
+
if self.nrows == -1:
|
|
1307
|
+
self.nrows = maxrow + 1
|
|
1308
|
+
elif maxrow >= self.nrows:
|
|
1309
|
+
raise IndexError(f"invalid row index {maxrow}")
|
|
1310
|
+
if self.ncols == -1:
|
|
1311
|
+
self.ncols = maxcol + 1
|
|
1312
|
+
elif maxcol >= self.ncols:
|
|
1313
|
+
raise IndexError(f"invalid column index {maxcol}")
|
|
1314
|
+
|
|
1315
|
+
if self.base is None:
|
|
1316
|
+
self.set_base_from_entries(values)
|
|
1317
|
+
|
|
1318
|
+
if self.sparse is False:
|
|
1319
|
+
# If we actually want a dense result, convert to MA_ENTRIES_SEQ_FLAT
|
|
1320
|
+
self.entries = [self.base.zero()] * (self.nrows * self.ncols)
|
|
1321
|
+
self.typ = MA_ENTRIES_SEQ_FLAT
|
|
1322
|
+
for t in seqsparse:
|
|
1323
|
+
se = <SparseEntry>t
|
|
1324
|
+
self.entries[se.i*self.ncols + se.j] = se.entry
|
|
1325
|
+
else:
|
|
1326
|
+
self.entries = seqsparse
|
|
1327
|
+
self.typ = MA_ENTRIES_SEQ_SPARSE
|
|
1328
|
+
|
|
1329
|
+
cdef int process_method(self) except -1:
|
|
1330
|
+
"""
|
|
1331
|
+
Convert type ``METHOD`` to ``MATRIX``.
|
|
1332
|
+
"""
|
|
1333
|
+
args = ()
|
|
1334
|
+
if self.base is not None:
|
|
1335
|
+
args += (self.base,)
|
|
1336
|
+
m = self.entries(*args)
|
|
1337
|
+
if not isinstance(m, Matrix):
|
|
1338
|
+
raise TypeError(f"{self.entries!r} did not return a matrix")
|
|
1339
|
+
self.entries = m
|
|
1340
|
+
self.typ = MA_ENTRIES_MATRIX
|
|
1341
|
+
|
|
1342
|
+
cdef int process_ndarray(self) except -1:
|
|
1343
|
+
"""
|
|
1344
|
+
Convert type ``NDARRAY`` to ``MATRIX`` or ``SEQ_SEQ``.
|
|
1345
|
+
"""
|
|
1346
|
+
# TODO: this is old code which should be cleaned up and made
|
|
1347
|
+
# more efficient
|
|
1348
|
+
e = self.entries
|
|
1349
|
+
cdef long inrows, incols
|
|
1350
|
+
(inrows, incols) = e.shape
|
|
1351
|
+
self.set_nrows(inrows)
|
|
1352
|
+
self.set_ncols(incols)
|
|
1353
|
+
str_dtype = str(e.dtype)
|
|
1354
|
+
|
|
1355
|
+
if not (e.flags.c_contiguous is True or e.flags.f_contiguous is True):
|
|
1356
|
+
raise TypeError('numpy matrix must be either c_contiguous or f_contiguous')
|
|
1357
|
+
|
|
1358
|
+
from sage.matrix.constructor import matrix
|
|
1359
|
+
from sage.rings.real_double import RDF
|
|
1360
|
+
from sage.rings.complex_double import CDF
|
|
1361
|
+
|
|
1362
|
+
if 'float32' in str_dtype:
|
|
1363
|
+
m = matrix(RDF, inrows, incols, 0)
|
|
1364
|
+
m._replace_self_with_numpy32(e)
|
|
1365
|
+
self.typ = MA_ENTRIES_MATRIX
|
|
1366
|
+
self.setdefault_base(RDF)
|
|
1367
|
+
elif 'float64' in str_dtype:
|
|
1368
|
+
m = matrix(RDF, inrows, incols, 0)
|
|
1369
|
+
m._replace_self_with_numpy(e)
|
|
1370
|
+
self.typ = MA_ENTRIES_MATRIX
|
|
1371
|
+
self.setdefault_base(RDF)
|
|
1372
|
+
elif 'complex64' in str_dtype:
|
|
1373
|
+
m = matrix(CDF, inrows, incols, 0)
|
|
1374
|
+
m._replace_self_with_numpy32(e)
|
|
1375
|
+
self.typ = MA_ENTRIES_MATRIX
|
|
1376
|
+
self.setdefault_base(CDF)
|
|
1377
|
+
elif 'complex128' in str_dtype:
|
|
1378
|
+
m = matrix(CDF, inrows, incols, 0)
|
|
1379
|
+
m._replace_self_with_numpy(e)
|
|
1380
|
+
self.typ = MA_ENTRIES_MATRIX
|
|
1381
|
+
self.setdefault_base(CDF)
|
|
1382
|
+
else:
|
|
1383
|
+
if 'int' in str_dtype:
|
|
1384
|
+
self.setdefault_base(ZZ)
|
|
1385
|
+
m = self.entries
|
|
1386
|
+
self.typ = MA_ENTRIES_SEQ_SEQ
|
|
1387
|
+
self.entries = m
|
|
1388
|
+
|
|
1389
|
+
cdef int finalize_seq_seq(self) except -1:
|
|
1390
|
+
"""
|
|
1391
|
+
Determine missing input (dimensions, base ring) for type
|
|
1392
|
+
``SEQ_SEQ`` and convert to ``SEQ_FLAT`` in the process.
|
|
1393
|
+
"""
|
|
1394
|
+
e = PySequence_Fast(self.entries, "not a sequence")
|
|
1395
|
+
self.set_nrows(len(e))
|
|
1396
|
+
if self.nrows == 0:
|
|
1397
|
+
if self.ncols == -1 and self.column_keys is None:
|
|
1398
|
+
self.set_ncols(0)
|
|
1399
|
+
self.setdefault_base(ZZ)
|
|
1400
|
+
return 0
|
|
1401
|
+
elif (self.ncols != -1 or self.column_keys is not None) and self.base is not None:
|
|
1402
|
+
# Everything known => OK
|
|
1403
|
+
return 0
|
|
1404
|
+
|
|
1405
|
+
# When sparse and given a list of sparse vectors, convert to a sparse sequence
|
|
1406
|
+
cdef long i, j
|
|
1407
|
+
if isinstance(e[0], Vector) and all(vec.is_sparse() for vec in e):
|
|
1408
|
+
if self.base is None:
|
|
1409
|
+
self.base = coercion_model.common_parent(*[(<Vector>vec)._parent._base
|
|
1410
|
+
for vec in e])
|
|
1411
|
+
self.entries = []
|
|
1412
|
+
for i, row in enumerate(e):
|
|
1413
|
+
for j, val in (<Vector?>row).iteritems():
|
|
1414
|
+
self.entries.append(make_SparseEntry(i, j, val))
|
|
1415
|
+
|
|
1416
|
+
self.set_ncols(max((<Vector>vec)._parent.ambient_module().rank() for vec in e))
|
|
1417
|
+
self.typ = MA_ENTRIES_SEQ_SPARSE
|
|
1418
|
+
return 0
|
|
1419
|
+
|
|
1420
|
+
# Process everything and convert to SEQ_FLAT
|
|
1421
|
+
cdef list entries = []
|
|
1422
|
+
cdef long c
|
|
1423
|
+
for row in e:
|
|
1424
|
+
c = 0
|
|
1425
|
+
for entry in row:
|
|
1426
|
+
sig_check()
|
|
1427
|
+
c += 1
|
|
1428
|
+
entries.append(entry)
|
|
1429
|
+
self.set_ncols(c)
|
|
1430
|
+
|
|
1431
|
+
self.set_seq_flat(entries)
|
|
1432
|
+
|
|
1433
|
+
cdef int finalize_seq_scalar(self) except -1:
|
|
1434
|
+
"""
|
|
1435
|
+
Determine missing input (dimensions, base ring) for type
|
|
1436
|
+
``SEQ_FLAT``.
|
|
1437
|
+
"""
|
|
1438
|
+
entries = PySequence_Fast(self.entries, "not a sequence")
|
|
1439
|
+
cdef long N = len(entries)
|
|
1440
|
+
|
|
1441
|
+
if self.ncols == 0 or self.nrows == 0 or N == 0:
|
|
1442
|
+
# If there are no entries, fill in missing dimensions as 0
|
|
1443
|
+
if self.nrows == -1:
|
|
1444
|
+
self.nrows = 0
|
|
1445
|
+
if self.ncols == -1:
|
|
1446
|
+
self.ncols = 0
|
|
1447
|
+
elif self.ncols == -1 and self.column_keys is None:
|
|
1448
|
+
if self.nrows == -1:
|
|
1449
|
+
if self.row_keys is None:
|
|
1450
|
+
# Assume row matrix
|
|
1451
|
+
self.nrows = 1
|
|
1452
|
+
self.ncols = N
|
|
1453
|
+
else:
|
|
1454
|
+
self.nrows = len(self.row_keys)
|
|
1455
|
+
self.ncols = N // self.nrows
|
|
1456
|
+
else:
|
|
1457
|
+
self.ncols = N // self.nrows
|
|
1458
|
+
elif self.nrows == -1 and self.row_keys is None:
|
|
1459
|
+
if self.ncols == -1:
|
|
1460
|
+
self.ncols = len(self.column_keys)
|
|
1461
|
+
self.nrows = N // self.ncols
|
|
1462
|
+
|
|
1463
|
+
self.set_seq_flat(entries)
|
|
1464
|
+
|
|
1465
|
+
cdef int finalize_callable(self) except -1:
|
|
1466
|
+
"""
|
|
1467
|
+
Determine base ring for type ``CALLABLE`` and convert to
|
|
1468
|
+
``SEQ_FLAT`` in the process.
|
|
1469
|
+
"""
|
|
1470
|
+
# Dimensions are required, so we must determine the base ring.
|
|
1471
|
+
# We do this by converting to the SEQ_FLAT type
|
|
1472
|
+
f = self.entries
|
|
1473
|
+
cdef list entries = []
|
|
1474
|
+
cdef long i, j
|
|
1475
|
+
for i in range(self.nrows):
|
|
1476
|
+
row = <object>i
|
|
1477
|
+
for j in range(self.ncols):
|
|
1478
|
+
sig_check()
|
|
1479
|
+
entries.append(f(row, j))
|
|
1480
|
+
|
|
1481
|
+
self.set_seq_flat(entries)
|
|
1482
|
+
|
|
1483
|
+
cdef inline entries_type get_type(self) except MA_EXCEPT:
|
|
1484
|
+
"""
|
|
1485
|
+
Return the type of ``self.entries``. In some cases, this might
|
|
1486
|
+
change ``self.entries``.
|
|
1487
|
+
|
|
1488
|
+
If the entries are invalid, return ``MA_ENTRIES_UNKNOWN``.
|
|
1489
|
+
|
|
1490
|
+
TESTS:
|
|
1491
|
+
|
|
1492
|
+
Check that :issue:`26655` is fixed::
|
|
1493
|
+
|
|
1494
|
+
sage: # needs sage.rings.finite_rings
|
|
1495
|
+
sage: F.<a> = GF(9)
|
|
1496
|
+
sage: M = MatrixSpace(F, 2, 2)
|
|
1497
|
+
sage: A = M([[1, a], [0, 1]])
|
|
1498
|
+
sage: M(pari(A))
|
|
1499
|
+
[1 a]
|
|
1500
|
+
[0 1]
|
|
1501
|
+
|
|
1502
|
+
Constructing a matrix from a PARI ``t_VEC`` or ``t_COL`` with
|
|
1503
|
+
``t_VEC`` or ``t_COL`` elements is currently not supported::
|
|
1504
|
+
|
|
1505
|
+
sage: M(pari([1, a, 0, 1])) # needs sage.libs.pari sage.rings.finite_rings
|
|
1506
|
+
Traceback (most recent call last):
|
|
1507
|
+
...
|
|
1508
|
+
NameError: name 'a' is not defined
|
|
1509
|
+
sage: M(pari([[1, a], [0, 1]])) # needs sage.libs.pari sage.rings.finite_rings
|
|
1510
|
+
Traceback (most recent call last):
|
|
1511
|
+
...
|
|
1512
|
+
NameError: name 'a' is not defined
|
|
1513
|
+
|
|
1514
|
+
Check that :issue:`38221` is fixed::
|
|
1515
|
+
|
|
1516
|
+
sage: # needs sage.groups
|
|
1517
|
+
sage: G = CyclicPermutationGroup(7)
|
|
1518
|
+
sage: R = GF(2)
|
|
1519
|
+
sage: A = G.algebra(R)
|
|
1520
|
+
sage: matrix(A, 3, 3, A.zero())
|
|
1521
|
+
[0 0 0]
|
|
1522
|
+
[0 0 0]
|
|
1523
|
+
[0 0 0]
|
|
1524
|
+
sage: matrix(A, 3, 3, A.one())
|
|
1525
|
+
[() 0 0]
|
|
1526
|
+
[ 0 () 0]
|
|
1527
|
+
[ 0 0 ()]
|
|
1528
|
+
|
|
1529
|
+
Verify that :issue:`34821` is fixed::
|
|
1530
|
+
|
|
1531
|
+
sage: matrix(ZZ, 2, 2, "3")
|
|
1532
|
+
[3 0]
|
|
1533
|
+
[0 3]
|
|
1534
|
+
"""
|
|
1535
|
+
# Check basic Python types. This is very fast, so it doesn't
|
|
1536
|
+
# hurt to do these first.
|
|
1537
|
+
if self.entries is None:
|
|
1538
|
+
return MA_ENTRIES_ZERO
|
|
1539
|
+
if isinstance(self.entries, (int, float, complex, Integer, str)):
|
|
1540
|
+
# Note that a string is not considered to be a sequence.
|
|
1541
|
+
if self.entries:
|
|
1542
|
+
return MA_ENTRIES_SCALAR
|
|
1543
|
+
return MA_ENTRIES_ZERO
|
|
1544
|
+
if isinstance(self.entries, (list, tuple)):
|
|
1545
|
+
return self.sequence_type()
|
|
1546
|
+
if isinstance(self.entries, dict):
|
|
1547
|
+
return MA_ENTRIES_MAPPING
|
|
1548
|
+
|
|
1549
|
+
# Note: some objects are callable, iterable and act like a
|
|
1550
|
+
# scalar, e.g. polynomials. So the order of these checks
|
|
1551
|
+
# matters a lot. Also the more efficient checks should be
|
|
1552
|
+
# done first.
|
|
1553
|
+
|
|
1554
|
+
# We check for Element first because that speeds up some
|
|
1555
|
+
# other checks.
|
|
1556
|
+
cdef bint is_elt = isinstance(self.entries, Element)
|
|
1557
|
+
if is_elt and isinstance(self.entries, Matrix):
|
|
1558
|
+
return MA_ENTRIES_MATRIX
|
|
1559
|
+
if is_elt and self.base is not None and self.entries.parent() == self.base:
|
|
1560
|
+
return MA_ENTRIES_SCALAR
|
|
1561
|
+
t = type(self.entries)
|
|
1562
|
+
try:
|
|
1563
|
+
f = t._matrix_
|
|
1564
|
+
except AttributeError:
|
|
1565
|
+
pass
|
|
1566
|
+
else:
|
|
1567
|
+
self.entries = f.__get__(self.entries, t)
|
|
1568
|
+
return MA_ENTRIES_METHOD
|
|
1569
|
+
if is_elt and element_is_scalar(<Element>self.entries):
|
|
1570
|
+
return MA_ENTRIES_SCALAR
|
|
1571
|
+
if not is_elt and is_numpy_type(t):
|
|
1572
|
+
import numpy
|
|
1573
|
+
if isinstance(self.entries, numpy.ndarray):
|
|
1574
|
+
# Convert to a numpy array if it was a matrix.
|
|
1575
|
+
if t is not numpy.ndarray:
|
|
1576
|
+
self.entries = numpy.array(self.entries)
|
|
1577
|
+
return MA_ENTRIES_NDARRAY
|
|
1578
|
+
return MA_ENTRIES_SCALAR
|
|
1579
|
+
if isinstance(self.entries, Gen): # PARI object
|
|
1580
|
+
from sage.libs.pari.convert_sage_matrix import pari_typ_to_entries_type
|
|
1581
|
+
return pari_typ_to_entries_type(self)
|
|
1582
|
+
if isinstance(self.entries, MatrixArgs):
|
|
1583
|
+
# Prevent recursion
|
|
1584
|
+
return MA_ENTRIES_UNKNOWN
|
|
1585
|
+
try:
|
|
1586
|
+
self.entries = list(self.entries)
|
|
1587
|
+
except TypeError:
|
|
1588
|
+
pass
|
|
1589
|
+
else:
|
|
1590
|
+
return self.sequence_type()
|
|
1591
|
+
if callable(self.entries):
|
|
1592
|
+
return MA_ENTRIES_CALLABLE
|
|
1593
|
+
if is_elt: # Last resort
|
|
1594
|
+
return MA_ENTRIES_SCALAR
|
|
1595
|
+
return MA_ENTRIES_UNKNOWN
|
|
1596
|
+
|
|
1597
|
+
cdef entries_type sequence_type(self) except MA_EXCEPT:
|
|
1598
|
+
"""
|
|
1599
|
+
Return the type of ``self.entries``, where ``self.entries``
|
|
1600
|
+
is a sequence.
|
|
1601
|
+
|
|
1602
|
+
If the entries are invalid, return ``MA_ENTRIES_UNKNOWN``.
|
|
1603
|
+
|
|
1604
|
+
TESTS:
|
|
1605
|
+
|
|
1606
|
+
Verify that :issue:`34821` is fixed::
|
|
1607
|
+
|
|
1608
|
+
sage: matrix(ZZ, 1,2, ["1", "2"])
|
|
1609
|
+
[1 2]
|
|
1610
|
+
sage: matrix(ZZ, 2,1, ["1", "2"])
|
|
1611
|
+
[1]
|
|
1612
|
+
[2]
|
|
1613
|
+
"""
|
|
1614
|
+
if not self.entries:
|
|
1615
|
+
return MA_ENTRIES_SEQ_FLAT
|
|
1616
|
+
x = self.entries[0]
|
|
1617
|
+
if isinstance(x, (list, tuple, Vector)):
|
|
1618
|
+
return MA_ENTRIES_SEQ_SEQ
|
|
1619
|
+
if type(x) is SparseEntry:
|
|
1620
|
+
return MA_ENTRIES_SEQ_SPARSE
|
|
1621
|
+
if self.nrows != -1 and self.ncols != -1 and self.ncols != 1:
|
|
1622
|
+
# Determine type from the number of entries. Unfortunately,
|
|
1623
|
+
# this only works if the number of columns is not 1.
|
|
1624
|
+
if len(self.entries) == self.nrows:
|
|
1625
|
+
return MA_ENTRIES_SEQ_SEQ
|
|
1626
|
+
else:
|
|
1627
|
+
return MA_ENTRIES_SEQ_FLAT
|
|
1628
|
+
if isinstance(x, (int, float, complex, str)):
|
|
1629
|
+
# Note that a string is not considered to be a sequence.
|
|
1630
|
+
return MA_ENTRIES_SEQ_FLAT
|
|
1631
|
+
if isinstance(x, Element) and element_is_scalar(<Element>x):
|
|
1632
|
+
return MA_ENTRIES_SEQ_FLAT
|
|
1633
|
+
try:
|
|
1634
|
+
iter(x)
|
|
1635
|
+
except TypeError:
|
|
1636
|
+
return MA_ENTRIES_SEQ_FLAT
|
|
1637
|
+
else:
|
|
1638
|
+
return MA_ENTRIES_SEQ_SEQ
|
|
1639
|
+
|
|
1640
|
+
|
|
1641
|
+
cpdef MatrixArgs MatrixArgs_init(space, entries):
|
|
1642
|
+
"""
|
|
1643
|
+
Construct a :class:`MatrixArgs` object from a matrix space and
|
|
1644
|
+
entries. This is the typical use in a matrix constructor.
|
|
1645
|
+
|
|
1646
|
+
If the given entries is already an instance of :class:`MatrixArgs`,
|
|
1647
|
+
then just set the space and return the same object.
|
|
1648
|
+
|
|
1649
|
+
EXAMPLES::
|
|
1650
|
+
|
|
1651
|
+
sage: from sage.matrix.args import MatrixArgs_init
|
|
1652
|
+
sage: S = MatrixSpace(GF(2), 2, 4)
|
|
1653
|
+
sage: ma = MatrixArgs_init(S, {(1, 3): 7})
|
|
1654
|
+
sage: M = ma.matrix(); M
|
|
1655
|
+
[0 0 0 0]
|
|
1656
|
+
[0 0 0 1]
|
|
1657
|
+
sage: parent(M) is S
|
|
1658
|
+
True
|
|
1659
|
+
"""
|
|
1660
|
+
cdef MatrixArgs ret
|
|
1661
|
+
if isinstance(entries, MatrixArgs):
|
|
1662
|
+
ret = <MatrixArgs>entries
|
|
1663
|
+
else:
|
|
1664
|
+
ret = MatrixArgs.__new__(MatrixArgs)
|
|
1665
|
+
ret.entries = entries
|
|
1666
|
+
ret.set_space(space)
|
|
1667
|
+
ret.finalize()
|
|
1668
|
+
return ret
|