passagemath-categories 10.6.44__cp310-cp310-win_arm64.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.
Files changed (719) hide show
  1. passagemath_categories/__init__.py +3 -0
  2. passagemath_categories-10.6.44.dist-info/DELVEWHEEL +2 -0
  3. passagemath_categories-10.6.44.dist-info/METADATA +157 -0
  4. passagemath_categories-10.6.44.dist-info/RECORD +719 -0
  5. passagemath_categories-10.6.44.dist-info/WHEEL +5 -0
  6. passagemath_categories-10.6.44.dist-info/top_level.txt +3 -0
  7. passagemath_categories.libs/libgmp-10-98b8b97e0a62cfb2d4dd4b0f18b70bdd.dll +0 -0
  8. passagemath_categories.libs/msvcp140-9cb625fcbc2fbbd6fca1aee8b24b0ebe.dll +0 -0
  9. sage/all__sagemath_categories.py +37 -0
  10. sage/arith/all.py +38 -0
  11. sage/arith/constants.pxd +27 -0
  12. sage/arith/functions.cp310-win_arm64.pyd +0 -0
  13. sage/arith/functions.pxd +4 -0
  14. sage/arith/functions.pyx +221 -0
  15. sage/arith/misc.py +6552 -0
  16. sage/arith/multi_modular.cp310-win_arm64.pyd +0 -0
  17. sage/arith/multi_modular.pxd +39 -0
  18. sage/arith/multi_modular.pyx +994 -0
  19. sage/arith/rational_reconstruction.cp310-win_arm64.pyd +0 -0
  20. sage/arith/rational_reconstruction.pxd +4 -0
  21. sage/arith/rational_reconstruction.pyx +115 -0
  22. sage/arith/srange.cp310-win_arm64.pyd +0 -0
  23. sage/arith/srange.pyx +571 -0
  24. sage/calculus/all__sagemath_categories.py +2 -0
  25. sage/calculus/functional.py +481 -0
  26. sage/calculus/functions.py +151 -0
  27. sage/categories/additive_groups.py +73 -0
  28. sage/categories/additive_magmas.py +1044 -0
  29. sage/categories/additive_monoids.py +114 -0
  30. sage/categories/additive_semigroups.py +184 -0
  31. sage/categories/affine_weyl_groups.py +238 -0
  32. sage/categories/algebra_ideals.py +95 -0
  33. sage/categories/algebra_modules.py +96 -0
  34. sage/categories/algebras.py +349 -0
  35. sage/categories/algebras_with_basis.py +377 -0
  36. sage/categories/all.py +160 -0
  37. sage/categories/aperiodic_semigroups.py +29 -0
  38. sage/categories/associative_algebras.py +47 -0
  39. sage/categories/bialgebras.py +101 -0
  40. sage/categories/bialgebras_with_basis.py +414 -0
  41. sage/categories/bimodules.py +206 -0
  42. sage/categories/chain_complexes.py +268 -0
  43. sage/categories/classical_crystals.py +480 -0
  44. sage/categories/coalgebras.py +405 -0
  45. sage/categories/coalgebras_with_basis.py +232 -0
  46. sage/categories/coercion_methods.cp310-win_arm64.pyd +0 -0
  47. sage/categories/coercion_methods.pyx +52 -0
  48. sage/categories/commutative_additive_groups.py +104 -0
  49. sage/categories/commutative_additive_monoids.py +45 -0
  50. sage/categories/commutative_additive_semigroups.py +48 -0
  51. sage/categories/commutative_algebra_ideals.py +87 -0
  52. sage/categories/commutative_algebras.py +94 -0
  53. sage/categories/commutative_ring_ideals.py +58 -0
  54. sage/categories/commutative_rings.py +736 -0
  55. sage/categories/complete_discrete_valuation.py +293 -0
  56. sage/categories/complex_reflection_groups.py +145 -0
  57. sage/categories/complex_reflection_or_generalized_coxeter_groups.py +1249 -0
  58. sage/categories/coxeter_group_algebras.py +186 -0
  59. sage/categories/coxeter_groups.py +3402 -0
  60. sage/categories/crystals.py +2628 -0
  61. sage/categories/cw_complexes.py +216 -0
  62. sage/categories/dedekind_domains.py +137 -0
  63. sage/categories/discrete_valuation.py +325 -0
  64. sage/categories/distributive_magmas_and_additive_magmas.py +100 -0
  65. sage/categories/division_rings.py +114 -0
  66. sage/categories/domains.py +95 -0
  67. sage/categories/drinfeld_modules.py +789 -0
  68. sage/categories/dual.py +42 -0
  69. sage/categories/enumerated_sets.py +1146 -0
  70. sage/categories/euclidean_domains.py +271 -0
  71. sage/categories/examples/algebras_with_basis.py +102 -0
  72. sage/categories/examples/all.py +1 -0
  73. sage/categories/examples/commutative_additive_monoids.py +130 -0
  74. sage/categories/examples/commutative_additive_semigroups.py +199 -0
  75. sage/categories/examples/coxeter_groups.py +8 -0
  76. sage/categories/examples/crystals.py +236 -0
  77. sage/categories/examples/cw_complexes.py +163 -0
  78. sage/categories/examples/facade_sets.py +187 -0
  79. sage/categories/examples/filtered_algebras_with_basis.py +204 -0
  80. sage/categories/examples/filtered_modules_with_basis.py +154 -0
  81. sage/categories/examples/finite_coxeter_groups.py +252 -0
  82. sage/categories/examples/finite_dimensional_algebras_with_basis.py +148 -0
  83. sage/categories/examples/finite_dimensional_lie_algebras_with_basis.py +495 -0
  84. sage/categories/examples/finite_enumerated_sets.py +208 -0
  85. sage/categories/examples/finite_monoids.py +150 -0
  86. sage/categories/examples/finite_semigroups.py +190 -0
  87. sage/categories/examples/finite_weyl_groups.py +191 -0
  88. sage/categories/examples/graded_connected_hopf_algebras_with_basis.py +152 -0
  89. sage/categories/examples/graded_modules_with_basis.py +168 -0
  90. sage/categories/examples/graphs.py +122 -0
  91. sage/categories/examples/hopf_algebras_with_basis.py +145 -0
  92. sage/categories/examples/infinite_enumerated_sets.py +190 -0
  93. sage/categories/examples/lie_algebras.py +352 -0
  94. sage/categories/examples/lie_algebras_with_basis.py +196 -0
  95. sage/categories/examples/magmas.py +162 -0
  96. sage/categories/examples/manifolds.py +94 -0
  97. sage/categories/examples/monoids.py +144 -0
  98. sage/categories/examples/posets.py +178 -0
  99. sage/categories/examples/semigroups.py +580 -0
  100. sage/categories/examples/semigroups_cython.cp310-win_arm64.pyd +0 -0
  101. sage/categories/examples/semigroups_cython.pyx +221 -0
  102. sage/categories/examples/semirings.py +249 -0
  103. sage/categories/examples/sets_cat.py +706 -0
  104. sage/categories/examples/sets_with_grading.py +101 -0
  105. sage/categories/examples/with_realizations.py +542 -0
  106. sage/categories/fields.py +991 -0
  107. sage/categories/filtered_algebras.py +63 -0
  108. sage/categories/filtered_algebras_with_basis.py +548 -0
  109. sage/categories/filtered_hopf_algebras_with_basis.py +138 -0
  110. sage/categories/filtered_modules.py +210 -0
  111. sage/categories/filtered_modules_with_basis.py +1209 -0
  112. sage/categories/finite_complex_reflection_groups.py +1506 -0
  113. sage/categories/finite_coxeter_groups.py +1138 -0
  114. sage/categories/finite_crystals.py +103 -0
  115. sage/categories/finite_dimensional_algebras_with_basis.py +1860 -0
  116. sage/categories/finite_dimensional_bialgebras_with_basis.py +33 -0
  117. sage/categories/finite_dimensional_coalgebras_with_basis.py +33 -0
  118. sage/categories/finite_dimensional_graded_lie_algebras_with_basis.py +231 -0
  119. sage/categories/finite_dimensional_hopf_algebras_with_basis.py +38 -0
  120. sage/categories/finite_dimensional_lie_algebras_with_basis.py +2774 -0
  121. sage/categories/finite_dimensional_modules_with_basis.py +1566 -0
  122. sage/categories/finite_dimensional_nilpotent_lie_algebras_with_basis.py +167 -0
  123. sage/categories/finite_dimensional_semisimple_algebras_with_basis.py +270 -0
  124. sage/categories/finite_enumerated_sets.py +769 -0
  125. sage/categories/finite_fields.py +252 -0
  126. sage/categories/finite_groups.py +256 -0
  127. sage/categories/finite_lattice_posets.py +242 -0
  128. sage/categories/finite_monoids.py +316 -0
  129. sage/categories/finite_permutation_groups.py +339 -0
  130. sage/categories/finite_posets.py +1994 -0
  131. sage/categories/finite_semigroups.py +136 -0
  132. sage/categories/finite_sets.py +93 -0
  133. sage/categories/finite_weyl_groups.py +39 -0
  134. sage/categories/finitely_generated_lambda_bracket_algebras.py +112 -0
  135. sage/categories/finitely_generated_lie_conformal_algebras.py +114 -0
  136. sage/categories/finitely_generated_magmas.py +57 -0
  137. sage/categories/finitely_generated_semigroups.py +214 -0
  138. sage/categories/function_fields.py +76 -0
  139. sage/categories/g_sets.py +77 -0
  140. sage/categories/gcd_domains.py +65 -0
  141. sage/categories/generalized_coxeter_groups.py +94 -0
  142. sage/categories/graded_algebras.py +85 -0
  143. sage/categories/graded_algebras_with_basis.py +258 -0
  144. sage/categories/graded_bialgebras.py +32 -0
  145. sage/categories/graded_bialgebras_with_basis.py +32 -0
  146. sage/categories/graded_coalgebras.py +65 -0
  147. sage/categories/graded_coalgebras_with_basis.py +51 -0
  148. sage/categories/graded_hopf_algebras.py +41 -0
  149. sage/categories/graded_hopf_algebras_with_basis.py +169 -0
  150. sage/categories/graded_lie_algebras.py +91 -0
  151. sage/categories/graded_lie_algebras_with_basis.py +44 -0
  152. sage/categories/graded_lie_conformal_algebras.py +74 -0
  153. sage/categories/graded_modules.py +133 -0
  154. sage/categories/graded_modules_with_basis.py +329 -0
  155. sage/categories/graphs.py +138 -0
  156. sage/categories/group_algebras.py +430 -0
  157. sage/categories/groupoid.py +94 -0
  158. sage/categories/groups.py +667 -0
  159. sage/categories/h_trivial_semigroups.py +64 -0
  160. sage/categories/hecke_modules.py +185 -0
  161. sage/categories/highest_weight_crystals.py +980 -0
  162. sage/categories/hopf_algebras.py +219 -0
  163. sage/categories/hopf_algebras_with_basis.py +309 -0
  164. sage/categories/infinite_enumerated_sets.py +115 -0
  165. sage/categories/integral_domains.py +203 -0
  166. sage/categories/j_trivial_semigroups.py +29 -0
  167. sage/categories/kac_moody_algebras.py +82 -0
  168. sage/categories/kahler_algebras.py +203 -0
  169. sage/categories/l_trivial_semigroups.py +63 -0
  170. sage/categories/lambda_bracket_algebras.py +280 -0
  171. sage/categories/lambda_bracket_algebras_with_basis.py +107 -0
  172. sage/categories/lattice_posets.py +89 -0
  173. sage/categories/left_modules.py +49 -0
  174. sage/categories/lie_algebras.py +1070 -0
  175. sage/categories/lie_algebras_with_basis.py +261 -0
  176. sage/categories/lie_conformal_algebras.py +350 -0
  177. sage/categories/lie_conformal_algebras_with_basis.py +147 -0
  178. sage/categories/lie_groups.py +73 -0
  179. sage/categories/loop_crystals.py +1290 -0
  180. sage/categories/magmas.py +1189 -0
  181. sage/categories/magmas_and_additive_magmas.py +149 -0
  182. sage/categories/magmatic_algebras.py +365 -0
  183. sage/categories/manifolds.py +352 -0
  184. sage/categories/matrix_algebras.py +40 -0
  185. sage/categories/metric_spaces.py +387 -0
  186. sage/categories/modular_abelian_varieties.py +78 -0
  187. sage/categories/modules.py +989 -0
  188. sage/categories/modules_with_basis.py +2985 -0
  189. sage/categories/monoid_algebras.py +38 -0
  190. sage/categories/monoids.py +739 -0
  191. sage/categories/noetherian_rings.py +87 -0
  192. sage/categories/number_fields.py +242 -0
  193. sage/categories/ore_modules.py +189 -0
  194. sage/categories/partially_ordered_monoids.py +49 -0
  195. sage/categories/permutation_groups.py +63 -0
  196. sage/categories/pointed_sets.py +42 -0
  197. sage/categories/polyhedra.py +74 -0
  198. sage/categories/poor_man_map.py +270 -0
  199. sage/categories/posets.py +722 -0
  200. sage/categories/principal_ideal_domains.py +270 -0
  201. sage/categories/quantum_group_representations.py +543 -0
  202. sage/categories/quotient_fields.py +728 -0
  203. sage/categories/r_trivial_semigroups.py +45 -0
  204. sage/categories/regular_crystals.py +898 -0
  205. sage/categories/regular_supercrystals.py +170 -0
  206. sage/categories/right_modules.py +49 -0
  207. sage/categories/ring_ideals.py +74 -0
  208. sage/categories/rings.py +1904 -0
  209. sage/categories/rngs.py +175 -0
  210. sage/categories/schemes.py +393 -0
  211. sage/categories/semigroups.py +1060 -0
  212. sage/categories/semirings.py +71 -0
  213. sage/categories/semisimple_algebras.py +114 -0
  214. sage/categories/sets_with_grading.py +235 -0
  215. sage/categories/shephard_groups.py +43 -0
  216. sage/categories/signed_tensor.py +120 -0
  217. sage/categories/simplicial_complexes.py +134 -0
  218. sage/categories/simplicial_sets.py +1206 -0
  219. sage/categories/super_algebras.py +149 -0
  220. sage/categories/super_algebras_with_basis.py +144 -0
  221. sage/categories/super_hopf_algebras_with_basis.py +126 -0
  222. sage/categories/super_lie_conformal_algebras.py +193 -0
  223. sage/categories/super_modules.py +229 -0
  224. sage/categories/super_modules_with_basis.py +193 -0
  225. sage/categories/supercommutative_algebras.py +99 -0
  226. sage/categories/supercrystals.py +406 -0
  227. sage/categories/tensor.py +110 -0
  228. sage/categories/topological_spaces.py +170 -0
  229. sage/categories/triangular_kac_moody_algebras.py +439 -0
  230. sage/categories/tutorial.py +58 -0
  231. sage/categories/unique_factorization_domains.py +318 -0
  232. sage/categories/unital_algebras.py +426 -0
  233. sage/categories/vector_bundles.py +159 -0
  234. sage/categories/vector_spaces.py +357 -0
  235. sage/categories/weyl_groups.py +853 -0
  236. sage/combinat/all__sagemath_categories.py +34 -0
  237. sage/combinat/backtrack.py +180 -0
  238. sage/combinat/combinat.py +2269 -0
  239. sage/combinat/combinat_cython.cp310-win_arm64.pyd +0 -0
  240. sage/combinat/combinat_cython.pxd +6 -0
  241. sage/combinat/combinat_cython.pyx +390 -0
  242. sage/combinat/combination.py +796 -0
  243. sage/combinat/combinatorial_map.py +416 -0
  244. sage/combinat/composition.py +2192 -0
  245. sage/combinat/dlx.py +510 -0
  246. sage/combinat/integer_lists/__init__.py +7 -0
  247. sage/combinat/integer_lists/base.cp310-win_arm64.pyd +0 -0
  248. sage/combinat/integer_lists/base.pxd +16 -0
  249. sage/combinat/integer_lists/base.pyx +713 -0
  250. sage/combinat/integer_lists/invlex.cp310-win_arm64.pyd +0 -0
  251. sage/combinat/integer_lists/invlex.pxd +4 -0
  252. sage/combinat/integer_lists/invlex.pyx +1650 -0
  253. sage/combinat/integer_lists/lists.py +328 -0
  254. sage/combinat/integer_lists/nn.py +48 -0
  255. sage/combinat/integer_vector.py +1818 -0
  256. sage/combinat/integer_vector_weighted.py +413 -0
  257. sage/combinat/matrices/all__sagemath_categories.py +5 -0
  258. sage/combinat/matrices/dancing_links.cp310-win_arm64.pyd +0 -0
  259. sage/combinat/matrices/dancing_links.pyx +1159 -0
  260. sage/combinat/matrices/dancing_links_c.h +380 -0
  261. sage/combinat/matrices/dlxcpp.py +136 -0
  262. sage/combinat/partition.py +10070 -0
  263. sage/combinat/partitions.cp310-win_arm64.pyd +0 -0
  264. sage/combinat/partitions.pyx +743 -0
  265. sage/combinat/permutation.py +10168 -0
  266. sage/combinat/permutation_cython.cp310-win_arm64.pyd +0 -0
  267. sage/combinat/permutation_cython.pxd +11 -0
  268. sage/combinat/permutation_cython.pyx +407 -0
  269. sage/combinat/q_analogues.py +1090 -0
  270. sage/combinat/ranker.py +268 -0
  271. sage/combinat/subset.py +1561 -0
  272. sage/combinat/subsets_hereditary.py +202 -0
  273. sage/combinat/subsets_pairwise.py +184 -0
  274. sage/combinat/tools.py +63 -0
  275. sage/combinat/tuple.py +348 -0
  276. sage/data_structures/all.py +2 -0
  277. sage/data_structures/all__sagemath_categories.py +2 -0
  278. sage/data_structures/binary_matrix.pxd +138 -0
  279. sage/data_structures/binary_search.cp310-win_arm64.pyd +0 -0
  280. sage/data_structures/binary_search.pxd +3 -0
  281. sage/data_structures/binary_search.pyx +66 -0
  282. sage/data_structures/bitset.cp310-win_arm64.pyd +0 -0
  283. sage/data_structures/bitset.pxd +40 -0
  284. sage/data_structures/bitset.pyx +2385 -0
  285. sage/data_structures/bitset_base.cp310-win_arm64.pyd +0 -0
  286. sage/data_structures/bitset_base.pxd +926 -0
  287. sage/data_structures/bitset_base.pyx +117 -0
  288. sage/data_structures/bitset_intrinsics.h +487 -0
  289. sage/data_structures/blas_dict.cp310-win_arm64.pyd +0 -0
  290. sage/data_structures/blas_dict.pxd +12 -0
  291. sage/data_structures/blas_dict.pyx +469 -0
  292. sage/data_structures/list_of_pairs.cp310-win_arm64.pyd +0 -0
  293. sage/data_structures/list_of_pairs.pxd +16 -0
  294. sage/data_structures/list_of_pairs.pyx +122 -0
  295. sage/data_structures/mutable_poset.py +3312 -0
  296. sage/data_structures/pairing_heap.cp310-win_arm64.pyd +0 -0
  297. sage/data_structures/pairing_heap.h +346 -0
  298. sage/data_structures/pairing_heap.pxd +88 -0
  299. sage/data_structures/pairing_heap.pyx +1464 -0
  300. sage/data_structures/sparse_bitset.pxd +62 -0
  301. sage/data_structures/stream.py +5070 -0
  302. sage/databases/all__sagemath_categories.py +7 -0
  303. sage/databases/sql_db.py +2236 -0
  304. sage/ext/all__sagemath_categories.py +3 -0
  305. sage/ext/fast_callable.cp310-win_arm64.pyd +0 -0
  306. sage/ext/fast_callable.pxd +4 -0
  307. sage/ext/fast_callable.pyx +2746 -0
  308. sage/ext/fast_eval.cp310-win_arm64.pyd +0 -0
  309. sage/ext/fast_eval.pxd +1 -0
  310. sage/ext/fast_eval.pyx +102 -0
  311. sage/ext/interpreters/all__sagemath_categories.py +2 -0
  312. sage/ext/interpreters/wrapper_el.cp310-win_arm64.pyd +0 -0
  313. sage/ext/interpreters/wrapper_el.pxd +18 -0
  314. sage/ext/interpreters/wrapper_el.pyx +148 -0
  315. sage/ext/interpreters/wrapper_py.cp310-win_arm64.pyd +0 -0
  316. sage/ext/interpreters/wrapper_py.pxd +17 -0
  317. sage/ext/interpreters/wrapper_py.pyx +133 -0
  318. sage/functions/airy.py +937 -0
  319. sage/functions/all.py +97 -0
  320. sage/functions/bessel.py +2102 -0
  321. sage/functions/error.py +784 -0
  322. sage/functions/exp_integral.py +1529 -0
  323. sage/functions/gamma.py +1087 -0
  324. sage/functions/generalized.py +672 -0
  325. sage/functions/hyperbolic.py +747 -0
  326. sage/functions/hypergeometric.py +1156 -0
  327. sage/functions/jacobi.py +1705 -0
  328. sage/functions/log.py +1402 -0
  329. sage/functions/min_max.py +338 -0
  330. sage/functions/orthogonal_polys.py +3106 -0
  331. sage/functions/other.py +2303 -0
  332. sage/functions/piecewise.py +1505 -0
  333. sage/functions/prime_pi.cp310-win_arm64.pyd +0 -0
  334. sage/functions/prime_pi.pyx +262 -0
  335. sage/functions/special.py +1212 -0
  336. sage/functions/spike_function.py +278 -0
  337. sage/functions/transcendental.py +690 -0
  338. sage/functions/trig.py +1062 -0
  339. sage/functions/wigner.py +726 -0
  340. sage/geometry/abc.cp310-win_arm64.pyd +0 -0
  341. sage/geometry/abc.pyx +82 -0
  342. sage/geometry/all__sagemath_categories.py +1 -0
  343. sage/groups/all__sagemath_categories.py +11 -0
  344. sage/groups/generic.py +1733 -0
  345. sage/groups/groups_catalog.py +113 -0
  346. sage/groups/perm_gps/all__sagemath_categories.py +1 -0
  347. sage/groups/perm_gps/partn_ref/all.py +1 -0
  348. sage/groups/perm_gps/partn_ref/all__sagemath_categories.py +1 -0
  349. sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.cp310-win_arm64.pyd +0 -0
  350. sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pxd +52 -0
  351. sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx +906 -0
  352. sage/groups/perm_gps/partn_ref/canonical_augmentation.cp310-win_arm64.pyd +0 -0
  353. sage/groups/perm_gps/partn_ref/canonical_augmentation.pxd +85 -0
  354. sage/groups/perm_gps/partn_ref/canonical_augmentation.pyx +534 -0
  355. sage/groups/perm_gps/partn_ref/data_structures.cp310-win_arm64.pyd +0 -0
  356. sage/groups/perm_gps/partn_ref/data_structures.pxd +576 -0
  357. sage/groups/perm_gps/partn_ref/data_structures.pyx +1792 -0
  358. sage/groups/perm_gps/partn_ref/double_coset.cp310-win_arm64.pyd +0 -0
  359. sage/groups/perm_gps/partn_ref/double_coset.pxd +45 -0
  360. sage/groups/perm_gps/partn_ref/double_coset.pyx +739 -0
  361. sage/groups/perm_gps/partn_ref/refinement_lists.cp310-win_arm64.pyd +0 -0
  362. sage/groups/perm_gps/partn_ref/refinement_lists.pxd +18 -0
  363. sage/groups/perm_gps/partn_ref/refinement_lists.pyx +82 -0
  364. sage/groups/perm_gps/partn_ref/refinement_python.cp310-win_arm64.pyd +0 -0
  365. sage/groups/perm_gps/partn_ref/refinement_python.pxd +16 -0
  366. sage/groups/perm_gps/partn_ref/refinement_python.pyx +564 -0
  367. sage/groups/perm_gps/partn_ref/refinement_sets.cp310-win_arm64.pyd +0 -0
  368. sage/groups/perm_gps/partn_ref/refinement_sets.pxd +60 -0
  369. sage/groups/perm_gps/partn_ref/refinement_sets.pyx +858 -0
  370. sage/interfaces/abc.py +140 -0
  371. sage/interfaces/all.py +58 -0
  372. sage/interfaces/all__sagemath_categories.py +1 -0
  373. sage/interfaces/expect.py +1643 -0
  374. sage/interfaces/interface.py +1682 -0
  375. sage/interfaces/process.cp310-win_arm64.pyd +0 -0
  376. sage/interfaces/process.pxd +5 -0
  377. sage/interfaces/process.pyx +320 -0
  378. sage/interfaces/quit.py +167 -0
  379. sage/interfaces/sage0.py +604 -0
  380. sage/interfaces/sagespawn.cp310-win_arm64.pyd +0 -0
  381. sage/interfaces/sagespawn.pyx +308 -0
  382. sage/interfaces/tab_completion.py +101 -0
  383. sage/misc/all__sagemath_categories.py +78 -0
  384. sage/misc/allocator.cp310-win_arm64.pyd +0 -0
  385. sage/misc/allocator.pxd +6 -0
  386. sage/misc/allocator.pyx +47 -0
  387. sage/misc/binary_tree.cp310-win_arm64.pyd +0 -0
  388. sage/misc/binary_tree.pxd +29 -0
  389. sage/misc/binary_tree.pyx +537 -0
  390. sage/misc/callable_dict.cp310-win_arm64.pyd +0 -0
  391. sage/misc/callable_dict.pyx +89 -0
  392. sage/misc/citation.cp310-win_arm64.pyd +0 -0
  393. sage/misc/citation.pyx +159 -0
  394. sage/misc/converting_dict.py +293 -0
  395. sage/misc/defaults.py +129 -0
  396. sage/misc/derivative.cp310-win_arm64.pyd +0 -0
  397. sage/misc/derivative.pyx +223 -0
  398. sage/misc/functional.py +2005 -0
  399. sage/misc/html.py +589 -0
  400. sage/misc/latex.py +2673 -0
  401. sage/misc/latex_macros.py +236 -0
  402. sage/misc/latex_standalone.py +1833 -0
  403. sage/misc/map_threaded.py +38 -0
  404. sage/misc/mathml.py +76 -0
  405. sage/misc/method_decorator.py +88 -0
  406. sage/misc/mrange.py +755 -0
  407. sage/misc/multireplace.py +41 -0
  408. sage/misc/object_multiplexer.py +92 -0
  409. sage/misc/parser.cp310-win_arm64.pyd +0 -0
  410. sage/misc/parser.pyx +1107 -0
  411. sage/misc/random_testing.py +264 -0
  412. sage/misc/rest_index_of_methods.py +377 -0
  413. sage/misc/search.cp310-win_arm64.pyd +0 -0
  414. sage/misc/search.pxd +2 -0
  415. sage/misc/search.pyx +68 -0
  416. sage/misc/stopgap.cp310-win_arm64.pyd +0 -0
  417. sage/misc/stopgap.pyx +95 -0
  418. sage/misc/table.py +853 -0
  419. sage/monoids/all__sagemath_categories.py +1 -0
  420. sage/monoids/indexed_free_monoid.py +1071 -0
  421. sage/monoids/monoid.py +82 -0
  422. sage/numerical/all__sagemath_categories.py +1 -0
  423. sage/numerical/backends/all__sagemath_categories.py +1 -0
  424. sage/numerical/backends/generic_backend.cp310-win_arm64.pyd +0 -0
  425. sage/numerical/backends/generic_backend.pxd +61 -0
  426. sage/numerical/backends/generic_backend.pyx +1893 -0
  427. sage/numerical/backends/generic_sdp_backend.cp310-win_arm64.pyd +0 -0
  428. sage/numerical/backends/generic_sdp_backend.pxd +38 -0
  429. sage/numerical/backends/generic_sdp_backend.pyx +755 -0
  430. sage/parallel/all.py +6 -0
  431. sage/parallel/decorate.py +575 -0
  432. sage/parallel/map_reduce.py +1997 -0
  433. sage/parallel/multiprocessing_sage.py +77 -0
  434. sage/parallel/ncpus.py +35 -0
  435. sage/parallel/parallelism.py +364 -0
  436. sage/parallel/reference.py +47 -0
  437. sage/parallel/use_fork.py +333 -0
  438. sage/rings/abc.cp310-win_arm64.pyd +0 -0
  439. sage/rings/abc.pxd +31 -0
  440. sage/rings/abc.pyx +526 -0
  441. sage/rings/algebraic_closure_finite_field.py +1154 -0
  442. sage/rings/all__sagemath_categories.py +91 -0
  443. sage/rings/big_oh.py +227 -0
  444. sage/rings/continued_fraction.py +2754 -0
  445. sage/rings/continued_fraction_gosper.py +220 -0
  446. sage/rings/factorint.cp310-win_arm64.pyd +0 -0
  447. sage/rings/factorint.pyx +295 -0
  448. sage/rings/fast_arith.cp310-win_arm64.pyd +0 -0
  449. sage/rings/fast_arith.pxd +21 -0
  450. sage/rings/fast_arith.pyx +535 -0
  451. sage/rings/finite_rings/all__sagemath_categories.py +9 -0
  452. sage/rings/finite_rings/conway_polynomials.py +542 -0
  453. sage/rings/finite_rings/element_base.cp310-win_arm64.pyd +0 -0
  454. sage/rings/finite_rings/element_base.pxd +12 -0
  455. sage/rings/finite_rings/element_base.pyx +1176 -0
  456. sage/rings/finite_rings/finite_field_base.cp310-win_arm64.pyd +0 -0
  457. sage/rings/finite_rings/finite_field_base.pxd +7 -0
  458. sage/rings/finite_rings/finite_field_base.pyx +2171 -0
  459. sage/rings/finite_rings/finite_field_constructor.py +827 -0
  460. sage/rings/finite_rings/finite_field_prime_modn.py +372 -0
  461. sage/rings/finite_rings/galois_group.py +154 -0
  462. sage/rings/finite_rings/hom_finite_field.cp310-win_arm64.pyd +0 -0
  463. sage/rings/finite_rings/hom_finite_field.pxd +23 -0
  464. sage/rings/finite_rings/hom_finite_field.pyx +856 -0
  465. sage/rings/finite_rings/hom_prime_finite_field.cp310-win_arm64.pyd +0 -0
  466. sage/rings/finite_rings/hom_prime_finite_field.pxd +15 -0
  467. sage/rings/finite_rings/hom_prime_finite_field.pyx +164 -0
  468. sage/rings/finite_rings/homset.py +357 -0
  469. sage/rings/finite_rings/integer_mod.cp310-win_arm64.pyd +0 -0
  470. sage/rings/finite_rings/integer_mod.pxd +56 -0
  471. sage/rings/finite_rings/integer_mod.pyx +4586 -0
  472. sage/rings/finite_rings/integer_mod_limits.h +11 -0
  473. sage/rings/finite_rings/integer_mod_ring.py +2044 -0
  474. sage/rings/finite_rings/residue_field.cp310-win_arm64.pyd +0 -0
  475. sage/rings/finite_rings/residue_field.pxd +30 -0
  476. sage/rings/finite_rings/residue_field.pyx +1811 -0
  477. sage/rings/finite_rings/stdint.pxd +19 -0
  478. sage/rings/fraction_field.py +1452 -0
  479. sage/rings/fraction_field_element.cp310-win_arm64.pyd +0 -0
  480. sage/rings/fraction_field_element.pyx +1357 -0
  481. sage/rings/function_field/all.py +7 -0
  482. sage/rings/function_field/all__sagemath_categories.py +2 -0
  483. sage/rings/function_field/constructor.py +218 -0
  484. sage/rings/function_field/element.cp310-win_arm64.pyd +0 -0
  485. sage/rings/function_field/element.pxd +11 -0
  486. sage/rings/function_field/element.pyx +1008 -0
  487. sage/rings/function_field/element_rational.cp310-win_arm64.pyd +0 -0
  488. sage/rings/function_field/element_rational.pyx +513 -0
  489. sage/rings/function_field/extensions.py +230 -0
  490. sage/rings/function_field/function_field.py +1468 -0
  491. sage/rings/function_field/function_field_rational.py +1005 -0
  492. sage/rings/function_field/ideal.py +1155 -0
  493. sage/rings/function_field/ideal_rational.py +629 -0
  494. sage/rings/function_field/jacobian_base.py +826 -0
  495. sage/rings/function_field/jacobian_hess.py +1053 -0
  496. sage/rings/function_field/jacobian_khuri_makdisi.py +1027 -0
  497. sage/rings/function_field/maps.py +1039 -0
  498. sage/rings/function_field/order.py +281 -0
  499. sage/rings/function_field/order_basis.py +586 -0
  500. sage/rings/function_field/order_rational.py +576 -0
  501. sage/rings/function_field/place.py +426 -0
  502. sage/rings/function_field/place_rational.py +181 -0
  503. sage/rings/generic.py +320 -0
  504. sage/rings/homset.py +332 -0
  505. sage/rings/ideal.py +1885 -0
  506. sage/rings/ideal_monoid.py +215 -0
  507. sage/rings/infinity.py +1890 -0
  508. sage/rings/integer.cp310-win_arm64.pyd +0 -0
  509. sage/rings/integer.pxd +45 -0
  510. sage/rings/integer.pyx +7874 -0
  511. sage/rings/integer_ring.cp310-win_arm64.pyd +0 -0
  512. sage/rings/integer_ring.pxd +8 -0
  513. sage/rings/integer_ring.pyx +1693 -0
  514. sage/rings/laurent_series_ring.py +931 -0
  515. sage/rings/laurent_series_ring_element.cp310-win_arm64.pyd +0 -0
  516. sage/rings/laurent_series_ring_element.pxd +11 -0
  517. sage/rings/laurent_series_ring_element.pyx +1927 -0
  518. sage/rings/lazy_series.py +7815 -0
  519. sage/rings/lazy_series_ring.py +4356 -0
  520. sage/rings/localization.py +1043 -0
  521. sage/rings/morphism.cp310-win_arm64.pyd +0 -0
  522. sage/rings/morphism.pxd +39 -0
  523. sage/rings/morphism.pyx +3299 -0
  524. sage/rings/multi_power_series_ring.py +1145 -0
  525. sage/rings/multi_power_series_ring_element.py +2184 -0
  526. sage/rings/noncommutative_ideals.cp310-win_arm64.pyd +0 -0
  527. sage/rings/noncommutative_ideals.pyx +423 -0
  528. sage/rings/number_field/all__sagemath_categories.py +1 -0
  529. sage/rings/number_field/number_field_base.cp310-win_arm64.pyd +0 -0
  530. sage/rings/number_field/number_field_base.pxd +8 -0
  531. sage/rings/number_field/number_field_base.pyx +507 -0
  532. sage/rings/number_field/number_field_element_base.cp310-win_arm64.pyd +0 -0
  533. sage/rings/number_field/number_field_element_base.pxd +6 -0
  534. sage/rings/number_field/number_field_element_base.pyx +36 -0
  535. sage/rings/number_field/number_field_ideal.py +3550 -0
  536. sage/rings/padics/all__sagemath_categories.py +4 -0
  537. sage/rings/padics/local_generic.py +1670 -0
  538. sage/rings/padics/local_generic_element.cp310-win_arm64.pyd +0 -0
  539. sage/rings/padics/local_generic_element.pxd +5 -0
  540. sage/rings/padics/local_generic_element.pyx +1017 -0
  541. sage/rings/padics/misc.py +256 -0
  542. sage/rings/padics/padic_generic.py +1911 -0
  543. sage/rings/padics/pow_computer.cp310-win_arm64.pyd +0 -0
  544. sage/rings/padics/pow_computer.pxd +38 -0
  545. sage/rings/padics/pow_computer.pyx +671 -0
  546. sage/rings/padics/precision_error.py +24 -0
  547. sage/rings/polynomial/all__sagemath_categories.py +25 -0
  548. sage/rings/polynomial/commutative_polynomial.cp310-win_arm64.pyd +0 -0
  549. sage/rings/polynomial/commutative_polynomial.pxd +6 -0
  550. sage/rings/polynomial/commutative_polynomial.pyx +24 -0
  551. sage/rings/polynomial/cyclotomic.cp310-win_arm64.pyd +0 -0
  552. sage/rings/polynomial/cyclotomic.pyx +404 -0
  553. sage/rings/polynomial/flatten.py +711 -0
  554. sage/rings/polynomial/ideal.py +102 -0
  555. sage/rings/polynomial/infinite_polynomial_element.py +1768 -0
  556. sage/rings/polynomial/infinite_polynomial_ring.py +1653 -0
  557. sage/rings/polynomial/laurent_polynomial.cp310-win_arm64.pyd +0 -0
  558. sage/rings/polynomial/laurent_polynomial.pxd +18 -0
  559. sage/rings/polynomial/laurent_polynomial.pyx +2190 -0
  560. sage/rings/polynomial/laurent_polynomial_ideal.py +590 -0
  561. sage/rings/polynomial/laurent_polynomial_ring.py +832 -0
  562. sage/rings/polynomial/laurent_polynomial_ring_base.py +708 -0
  563. sage/rings/polynomial/multi_polynomial.cp310-win_arm64.pyd +0 -0
  564. sage/rings/polynomial/multi_polynomial.pxd +15 -0
  565. sage/rings/polynomial/multi_polynomial.pyx +3082 -0
  566. sage/rings/polynomial/multi_polynomial_element.py +2570 -0
  567. sage/rings/polynomial/multi_polynomial_ideal.py +5771 -0
  568. sage/rings/polynomial/multi_polynomial_ring.py +947 -0
  569. sage/rings/polynomial/multi_polynomial_ring_base.cp310-win_arm64.pyd +0 -0
  570. sage/rings/polynomial/multi_polynomial_ring_base.pxd +15 -0
  571. sage/rings/polynomial/multi_polynomial_ring_base.pyx +1855 -0
  572. sage/rings/polynomial/multi_polynomial_sequence.py +2204 -0
  573. sage/rings/polynomial/polydict.cp310-win_arm64.pyd +0 -0
  574. sage/rings/polynomial/polydict.pxd +45 -0
  575. sage/rings/polynomial/polydict.pyx +2701 -0
  576. sage/rings/polynomial/polynomial_compiled.cp310-win_arm64.pyd +0 -0
  577. sage/rings/polynomial/polynomial_compiled.pxd +59 -0
  578. sage/rings/polynomial/polynomial_compiled.pyx +509 -0
  579. sage/rings/polynomial/polynomial_element.cp310-win_arm64.pyd +0 -0
  580. sage/rings/polynomial/polynomial_element.pxd +67 -0
  581. sage/rings/polynomial/polynomial_element.pyx +13255 -0
  582. sage/rings/polynomial/polynomial_element_generic.py +1637 -0
  583. sage/rings/polynomial/polynomial_fateman.py +97 -0
  584. sage/rings/polynomial/polynomial_quotient_ring.py +2465 -0
  585. sage/rings/polynomial/polynomial_quotient_ring_element.py +779 -0
  586. sage/rings/polynomial/polynomial_ring.py +3784 -0
  587. sage/rings/polynomial/polynomial_ring_constructor.py +1051 -0
  588. sage/rings/polynomial/polynomial_ring_homomorphism.cp310-win_arm64.pyd +0 -0
  589. sage/rings/polynomial/polynomial_ring_homomorphism.pxd +5 -0
  590. sage/rings/polynomial/polynomial_ring_homomorphism.pyx +121 -0
  591. sage/rings/polynomial/polynomial_singular_interface.py +549 -0
  592. sage/rings/polynomial/symmetric_ideal.py +989 -0
  593. sage/rings/polynomial/symmetric_reduction.cp310-win_arm64.pyd +0 -0
  594. sage/rings/polynomial/symmetric_reduction.pxd +8 -0
  595. sage/rings/polynomial/symmetric_reduction.pyx +669 -0
  596. sage/rings/polynomial/term_order.py +2279 -0
  597. sage/rings/polynomial/toy_buchberger.py +449 -0
  598. sage/rings/polynomial/toy_d_basis.py +387 -0
  599. sage/rings/polynomial/toy_variety.py +362 -0
  600. sage/rings/power_series_mpoly.cp310-win_arm64.pyd +0 -0
  601. sage/rings/power_series_mpoly.pxd +9 -0
  602. sage/rings/power_series_mpoly.pyx +161 -0
  603. sage/rings/power_series_poly.cp310-win_arm64.pyd +0 -0
  604. sage/rings/power_series_poly.pxd +10 -0
  605. sage/rings/power_series_poly.pyx +1317 -0
  606. sage/rings/power_series_ring.py +1441 -0
  607. sage/rings/power_series_ring_element.cp310-win_arm64.pyd +0 -0
  608. sage/rings/power_series_ring_element.pxd +12 -0
  609. sage/rings/power_series_ring_element.pyx +3028 -0
  610. sage/rings/puiseux_series_ring.py +487 -0
  611. sage/rings/puiseux_series_ring_element.cp310-win_arm64.pyd +0 -0
  612. sage/rings/puiseux_series_ring_element.pxd +7 -0
  613. sage/rings/puiseux_series_ring_element.pyx +1055 -0
  614. sage/rings/qqbar_decorators.py +167 -0
  615. sage/rings/quotient_ring.py +1598 -0
  616. sage/rings/quotient_ring_element.py +979 -0
  617. sage/rings/rational.cp310-win_arm64.pyd +0 -0
  618. sage/rings/rational.pxd +20 -0
  619. sage/rings/rational.pyx +4284 -0
  620. sage/rings/rational_field.py +1730 -0
  621. sage/rings/real_double.cp310-win_arm64.pyd +0 -0
  622. sage/rings/real_double.pxd +16 -0
  623. sage/rings/real_double.pyx +2218 -0
  624. sage/rings/real_lazy.cp310-win_arm64.pyd +0 -0
  625. sage/rings/real_lazy.pxd +30 -0
  626. sage/rings/real_lazy.pyx +1773 -0
  627. sage/rings/ring.cp310-win_arm64.pyd +0 -0
  628. sage/rings/ring.pxd +30 -0
  629. sage/rings/ring.pyx +850 -0
  630. sage/rings/semirings/all.py +3 -0
  631. sage/rings/semirings/non_negative_integer_semiring.py +107 -0
  632. sage/rings/semirings/tropical_mpolynomial.py +972 -0
  633. sage/rings/semirings/tropical_polynomial.py +997 -0
  634. sage/rings/semirings/tropical_semiring.cp310-win_arm64.pyd +0 -0
  635. sage/rings/semirings/tropical_semiring.pyx +676 -0
  636. sage/rings/semirings/tropical_variety.py +1701 -0
  637. sage/rings/sum_of_squares.cp310-win_arm64.pyd +0 -0
  638. sage/rings/sum_of_squares.pxd +3 -0
  639. sage/rings/sum_of_squares.pyx +336 -0
  640. sage/rings/tests.py +504 -0
  641. sage/schemes/affine/affine_homset.py +508 -0
  642. sage/schemes/affine/affine_morphism.py +1574 -0
  643. sage/schemes/affine/affine_point.py +460 -0
  644. sage/schemes/affine/affine_rational_point.py +308 -0
  645. sage/schemes/affine/affine_space.py +1264 -0
  646. sage/schemes/affine/affine_subscheme.py +592 -0
  647. sage/schemes/affine/all.py +25 -0
  648. sage/schemes/all__sagemath_categories.py +5 -0
  649. sage/schemes/generic/algebraic_scheme.py +2092 -0
  650. sage/schemes/generic/all.py +5 -0
  651. sage/schemes/generic/ambient_space.py +400 -0
  652. sage/schemes/generic/divisor.py +465 -0
  653. sage/schemes/generic/divisor_group.py +313 -0
  654. sage/schemes/generic/glue.py +84 -0
  655. sage/schemes/generic/homset.py +820 -0
  656. sage/schemes/generic/hypersurface.py +234 -0
  657. sage/schemes/generic/morphism.py +2107 -0
  658. sage/schemes/generic/point.py +237 -0
  659. sage/schemes/generic/scheme.py +1190 -0
  660. sage/schemes/generic/spec.py +199 -0
  661. sage/schemes/product_projective/all.py +6 -0
  662. sage/schemes/product_projective/homset.py +236 -0
  663. sage/schemes/product_projective/morphism.py +517 -0
  664. sage/schemes/product_projective/point.py +568 -0
  665. sage/schemes/product_projective/rational_point.py +550 -0
  666. sage/schemes/product_projective/space.py +1301 -0
  667. sage/schemes/product_projective/subscheme.py +466 -0
  668. sage/schemes/projective/all.py +24 -0
  669. sage/schemes/projective/proj_bdd_height.py +453 -0
  670. sage/schemes/projective/projective_homset.py +718 -0
  671. sage/schemes/projective/projective_morphism.py +2792 -0
  672. sage/schemes/projective/projective_point.py +1484 -0
  673. sage/schemes/projective/projective_rational_point.py +569 -0
  674. sage/schemes/projective/projective_space.py +2571 -0
  675. sage/schemes/projective/projective_subscheme.py +1574 -0
  676. sage/sets/all.py +17 -0
  677. sage/sets/cartesian_product.py +376 -0
  678. sage/sets/condition_set.py +525 -0
  679. sage/sets/disjoint_set.cp310-win_arm64.pyd +0 -0
  680. sage/sets/disjoint_set.pxd +36 -0
  681. sage/sets/disjoint_set.pyx +998 -0
  682. sage/sets/disjoint_union_enumerated_sets.py +625 -0
  683. sage/sets/family.cp310-win_arm64.pyd +0 -0
  684. sage/sets/family.pxd +12 -0
  685. sage/sets/family.pyx +1556 -0
  686. sage/sets/finite_enumerated_set.py +406 -0
  687. sage/sets/finite_set_map_cy.cp310-win_arm64.pyd +0 -0
  688. sage/sets/finite_set_map_cy.pxd +34 -0
  689. sage/sets/finite_set_map_cy.pyx +708 -0
  690. sage/sets/finite_set_maps.py +591 -0
  691. sage/sets/image_set.py +448 -0
  692. sage/sets/integer_range.py +829 -0
  693. sage/sets/non_negative_integers.py +241 -0
  694. sage/sets/positive_integers.py +93 -0
  695. sage/sets/primes.py +188 -0
  696. sage/sets/real_set.py +2760 -0
  697. sage/sets/recursively_enumerated_set.cp310-win_arm64.pyd +0 -0
  698. sage/sets/recursively_enumerated_set.pxd +31 -0
  699. sage/sets/recursively_enumerated_set.pyx +2088 -0
  700. sage/sets/set.py +2083 -0
  701. sage/sets/set_from_iterator.py +1021 -0
  702. sage/sets/totally_ordered_finite_set.py +329 -0
  703. sage/symbolic/all__sagemath_categories.py +1 -0
  704. sage/symbolic/function.cp310-win_arm64.pyd +0 -0
  705. sage/symbolic/function.pxd +29 -0
  706. sage/symbolic/function.pyx +1488 -0
  707. sage/symbolic/symbols.py +56 -0
  708. sage/tests/all__sagemath_categories.py +1 -0
  709. sage/tests/cython.cp310-win_arm64.pyd +0 -0
  710. sage/tests/cython.pyx +37 -0
  711. sage/tests/stl_vector.cp310-win_arm64.pyd +0 -0
  712. sage/tests/stl_vector.pyx +171 -0
  713. sage/typeset/all.py +6 -0
  714. sage/typeset/ascii_art.py +295 -0
  715. sage/typeset/character_art.py +789 -0
  716. sage/typeset/character_art_factory.py +572 -0
  717. sage/typeset/symbols.py +334 -0
  718. sage/typeset/unicode_art.py +183 -0
  719. sage/typeset/unicode_characters.py +101 -0
@@ -0,0 +1,1566 @@
1
+ # sage_setup: distribution = sagemath-categories
2
+ r"""
3
+ Finite dimensional modules with basis
4
+ """
5
+ # ****************************************************************************
6
+ # Copyright (C) 2008 Teresa Gomez-Diaz (CNRS) <Teresa.Gomez-Diaz@univ-mlv.fr>
7
+ # 2011 Nicolas M. Thiery <nthiery at users.sf.net>
8
+ #
9
+ # Distributed under the terms of the GNU General Public License (GPL)
10
+ # http://www.gnu.org/licenses/
11
+ # *****************************************************************************
12
+
13
+ import functools
14
+ import operator
15
+ from sage.categories.category_with_axiom import CategoryWithAxiom, CategoryWithAxiom_over_base_ring
16
+ from sage.categories.fields import Fields
17
+ from sage.categories.homsets import HomsetsCategory
18
+ from sage.categories.tensor import TensorProductsCategory
19
+ from sage.misc.cachefunc import cached_method
20
+ from sage.misc.lazy_attribute import lazy_attribute
21
+
22
+
23
+ class FiniteDimensionalModulesWithBasis(CategoryWithAxiom_over_base_ring):
24
+ """
25
+ The category of finite dimensional modules with a distinguished basis.
26
+
27
+ EXAMPLES::
28
+
29
+ sage: C = FiniteDimensionalModulesWithBasis(ZZ); C
30
+ Category of finite dimensional modules with basis over Integer Ring
31
+ sage: sorted(C.super_categories(), key=str)
32
+ [Category of finite dimensional modules over Integer Ring,
33
+ Category of modules with basis over Integer Ring]
34
+ sage: C is Modules(ZZ).WithBasis().FiniteDimensional()
35
+ True
36
+
37
+ TESTS::
38
+
39
+ sage: TestSuite(C).run()
40
+ """
41
+
42
+ class ParentMethods:
43
+
44
+ def gens(self) -> tuple:
45
+ """
46
+ Return the generators of ``self``.
47
+
48
+ OUTPUT: a tuple containing the basis elements of ``self``
49
+
50
+ EXAMPLES::
51
+
52
+ sage: F = CombinatorialFreeModule(ZZ, ['a', 'b', 'c']) # needs sage.modules
53
+ sage: F.gens() # needs sage.modules
54
+ (B['a'], B['b'], B['c'])
55
+ """
56
+ return tuple(self.basis())
57
+
58
+ def annihilator(self, S, action=operator.mul, side='right', category=None):
59
+ r"""
60
+ Return the annihilator of a finite set.
61
+
62
+ INPUT:
63
+
64
+ - ``S`` -- a finite set
65
+
66
+ - ``action`` -- a function (default: :obj:`operator.mul`)
67
+
68
+ - ``side`` -- ``'left'`` or ``'right'`` (default: ``'right'``)
69
+
70
+ - ``category`` -- a category
71
+
72
+ Assumptions:
73
+
74
+ - ``action`` takes elements of ``self`` as first argument
75
+ and elements of ``S`` as second argument;
76
+
77
+ - The codomain is any vector space, and ``action`` is
78
+ linear on its first argument; typically it is bilinear;
79
+
80
+ - If ``side`` is 'left', this is reversed.
81
+
82
+ OUTPUT:
83
+
84
+ The subspace of the elements `x` of ``self`` such that
85
+ ``action(x,s) = 0`` for all `s\in S`. If ``side`` is
86
+ 'left' replace the above equation by ``action(s,x) = 0``.
87
+
88
+ If ``self`` is a ring, ``action`` an action of ``self`` on
89
+ a module `M` and `S` is a subset of `M`, we recover the
90
+ :wikipedia:`Annihilator_%28ring_theory%29`. Similarly this
91
+ can be used to compute torsion or orthogonals.
92
+
93
+ .. SEEALSO:: :meth:`annihilator_basis` for lots of examples.
94
+
95
+ EXAMPLES::
96
+
97
+ sage: # needs sage.modules
98
+ sage: F = FiniteDimensionalAlgebrasWithBasis(QQ).example(); F
99
+ An example of a finite dimensional algebra with basis:
100
+ the path algebra of the Kronecker quiver
101
+ (containing the arrows a:x->y and b:x->y) over Rational Field
102
+ sage: x, y, a, b = F.basis()
103
+ sage: A = F.annihilator([a + 3*b + 2*y]); A
104
+ Free module generated by {0} over Rational Field
105
+ sage: [b.lift() for b in A.basis()]
106
+ [-1/2*a - 3/2*b + x]
107
+
108
+ The category can be used to specify other properties of
109
+ this subspace, like that this is a subalgebra::
110
+
111
+ sage: # needs sage.modules
112
+ sage: center = F.annihilator(F.basis(), F.bracket,
113
+ ....: category=Algebras(QQ).Subobjects())
114
+ sage: (e,) = center.basis()
115
+ sage: e.lift()
116
+ x + y
117
+ sage: e * e == e
118
+ True
119
+
120
+ Taking annihilator is order reversing for inclusion::
121
+
122
+ sage: # needs sage.modules
123
+ sage: A = F.annihilator([]); A .rename('A')
124
+ sage: Ax = F.annihilator([x]); Ax .rename('Ax')
125
+ sage: Ay = F.annihilator([y]); Ay .rename('Ay')
126
+ sage: Axy = F.annihilator([x,y]); Axy.rename('Axy')
127
+ sage: P = Poset(([A, Ax, Ay, Axy], attrcall("is_submodule"))) # needs sage.graphs
128
+ sage: sorted(P.cover_relations(), key=str) # needs sage.graphs
129
+ [[Ax, A], [Axy, Ax], [Axy, Ay], [Ay, A]]
130
+ """
131
+ return self.submodule(self.annihilator_basis(S, action, side),
132
+ already_echelonized=True,
133
+ category=category)
134
+
135
+ def annihilator_basis(self, S, action=operator.mul, side='right'):
136
+ """
137
+ Return a basis of the annihilator of a finite set of elements.
138
+
139
+ INPUT:
140
+
141
+ - ``S`` -- a finite set of objects
142
+
143
+ - ``action`` -- a function (default: :obj:`operator.mul`)
144
+
145
+ - ``side`` -- ``'left'`` or ``'right'`` (default: ``'right'``):
146
+ on which side of ``self`` the elements of `S` acts
147
+
148
+ See :meth:`annihilator` for the assumptions and definition
149
+ of the annihilator.
150
+
151
+ EXAMPLES:
152
+
153
+ By default, the action is the standard `*` operation. So
154
+ our first example is about an algebra::
155
+
156
+ sage: # needs sage.graphs sage.modules
157
+ sage: F = FiniteDimensionalAlgebrasWithBasis(QQ).example(); F
158
+ An example of a finite dimensional algebra with basis:
159
+ the path algebra of the Kronecker quiver
160
+ (containing the arrows a:x->y and b:x->y) over Rational Field
161
+ sage: x,y,a,b = F.basis()
162
+
163
+ In this algebra, multiplication on the right by `x`
164
+ annihilates all basis elements but `x`::
165
+
166
+ sage: x*x, y*x, a*x, b*x # needs sage.graphs sage.modules
167
+ (x, 0, 0, 0)
168
+
169
+ So the annihilator is the subspace spanned by `y`, `a`, and `b`::
170
+
171
+ sage: F.annihilator_basis([x]) # needs sage.graphs sage.modules
172
+ (y, a, b)
173
+
174
+ The same holds for `a` and `b`::
175
+
176
+ sage: x*a, y*a, a*a, b*a # needs sage.graphs sage.modules
177
+ (a, 0, 0, 0)
178
+ sage: F.annihilator_basis([a]) # needs sage.graphs sage.modules
179
+ (y, a, b)
180
+
181
+ On the other hand, `y` annihilates only `x`::
182
+
183
+ sage: F.annihilator_basis([y]) # needs sage.graphs sage.modules
184
+ (x,)
185
+
186
+ Here is a non trivial annihilator::
187
+
188
+ sage: F.annihilator_basis([a + 3*b + 2*y]) # needs sage.graphs sage.modules
189
+ (-1/2*a - 3/2*b + x,)
190
+
191
+ Let's check it::
192
+
193
+ sage: (-1/2*a - 3/2*b + x) * (a + 3*b + 2*y) # needs sage.graphs sage.modules
194
+ 0
195
+
196
+ Doing the same calculations on the left exchanges the
197
+ roles of `x` and `y`::
198
+
199
+ sage: # needs sage.graphs sage.modules
200
+ sage: F.annihilator_basis([y], side='left')
201
+ (x, a, b)
202
+ sage: F.annihilator_basis([a], side='left')
203
+ (x, a, b)
204
+ sage: F.annihilator_basis([b], side='left')
205
+ (x, a, b)
206
+ sage: F.annihilator_basis([x], side='left')
207
+ (y,)
208
+ sage: F.annihilator_basis([a + 3*b + 2*x], side='left')
209
+ (-1/2*a - 3/2*b + y,)
210
+
211
+ By specifying an inner product, this method can be used to
212
+ compute the orthogonal of a subspace::
213
+
214
+ sage: # needs sage.graphs sage.modules
215
+ sage: x,y,a,b = F.basis()
216
+ sage: def scalar(u, v):
217
+ ....: return vector([sum(u[i]*v[i] for i in F.basis().keys())])
218
+ sage: F.annihilator_basis([x + y, a + b], scalar)
219
+ (x - y, a - b)
220
+
221
+ By specifying the standard Lie bracket as action, one can
222
+ compute the commutator of a subspace of `F`::
223
+
224
+ sage: F.annihilator_basis([a + b], action=F.bracket) # needs sage.graphs sage.modules
225
+ (x + y, a, b)
226
+
227
+ In particular one can compute a basis of the center of the
228
+ algebra. In our example, it is reduced to the identity::
229
+
230
+ sage: F.annihilator_basis(F.algebra_generators(), action=F.bracket) # needs sage.graphs sage.modules
231
+ (x + y,)
232
+
233
+ But see also
234
+ :meth:`FiniteDimensionalAlgebrasWithBasis.ParentMethods.center_basis`.
235
+ """
236
+ # TODO: optimize this!
237
+ from sage.matrix.constructor import matrix
238
+ if side == 'right':
239
+ action_left = action
240
+ action = lambda b,s: action_left(s, b)
241
+
242
+ mat = matrix(self.base_ring(), self.dimension(), 0)
243
+ for s in S:
244
+ mat = mat.augment(matrix(self.base_ring(),
245
+ [action(s, b)._vector_() for b in self.basis()]))
246
+ return tuple(map(self.from_vector, mat.left_kernel().basis()))
247
+
248
+ @cached_method
249
+ def _dense_free_module(self, base_ring=None):
250
+ """
251
+ Return a dense free module of the same dimension as ``self``.
252
+
253
+ INPUT:
254
+
255
+ - ``base_ring`` -- a ring or ``None``
256
+
257
+ If ``base_ring`` is ``None``, then the base ring of ``self``
258
+ is used.
259
+
260
+ This method is mostly used by ``_vector_``
261
+
262
+ EXAMPLES::
263
+
264
+ sage: C = CombinatorialFreeModule(QQ['x'], ['a','b','c']); C # needs sage.modules
265
+ Free module generated by {'a', 'b', 'c'} over
266
+ Univariate Polynomial Ring in x over Rational Field
267
+ sage: C._dense_free_module() # needs sage.modules
268
+ Ambient free module of rank 3 over the principal ideal domain
269
+ Univariate Polynomial Ring in x over Rational Field
270
+ sage: C._dense_free_module(QQ['x,y']) # needs sage.modules
271
+ Ambient free module of rank 3 over the integral domain
272
+ Multivariate Polynomial Ring in x, y over Rational Field
273
+ """
274
+ if base_ring is None:
275
+ base_ring = self.base_ring()
276
+ from sage.modules.free_module import FreeModule
277
+ return FreeModule(base_ring, self.dimension())
278
+
279
+ def from_vector(self, vector, order=None, coerce=True):
280
+ """
281
+ Build an element of ``self`` from a vector.
282
+
283
+ EXAMPLES::
284
+
285
+ sage: # needs sage.modules
286
+ sage: p_mult = matrix([[0,0,0], [0,0,-1], [0,0,0]])
287
+ sage: q_mult = matrix([[0,0,1], [0,0,0], [0,0,0]])
288
+ sage: A = algebras.FiniteDimensional(
289
+ ....: QQ, [p_mult, q_mult, matrix(QQ, 3, 3)], 'p,q,z')
290
+ sage: A.from_vector(vector([1,0,2]))
291
+ p + 2*z
292
+ """
293
+ if order is None:
294
+ try:
295
+ order = sorted(self.basis().keys())
296
+ except AttributeError: # Not a family, assume it is list-like
297
+ order = range(self.dimension())
298
+ if not coerce or vector.base_ring() is self.base_ring():
299
+ return self._from_dict({order[i]: c for i,c in vector.items()},
300
+ coerce=False)
301
+ R = self.base_ring()
302
+ return self._from_dict({order[i]: R(c) for i,c in vector.items() if R(c)},
303
+ coerce=False, remove_zeros=False)
304
+
305
+ def echelon_form(self, elements, row_reduced=False, order=None):
306
+ r"""
307
+ Return a basis in echelon form of the subspace spanned by
308
+ a finite set of elements.
309
+
310
+ INPUT:
311
+
312
+ - ``elements`` -- list or finite iterable of elements of ``self``
313
+ - ``row_reduced`` -- boolean (default: ``False``); whether to
314
+ compute the basis for the row reduced echelon form
315
+ - ``order`` -- (optional) either something that can
316
+ be converted into a tuple or a key function
317
+
318
+ OUTPUT:
319
+
320
+ A list of elements of ``self`` whose expressions as vectors
321
+ form a matrix in echelon form. If ``base_ring`` is specified,
322
+ then the calculation is achieved in this base ring.
323
+
324
+ EXAMPLES::
325
+
326
+ sage: # needs sage.modules
327
+ sage: X = CombinatorialFreeModule(QQ, range(3), prefix='x')
328
+ sage: x = X.basis()
329
+ sage: V = X.echelon_form([x[0]-x[1], x[0]-x[2], x[1]-x[2]]); V
330
+ [x[0] - x[2], x[1] - x[2]]
331
+ sage: matrix(list(map(vector, V)))
332
+ [ 1 0 -1]
333
+ [ 0 1 -1]
334
+
335
+ ::
336
+
337
+ sage: # needs sage.modules
338
+ sage: F = CombinatorialFreeModule(ZZ, [1,2,3,4])
339
+ sage: B = F.basis()
340
+ sage: elements = [B[1]-17*B[2]+6*B[3], B[1]-17*B[2]+B[4]]
341
+ sage: F.echelon_form(elements)
342
+ [B[1] - 17*B[2] + B[4], 6*B[3] - B[4]]
343
+
344
+ ::
345
+
346
+ sage: F = CombinatorialFreeModule(QQ, ['a','b','c']) # needs sage.modules
347
+ sage: a,b,c = F.basis() # needs sage.modules
348
+ sage: F.echelon_form([8*a+b+10*c, -3*a+b-c, a-b-c]) # needs sage.modules
349
+ [B['a'] + B['c'], B['b'] + 2*B['c']]
350
+
351
+ ::
352
+
353
+ sage: R.<x,y> = QQ[]
354
+ sage: C = CombinatorialFreeModule(R, range(3), prefix='x') # needs sage.modules
355
+ sage: x = C.basis() # needs sage.modules
356
+ sage: C.echelon_form([x[0] - x[1], 2*x[1] - 2*x[2], x[0] - x[2]]) # needs sage.modules sage.rings.function_field
357
+ [x[0] - x[2], x[1] - x[2]]
358
+
359
+ ::
360
+
361
+ sage: M = MatrixSpace(QQ, 3, 3) # needs sage.modules
362
+ sage: A = M([[0, 0, 2], [0, 0, 0], [0, 0, 0]]) # needs sage.modules
363
+ sage: M.echelon_form([A, A]) # needs sage.modules
364
+ [
365
+ [0 0 1]
366
+ [0 0 0]
367
+ [0 0 0]
368
+ ]
369
+
370
+ TESTS:
371
+
372
+ We convert the input elements to ``self``::
373
+
374
+ sage: E.<x,y,z> = ExteriorAlgebra(QQ) # needs sage.modules
375
+ sage: E.echelon_form([1, x + 2]) # needs sage.modules
376
+ [1, x]
377
+ """
378
+ # Make sure elements consists of elements of ``self``
379
+ elements = [self(y) for y in elements]
380
+ if order is not None:
381
+ order = self._compute_support_order(elements, order)
382
+ from sage.matrix.constructor import matrix
383
+ mat = matrix(self.base_ring(), [g._vector_(order=order) for g in elements])
384
+ # Echelonizing a matrix over a field returned the rref
385
+ if row_reduced and self.base_ring() not in Fields():
386
+ try:
387
+ mat = mat.rref().change_ring(self.base_ring())
388
+ except (ValueError, TypeError):
389
+ raise ValueError("unable to compute the row reduced echelon form")
390
+ else:
391
+ mat.echelonize()
392
+ ret = [self.from_vector(vec, order=order) for vec in mat if vec]
393
+ return ret
394
+
395
+ def invariant_module(self, S, action=operator.mul, action_on_basis=None,
396
+ side='left', **kwargs):
397
+ r"""
398
+ Return the submodule of ``self`` invariant under the action
399
+ of ``S``.
400
+
401
+ For a semigroup `S` acting on a module `M`, the invariant
402
+ submodule is given by
403
+
404
+ .. MATH::
405
+
406
+ M^S = \{m \in M : s \cdot m = m,\, \forall s \in S\}.
407
+
408
+ INPUT:
409
+
410
+ - ``S`` -- a finitely-generated semigroup
411
+ - ``action`` -- a function (default: :obj:`operator.mul`)
412
+ - ``side`` -- ``'left'`` or ``'right'`` (default: ``'right'``);
413
+ which side of ``self`` the elements of ``S`` acts
414
+ - ``action_on_basis`` -- (optional) define the action of ``S``
415
+ on the basis of ``self``
416
+
417
+ OUTPUT: :class:`~sage.modules.with_basis.invariant.FiniteDimensionalInvariantModule`
418
+
419
+ EXAMPLES:
420
+
421
+ We build the invariant module of the permutation representation
422
+ of the symmetric group::
423
+
424
+ sage: # needs sage.combinat sage.groups sage.modules
425
+ sage: G = SymmetricGroup(3); G.rename('S3')
426
+ sage: M = FreeModule(ZZ, [1,2,3], prefix='M'); M.rename('M')
427
+ sage: action = lambda g, x: M.term(g(x))
428
+ sage: I = M.invariant_module(G, action_on_basis=action); I
429
+ (S3)-invariant submodule of M
430
+ sage: I.basis()
431
+ Finite family {0: B[0]}
432
+ sage: [I.lift(b) for b in I.basis()]
433
+ [M[1] + M[2] + M[3]]
434
+ sage: G.rename(); M.rename() # reset the names
435
+
436
+ We can construct the invariant module of any module that has
437
+ an action of ``S``. In this example, we consider the dihedral
438
+ group `G = D_4` and the subgroup `H < G` of all rotations. We
439
+ construct the `H`-invariant module of the group algebra `\QQ[G]`::
440
+
441
+ sage: # needs sage.groups
442
+ sage: G = groups.permutation.Dihedral(4)
443
+ sage: H = G.subgroup(G.gen(0))
444
+ sage: H
445
+ Subgroup generated by [(1,2,3,4)]
446
+ of (Dihedral group of order 8 as a permutation group)
447
+ sage: H.cardinality()
448
+ 4
449
+
450
+ sage: # needs sage.groups sage.modules
451
+ sage: A = G.algebra(QQ)
452
+ sage: I = A.invariant_module(H)
453
+ sage: [I.lift(b) for b in I.basis()]
454
+ [() + (1,2,3,4) + (1,3)(2,4) + (1,4,3,2),
455
+ (2,4) + (1,2)(3,4) + (1,3) + (1,4)(2,3)]
456
+ sage: all(h * I.lift(b) == I.lift(b)
457
+ ....: for b in I.basis() for h in H)
458
+ True
459
+ """
460
+ if action_on_basis is not None:
461
+ from sage.modules.with_basis.representation import Representation
462
+ M = Representation(S, self, action_on_basis, side=side)
463
+ else:
464
+ M = self
465
+
466
+ from sage.modules.with_basis.invariant import FiniteDimensionalInvariantModule
467
+ return FiniteDimensionalInvariantModule(M, S, action=action, side=side, **kwargs)
468
+
469
+ def twisted_invariant_module(self, G, chi,
470
+ action=operator.mul,
471
+ action_on_basis=None,
472
+ side='left',
473
+ **kwargs):
474
+ r"""
475
+ Create the isotypic component of the action of ``G`` on
476
+ ``self`` with irreducible character given by ``chi``.
477
+
478
+ .. SEEALSO::
479
+
480
+ -:class:`~sage.modules.with_basis.invariant.FiniteDimensionalTwistedInvariantModule`
481
+
482
+ INPUT:
483
+
484
+ - ``G`` -- a finitely-generated group
485
+ - ``chi`` -- list/tuple of character values or an instance of
486
+ :class:`~sage.groups.class_function.ClassFunction_gap`
487
+ - ``action`` -- a function (default: :obj:`operator.mul`)
488
+ - ``action_on_basis`` -- (optional) define the action of ``g``
489
+ on the basis of ``self``
490
+ - ``side`` -- ``'left'`` or ``'right'`` (default: ``'right'``);
491
+ which side of ``self`` the elements of ``S`` acts
492
+
493
+ OUTPUT: :class:`~sage.modules.with_basis.invariant.FiniteDimensionalTwistedInvariantModule`
494
+
495
+ EXAMPLES::
496
+
497
+ sage: # needs sage.combinat sage.groups sage.modules
498
+ sage: M = CombinatorialFreeModule(QQ, [1,2,3])
499
+ sage: G = SymmetricGroup(3)
500
+ sage: def action(g, x): return(M.term(g(x))) # permute coordinates
501
+ sage: T = M.twisted_invariant_module(G, [2,0,-1],
502
+ ....: action_on_basis=action)
503
+ sage: import __main__; __main__.action = action
504
+ sage: TestSuite(T).run()
505
+ """
506
+
507
+ if action_on_basis is not None:
508
+ from sage.modules.with_basis.representation import Representation
509
+ from sage.categories.modules import Modules
510
+ category = kwargs.pop('category', Modules(self.base_ring()).WithBasis())
511
+ M = Representation(G, self, action_on_basis, side=side, category=category)
512
+ else:
513
+ M = self
514
+
515
+ from sage.modules.with_basis.invariant import FiniteDimensionalTwistedInvariantModule
516
+ return FiniteDimensionalTwistedInvariantModule(M, G, chi,
517
+ action, side, **kwargs)
518
+
519
+ class ElementMethods:
520
+ def dense_coefficient_list(self, order=None):
521
+ """
522
+ Return a list of *all* coefficients of ``self``.
523
+
524
+ By default, this list is ordered in the same way as the
525
+ indexing set of the basis of the parent of ``self``.
526
+
527
+ INPUT:
528
+
529
+ - ``order`` -- (optional) an ordering of the basis indexing set
530
+
531
+ EXAMPLES::
532
+
533
+ sage: # needs sage.modules
534
+ sage: v = vector([0, -1, -3])
535
+ sage: v.dense_coefficient_list()
536
+ [0, -1, -3]
537
+ sage: v.dense_coefficient_list([2,1,0])
538
+ [-3, -1, 0]
539
+ sage: sorted(v.coefficients())
540
+ [-3, -1]
541
+ """
542
+ if order is None:
543
+ try:
544
+ order = sorted(self.parent().basis().keys())
545
+ except AttributeError: # Not a family, assume it is list-like
546
+ order = range(self.parent().dimension())
547
+ return [self[i] for i in order]
548
+
549
+ def _vector_(self, order=None):
550
+ r"""
551
+ Return ``self`` as a vector.
552
+
553
+ EXAMPLES::
554
+
555
+ sage: # needs sage.modules
556
+ sage: v = vector([0, -1, -3])
557
+ sage: v._vector_()
558
+ (0, -1, -3)
559
+ sage: C = CombinatorialFreeModule(QQ['x'], ['a','b','c'])
560
+ sage: C.an_element()._vector_()
561
+ (2, 2, 3)
562
+ """
563
+ if order is None:
564
+ dense_free_module = self.parent()._dense_free_module()
565
+ else:
566
+ from sage.modules.free_module import FreeModule
567
+ dense_free_module = FreeModule(self.parent().base_ring(), len(order))
568
+ # We slightly break encapsulation for speed reasons
569
+ return dense_free_module.element_class(dense_free_module,
570
+ self.dense_coefficient_list(order),
571
+ coerce=True, copy=False)
572
+
573
+ class MorphismMethods:
574
+ def matrix(self, base_ring=None, side='left', *,
575
+ row_order=None, column_order=None):
576
+ r"""
577
+ Return the matrix of this morphism in the distinguished
578
+ bases of the domain and codomain.
579
+
580
+ INPUT:
581
+
582
+ - ``base_ring`` -- a ring (default: ``None``, meaning the
583
+ base ring of the codomain)
584
+
585
+ - ``side`` -- ``'left'`` or ``'right'`` (default: ``'left'``)
586
+
587
+ If ``side`` is ``'left'``, this morphism is considered as
588
+ acting on the left; i.e., each column of the matrix
589
+ represents the image of an element of the basis of the
590
+ domain.
591
+
592
+ - ``row_order`` -- (optional) an ordering of the basis
593
+ indexing set of the codomain (if ``side='left'``)
594
+ or domain (if ``side='right'``).
595
+
596
+ - ``column_order`` -- (optional) an ordering of the basis
597
+ indexing set of the domain (if ``side='left'``)
598
+ or codomain (if ``side='right'``).
599
+
600
+ If ``row_order`` or ``column_order`` are not specified,
601
+ the order of the rows and columns matches with the order
602
+ in which the bases are enumerated.
603
+
604
+ .. SEEALSO:: :func:`Modules.WithBasis.ParentMethods.module_morphism`
605
+
606
+ EXAMPLES::
607
+
608
+ sage: # needs sage.modules
609
+ sage: X = CombinatorialFreeModule(ZZ, [1,2]); x = X.basis()
610
+ sage: Y = CombinatorialFreeModule(ZZ, [3,4]); y = Y.basis()
611
+ sage: phi = X.module_morphism(on_basis={1: y[3] + 3*y[4],
612
+ ....: 2: 2*y[3] + 5*y[4]}.__getitem__,
613
+ ....: codomain=Y)
614
+ sage: phi.matrix()
615
+ [1 2]
616
+ [3 5]
617
+ sage: phi.matrix(side='right')
618
+ [1 3]
619
+ [2 5]
620
+
621
+ sage: phi.matrix().parent() # needs sage.modules
622
+ Full MatrixSpace of 2 by 2 dense matrices over Integer Ring
623
+ sage: phi.matrix(QQ).parent() # needs sage.modules
624
+ Full MatrixSpace of 2 by 2 dense matrices over Rational Field
625
+
626
+ The resulting matrix is immutable::
627
+
628
+ sage: phi.matrix().is_mutable() # needs sage.modules
629
+ False
630
+
631
+ The zero morphism has a zero matrix::
632
+
633
+ sage: Hom(X, Y).zero().matrix() # needs sage.modules
634
+ [0 0]
635
+ [0 0]
636
+
637
+ Using ``row_order`` and ``column_order``::
638
+
639
+ sage: # needs sage.modules
640
+ sage: M = matrix(ZZ, [[1, 2, 3], [4, 5, 6]],
641
+ ....: column_keys=['a', 'b', 'c'],
642
+ ....: row_keys=['v', 'w']); M
643
+ Generic morphism:
644
+ From: Free module generated by {'a', 'b', 'c'} over Integer Ring
645
+ To: Free module generated by {'v', 'w'} over Integer Ring
646
+ sage: M.matrix()
647
+ [1 2 3]
648
+ [4 5 6]
649
+ sage: M.matrix(row_order='wv', column_order='cb')
650
+ [6 5]
651
+ [3 2]
652
+
653
+ .. TODO::
654
+
655
+ Add support for morphisms where the codomain has a
656
+ different base ring than the domain::
657
+
658
+ sage: Y = CombinatorialFreeModule(QQ, [3,4]); y = Y.basis() # needs sage.modules
659
+ sage: phi = X.module_morphism(on_basis={1: y[3] + 3*y[4], # needs sage.modules
660
+ ....: 2: 2*y[3] + 5/2*y[4]}.__getitem__,
661
+ ....: codomain=Y)
662
+ sage: phi.matrix().parent() # not implemented # needs sage.modules
663
+ Full MatrixSpace of 2 by 2 dense matrices over Rational Field
664
+
665
+ This currently does not work because, in this case,
666
+ the morphism is just in the category of commutative
667
+ additive groups (i.e. the intersection of the
668
+ categories of modules over `\ZZ` and over `\QQ`)::
669
+
670
+ sage: phi.parent().homset_category() # needs sage.modules
671
+ Category of commutative additive semigroups
672
+ sage: phi.parent().homset_category() # not implemented, needs sage.modules
673
+ Category of finite dimensional modules with basis over Integer Ring
674
+
675
+ TESTS:
676
+
677
+ Check that :issue:`23216` is fixed::
678
+
679
+ sage: # needs sage.modules
680
+ sage: X = CombinatorialFreeModule(QQ, [])
681
+ sage: Y = CombinatorialFreeModule(QQ, [1,2,3])
682
+ sage: Hom(X, Y).zero().matrix()
683
+ []
684
+ sage: Hom(X, Y).zero().matrix().parent()
685
+ Full MatrixSpace of 3 by 0 dense matrices over Rational Field
686
+ """
687
+ m, *_ = self._matrix_side_bases_orders(base_ring, side,
688
+ row_order=row_order, column_order=column_order)
689
+ return m
690
+
691
+ def _repr_matrix(self, *, row_order=None, column_order=None):
692
+ r"""
693
+ Return a string representation of this morphism (as a matrix).
694
+
695
+ EXAMPLES::
696
+
697
+ sage: # needs sage.modules
698
+ sage: M = matrix(ZZ, [[1, 0, 0], [0, 1, 0]],
699
+ ....: column_keys=['a', 'b', 'c'],
700
+ ....: row_keys=['v', 'w']); M
701
+ Generic morphism:
702
+ From: Free module generated by {'a', 'b', 'c'} over Integer Ring
703
+ To: Free module generated by {'v', 'w'} over Integer Ring
704
+ sage: M._repr_ = M._repr_matrix
705
+ sage: M # indirect doctest
706
+ a b c
707
+ v[1 0 0]
708
+ w[0 1 0]
709
+ sage: print(M._repr_matrix(row_order='wv', column_order='cb'))
710
+ c b
711
+ w[0 1]
712
+ v[0 0]
713
+ """
714
+ matrix, _, _, _, row_order, column_order = self._matrix_side_bases_orders(
715
+ row_order=row_order, column_order=column_order)
716
+
717
+ from sage.matrix.constructor import options
718
+
719
+ if matrix.nrows() <= options.max_rows() and matrix.ncols() <= options.max_cols():
720
+ return matrix.str(top_border=column_order,
721
+ left_border=row_order)
722
+
723
+ return repr(matrix)
724
+
725
+ def _ascii_art_matrix(self, *, row_order=None, column_order=None):
726
+ r"""
727
+ Return an ASCII art representation of this morphism (as a matrix).
728
+
729
+ EXAMPLES::
730
+
731
+ sage: # needs sage.modules
732
+ sage: M = matrix(ZZ, [[1, 0, 0], [0, 1, 0]],
733
+ ....: column_keys=['a', 'b', 'c'],
734
+ ....: row_keys=['v', 'w']); M
735
+ Generic morphism:
736
+ From: Free module generated by {'a', 'b', 'c'} over Integer Ring
737
+ To: Free module generated by {'v', 'w'} over Integer Ring
738
+ sage: M._ascii_art_ = M._ascii_art_matrix
739
+ sage: ascii_art(M) # indirect doctest
740
+ a b c
741
+ v[1 0 0]
742
+ w[0 1 0]
743
+ sage: print(M._ascii_art_matrix(row_order='wv', column_order='cb'))
744
+ c b
745
+ w[0 1]
746
+ v[0 0]
747
+ """
748
+ matrix, _, _, _, row_order, column_order = self._matrix_side_bases_orders(
749
+ row_order=row_order, column_order=column_order)
750
+
751
+ from sage.matrix.constructor import options
752
+
753
+ if matrix.nrows() <= options.max_rows() and matrix.ncols() <= options.max_cols():
754
+ return matrix.str(character_art=True,
755
+ top_border=column_order,
756
+ left_border=row_order)
757
+
758
+ from sage.typeset.ascii_art import AsciiArt
759
+
760
+ return AsciiArt(repr(self).splitlines())
761
+
762
+ def _unicode_art_matrix(self, *, row_order=None, column_order=None):
763
+ r"""
764
+ Return a unicode art representation of this morphism (as a matrix).
765
+
766
+ EXAMPLES::
767
+
768
+ sage: # needs sage.modules
769
+ sage: M = matrix(ZZ, [[1, 0, 0], [0, 1, 0]],
770
+ ....: column_keys=['a', 'b', 'c'],
771
+ ....: row_keys=['v', 'w']); M
772
+ Generic morphism:
773
+ From: Free module generated by {'a', 'b', 'c'} over Integer Ring
774
+ To: Free module generated by {'v', 'w'} over Integer Ring
775
+ sage: M._unicode_art_ = M._unicode_art_matrix
776
+ sage: unicode_art(M) # indirect doctest
777
+ a b c
778
+ v⎛1 0 0⎞
779
+ w⎝0 1 0⎠
780
+ sage: print(M._unicode_art_matrix(row_order='wv', column_order='cb'))
781
+ c b
782
+ w⎛0 1⎞
783
+ v⎝0 0⎠
784
+ """
785
+ matrix, _, _, _, row_order, column_order = self._matrix_side_bases_orders(
786
+ row_order=row_order, column_order=column_order)
787
+
788
+ from sage.matrix.constructor import options
789
+
790
+ if matrix.nrows() <= options.max_rows() and matrix.ncols() <= options.max_cols():
791
+ return matrix.str(unicode=True, character_art=True,
792
+ top_border=column_order,
793
+ left_border=row_order)
794
+
795
+ from sage.typeset.unicode_art import UnicodeArt
796
+
797
+ return UnicodeArt(repr(self).splitlines())
798
+
799
+ def __invert__(self):
800
+ """
801
+ Return the inverse morphism of ``self``.
802
+
803
+ This is achieved by inverting the ``self.matrix()``.
804
+ An error is raised if ``self`` is not invertible.
805
+
806
+ EXAMPLES::
807
+
808
+ sage: # needs sage.modules
809
+ sage: category = FiniteDimensionalModulesWithBasis(ZZ)
810
+ sage: X = CombinatorialFreeModule(ZZ, [1,2], category=category); X.rename('X'); x = X.basis()
811
+ sage: Y = CombinatorialFreeModule(ZZ, [3,4], category=category); Y.rename('Y'); y = Y.basis()
812
+ sage: phi = X.module_morphism(on_basis={1: y[3] + 3*y[4], 2: 2*y[3] + 5*y[4]}.__getitem__,
813
+ ....: codomain=Y, category=category)
814
+ sage: psi = ~phi
815
+ sage: psi
816
+ Generic morphism:
817
+ From: Y
818
+ To: X
819
+ sage: psi.parent()
820
+ Set of Morphisms from Y to X in Category of finite dimensional modules with basis over Integer Ring
821
+ sage: psi(y[3])
822
+ -5*B[1] + 3*B[2]
823
+ sage: psi(y[4])
824
+ 2*B[1] - B[2]
825
+ sage: psi.matrix()
826
+ [-5 2]
827
+ [ 3 -1]
828
+ sage: psi(phi(x[1])), psi(phi(x[2]))
829
+ (B[1], B[2])
830
+ sage: phi(psi(y[3])), phi(psi(y[4]))
831
+ (B[3], B[4])
832
+
833
+ We check that this function complains if the morphism is not invertible::
834
+
835
+ sage: # needs sage.modules
836
+ sage: phi = X.module_morphism(on_basis={1: y[3] + y[4], 2: y[3] + y[4]}.__getitem__,
837
+ ....: codomain=Y, category=category)
838
+ sage: ~phi
839
+ Traceback (most recent call last):
840
+ ...
841
+ RuntimeError: morphism is not invertible
842
+ sage: phi = X.module_morphism(on_basis={1: y[3] + y[4], 2: y[3] + 5*y[4]}.__getitem__,
843
+ ....: codomain=Y, category=category)
844
+ sage: ~phi
845
+ Traceback (most recent call last):
846
+ ...
847
+ RuntimeError: morphism is not invertible
848
+ """
849
+ mat = self.matrix()
850
+ try:
851
+ inv_mat = mat.parent()(~mat)
852
+ except (ZeroDivisionError, TypeError):
853
+ raise RuntimeError("morphism is not invertible")
854
+ return self.codomain().module_morphism(
855
+ matrix=inv_mat,
856
+ codomain=self.domain(), category=self.category_for())
857
+
858
+ def is_injective(self) -> bool:
859
+ """
860
+ Tell whether ``self`` is injective.
861
+
862
+ EXAMPLES::
863
+
864
+ sage: # needs sage.modules
865
+ sage: V1 = QQ^2
866
+ sage: V2 = QQ^3
867
+ sage: phi = V1.hom(Matrix([[1,2,3], [4,5,6]]),V2)
868
+ sage: phi.is_injective()
869
+ True
870
+ sage: psi = V2.hom(Matrix([[1,2], [3,4], [5,6]]),V1)
871
+ sage: psi.is_injective()
872
+ False
873
+
874
+ AUTHOR:
875
+
876
+ -- Simon King (2010-05)
877
+ """
878
+ mat, side, *_ = self._matrix_side_bases_orders(side='any')
879
+ if side == 'left':
880
+ ker = mat.right_kernel()
881
+ else:
882
+ ker = mat.left_kernel()
883
+ return ker.dimension() == 0
884
+
885
+ def nullity(self):
886
+ r"""
887
+ Return the nullity of the matrix representing this morphism.
888
+
889
+ This is the dimension of its kernel.
890
+
891
+ EXAMPLES::
892
+
893
+ sage: # needs sage.modules
894
+ sage: V = ZZ^2; phi = V.hom(V.basis())
895
+ sage: phi.nullity()
896
+ 0
897
+ sage: V = ZZ^2; phi = V.hom([V.0, V.0])
898
+ sage: phi.nullity()
899
+ 1
900
+
901
+ ::
902
+
903
+ sage: # needs sage.modules
904
+ sage: m = matrix(2, [1, 2])
905
+ sage: V = ZZ^2
906
+ sage: h1 = V.hom(m)
907
+ sage: h1.nullity()
908
+ 1
909
+ sage: W = ZZ^1
910
+ sage: h2 = W.hom(m, side="right")
911
+ sage: h2.nullity()
912
+ 0
913
+ """
914
+ # Avoid using the method matrix() because of Issue #37877
915
+ mat, side, *_ = self._matrix_side_bases_orders(side='any')
916
+ if side == 'left':
917
+ return mat.right_nullity()
918
+ else:
919
+ return mat.left_nullity()
920
+
921
+ def kernel_basis(self):
922
+ """
923
+ Return a basis of the kernel of ``self`` in echelon form.
924
+
925
+ EXAMPLES::
926
+
927
+ sage: SGA = SymmetricGroupAlgebra(QQ, 3) # needs sage.combinat sage.groups
928
+ sage: f = SGA.module_morphism(lambda x: SGA(x**2), codomain=SGA) # needs sage.combinat sage.groups
929
+ sage: f.kernel_basis() # needs sage.combinat sage.groups
930
+ ([1, 2, 3] - [3, 2, 1], [1, 3, 2] - [3, 2, 1], [2, 1, 3] - [3, 2, 1])
931
+ """
932
+ # Avoid using the method matrix() because of Issue #37877
933
+ mat, *_ = self._matrix_side_bases_orders()
934
+ return tuple(map(self.domain().from_vector,
935
+ mat.right_kernel_matrix().rows()))
936
+
937
+ def kernel(self):
938
+ """
939
+ Return the kernel of ``self`` as a submodule of the domain.
940
+
941
+ EXAMPLES::
942
+
943
+ sage: # needs sage.combinat sage.groups
944
+ sage: SGA = SymmetricGroupAlgebra(QQ, 3)
945
+ sage: f = SGA.module_morphism(lambda x: SGA(x**2), codomain=SGA)
946
+ sage: K = f.kernel()
947
+ sage: K
948
+ Free module generated by {0, 1, 2} over Rational Field
949
+ sage: K.ambient()
950
+ Symmetric group algebra of order 3 over Rational Field
951
+ """
952
+ D = self.domain()
953
+ return D.submodule(self.kernel_basis(), already_echelonized=True,
954
+ category=self.category_for())
955
+
956
+ def image_basis(self):
957
+ """
958
+ Return a basis for the image of ``self`` in echelon form.
959
+
960
+ EXAMPLES::
961
+
962
+ sage: SGA = SymmetricGroupAlgebra(QQ, 3) # needs sage.combinat sage.groups
963
+ sage: f = SGA.module_morphism(lambda x: SGA(x**2), codomain=SGA) # needs sage.combinat sage.groups
964
+ sage: f.image_basis() # needs sage.combinat sage.groups
965
+ ([1, 2, 3], [2, 3, 1], [3, 1, 2])
966
+ """
967
+ C = self.codomain()
968
+ return tuple(C.echelon_form( map(self, self.domain().basis()) ))
969
+
970
+ def image(self):
971
+ """
972
+ Return the image of ``self`` as a submodule of the codomain.
973
+
974
+ EXAMPLES::
975
+
976
+ sage: SGA = SymmetricGroupAlgebra(QQ, 3) # needs sage.combinat sage.groups
977
+ sage: f = SGA.module_morphism(lambda x: SGA(x**2), codomain=SGA) # needs sage.combinat sage.groups
978
+ sage: f.image() # needs sage.combinat sage.groups
979
+ Free module generated by {0, 1, 2} over Rational Field
980
+ """
981
+ C = self.codomain()
982
+ return C.submodule(self.image_basis(), already_echelonized=True,
983
+ category=self.category_for())
984
+
985
+ def rank(self):
986
+ r"""
987
+ Return the rank of the matrix representing this morphism.
988
+
989
+ EXAMPLES::
990
+
991
+ sage: # needs sage.modules
992
+ sage: V = ZZ^2; phi = V.hom(V.basis())
993
+ sage: phi.rank()
994
+ 2
995
+ sage: V = ZZ^2; phi = V.hom([V.0, V.0])
996
+ sage: phi.rank()
997
+ 1
998
+ """
999
+ return self.matrix().rank()
1000
+
1001
+ @cached_method
1002
+ def _matrix_cmr(self):
1003
+ r"""
1004
+ Return ``self`` as a :class:`sage.matrix.matrix_cmr_sparse.Matrix_cmr_chr_sparse`.
1005
+
1006
+ EXAMPLES::
1007
+
1008
+ sage: # needs sage.libs.cmr
1009
+ sage: M = matrix(ZZ, [[1, 0, 1], [0, 1, 1], [1, 2, 3]],
1010
+ ....: column_keys=['a', 'b', 'c'],
1011
+ ....: row_keys=['u', 'v', 'w']); M
1012
+ Generic morphism:
1013
+ From: Free module generated by {'a', 'b', 'c'} over Integer Ring
1014
+ To: Free module generated by {'u', 'v', 'w'} over Integer Ring
1015
+ sage: M_cmr = M._matrix_cmr(); M_cmr
1016
+ [1 0 1]
1017
+ [0 1 1]
1018
+ [1 2 3]
1019
+ sage: type(M_cmr)
1020
+ <class 'sage.matrix.matrix_cmr_sparse.Matrix_cmr_chr_sparse'>
1021
+ """
1022
+ from sage.matrix.matrix_cmr_sparse import Matrix_cmr_chr_sparse
1023
+ from sage.matrix.matrix_space import MatrixSpace
1024
+ M = self.matrix()
1025
+ MS = MatrixSpace(self.base_ring(), M.nrows(), M.ncols(), sparse=True)
1026
+ return Matrix_cmr_chr_sparse(MS, M)
1027
+
1028
+ def is_unimodular(self, **kwds):
1029
+ r"""
1030
+ Return whether ``self`` is a unimodular morphism.
1031
+
1032
+ This does not depend on the choice of bases for
1033
+ domain and codomain.
1034
+
1035
+ See :meth:`~sage.matrix.matrix_cmr_sparse.Matrix_cmr_chr_sparse.is_unimodular` for
1036
+ the detailed documentation.
1037
+
1038
+ EXAMPLES::
1039
+
1040
+ sage: # needs sage.modules
1041
+ sage: M = matrix(ZZ, [[1, 0, 0], [0, 1, 0]],
1042
+ ....: column_keys=['a', 'b', 'c'],
1043
+ ....: row_keys=['v', 'w']); M
1044
+ Generic morphism:
1045
+ From: Free module generated by {'a', 'b', 'c'} over Integer Ring
1046
+ To: Free module generated by {'v', 'w'} over Integer Ring
1047
+ sage: M.is_unimodular() # needs sage.libs.cmr
1048
+ True
1049
+ """
1050
+ try:
1051
+ matrix = self._matrix_cmr()
1052
+ except (ImportError, TypeError):
1053
+ matrix = self.matrix()
1054
+ try:
1055
+ method = matrix.is_unimodular
1056
+ except AttributeError:
1057
+ raise NotImplementedError
1058
+ else:
1059
+ return method(**kwds)
1060
+
1061
+ def is_strongly_unimodular(self, **kwds):
1062
+ r"""
1063
+ Return whether ``self`` is a strongly unimodular morphism.
1064
+
1065
+ This does not depend on the choice of bases for
1066
+ domain and codomain.
1067
+
1068
+ See :meth:`~sage.matrix.matrix_cmr_sparse.Matrix_cmr_chr_sparse.is_strongly_unimodular` for
1069
+ the detailed documentation.
1070
+
1071
+ EXAMPLES::
1072
+
1073
+ sage: # needs sage.modules
1074
+ sage: M = matrix(ZZ, [[1, 0, 1], [0, 1, 1], [1, 2, 3]],
1075
+ ....: column_keys=['a', 'b', 'c'],
1076
+ ....: row_keys=['u', 'v', 'w']); M
1077
+ Generic morphism:
1078
+ From: Free module generated by {'a', 'b', 'c'} over Integer Ring
1079
+ To: Free module generated by {'u', 'v', 'w'} over Integer Ring
1080
+ sage: M.is_unimodular() # needs sage.libs.cmr
1081
+ True
1082
+ sage: M.is_strongly_unimodular() # needs sage.libs.cmr
1083
+ False
1084
+ """
1085
+ try:
1086
+ matrix = self._matrix_cmr()
1087
+ except (ImportError, TypeError):
1088
+ matrix = self.matrix()
1089
+ try:
1090
+ method = matrix.is_strongly_unimodular
1091
+ except AttributeError:
1092
+ raise NotImplementedError
1093
+ else:
1094
+ return method(**kwds)
1095
+
1096
+ def equimodulus(self, **kwds):
1097
+ r"""
1098
+ Return the integer `k` such that ``self`` is equimodular with determinant gcd `k`.
1099
+
1100
+ See :meth:`~sage.matrix.matrix_cmr_sparse.Matrix_cmr_chr_sparse.equimodulus` for
1101
+ the detailed documentation.
1102
+ """
1103
+ try:
1104
+ matrix = self._matrix_cmr()
1105
+ except (ImportError, TypeError):
1106
+ matrix = self.matrix()
1107
+ try:
1108
+ method = matrix.equimodulus
1109
+ except AttributeError:
1110
+ raise NotImplementedError
1111
+ else:
1112
+ return method(**kwds)
1113
+
1114
+ def strong_equimodulus(self, **kwds):
1115
+ r"""
1116
+ Return the integer `k` such that ``self`` is strongly equimodular with determinant gcd `k`.
1117
+
1118
+ See :meth:`~sage.matrix.matrix_cmr_sparse.Matrix_cmr_chr_sparse.strong_equimodulus` for
1119
+ the detailed documentation.
1120
+ """
1121
+ try:
1122
+ matrix = self._matrix_cmr()
1123
+ except (ImportError, TypeError):
1124
+ matrix = self.matrix()
1125
+ try:
1126
+ method = matrix.strong_equimodulus
1127
+ except AttributeError:
1128
+ raise NotImplementedError
1129
+ else:
1130
+ return method(**kwds)
1131
+
1132
+ def is_k_equimodular(self, k, **kwds):
1133
+ r"""
1134
+ Return whether ``self`` is an equimodular morphism with determinant gcd `k`.
1135
+
1136
+ This does not depend on the choice of bases for
1137
+ domain and codomain.
1138
+
1139
+ See :meth:`~sage.matrix.matrix_cmr_sparse.Matrix_cmr_chr_sparse.is_k_equimodular` for
1140
+ the detailed documentation.
1141
+
1142
+ EXAMPLES::
1143
+
1144
+ sage: # needs sage.modules
1145
+ sage: M = matrix(ZZ, [[1, 0, 1], [0, 1, 1], [1, 2, 3]],
1146
+ ....: column_keys=['a', 'b', 'c'],
1147
+ ....: row_keys=['u', 'v', 'w']); M
1148
+ Generic morphism:
1149
+ From: Free module generated by {'a', 'b', 'c'} over Integer Ring
1150
+ To: Free module generated by {'u', 'v', 'w'} over Integer Ring
1151
+ sage: M.is_k_equimodular(1) # needs sage.libs.cmr
1152
+ True
1153
+ sage: M.is_k_equimodular(2) # needs sage.libs.cmr
1154
+ False
1155
+ """
1156
+ try:
1157
+ matrix = self._matrix_cmr()
1158
+ except (ImportError, TypeError):
1159
+ matrix = self.matrix()
1160
+ try:
1161
+ method = matrix.is_k_equimodular
1162
+ except AttributeError:
1163
+ raise NotImplementedError
1164
+ else:
1165
+ return method(k, **kwds)
1166
+
1167
+ def is_strongly_k_equimodular(self, k, **kwds):
1168
+ r"""
1169
+ Return whether ``self`` is a strongly equimodular morphism with determinant gcd `k`.
1170
+
1171
+ This does not depend on the choice of bases for
1172
+ domain and codomain.
1173
+
1174
+ See :meth:`~sage.matrix.matrix_cmr_sparse.Matrix_cmr_chr_sparse.is_strongly_k_equimodular` for
1175
+ the detailed documentation.
1176
+
1177
+ EXAMPLES::
1178
+
1179
+ sage: # needs sage.modules
1180
+ sage: M = matrix(ZZ, [[1, 0, 1], [0, 1, 1], [1, 2, 3]],
1181
+ ....: column_keys=['a', 'b', 'c'],
1182
+ ....: row_keys=['u', 'v', 'w']); M
1183
+ Generic morphism:
1184
+ From: Free module generated by {'a', 'b', 'c'} over Integer Ring
1185
+ To: Free module generated by {'u', 'v', 'w'} over Integer Ring
1186
+ sage: M.is_strongly_k_equimodular(1) # needs sage.libs.cmr
1187
+ False
1188
+ sage: M = matrix(ZZ, [[1, 0, 0], [0, 1, 0]],
1189
+ ....: column_keys=['a', 'b', 'c'],
1190
+ ....: row_keys=['v', 'w']); M
1191
+ Generic morphism:
1192
+ From: Free module generated by {'a', 'b', 'c'} over Integer Ring
1193
+ To: Free module generated by {'v', 'w'} over Integer Ring
1194
+ sage: M.is_strongly_k_equimodular(1) # needs sage.libs.cmr
1195
+ True
1196
+ """
1197
+ try:
1198
+ matrix = self._matrix_cmr()
1199
+ except (ImportError, TypeError):
1200
+ matrix = self.matrix()
1201
+ try:
1202
+ method = matrix.is_strongly_k_equimodular
1203
+ except AttributeError:
1204
+ raise NotImplementedError
1205
+ else:
1206
+ return method(k, **kwds)
1207
+
1208
+ def _wrapped_method_with_certificate(self, matrix_method):
1209
+
1210
+ @functools.wraps(matrix_method)
1211
+ def wrapper(*, certificate=False, **kwds):
1212
+ if not certificate:
1213
+ return matrix_method(**kwds)
1214
+ column_keys = self.domain().basis().keys()
1215
+ row_keys = self.codomain().basis().keys()
1216
+ return matrix_method(certificate=True,
1217
+ column_keys=column_keys,
1218
+ row_keys=row_keys,
1219
+ **kwds)
1220
+ return wrapper
1221
+
1222
+ def is_conetwork_matrix(self, **kwds):
1223
+ r"""
1224
+ Return whether the matrix of ``self`` is a conetwork matrix.
1225
+
1226
+ A matrix is a conetwork matrix if and only if its transpose is a network matrix.
1227
+
1228
+ This depends on the choice of bases for domain and codomain.
1229
+
1230
+ See :meth:`~sage.matrix.matrix_cmr_sparse.Matrix_cmr_chr_sparse.is_conetwork_matrix` for
1231
+ the detailed documentation.
1232
+
1233
+ EXAMPLES::
1234
+
1235
+ sage: # needs sage.libs.cmr
1236
+ sage: M = matrix([[1, 0, 0, 0, 1, -1, 1, 0, 0],
1237
+ ....: [0, 1, 0, 0, 0, 1, -1, 1, 0],
1238
+ ....: [0, 0, 1, 0, 0, 0, 1, -1, 1],
1239
+ ....: [0, 0, 0, 1, 1, 0, 0, 1, -1]],
1240
+ ....: column_keys=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'],
1241
+ ....: row_keys=range(4)); M
1242
+ Generic morphism:
1243
+ From: Free module generated by {'a', 'b', 'c', 'd',
1244
+ 'e', 'f', 'g', 'h', 'i'} over Integer Ring
1245
+ To: Free module generated by {0, 1, 2, 3} over Integer Ring
1246
+ sage: M.is_conetwork_matrix()
1247
+ True
1248
+ sage: result, certificate = M.is_conetwork_matrix(certificate=True)
1249
+ sage: result, certificate
1250
+ (True,
1251
+ (Digraph on 10 vertices,
1252
+ {'a': (8, 7),
1253
+ 'b': (1, 29),
1254
+ 'c': (34, 2),
1255
+ 'd': (41, 7),
1256
+ 'e': (7, 3),
1257
+ 'f': (22, 0),
1258
+ 'g': (3, 0),
1259
+ 'h': (3, 1),
1260
+ 'i': (2, 1)},
1261
+ {0: (8, 22), 1: (22, 29), 2: (34, 0), 3: (41, 2)}))
1262
+ """
1263
+ try:
1264
+ matrix = self._matrix_cmr()
1265
+ except (ImportError, TypeError):
1266
+ matrix = self.matrix()
1267
+ try:
1268
+ method = self._wrapped_method_with_certificate(matrix.is_conetwork_matrix)
1269
+ except AttributeError:
1270
+ raise NotImplementedError
1271
+ else:
1272
+ return method(**kwds)
1273
+
1274
+ def is_network_matrix(self, **kwds):
1275
+ r"""
1276
+ Return whether the matrix of ``self`` is a network matrix.
1277
+
1278
+ This depends on the choice of bases for domain and codomain.
1279
+
1280
+ See :meth:`~sage.matrix.matrix_cmr_sparse.Matrix_cmr_chr_sparse.is_network_matrix` for
1281
+ the detailed documentation.
1282
+
1283
+ EXAMPLES::
1284
+
1285
+ sage: # needs sage.libs.cmr
1286
+ sage: M = matrix([[-1, 0, 0, 0, 1, -1, 0],
1287
+ ....: [ 1, 0, 0, 1, -1, 1, 0],
1288
+ ....: [ 0, -1, 0, -1, 1, -1, 0],
1289
+ ....: [ 0, 1, 0, 0, 0, 0, 1],
1290
+ ....: [ 0, 0, 1, -1, 1, 0, 1],
1291
+ ....: [ 0, 0, -1, 1, -1, 0, 0]],
1292
+ ....: column_keys=['a', 'b', 'c', 'd', 'e', 'f', 'g'],
1293
+ ....: row_keys=range(6)); M
1294
+ Generic morphism:
1295
+ From: Free module generated by {'a', 'b', 'c', 'd', 'e', 'f', 'g'} over Integer Ring
1296
+ To: Free module generated by {0, 1, 2, 3, 4, 5} over Integer Ring
1297
+ sage: M.is_network_matrix()
1298
+ True
1299
+ sage: result, certificate = M.is_network_matrix(certificate=True)
1300
+ sage: result, certificate
1301
+ (True,
1302
+ (Digraph on 7 vertices,
1303
+ {0: (9, 8), 1: (3, 8), 2: (3, 4), 3: (5, 4), 4: (4, 6), 5: (0, 6)},
1304
+ {'a': (3, 9), 'b': (5, 3), 'c': (4, 0), 'd': (0, 8),
1305
+ 'e': (9, 0), 'f': (4, 9), 'g': (5, 6)}))
1306
+ sage: digraph, forest_arcs, coforest_arcs = certificate
1307
+ sage: digraph.plot(edge_colors={'red': forest_arcs.values()}) # needs sage.plot
1308
+ Graphics object consisting of 21 graphics primitives
1309
+ """
1310
+ try:
1311
+ matrix = self._matrix_cmr()
1312
+ except (ImportError, TypeError):
1313
+ matrix = self.matrix()
1314
+ try:
1315
+ method = self._wrapped_method_with_certificate(matrix.is_network_matrix)
1316
+ except AttributeError:
1317
+ raise NotImplementedError
1318
+ else:
1319
+ return method(**kwds)
1320
+
1321
+ def is_totally_unimodular(self, **kwds):
1322
+ r"""
1323
+ Return whether the matrix of ``self`` is totally unimodular.
1324
+
1325
+ This depends on the choice of bases for domain and codomain.
1326
+
1327
+ See :meth:`~sage.matrix.matrix_cmr_sparse.Matrix_cmr_chr_sparse.is_totally_unimodular` for
1328
+ the detailed documentation.
1329
+
1330
+ EXAMPLES::
1331
+
1332
+ sage: # needs sage.libs.cmr
1333
+ sage: M = matrix(ZZ, [[1, 0], [-1, 1], [0, 1]],
1334
+ ....: column_keys=['a', 'b'],
1335
+ ....: row_keys=['u', 'v', 'w']); M
1336
+ Generic morphism:
1337
+ From: Free module generated by {'a', 'b'} over Integer Ring
1338
+ To: Free module generated by {'u', 'v', 'w'} over Integer Ring
1339
+ sage: M.is_totally_unimodular()
1340
+ True
1341
+ sage: result, certificate = M.is_totally_unimodular(certificate=True)
1342
+ sage: result, certificate
1343
+ (True, GraphicNode (3×2))
1344
+ sage: certificate.graph()
1345
+ Digraph on 4 vertices
1346
+
1347
+ sage: # needs sage.libs.cmr
1348
+ sage: M = matrix(ZZ,
1349
+ ....: [[1, 1, 0, 0, 0, 0, 0, 0, 0],
1350
+ ....: [1, 1, 1, 0, 0, 0, 0, 0, 0],
1351
+ ....: [1, 0, 0, 1, 0, 0, 0, 0, 0],
1352
+ ....: [0, 1, 1, 1, 0, 0, 0, 0, 0],
1353
+ ....: [0, 0, 1, 1, 0, 0, 0, 0, 0],
1354
+ ....: [0, 0, 0, 0, 1, 1, 1, 0, 0],
1355
+ ....: [0, 0, 0, 0, 1, 1, 0, 1, 0],
1356
+ ....: [0, 0, 0, 0, 0, 1, 0, 1, 1],
1357
+ ....: [0, 0, 0, 0, 0, 0, 1, 1, 1]],
1358
+ ....: row_keys='ABCDEFGHI',
1359
+ ....: column_keys='abcdefghi')
1360
+ sage: M._unicode_art_matrix()
1361
+ a b c d e f g h i
1362
+ A⎛1 1 0 0 0 0 0 0 0⎞
1363
+ B⎜1 1 1 0 0 0 0 0 0⎟
1364
+ C⎜1 0 0 1 0 0 0 0 0⎟
1365
+ D⎜0 1 1 1 0 0 0 0 0⎟
1366
+ E⎜0 0 1 1 0 0 0 0 0⎟
1367
+ F⎜0 0 0 0 1 1 1 0 0⎟
1368
+ G⎜0 0 0 0 1 1 0 1 0⎟
1369
+ H⎜0 0 0 0 0 1 0 1 1⎟
1370
+ I⎝0 0 0 0 0 0 1 1 1⎠
1371
+ sage: result, certificate = M.is_totally_unimodular(certificate=True)
1372
+ sage: result, certificate
1373
+ (False, (OneSumNode (9×9) with 2 children, (('D', 'C', 'A'), ('d', 'b', 'a'))))
1374
+ sage: unicode_art(certificate[0])
1375
+ ╭OneSumNode (9×9) with 2 children─╮
1376
+ │ │
1377
+ ThreeConnectedIrregularNode (5×4) UnknownNode (4×5)
1378
+ """
1379
+ try:
1380
+ matrix = self._matrix_cmr()
1381
+ except (ImportError, TypeError):
1382
+ matrix = self.matrix()
1383
+ try:
1384
+ method = self._wrapped_method_with_certificate(matrix.is_totally_unimodular)
1385
+ except AttributeError:
1386
+ raise NotImplementedError
1387
+ else:
1388
+ return method(**kwds)
1389
+
1390
+ class Homsets(HomsetsCategory):
1391
+
1392
+ class Endset(CategoryWithAxiom):
1393
+
1394
+ class ElementMethods:
1395
+
1396
+ @lazy_attribute
1397
+ def characteristic_polynomial(self):
1398
+ r"""
1399
+ Return the characteristic polynomial of this endomorphism.
1400
+
1401
+ :meth:`characteristic_polynomial` and :meth:`charpoly` are the same method.
1402
+
1403
+ INPUT:
1404
+
1405
+ - ``var`` -- variable
1406
+
1407
+ EXAMPLES::
1408
+
1409
+ sage: # needs sage.modules
1410
+ sage: V = ZZ^2; phi = V.hom([V.0 + V.1, 2*V.1])
1411
+ sage: phi.characteristic_polynomial()
1412
+ x^2 - 3*x + 2
1413
+ sage: phi.charpoly()
1414
+ x^2 - 3*x + 2
1415
+ sage: phi.matrix().charpoly()
1416
+ x^2 - 3*x + 2
1417
+ sage: phi.charpoly('T')
1418
+ T^2 - 3*T + 2
1419
+ sage: W = CombinatorialFreeModule(ZZ, ['x', 'y'])
1420
+ sage: M = matrix(ZZ, [[1, 0], [1, 2]])
1421
+ sage: psi = W.module_morphism(matrix=M, codomain=W)
1422
+ sage: psi.charpoly()
1423
+ x^2 - 3*x + 2
1424
+ """
1425
+ return self.matrix().charpoly
1426
+
1427
+ charpoly = characteristic_polynomial
1428
+
1429
+ @lazy_attribute
1430
+ def determinant(self):
1431
+ """
1432
+ Return the determinant of this endomorphism.
1433
+
1434
+ :meth:`determinant` and :meth:`det` are the same method.
1435
+
1436
+ EXAMPLES::
1437
+
1438
+ sage: # needs sage.modules
1439
+ sage: V = ZZ^2; phi = V.hom([V.0 + V.1, 2*V.1])
1440
+ sage: phi.determinant()
1441
+ 2
1442
+ sage: phi.det()
1443
+ 2
1444
+ sage: W = CombinatorialFreeModule(ZZ, ['x', 'y'])
1445
+ sage: M = matrix(ZZ, [[1, 0], [1, 2]])
1446
+ sage: psi = W.module_morphism(matrix=M, codomain=W)
1447
+ sage: psi.det()
1448
+ 2
1449
+ """
1450
+ return self.matrix().determinant
1451
+
1452
+ det = determinant
1453
+
1454
+ @lazy_attribute
1455
+ def fcp(self):
1456
+ """
1457
+ Return the factorization of the characteristic polynomial.
1458
+
1459
+ INPUT:
1460
+
1461
+ - ``var`` -- variable
1462
+
1463
+ EXAMPLES::
1464
+
1465
+ sage: # needs sage.modules
1466
+ sage: V = ZZ^2; phi = V.hom([V.0 + V.1, 2*V.1])
1467
+ sage: phi.fcp() # needs sage.libs.pari
1468
+ (x - 2) * (x - 1)
1469
+ sage: phi.fcp('T') # needs sage.libs.pari
1470
+ (T - 2) * (T - 1)
1471
+ sage: W = CombinatorialFreeModule(ZZ, ['x', 'y'])
1472
+ sage: M = matrix(ZZ, [[1, 0], [1, 2]])
1473
+ sage: psi = W.module_morphism(matrix=M, codomain=W)
1474
+ sage: psi.fcp() # needs sage.libs.pari
1475
+ (x - 2) * (x - 1)
1476
+ """
1477
+ return self.matrix().fcp
1478
+
1479
+ @lazy_attribute
1480
+ def minimal_polynomial(self):
1481
+ r"""
1482
+ Return the minimal polynomial of this endomorphism.
1483
+
1484
+ :meth:`minimal_polynomial` and :meth:`minpoly` are the same method.
1485
+
1486
+ INPUT:
1487
+
1488
+ - ``var`` -- string (default: ``'x'``); a variable name
1489
+
1490
+ EXAMPLES:
1491
+
1492
+ Compute the minimal polynomial, and check it. ::
1493
+
1494
+ sage: # needs sage.modules
1495
+ sage: V = GF(7)^3
1496
+ sage: H = V.Hom(V)([[0,1,2], [-1,0,3], [2,4,1]]); H
1497
+ Vector space morphism represented by the matrix:
1498
+ [0 1 2]
1499
+ [6 0 3]
1500
+ [2 4 1]
1501
+ Domain: Vector space of dimension 3 over Finite Field of size 7
1502
+ Codomain: Vector space of dimension 3 over Finite Field of size 7
1503
+ sage: H.minpoly() # needs sage.libs.pari
1504
+ x^3 + 6*x^2 + 6*x + 1
1505
+ sage: H.minimal_polynomial() # needs sage.libs.pari
1506
+ x^3 + 6*x^2 + 6*x + 1
1507
+ sage: H^3 + (H^2)*6 + H*6 + 1
1508
+ Vector space morphism represented by the matrix:
1509
+ [0 0 0]
1510
+ [0 0 0]
1511
+ [0 0 0]
1512
+ Domain: Vector space of dimension 3 over Finite Field of size 7
1513
+ Codomain: Vector space of dimension 3 over Finite Field of size 7
1514
+
1515
+ sage: # needs sage.modules sage.rings.finite_rings
1516
+ sage: k = GF(9, 'c')
1517
+ sage: V = CombinatorialFreeModule(k, ['x', 'y', 'z', 'w'])
1518
+ sage: A = matrix(k, 4, [1,1,0,0, 0,1,0,0, 0,0,5,0, 0,0,0,5])
1519
+ sage: phi = V.module_morphism(matrix=A, codomain=V)
1520
+ sage: factor(phi.minpoly())
1521
+ (x + 1) * (x + 2)^2
1522
+ sage: A.minpoly()(A) == 0
1523
+ True
1524
+ sage: factor(phi.charpoly())
1525
+ (x + 1)^2 * (x + 2)^2
1526
+ """
1527
+ return self.matrix().minimal_polynomial
1528
+
1529
+ minpoly = minimal_polynomial
1530
+
1531
+ @lazy_attribute
1532
+ def trace(self):
1533
+ r"""
1534
+ Return the trace of this endomorphism.
1535
+
1536
+ EXAMPLES::
1537
+
1538
+ sage: # needs sage.modules
1539
+ sage: V = ZZ^2; phi = V.hom([V.0 + V.1, 2*V.1])
1540
+ sage: phi.trace()
1541
+ 3
1542
+ sage: W = CombinatorialFreeModule(ZZ, ['x', 'y'])
1543
+ sage: M = matrix(ZZ, [[1, 0], [1, 2]])
1544
+ sage: psi = W.module_morphism(matrix=M, codomain=W)
1545
+ sage: psi.trace()
1546
+ 3
1547
+ """
1548
+ return self.matrix().trace
1549
+
1550
+ class TensorProducts(TensorProductsCategory):
1551
+
1552
+ def extra_super_categories(self):
1553
+ """
1554
+ Implement the fact that a (finite) tensor product of
1555
+ finite dimensional modules is a finite dimensional module.
1556
+
1557
+ EXAMPLES::
1558
+
1559
+ sage: C = ModulesWithBasis(ZZ).FiniteDimensional().TensorProducts()
1560
+ sage: C.extra_super_categories()
1561
+ [Category of finite dimensional modules with basis over Integer Ring]
1562
+ sage: C.FiniteDimensional()
1563
+ Category of tensor products of
1564
+ finite dimensional modules with basis over Integer Ring
1565
+ """
1566
+ return [self.base_category()]