passagemath-singular 10.6.31rc3__cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of passagemath-singular might be problematic. Click here for more details.

Files changed (491) hide show
  1. PySingular.cpython-314-x86_64-linux-gnu.so +0 -0
  2. passagemath_singular-10.6.31rc3.dist-info/METADATA +183 -0
  3. passagemath_singular-10.6.31rc3.dist-info/RECORD +491 -0
  4. passagemath_singular-10.6.31rc3.dist-info/WHEEL +6 -0
  5. passagemath_singular-10.6.31rc3.dist-info/top_level.txt +3 -0
  6. passagemath_singular.libs/libSingular-4-20aec911.4.1.so +0 -0
  7. passagemath_singular.libs/libcddgmp-21acf0c6.so.0.1.3 +0 -0
  8. passagemath_singular.libs/libfactory-4-fcee31da.4.1.so +0 -0
  9. passagemath_singular.libs/libflint-66e12231.so.21.0.0 +0 -0
  10. passagemath_singular.libs/libgf2x-a4cdec90.so.3.0.0 +0 -0
  11. passagemath_singular.libs/libgfortran-83c28eba.so.5.0.0 +0 -0
  12. passagemath_singular.libs/libgmp-6e109695.so.10.5.0 +0 -0
  13. passagemath_singular.libs/libgsl-cda90e79.so.28.0.0 +0 -0
  14. passagemath_singular.libs/libmpfr-82690d50.so.6.2.1 +0 -0
  15. passagemath_singular.libs/libntl-e6f0d543.so.44.0.1 +0 -0
  16. passagemath_singular.libs/libomalloc-0-5c9e866e.9.6.so +0 -0
  17. passagemath_singular.libs/libopenblasp-r0-6dcb67f9.3.29.so +0 -0
  18. passagemath_singular.libs/libpolys-4-5c0a87e0.4.1.so +0 -0
  19. passagemath_singular.libs/libquadmath-2284e583.so.0.0.0 +0 -0
  20. passagemath_singular.libs/libreadline-ea270e21.so.8.2 +0 -0
  21. passagemath_singular.libs/libsingular_resources-4-a1aafc6d.4.1.so +0 -0
  22. passagemath_singular.libs/libtinfo-ceb117d9.so.6.3 +0 -0
  23. sage/algebras/all__sagemath_singular.py +3 -0
  24. sage/algebras/fusion_rings/all.py +19 -0
  25. sage/algebras/fusion_rings/f_matrix.py +2448 -0
  26. sage/algebras/fusion_rings/fast_parallel_fmats_methods.cpython-314-x86_64-linux-gnu.so +0 -0
  27. sage/algebras/fusion_rings/fast_parallel_fmats_methods.pxd +5 -0
  28. sage/algebras/fusion_rings/fast_parallel_fmats_methods.pyx +538 -0
  29. sage/algebras/fusion_rings/fast_parallel_fusion_ring_braid_repn.cpython-314-x86_64-linux-gnu.so +0 -0
  30. sage/algebras/fusion_rings/fast_parallel_fusion_ring_braid_repn.pxd +3 -0
  31. sage/algebras/fusion_rings/fast_parallel_fusion_ring_braid_repn.pyx +331 -0
  32. sage/algebras/fusion_rings/fusion_double.py +899 -0
  33. sage/algebras/fusion_rings/fusion_ring.py +1580 -0
  34. sage/algebras/fusion_rings/poly_tup_engine.cpython-314-x86_64-linux-gnu.so +0 -0
  35. sage/algebras/fusion_rings/poly_tup_engine.pxd +24 -0
  36. sage/algebras/fusion_rings/poly_tup_engine.pyx +579 -0
  37. sage/algebras/fusion_rings/shm_managers.cpython-314-x86_64-linux-gnu.so +0 -0
  38. sage/algebras/fusion_rings/shm_managers.pxd +24 -0
  39. sage/algebras/fusion_rings/shm_managers.pyx +780 -0
  40. sage/algebras/letterplace/all.py +1 -0
  41. sage/algebras/letterplace/free_algebra_element_letterplace.cpython-314-x86_64-linux-gnu.so +0 -0
  42. sage/algebras/letterplace/free_algebra_element_letterplace.pxd +18 -0
  43. sage/algebras/letterplace/free_algebra_element_letterplace.pyx +755 -0
  44. sage/algebras/letterplace/free_algebra_letterplace.cpython-314-x86_64-linux-gnu.so +0 -0
  45. sage/algebras/letterplace/free_algebra_letterplace.pxd +35 -0
  46. sage/algebras/letterplace/free_algebra_letterplace.pyx +914 -0
  47. sage/algebras/letterplace/letterplace_ideal.cpython-314-x86_64-linux-gnu.so +0 -0
  48. sage/algebras/letterplace/letterplace_ideal.pyx +408 -0
  49. sage/algebras/quatalg/all.py +2 -0
  50. sage/algebras/quatalg/quaternion_algebra.py +4778 -0
  51. sage/algebras/quatalg/quaternion_algebra_cython.cpython-314-x86_64-linux-gnu.so +0 -0
  52. sage/algebras/quatalg/quaternion_algebra_cython.pyx +261 -0
  53. sage/algebras/quatalg/quaternion_algebra_element.cpython-314-x86_64-linux-gnu.so +0 -0
  54. sage/algebras/quatalg/quaternion_algebra_element.pxd +29 -0
  55. sage/algebras/quatalg/quaternion_algebra_element.pyx +2176 -0
  56. sage/all__sagemath_singular.py +11 -0
  57. sage/ext_data/all__sagemath_singular.py +1 -0
  58. sage/ext_data/singular/function_field/core.lib +98 -0
  59. sage/interfaces/all__sagemath_singular.py +1 -0
  60. sage/interfaces/singular.py +2835 -0
  61. sage/libs/all__sagemath_singular.py +1 -0
  62. sage/libs/singular/__init__.py +1 -0
  63. sage/libs/singular/decl.pxd +1168 -0
  64. sage/libs/singular/function.cpython-314-x86_64-linux-gnu.so +0 -0
  65. sage/libs/singular/function.pxd +87 -0
  66. sage/libs/singular/function.pyx +1901 -0
  67. sage/libs/singular/function_factory.py +61 -0
  68. sage/libs/singular/groebner_strategy.cpython-314-x86_64-linux-gnu.so +0 -0
  69. sage/libs/singular/groebner_strategy.pxd +22 -0
  70. sage/libs/singular/groebner_strategy.pyx +582 -0
  71. sage/libs/singular/option.cpython-314-x86_64-linux-gnu.so +0 -0
  72. sage/libs/singular/option.pyx +671 -0
  73. sage/libs/singular/polynomial.cpython-314-x86_64-linux-gnu.so +0 -0
  74. sage/libs/singular/polynomial.pxd +39 -0
  75. sage/libs/singular/polynomial.pyx +661 -0
  76. sage/libs/singular/ring.cpython-314-x86_64-linux-gnu.so +0 -0
  77. sage/libs/singular/ring.pxd +58 -0
  78. sage/libs/singular/ring.pyx +893 -0
  79. sage/libs/singular/singular.cpython-314-x86_64-linux-gnu.so +0 -0
  80. sage/libs/singular/singular.pxd +72 -0
  81. sage/libs/singular/singular.pyx +1944 -0
  82. sage/libs/singular/standard_options.py +145 -0
  83. sage/matrix/all__sagemath_singular.py +1 -0
  84. sage/matrix/matrix_mpolynomial_dense.cpython-314-x86_64-linux-gnu.so +0 -0
  85. sage/matrix/matrix_mpolynomial_dense.pxd +7 -0
  86. sage/matrix/matrix_mpolynomial_dense.pyx +615 -0
  87. sage/rings/all__sagemath_singular.py +1 -0
  88. sage/rings/function_field/all__sagemath_singular.py +1 -0
  89. sage/rings/function_field/derivations_polymod.py +911 -0
  90. sage/rings/function_field/element_polymod.cpython-314-x86_64-linux-gnu.so +0 -0
  91. sage/rings/function_field/element_polymod.pyx +406 -0
  92. sage/rings/function_field/function_field_polymod.py +2611 -0
  93. sage/rings/function_field/ideal_polymod.py +1775 -0
  94. sage/rings/function_field/order_polymod.py +1475 -0
  95. sage/rings/function_field/place_polymod.py +681 -0
  96. sage/rings/polynomial/all__sagemath_singular.py +1 -0
  97. sage/rings/polynomial/multi_polynomial_ideal_libsingular.cpython-314-x86_64-linux-gnu.so +0 -0
  98. sage/rings/polynomial/multi_polynomial_ideal_libsingular.pxd +5 -0
  99. sage/rings/polynomial/multi_polynomial_ideal_libsingular.pyx +339 -0
  100. sage/rings/polynomial/multi_polynomial_libsingular.cpython-314-x86_64-linux-gnu.so +0 -0
  101. sage/rings/polynomial/multi_polynomial_libsingular.pxd +30 -0
  102. sage/rings/polynomial/multi_polynomial_libsingular.pyx +6277 -0
  103. sage/rings/polynomial/plural.cpython-314-x86_64-linux-gnu.so +0 -0
  104. sage/rings/polynomial/plural.pxd +48 -0
  105. sage/rings/polynomial/plural.pyx +3171 -0
  106. sage/symbolic/all__sagemath_singular.py +1 -0
  107. sage/symbolic/comparison_impl.pxi +428 -0
  108. sage/symbolic/constants_c_impl.pxi +178 -0
  109. sage/symbolic/expression.cpython-314-x86_64-linux-gnu.so +0 -0
  110. sage/symbolic/expression.pxd +7 -0
  111. sage/symbolic/expression.pyx +14200 -0
  112. sage/symbolic/getitem_impl.pxi +202 -0
  113. sage/symbolic/pynac.pxi +572 -0
  114. sage/symbolic/pynac_constant_impl.pxi +133 -0
  115. sage/symbolic/pynac_function_impl.pxi +206 -0
  116. sage/symbolic/pynac_impl.pxi +2576 -0
  117. sage/symbolic/pynac_wrap.h +124 -0
  118. sage/symbolic/series_impl.pxi +272 -0
  119. sage/symbolic/substitution_map_impl.pxi +94 -0
  120. sage_wheels/bin/ESingular +0 -0
  121. sage_wheels/bin/Singular +0 -0
  122. sage_wheels/bin/TSingular +0 -0
  123. sage_wheels/lib/singular/MOD/cohomo.la +41 -0
  124. sage_wheels/lib/singular/MOD/cohomo.so +0 -0
  125. sage_wheels/lib/singular/MOD/customstd.la +41 -0
  126. sage_wheels/lib/singular/MOD/customstd.so +0 -0
  127. sage_wheels/lib/singular/MOD/freealgebra.la +41 -0
  128. sage_wheels/lib/singular/MOD/freealgebra.so +0 -0
  129. sage_wheels/lib/singular/MOD/gfanlib.la +41 -0
  130. sage_wheels/lib/singular/MOD/gfanlib.so +0 -0
  131. sage_wheels/lib/singular/MOD/gitfan.la +41 -0
  132. sage_wheels/lib/singular/MOD/gitfan.so +0 -0
  133. sage_wheels/lib/singular/MOD/interval.la +41 -0
  134. sage_wheels/lib/singular/MOD/interval.so +0 -0
  135. sage_wheels/lib/singular/MOD/loctriv.la +41 -0
  136. sage_wheels/lib/singular/MOD/loctriv.so +0 -0
  137. sage_wheels/lib/singular/MOD/machinelearning.la +41 -0
  138. sage_wheels/lib/singular/MOD/machinelearning.so +0 -0
  139. sage_wheels/lib/singular/MOD/p_Procs_FieldGeneral.la +41 -0
  140. sage_wheels/lib/singular/MOD/p_Procs_FieldGeneral.so +0 -0
  141. sage_wheels/lib/singular/MOD/p_Procs_FieldIndep.la +41 -0
  142. sage_wheels/lib/singular/MOD/p_Procs_FieldIndep.so +0 -0
  143. sage_wheels/lib/singular/MOD/p_Procs_FieldQ.la +41 -0
  144. sage_wheels/lib/singular/MOD/p_Procs_FieldQ.so +0 -0
  145. sage_wheels/lib/singular/MOD/p_Procs_FieldZp.la +41 -0
  146. sage_wheels/lib/singular/MOD/p_Procs_FieldZp.so +0 -0
  147. sage_wheels/lib/singular/MOD/partialgb.la +41 -0
  148. sage_wheels/lib/singular/MOD/partialgb.so +0 -0
  149. sage_wheels/lib/singular/MOD/pyobject.la +41 -0
  150. sage_wheels/lib/singular/MOD/pyobject.so +0 -0
  151. sage_wheels/lib/singular/MOD/singmathic.la +41 -0
  152. sage_wheels/lib/singular/MOD/singmathic.so +0 -0
  153. sage_wheels/lib/singular/MOD/sispasm.la +41 -0
  154. sage_wheels/lib/singular/MOD/sispasm.so +0 -0
  155. sage_wheels/lib/singular/MOD/subsets.la +41 -0
  156. sage_wheels/lib/singular/MOD/subsets.so +0 -0
  157. sage_wheels/lib/singular/MOD/systhreads.la +41 -0
  158. sage_wheels/lib/singular/MOD/systhreads.so +0 -0
  159. sage_wheels/lib/singular/MOD/syzextra.la +41 -0
  160. sage_wheels/lib/singular/MOD/syzextra.so +0 -0
  161. sage_wheels/libexec/singular/MOD/change_cost +0 -0
  162. sage_wheels/libexec/singular/MOD/singularsurf +11 -0
  163. sage_wheels/libexec/singular/MOD/singularsurf_jupyter +9 -0
  164. sage_wheels/libexec/singular/MOD/singularsurf_win +10 -0
  165. sage_wheels/libexec/singular/MOD/solve_IP +0 -0
  166. sage_wheels/libexec/singular/MOD/surfex +16 -0
  167. sage_wheels/libexec/singular/MOD/toric_ideal +0 -0
  168. sage_wheels/share/factory/gftables/10201 +342 -0
  169. sage_wheels/share/factory/gftables/1024 +37 -0
  170. sage_wheels/share/factory/gftables/10609 +356 -0
  171. sage_wheels/share/factory/gftables/11449 +384 -0
  172. sage_wheels/share/factory/gftables/11881 +398 -0
  173. sage_wheels/share/factory/gftables/121 +6 -0
  174. sage_wheels/share/factory/gftables/12167 +408 -0
  175. sage_wheels/share/factory/gftables/125 +7 -0
  176. sage_wheels/share/factory/gftables/12769 +428 -0
  177. sage_wheels/share/factory/gftables/128 +7 -0
  178. sage_wheels/share/factory/gftables/1331 +47 -0
  179. sage_wheels/share/factory/gftables/1369 +48 -0
  180. sage_wheels/share/factory/gftables/14641 +490 -0
  181. sage_wheels/share/factory/gftables/15625 +523 -0
  182. sage_wheels/share/factory/gftables/16 +3 -0
  183. sage_wheels/share/factory/gftables/16129 +540 -0
  184. sage_wheels/share/factory/gftables/16384 +549 -0
  185. sage_wheels/share/factory/gftables/16807 +563 -0
  186. sage_wheels/share/factory/gftables/1681 +58 -0
  187. sage_wheels/share/factory/gftables/169 +8 -0
  188. sage_wheels/share/factory/gftables/17161 +574 -0
  189. sage_wheels/share/factory/gftables/1849 +64 -0
  190. sage_wheels/share/factory/gftables/18769 +628 -0
  191. sage_wheels/share/factory/gftables/19321 +646 -0
  192. sage_wheels/share/factory/gftables/19683 +659 -0
  193. sage_wheels/share/factory/gftables/2048 +71 -0
  194. sage_wheels/share/factory/gftables/2187 +75 -0
  195. sage_wheels/share/factory/gftables/2197 +76 -0
  196. sage_wheels/share/factory/gftables/2209 +76 -0
  197. sage_wheels/share/factory/gftables/22201 +742 -0
  198. sage_wheels/share/factory/gftables/22801 +762 -0
  199. sage_wheels/share/factory/gftables/2401 +82 -0
  200. sage_wheels/share/factory/gftables/243 +11 -0
  201. sage_wheels/share/factory/gftables/24389 +815 -0
  202. sage_wheels/share/factory/gftables/24649 +824 -0
  203. sage_wheels/share/factory/gftables/25 +3 -0
  204. sage_wheels/share/factory/gftables/256 +11 -0
  205. sage_wheels/share/factory/gftables/26569 +888 -0
  206. sage_wheels/share/factory/gftables/27 +3 -0
  207. sage_wheels/share/factory/gftables/27889 +932 -0
  208. sage_wheels/share/factory/gftables/2809 +96 -0
  209. sage_wheels/share/factory/gftables/28561 +954 -0
  210. sage_wheels/share/factory/gftables/289 +12 -0
  211. sage_wheels/share/factory/gftables/29791 +995 -0
  212. sage_wheels/share/factory/gftables/29929 +1000 -0
  213. sage_wheels/share/factory/gftables/3125 +107 -0
  214. sage_wheels/share/factory/gftables/32 +4 -0
  215. sage_wheels/share/factory/gftables/32041 +1070 -0
  216. sage_wheels/share/factory/gftables/32761 +1094 -0
  217. sage_wheels/share/factory/gftables/32768 +1095 -0
  218. sage_wheels/share/factory/gftables/343 +14 -0
  219. sage_wheels/share/factory/gftables/3481 +118 -0
  220. sage_wheels/share/factory/gftables/361 +14 -0
  221. sage_wheels/share/factory/gftables/36481 +1218 -0
  222. sage_wheels/share/factory/gftables/3721 +126 -0
  223. sage_wheels/share/factory/gftables/37249 +1244 -0
  224. sage_wheels/share/factory/gftables/38809 +1296 -0
  225. sage_wheels/share/factory/gftables/39601 +1322 -0
  226. sage_wheels/share/factory/gftables/4 +3 -0
  227. sage_wheels/share/factory/gftables/4096 +139 -0
  228. sage_wheels/share/factory/gftables/44521 +1486 -0
  229. sage_wheels/share/factory/gftables/4489 +152 -0
  230. sage_wheels/share/factory/gftables/49 +4 -0
  231. sage_wheels/share/factory/gftables/4913 +166 -0
  232. sage_wheels/share/factory/gftables/49729 +1660 -0
  233. sage_wheels/share/factory/gftables/5041 +170 -0
  234. sage_wheels/share/factory/gftables/50653 +1691 -0
  235. sage_wheels/share/factory/gftables/512 +20 -0
  236. sage_wheels/share/factory/gftables/51529 +1720 -0
  237. sage_wheels/share/factory/gftables/52441 +1750 -0
  238. sage_wheels/share/factory/gftables/529 +20 -0
  239. sage_wheels/share/factory/gftables/5329 +180 -0
  240. sage_wheels/share/factory/gftables/54289 +1812 -0
  241. sage_wheels/share/factory/gftables/57121 +1906 -0
  242. sage_wheels/share/factory/gftables/58081 +1938 -0
  243. sage_wheels/share/factory/gftables/59049 +1971 -0
  244. sage_wheels/share/factory/gftables/6241 +210 -0
  245. sage_wheels/share/factory/gftables/625 +23 -0
  246. sage_wheels/share/factory/gftables/63001 +2102 -0
  247. sage_wheels/share/factory/gftables/64 +5 -0
  248. sage_wheels/share/factory/gftables/6561 +221 -0
  249. sage_wheels/share/factory/gftables/6859 +231 -0
  250. sage_wheels/share/factory/gftables/6889 +232 -0
  251. sage_wheels/share/factory/gftables/729 +27 -0
  252. sage_wheels/share/factory/gftables/7921 +266 -0
  253. sage_wheels/share/factory/gftables/8 +3 -0
  254. sage_wheels/share/factory/gftables/81 +5 -0
  255. sage_wheels/share/factory/gftables/8192 +276 -0
  256. sage_wheels/share/factory/gftables/841 +30 -0
  257. sage_wheels/share/factory/gftables/9 +3 -0
  258. sage_wheels/share/factory/gftables/9409 +316 -0
  259. sage_wheels/share/factory/gftables/961 +34 -0
  260. sage_wheels/share/info/singular.info +191898 -0
  261. sage_wheels/share/singular/LIB/GND.lib +1359 -0
  262. sage_wheels/share/singular/LIB/JMBTest.lib +976 -0
  263. sage_wheels/share/singular/LIB/JMSConst.lib +1363 -0
  264. sage_wheels/share/singular/LIB/KVequiv.lib +699 -0
  265. sage_wheels/share/singular/LIB/SingularityDBM.lib +491 -0
  266. sage_wheels/share/singular/LIB/VecField.lib +1542 -0
  267. sage_wheels/share/singular/LIB/absfact.lib +959 -0
  268. sage_wheels/share/singular/LIB/ainvar.lib +730 -0
  269. sage_wheels/share/singular/LIB/aksaka.lib +419 -0
  270. sage_wheels/share/singular/LIB/alexpoly.lib +2542 -0
  271. sage_wheels/share/singular/LIB/algebra.lib +1193 -0
  272. sage_wheels/share/singular/LIB/all.lib +136 -0
  273. sage_wheels/share/singular/LIB/arcpoint.lib +514 -0
  274. sage_wheels/share/singular/LIB/arnold.lib +4553 -0
  275. sage_wheels/share/singular/LIB/arnoldclassify.lib +2058 -0
  276. sage_wheels/share/singular/LIB/arr.lib +3486 -0
  277. sage_wheels/share/singular/LIB/assprimeszerodim.lib +755 -0
  278. sage_wheels/share/singular/LIB/autgradalg.lib +3361 -0
  279. sage_wheels/share/singular/LIB/bfun.lib +1964 -0
  280. sage_wheels/share/singular/LIB/bimodules.lib +774 -0
  281. sage_wheels/share/singular/LIB/brillnoether.lib +226 -0
  282. sage_wheels/share/singular/LIB/brnoeth.lib +5017 -0
  283. sage_wheels/share/singular/LIB/central.lib +2169 -0
  284. sage_wheels/share/singular/LIB/chern.lib +4162 -0
  285. sage_wheels/share/singular/LIB/cimonom.lib +571 -0
  286. sage_wheels/share/singular/LIB/cisimplicial.lib +1835 -0
  287. sage_wheels/share/singular/LIB/classify.lib +3239 -0
  288. sage_wheels/share/singular/LIB/classify2.lib +1462 -0
  289. sage_wheels/share/singular/LIB/classifyMapGerms.lib +1515 -0
  290. sage_wheels/share/singular/LIB/classify_aeq.lib +3253 -0
  291. sage_wheels/share/singular/LIB/classifyceq.lib +2092 -0
  292. sage_wheels/share/singular/LIB/classifyci.lib +1133 -0
  293. sage_wheels/share/singular/LIB/combinat.lib +91 -0
  294. sage_wheels/share/singular/LIB/compregb.lib +276 -0
  295. sage_wheels/share/singular/LIB/control.lib +1636 -0
  296. sage_wheels/share/singular/LIB/crypto.lib +3795 -0
  297. sage_wheels/share/singular/LIB/curveInv.lib +667 -0
  298. sage_wheels/share/singular/LIB/curvepar.lib +1817 -0
  299. sage_wheels/share/singular/LIB/customstd.lib +100 -0
  300. sage_wheels/share/singular/LIB/deRham.lib +5979 -0
  301. sage_wheels/share/singular/LIB/decodegb.lib +2134 -0
  302. sage_wheels/share/singular/LIB/decomp.lib +1655 -0
  303. sage_wheels/share/singular/LIB/deflation.lib +872 -0
  304. sage_wheels/share/singular/LIB/deform.lib +925 -0
  305. sage_wheels/share/singular/LIB/difform.lib +3055 -0
  306. sage_wheels/share/singular/LIB/divisors.lib +750 -0
  307. sage_wheels/share/singular/LIB/dmod.lib +5817 -0
  308. sage_wheels/share/singular/LIB/dmodapp.lib +3269 -0
  309. sage_wheels/share/singular/LIB/dmodideal.lib +1211 -0
  310. sage_wheels/share/singular/LIB/dmodloc.lib +2645 -0
  311. sage_wheels/share/singular/LIB/dmodvar.lib +818 -0
  312. sage_wheels/share/singular/LIB/dummy.lib +17 -0
  313. sage_wheels/share/singular/LIB/elim.lib +1009 -0
  314. sage_wheels/share/singular/LIB/ellipticcovers.lib +548 -0
  315. sage_wheels/share/singular/LIB/enumpoints.lib +146 -0
  316. sage_wheels/share/singular/LIB/equising.lib +2127 -0
  317. sage_wheels/share/singular/LIB/ffmodstd.lib +2384 -0
  318. sage_wheels/share/singular/LIB/ffsolve.lib +1289 -0
  319. sage_wheels/share/singular/LIB/findifs.lib +778 -0
  320. sage_wheels/share/singular/LIB/finitediff.lib +1768 -0
  321. sage_wheels/share/singular/LIB/finvar.lib +7989 -0
  322. sage_wheels/share/singular/LIB/fpadim.lib +2429 -0
  323. sage_wheels/share/singular/LIB/fpalgebras.lib +1666 -0
  324. sage_wheels/share/singular/LIB/fpaprops.lib +1462 -0
  325. sage_wheels/share/singular/LIB/freegb.lib +3853 -0
  326. sage_wheels/share/singular/LIB/general.lib +1350 -0
  327. sage_wheels/share/singular/LIB/gfan.lib +1768 -0
  328. sage_wheels/share/singular/LIB/gitfan.lib +3130 -0
  329. sage_wheels/share/singular/LIB/gkdim.lib +99 -0
  330. sage_wheels/share/singular/LIB/gmspoly.lib +589 -0
  331. sage_wheels/share/singular/LIB/gmssing.lib +1739 -0
  332. sage_wheels/share/singular/LIB/goettsche.lib +909 -0
  333. sage_wheels/share/singular/LIB/graal.lib +1366 -0
  334. sage_wheels/share/singular/LIB/gradedModules.lib +2541 -0
  335. sage_wheels/share/singular/LIB/graphics.lib +360 -0
  336. sage_wheels/share/singular/LIB/grobcov.lib +7706 -0
  337. sage_wheels/share/singular/LIB/groups.lib +1123 -0
  338. sage_wheels/share/singular/LIB/grwalk.lib +507 -0
  339. sage_wheels/share/singular/LIB/hdepth.lib +194 -0
  340. sage_wheels/share/singular/LIB/help.cnf +57 -0
  341. sage_wheels/share/singular/LIB/hess.lib +1946 -0
  342. sage_wheels/share/singular/LIB/hnoether.lib +4292 -0
  343. sage_wheels/share/singular/LIB/hodge.lib +400 -0
  344. sage_wheels/share/singular/LIB/homolog.lib +1965 -0
  345. sage_wheels/share/singular/LIB/hyperel.lib +975 -0
  346. sage_wheels/share/singular/LIB/inout.lib +679 -0
  347. sage_wheels/share/singular/LIB/integralbasis.lib +6224 -0
  348. sage_wheels/share/singular/LIB/interval.lib +1418 -0
  349. sage_wheels/share/singular/LIB/intprog.lib +778 -0
  350. sage_wheels/share/singular/LIB/invar.lib +443 -0
  351. sage_wheels/share/singular/LIB/involut.lib +980 -0
  352. sage_wheels/share/singular/LIB/jacobson.lib +1215 -0
  353. sage_wheels/share/singular/LIB/kskernel.lib +534 -0
  354. sage_wheels/share/singular/LIB/latex.lib +3146 -0
  355. sage_wheels/share/singular/LIB/lejeune.lib +651 -0
  356. sage_wheels/share/singular/LIB/linalg.lib +2040 -0
  357. sage_wheels/share/singular/LIB/locnormal.lib +212 -0
  358. sage_wheels/share/singular/LIB/lrcalc.lib +526 -0
  359. sage_wheels/share/singular/LIB/makedbm.lib +294 -0
  360. sage_wheels/share/singular/LIB/mathml.lib +813 -0
  361. sage_wheels/share/singular/LIB/matrix.lib +1372 -0
  362. sage_wheels/share/singular/LIB/maxlike.lib +1132 -0
  363. sage_wheels/share/singular/LIB/methods.lib +212 -0
  364. sage_wheels/share/singular/LIB/moddiq.lib +322 -0
  365. sage_wheels/share/singular/LIB/modfinduni.lib +181 -0
  366. sage_wheels/share/singular/LIB/modnormal.lib +218 -0
  367. sage_wheels/share/singular/LIB/modprimdec.lib +1278 -0
  368. sage_wheels/share/singular/LIB/modquotient.lib +269 -0
  369. sage_wheels/share/singular/LIB/modstd.lib +1024 -0
  370. sage_wheels/share/singular/LIB/modular.lib +545 -0
  371. sage_wheels/share/singular/LIB/modules.lib +2561 -0
  372. sage_wheels/share/singular/LIB/modwalk.lib +609 -0
  373. sage_wheels/share/singular/LIB/mondromy.lib +1016 -0
  374. sage_wheels/share/singular/LIB/monomialideal.lib +3851 -0
  375. sage_wheels/share/singular/LIB/mprimdec.lib +2353 -0
  376. sage_wheels/share/singular/LIB/mregular.lib +1863 -0
  377. sage_wheels/share/singular/LIB/multigrading.lib +5629 -0
  378. sage_wheels/share/singular/LIB/ncHilb.lib +777 -0
  379. sage_wheels/share/singular/LIB/ncModslimgb.lib +791 -0
  380. sage_wheels/share/singular/LIB/ncalg.lib +16311 -0
  381. sage_wheels/share/singular/LIB/ncall.lib +31 -0
  382. sage_wheels/share/singular/LIB/ncdecomp.lib +468 -0
  383. sage_wheels/share/singular/LIB/ncfactor.lib +13371 -0
  384. sage_wheels/share/singular/LIB/ncfrac.lib +1023 -0
  385. sage_wheels/share/singular/LIB/nchilbert.lib +448 -0
  386. sage_wheels/share/singular/LIB/nchomolog.lib +759 -0
  387. sage_wheels/share/singular/LIB/ncloc.lib +361 -0
  388. sage_wheels/share/singular/LIB/ncpreim.lib +795 -0
  389. sage_wheels/share/singular/LIB/ncrat.lib +2849 -0
  390. sage_wheels/share/singular/LIB/nctools.lib +1887 -0
  391. sage_wheels/share/singular/LIB/nets.lib +1456 -0
  392. sage_wheels/share/singular/LIB/nfmodstd.lib +1000 -0
  393. sage_wheels/share/singular/LIB/nfmodsyz.lib +732 -0
  394. sage_wheels/share/singular/LIB/noether.lib +1106 -0
  395. sage_wheels/share/singular/LIB/normal.lib +8700 -0
  396. sage_wheels/share/singular/LIB/normaliz.lib +2226 -0
  397. sage_wheels/share/singular/LIB/ntsolve.lib +362 -0
  398. sage_wheels/share/singular/LIB/numerAlg.lib +560 -0
  399. sage_wheels/share/singular/LIB/numerDecom.lib +2261 -0
  400. sage_wheels/share/singular/LIB/olga.lib +1933 -0
  401. sage_wheels/share/singular/LIB/orbitparam.lib +351 -0
  402. sage_wheels/share/singular/LIB/parallel.lib +319 -0
  403. sage_wheels/share/singular/LIB/paraplanecurves.lib +3110 -0
  404. sage_wheels/share/singular/LIB/perron.lib +202 -0
  405. sage_wheels/share/singular/LIB/pfd.lib +2223 -0
  406. sage_wheels/share/singular/LIB/phindex.lib +642 -0
  407. sage_wheels/share/singular/LIB/pointid.lib +673 -0
  408. sage_wheels/share/singular/LIB/polybori.lib +1430 -0
  409. sage_wheels/share/singular/LIB/polyclass.lib +525 -0
  410. sage_wheels/share/singular/LIB/polylib.lib +1174 -0
  411. sage_wheels/share/singular/LIB/polymake.lib +1902 -0
  412. sage_wheels/share/singular/LIB/presolve.lib +1533 -0
  413. sage_wheels/share/singular/LIB/primdec.lib +9576 -0
  414. sage_wheels/share/singular/LIB/primdecint.lib +1782 -0
  415. sage_wheels/share/singular/LIB/primitiv.lib +401 -0
  416. sage_wheels/share/singular/LIB/puiseuxexpansions.lib +1631 -0
  417. sage_wheels/share/singular/LIB/purityfiltration.lib +960 -0
  418. sage_wheels/share/singular/LIB/qhmoduli.lib +1561 -0
  419. sage_wheels/share/singular/LIB/qmatrix.lib +293 -0
  420. sage_wheels/share/singular/LIB/random.lib +455 -0
  421. sage_wheels/share/singular/LIB/ratgb.lib +489 -0
  422. sage_wheels/share/singular/LIB/realclassify.lib +5759 -0
  423. sage_wheels/share/singular/LIB/realizationMatroids.lib +772 -0
  424. sage_wheels/share/singular/LIB/realrad.lib +1197 -0
  425. sage_wheels/share/singular/LIB/recover.lib +2628 -0
  426. sage_wheels/share/singular/LIB/redcgs.lib +3984 -0
  427. sage_wheels/share/singular/LIB/reesclos.lib +465 -0
  428. sage_wheels/share/singular/LIB/resbinomial.lib +2802 -0
  429. sage_wheels/share/singular/LIB/resgraph.lib +789 -0
  430. sage_wheels/share/singular/LIB/resjung.lib +820 -0
  431. sage_wheels/share/singular/LIB/resolve.lib +5110 -0
  432. sage_wheels/share/singular/LIB/resources.lib +170 -0
  433. sage_wheels/share/singular/LIB/reszeta.lib +5473 -0
  434. sage_wheels/share/singular/LIB/ring.lib +1328 -0
  435. sage_wheels/share/singular/LIB/ringgb.lib +343 -0
  436. sage_wheels/share/singular/LIB/rinvar.lib +1153 -0
  437. sage_wheels/share/singular/LIB/rootisolation.lib +1481 -0
  438. sage_wheels/share/singular/LIB/rootsmr.lib +709 -0
  439. sage_wheels/share/singular/LIB/rootsur.lib +886 -0
  440. sage_wheels/share/singular/LIB/rstandard.lib +607 -0
  441. sage_wheels/share/singular/LIB/rwalk.lib +336 -0
  442. sage_wheels/share/singular/LIB/sagbi.lib +1353 -0
  443. sage_wheels/share/singular/LIB/sagbiNormaliz.lib +1622 -0
  444. sage_wheels/share/singular/LIB/sagbiNormaliz0.lib +1498 -0
  445. sage_wheels/share/singular/LIB/sagbigrob.lib +449 -0
  446. sage_wheels/share/singular/LIB/schreyer.lib +321 -0
  447. sage_wheels/share/singular/LIB/schubert.lib +2551 -0
  448. sage_wheels/share/singular/LIB/sets.lib +524 -0
  449. sage_wheels/share/singular/LIB/sheafcoh.lib +1663 -0
  450. sage_wheels/share/singular/LIB/signcond.lib +437 -0
  451. sage_wheels/share/singular/LIB/sing.lib +1094 -0
  452. sage_wheels/share/singular/LIB/sing4ti2.lib +419 -0
  453. sage_wheels/share/singular/LIB/solve.lib +2243 -0
  454. sage_wheels/share/singular/LIB/spcurve.lib +1077 -0
  455. sage_wheels/share/singular/LIB/spectrum.lib +62 -0
  456. sage_wheels/share/singular/LIB/sresext.lib +757 -0
  457. sage_wheels/share/singular/LIB/ssi.lib +143 -0
  458. sage_wheels/share/singular/LIB/standard.lib +2769 -0
  459. sage_wheels/share/singular/LIB/stanleyreisner.lib +473 -0
  460. sage_wheels/share/singular/LIB/stdmodule.lib +547 -0
  461. sage_wheels/share/singular/LIB/stratify.lib +1070 -0
  462. sage_wheels/share/singular/LIB/surf.lib +506 -0
  463. sage_wheels/share/singular/LIB/surf_jupyter.lib +223 -0
  464. sage_wheels/share/singular/LIB/surfacesignature.lib +522 -0
  465. sage_wheels/share/singular/LIB/surfex.lib +1462 -0
  466. sage_wheels/share/singular/LIB/swalk.lib +877 -0
  467. sage_wheels/share/singular/LIB/symodstd.lib +1570 -0
  468. sage_wheels/share/singular/LIB/systhreads.lib +74 -0
  469. sage_wheels/share/singular/LIB/tasks.lib +1324 -0
  470. sage_wheels/share/singular/LIB/tateProdCplxNegGrad.lib +2412 -0
  471. sage_wheels/share/singular/LIB/teachstd.lib +858 -0
  472. sage_wheels/share/singular/LIB/template.lib +116 -0
  473. sage_wheels/share/singular/LIB/toric.lib +1119 -0
  474. sage_wheels/share/singular/LIB/transformation.lib +116 -0
  475. sage_wheels/share/singular/LIB/triang.lib +1197 -0
  476. sage_wheels/share/singular/LIB/tropical.lib +8741 -0
  477. sage_wheels/share/singular/LIB/tropicalEllipticCovers.lib +2922 -0
  478. sage_wheels/share/singular/LIB/tropicalNewton.lib +1128 -0
  479. sage_wheels/share/singular/LIB/tst.lib +1108 -0
  480. sage_wheels/share/singular/LIB/weierstr.lib +241 -0
  481. sage_wheels/share/singular/LIB/zeroset.lib +1478 -0
  482. sage_wheels/share/singular/emacs/.emacs-general +184 -0
  483. sage_wheels/share/singular/emacs/.emacs-singular +234 -0
  484. sage_wheels/share/singular/emacs/COPYING +44 -0
  485. sage_wheels/share/singular/emacs/cmd-cmpl.el +241 -0
  486. sage_wheels/share/singular/emacs/ex-cmpl.el +1681 -0
  487. sage_wheels/share/singular/emacs/hlp-cmpl.el +4318 -0
  488. sage_wheels/share/singular/emacs/lib-cmpl.el +179 -0
  489. sage_wheels/share/singular/emacs/singular.el +4273 -0
  490. sage_wheels/share/singular/emacs/singular.xpm +39 -0
  491. sage_wheels/share/singular/singular.idx +5002 -0
@@ -0,0 +1,2040 @@
1
+ /////////////////////////////////////////////////////////////////////////////
2
+ version="version linalg.lib 4.3.1.3 Feb_2023 "; // $Id: 0f92fc85b4f4f82ccea60c1e09263a5adf7c0e64 $
3
+ category="Linear Algebra";
4
+ info="
5
+ LIBRARY: linalg.lib Algorithmic Linear Algebra
6
+ AUTHORS: Ivor Saynisch (ivs@math.tu-cottbus.de)
7
+ @* Mathias Schulze (mschulze@mathematik.uni-kl.de)
8
+
9
+ PROCEDURES:
10
+ inverse(A); matrix, the inverse of A
11
+ inverse_B(A); list(matrix Inv,poly p),Inv*A=p*En ( using busadj(A) )
12
+ inverse_L(A); list(matrix Inv,poly p),Inv*A=p*En ( using lift )
13
+ sym_gauss(A); symmetric gaussian algorithm
14
+ orthogonalize(A); Gram-Schmidt orthogonalization
15
+ diag_test(A); test whether A can be diagnolized
16
+ busadj(A); coefficients of Adj(E*t-A) and coefficients of det(E*t-A)
17
+ charpoly(A,v); characteristic polynomial of A ( using busadj(A) )
18
+ adjoint(A); adjoint of A ( using busadj(A) )
19
+ det_B(A); determinant of A ( using busadj(A) )
20
+ gaussred(A); gaussian reduction: P*A=U*S, S a row reduced form of A
21
+ gaussred_pivot(A); gaussian reduction: P*A=U*S, uses row pivoting
22
+ gauss_nf(A); gaussian normal form of A
23
+ mat_rk(A); rank of constant matrix A
24
+ U_D_O(A); P*A=U*D*O, P,D,U,O=permutation,diag,lower-,upper-triang
25
+ pos_def(A,i); test symmetric matrix for positive definiteness
26
+ hessenberg(M); Hessenberg form of M
27
+ eigenvals(M); eigenvalues with multiplicities of M
28
+ minipoly(M); minimal polynomial of M
29
+ spnf(sp); normal form of spectrum sp
30
+ spprint(sp); print spectrum sp
31
+ jordan(M); Jordan data of M
32
+ jordanbasis(M); Jordan basis and weight filtration of M
33
+ jordanmatrix(jd); Jordan matrix with Jordan data jd
34
+ jordannf(M); Jordan normal form of M
35
+ ";
36
+
37
+ LIB "matrix.lib";
38
+ LIB "ring.lib";
39
+ LIB "elim.lib";
40
+ LIB "general.lib";
41
+ //////////////////////////////////////////////////////////////////////////////
42
+ // help functions
43
+ //////////////////////////////////////////////////////////////////////////////
44
+ static proc const_mat(matrix A)
45
+ "RETURN: 1 (0) if A is (is not) a constant matrix"
46
+ {
47
+ int i;
48
+ int n=ncols(A);
49
+ def BR=basering;
50
+ def @R=changeord(list(list("dp",1:nvars(basering)),list("c",0:1)));
51
+ setring @R;
52
+ matrix A=fetch(BR,A);
53
+ for(i=1;i<=n;i=i+1){
54
+ if(deg(lead(A)[i])>=1){
55
+ //"input is not a constant matrix";
56
+ kill @R;
57
+ setring BR;
58
+ return(0);
59
+ }
60
+ }
61
+ kill @R;
62
+ setring BR;
63
+ return(1);
64
+ }
65
+ //////////////////////////////////////////////////////////////////////////////
66
+ static proc red(matrix A,int i,int j)
67
+ "USAGE: red(A,i,j); A = constant matrix
68
+ reduces column j with respect to A[i,i] and column i
69
+ reduces row j with respect to A[i,i] and row i
70
+ RETURN: matrix
71
+ "
72
+ {
73
+ module m=module(A);
74
+
75
+ if(A[i,i]==0)
76
+ {
77
+ m[i]=m[i]+m[j];
78
+ m=module(transpose(matrix(m)));
79
+ m[i]=m[i]+m[j];
80
+ m=module(transpose(matrix(m)));
81
+ }
82
+
83
+ A=matrix(m);
84
+ m[j]=m[j]-(A[i,j]/A[i,i])*m[i];
85
+ m=module(transpose(matrix(m)));
86
+ m[j]=m[j]-(A[i,j]/A[i,i])*m[i];
87
+ m=module(transpose(matrix(m)));
88
+
89
+ return(matrix(m));
90
+ }
91
+
92
+ //////////////////////////////////////////////////////////////////////////////
93
+ proc inner_product(vector v1,vector v2)
94
+ "RETURN: inner product <v1,v2> "
95
+ {
96
+ int k;
97
+ if (nrows(v2)>nrows(v1)) { k=nrows(v2); } else { k=nrows(v1); }
98
+ return ((transpose(matrix(v1,k,1))*matrix(v2,k,1))[1,1]);
99
+ }
100
+
101
+ /////////////////////////////////////////////////////////////////////////////
102
+ // user functions
103
+ /////////////////////////////////////////////////////////////////////////////
104
+
105
+ proc inverse(matrix A, list #)
106
+ "USAGE: inverse(A [,opt]); A a square matrix, opt integer
107
+ RETURN:
108
+ @format
109
+ a matrix:
110
+ - the inverse matrix of A, if A is invertible;
111
+ - the 1x1 0-matrix if A is not invertible (in the polynomial ring!).
112
+ There are the following options:
113
+ - opt=0 or not given: heuristically best option from below
114
+ - opt=1 : apply std to (transpose(E,A)), ordering (C,dp).
115
+ - opt=2 : apply interred (transpose(E,A)), ordering (C,dp).
116
+ - opt=3 : apply lift(A,E), ordering (C,dp).
117
+ @end format
118
+ NOTE: parameters and minpoly are allowed; opt=2 is only correct for
119
+ matrices with entries in a field
120
+ SEE ALSO: inverse_B, inverse_L
121
+ EXAMPLE: example inverse; shows an example
122
+ "
123
+ {
124
+ //--------------------------- initialization and check ------------------------
125
+ int ii,u,notInvertible,opt;
126
+ matrix invA;
127
+ int db = printlevel-voice+3; //used for comments
128
+ def R = basering;
129
+ int n = nrows(A);
130
+ module M = A;
131
+ intvec v = option(get); //get options to reset it later
132
+ if ( ncols(A)!=n )
133
+ {
134
+ ERROR("// ** no square matrix");
135
+ }
136
+ //----------------------- choose heurisitically best option ------------------
137
+ // This may change later, depending on improvements of the implementation
138
+ // at the monent we use if opt=0 or opt not given:
139
+ // opt = 1 (std) for everything
140
+ // opt = 2 (interred) for nothing, NOTE: interred is ok for constant matricea
141
+ // opt = 3 (lift) for nothing
142
+ // NOTE: interred is ok for constant matrices only (Beispiele am Ende der lib)
143
+ if(size(#) != 0) {opt = #[1];}
144
+ if(opt == 0)
145
+ {
146
+ if(npars(R) == 0) //no parameters
147
+ {
148
+ if( size(ideal(A-jet(A,0))) == 0 ) //constant matrix
149
+ {opt = 1;}
150
+ else
151
+ {opt = 1;}
152
+ }
153
+ else {opt = 1;}
154
+ }
155
+ //------------------------- change ring if necessary -------------------------
156
+ if( ordstr(R) != "C,dp(" + string(nvars(R)) + ")" )
157
+ {
158
+ u=1;
159
+ def @R=changeord(list(list("C",0:1),list("dp",1:nvars(basering))));
160
+ setring @R;
161
+ module M = fetch(R,M);
162
+ }
163
+ //----------------------------- opt=3: use lift ------------------------------
164
+ if( opt==3 )
165
+ {
166
+ module D2;
167
+ D2 = lift(M,freemodule(n));
168
+ if (size(ideal(D2))==0)
169
+ { //catch error in lift
170
+ dbprint(db,"// ** matrix is not invertible");
171
+ setring R;
172
+ if (u==1) { kill @R;}
173
+ return(invA);
174
+ }
175
+ }
176
+ //-------------- opt = 1 resp. opt = 2: use std resp. interred --------------
177
+ if( opt==1 or opt==2 )
178
+ {
179
+ option(redSB);
180
+ module B = freemodule(n),M;
181
+ if(opt == 2)
182
+ {
183
+ module D = interred(transpose(B));
184
+ D = transpose(simplify(D,1));
185
+ }
186
+ if(opt == 1)
187
+ {
188
+ module D = std(transpose(B));
189
+ D = transpose(simplify(D,1));
190
+ }
191
+ module D2 = D[1..n];
192
+ module D1 = D[n+1..2*n];
193
+ //----------------------- check if matrix is invertible ----------------------
194
+ for (ii=1; ii<=n; ii++)
195
+ {
196
+ if ( D1[ii] != gen(ii) )
197
+ {
198
+ notInvertible = 1;
199
+ break;
200
+ }
201
+ }
202
+ }
203
+ option(set,v);
204
+ //------------------ return to basering and return result ---------------------
205
+ if ( u==1 )
206
+ {
207
+ setring R;
208
+ module D2 = fetch(@R,D2);
209
+ if( opt==1 or opt==2 )
210
+ { module D1 = fetch(@R,D1);}
211
+ kill @R;
212
+ }
213
+ if( notInvertible == 1 )
214
+ {
215
+ // The matrix A seems to be non-invertible.
216
+ // Note that there are examples, where this is not true but only due to
217
+ // inexact computations in the field of reals or complex numbers:
218
+ // ring r = complex, x, dp;
219
+ // The following matrix has non-zero determinante but seems non-invertible:
220
+ // matrix A[3][3] = 1,i,i,0,1,2,1,0,1+i;
221
+ // For this example, inverse_B yields the correct answer.
222
+ // So, let's use this as a workaround whenever we have this situation:
223
+ list myList = inverse_B(A);
224
+ matrix Try = inverse_B(A)[1];
225
+ if (myList[2] == poly(1)) { return (Try); }
226
+ else
227
+ {
228
+ dbprint(db,"// ** matrix is not invertible");
229
+ return(invA);
230
+ }
231
+ }
232
+ else { return(matrix(D2)); } //matrix invertible with inverse D2
233
+
234
+ }
235
+ example
236
+ { "EXAMPLE:"; echo = 2;
237
+ ring r=0,(x,y,z),lp;
238
+ matrix A[3][3]=
239
+ 1,4,3,
240
+ 1,5,7,
241
+ 0,4,17;
242
+ print(inverse(A));"";
243
+ matrix B[3][3]=
244
+ y+1, x+y, y,
245
+ z, z+1, z,
246
+ y+z+2,x+y+z+2,y+z+1;
247
+ print(inverse(B));
248
+ print(B*inverse(B));
249
+ }
250
+
251
+ //////////////////////////////////////////////////////////////////////////////
252
+ proc sym_gauss(matrix A)
253
+ "USAGE: sym_gauss(A); A = symmetric matrix
254
+ RETURN: matrix, diagonalisation of A with symmetric gauss algorithm
255
+ EXAMPLE: example sym_gauss; shows an example"
256
+ {
257
+ int i,j;
258
+ int n=nrows(A);
259
+
260
+ if (ncols(A)!=n)
261
+ {
262
+ ERROR("input is not a square matrix");
263
+ }
264
+
265
+ if(!const_mat(A))
266
+ {
267
+ ERROR("input is not a constant matrix");
268
+ }
269
+
270
+ if(deg(std(A-transpose(A))[1])!=-1)
271
+ {
272
+ ERROR("input is not a symmetric matrix");
273
+ }
274
+
275
+ for(i=1; i<n; i++)
276
+ {
277
+ for(j=i+1; j<=n; j++)
278
+ {
279
+ if(A[i,j]!=0){ A=red(A,i,j); }
280
+ }
281
+ }
282
+ return(A);
283
+ }
284
+ example
285
+ {"EXAMPLE:"; echo = 2;
286
+ ring r=0,(x),lp;
287
+ matrix A[2][2]=1,4,4,15;
288
+ print(A);
289
+ print(sym_gauss(A));
290
+ }
291
+
292
+ //////////////////////////////////////////////////////////////////////////////
293
+ proc orthogonalize(matrix A)
294
+ "USAGE: orthogonalize(A); A = matrix of constants
295
+ RETURN: matrix, orthogonal basis of the column space of A
296
+ EXAMPLE: example orthogonalize; shows an example "
297
+ {
298
+ int i,j;
299
+ int n=ncols(A);
300
+ poly k;
301
+
302
+ if(!const_mat(A)){
303
+ "// ** input is not a constant matrix";
304
+ matrix B;
305
+ return(B);
306
+ }
307
+
308
+ module B=module(interred(A));
309
+
310
+ for(i=1;i<=n;i=i+1) {
311
+ for(j=1;j<i;j=j+1) {
312
+ k=inner_product(B[j],B[j]);
313
+ if (k==0) { "Error: vector of length zero"; return(matrix(B)); }
314
+ B[i]=B[i]-(inner_product(B[i],B[j])/k)*B[j];
315
+ }
316
+ }
317
+
318
+ return(matrix(B));
319
+ }
320
+ example
321
+ { "EXAMPLE:"; echo = 2;
322
+ ring r=0,(x),lp;
323
+ matrix A[4][4]=5,6,12,4,7,3,2,6,12,1,1,2,6,4,2,10;
324
+ print(A);
325
+ print(orthogonalize(A));
326
+ }
327
+
328
+ ////////////////////////////////////////////////////////////////////////////
329
+ proc diag_test(matrix A)
330
+ "USAGE: diag_test(A); A = const square matrix
331
+ RETURN: int, 1 if A is diagonalizable,@*
332
+ 0 if not@*
333
+ -1 if no statement is possible, since A does not split.
334
+ NOTE: The test works only for split matrices, i.e if eigenvalues of A
335
+ are in the ground field.
336
+ Does not work with parameters (uses factorize,gcd).
337
+ EXAMPLE: example diag_test; shows an example"
338
+ {
339
+ int i,j;
340
+ int n = nrows(A);
341
+ string mp = string(minpoly);
342
+ string cs = charstr(basering);
343
+ int np=0;
344
+
345
+ if(ncols(A) != n) {
346
+ "// input is not a square matrix";
347
+ return(-1);
348
+ }
349
+
350
+ if(!const_mat(A)){
351
+ "// input is not a constant matrix";
352
+ return(-1);
353
+ }
354
+
355
+ //Parameterring wegen factorize nicht erlaubt
356
+ for(i=1;i<size(cs);i=i+1){
357
+ if(cs[i]==","){np=np+1;} //Anzahl der Parameter
358
+ }
359
+ if(np>0){
360
+ "// rings with parameters not allowed";
361
+ return(-1);
362
+ }
363
+
364
+ //speichern des aktuellen Rings
365
+ def BR=basering;
366
+ //setze R[t]
367
+ ring rt = create_ring(ring_list(basering)[1], "(@t,"+varstr(basering)+")","lp");
368
+ matrix A=imap(BR,A);
369
+
370
+ intvec z;
371
+ intvec s;
372
+ poly X; //characteristisches Polynom
373
+ poly dXdt; //Ableitung von X nach t
374
+ ideal g; //ggT(X,dXdt)
375
+ poly b; //Komponente der Busadjunkten-Matrix
376
+ matrix E[n][n]; //Einheitsmatrix
377
+
378
+ E=E+1;
379
+ A=E*@t-A;
380
+ X=det(A);
381
+
382
+ matrix Xfactors=matrix(factorize(X,1)); //zerfaellt die Matrtix ?
383
+ int nf=ncols(Xfactors);
384
+
385
+ for(i=1;i<=nf;i++){
386
+ if(lead(Xfactors[1,i])>=@t^2){
387
+ //" matrix does not split";
388
+ setring BR;
389
+ return(-1);
390
+ }
391
+ }
392
+
393
+ dXdt=diff(X,@t);
394
+ g=std(ideal(gcd(X,dXdt)));
395
+
396
+ //Busadjunkte
397
+ z=2..n;
398
+ for(i=1;i<=n;i++){
399
+ s=2..n;
400
+ for(j=1;j<=n;j++){
401
+ b=det(submat(A,z,s));
402
+
403
+ if(0!=reduce(b,g)){
404
+ //" matrix not diagonalizable";
405
+ setring BR;
406
+ return(0);
407
+ }
408
+
409
+ s[j]=j;
410
+ }
411
+ z[i]=i;
412
+ }
413
+
414
+ //"Die Matrix ist diagonalisierbar";
415
+ setring BR;
416
+ return(1);
417
+ }
418
+ example
419
+ { "EXAMPLE:"; echo = 2;
420
+ ring r=0,(x),dp;
421
+ matrix A[4][4]=6,0,0,0,0,0,6,0,0,6,0,0,0,0,0,6;
422
+ print(A);
423
+ diag_test(A);
424
+ }
425
+
426
+ //////////////////////////////////////////////////////////////////////////////
427
+ proc busadj(matrix A)
428
+ "USAGE: busadj(A); A = square matrix (of size nxn)
429
+ RETURN: list L:
430
+ @format
431
+ L[1] contains the (n+1) coefficients of the characteristic
432
+ polynomial X of A, i.e.
433
+ X = L[1][1]+..+L[1][k]*t^(k-1)+..+(L[1][n+1])*t^n
434
+ L[2] contains the n (nxn)-matrices Hk which are the coefficients of
435
+ the busadjoint bA = adjoint(E*t-A) of A, i.e.
436
+ bA = (Hn-1)*t^(n-1)+...+Hk*t^k+...+H0, ( Hk=L[2][k+1] )
437
+ @end format
438
+ EXAMPLE: example busadj; shows an example"
439
+ {
440
+ int k;
441
+ int n = nrows(A);
442
+ matrix E = unitmat(n);
443
+ matrix H[n][n];
444
+ matrix B[n][n];
445
+ list bA, X, L;
446
+ poly a;
447
+
448
+ if(ncols(A) != n) {
449
+ "input is not a square matrix";
450
+ return(L);
451
+ }
452
+
453
+ bA = E;
454
+ X[1] = 1;
455
+ for(k=1; k<n; k++){
456
+ B = A*bA[1]; //bA[1] is the last H
457
+ a = -trace(B)/k;
458
+ H = B+a*E;
459
+ bA = insert(bA,H);
460
+ X = insert(X,a);
461
+ }
462
+ B = A*bA[1];
463
+ a = -trace(B)/n;
464
+ X = insert(X,a);
465
+
466
+ L = insert(L,bA);
467
+ L = insert(L,X);
468
+ return(L);
469
+ }
470
+ example
471
+ { "EXAMPLE"; echo = 2;
472
+ ring r = 0,(t,x),lp;
473
+ matrix A[2][2] = 1,x2,x,x2+3x;
474
+ print(A);
475
+ list L = busadj(A);
476
+ poly X = L[1][1]+L[1][2]*t+L[1][3]*t2; X;
477
+ matrix bA[2][2] = L[2][1]+L[2][2]*t;
478
+ print(bA); //the busadjoint of A;
479
+ print(bA*(t*unitmat(2)-A));
480
+ }
481
+
482
+ //////////////////////////////////////////////////////////////////////////////
483
+ proc charpoly(matrix A, list #)
484
+ "USAGE: charpoly(A[,v]); A square matrix, v string, name of a variable
485
+ RETURN: poly, the characteristic polynomial det(E*v-A)
486
+ (default: v=name of last variable)
487
+ NOTE: A must be independent of the variable v. The computation uses det.
488
+ If printlevel>0, det(E*v-A) is displayed recursively.
489
+ EXAMPLE: example charpoly; shows an example"
490
+ {
491
+ int n = nrows(A);
492
+ int z = nvars(basering);
493
+ int i,j;
494
+ string v;
495
+ poly X;
496
+ if(ncols(A) != n)
497
+ {
498
+ "// input is not a square matrix";
499
+ return(X);
500
+ }
501
+ //---------------------- test for correct variable -------------------------
502
+ if( size(#)==0 ){
503
+ #[1] = varstr(z);
504
+ }
505
+ if( typeof(#[1]) == "string") { v = #[1]; }
506
+ else
507
+ {
508
+ "// 2nd argument must be a name of a variable not contained in the matrix";
509
+ return(X);
510
+ }
511
+ j=-1;
512
+ for(i=1; i<=z; i++)
513
+ {
514
+ if(varstr(i)==v){j=i;}
515
+ }
516
+ if(j==-1)
517
+ {
518
+ "// "+v+" is not a variable in the basering";
519
+ return(X);
520
+ }
521
+ if ( size(select1(module(A),j)) != 0 )
522
+ {
523
+ "// matrix must not contain the variable "+v;
524
+ "// change to a ring with an extra variable, if necessary."
525
+ return(X);
526
+ }
527
+ //-------------------------- compute charpoly ------------------------------
528
+ X = det(var(j)*unitmat(n)-A);
529
+ if( printlevel-voice+2 >0) { showrecursive(X,var(j));}
530
+ return(X);
531
+ }
532
+ example
533
+ { "EXAMPLE"; echo=2;
534
+ ring r=0,(x,t),dp;
535
+ matrix A[3][3]=1,x2,x,x2,6,4,x,4,1;
536
+ print(A);
537
+ charpoly(A,"t");
538
+ }
539
+
540
+ //////////////////////////////////////////////////////////////////////////////
541
+ proc charpoly_B(matrix A, list #)
542
+ "USAGE: charpoly_B(A[,v]); A square matrix, v string, name of a variable
543
+ RETURN: poly, the characteristic polynomial det(E*v-A)
544
+ (default: v=name of last variable)
545
+ NOTE: A must be constant in the variable v. The computation uses busadj(A).
546
+ EXAMPLE: example charpoly_B; shows an example"
547
+ {
548
+ int i,j;
549
+ string s,v;
550
+ list L;
551
+ int n = nrows(A);
552
+ poly X = 0;
553
+ def BR = basering;
554
+
555
+ if(ncols(A) != n){
556
+ "// input is not a square matrix";
557
+ return(X);
558
+ }
559
+
560
+ //test for correct variable
561
+ if( size(#)==0 ){
562
+ #[1] = varstr(nvars(BR));
563
+ }
564
+ if( typeof(#[1]) == "string"){
565
+ v = #[1];
566
+ }
567
+ else{
568
+ "// 2nd argument must be a name of a variable not contained in the matrix";
569
+ return(X);
570
+ }
571
+
572
+ j=-1;
573
+ for(i=1; i<=nvars(BR); i++){
574
+ if(varstr(i)==v){j=i;}
575
+ }
576
+ if(j==-1){
577
+ "// "+v+" is not a variable in the basering";
578
+ return(X);
579
+ }
580
+
581
+ //var cannot be in A
582
+ intvec is=0:nvars(BR);
583
+ is[j]=1;
584
+
585
+ def @R=changeord(list(list("Wp",is)));
586
+ setring @R;
587
+ matrix A = imap(BR,A);
588
+ for(i=1; i<=n; i++){
589
+ if(deg(lead(A)[i])>=1){
590
+ "// matrix must not contain the variable "+v;
591
+ kill @R;
592
+ setring BR;
593
+ return(X);
594
+ }
595
+ }
596
+
597
+ //get coefficients and build the char. poly
598
+ kill @R;
599
+ setring BR;
600
+ L = busadj(A);
601
+ for(i=1; i<=n+1; i++){
602
+ execute("X=X+L[1][i]*"+v+"^"+string(i-1)+";");
603
+ }
604
+
605
+ return(X);
606
+ }
607
+ example
608
+ { "EXAMPLE"; echo=2;
609
+ ring r=0,(x,t),dp;
610
+ matrix A[3][3]=1,x2,x,x2,6,4,x,4,1;
611
+ print(A);
612
+ charpoly_B(A,"t");
613
+ }
614
+
615
+ //////////////////////////////////////////////////////////////////////////////
616
+ proc adjoint(matrix A)
617
+ "USAGE: adjoint(A); A = square matrix
618
+ RETURN: adjoint matrix of A, i.e. Adj*A=det(A)*E
619
+ NOTE: computation uses busadj(A)
620
+ EXAMPLE: example adjoint; shows an example"
621
+ {
622
+ int n=nrows(A);
623
+ matrix Adj[n][n];
624
+ list L;
625
+
626
+ if(ncols(A) != n) {
627
+ "// input is not a square matrix";
628
+ return(Adj);
629
+ }
630
+
631
+ L = busadj(A);
632
+ Adj= (-1)^(n-1)*L[2][1];
633
+ return(Adj);
634
+
635
+ }
636
+ example
637
+ { "EXAMPLE"; echo=2;
638
+ ring r=0,(t,x),lp;
639
+ matrix A[2][2]=1,x2,x,x2+3x;
640
+ print(A);
641
+ matrix Adj[2][2]=adjoint(A);
642
+ print(Adj); //Adj*A=det(A)*E
643
+ print(Adj*A);
644
+ }
645
+
646
+ //////////////////////////////////////////////////////////////////////////////
647
+ proc inverse_B(matrix A)
648
+ "USAGE: inverse_B(A); A = square matrix
649
+ RETURN: list Inv with
650
+ - Inv[1] = matrix I and
651
+ - Inv[2] = poly p
652
+ such that I*A = unitmat(n)*p;
653
+ NOTE: p=1 if 1/det(A) is computable and p=det(A) if not;
654
+ the computation uses busadj.
655
+ SEE ALSO: inverse, inverse_L
656
+ EXAMPLE: example inverse_B; shows an example"
657
+ {
658
+ int i;
659
+ int n=nrows(A);
660
+ matrix I[n][n];
661
+ poly factor;
662
+ list L;
663
+ list Inv;
664
+
665
+ if(ncols(A) != n) {
666
+ "input is not a square matrix";
667
+ return(I);
668
+ }
669
+
670
+ L=busadj(A);
671
+ I=module(-L[2][1]); //+-Adj(A)
672
+
673
+ if(reduce(1,std(L[1][1]))==0){
674
+ I=I*lift(L[1][1],1)[1][1];
675
+ factor=1;
676
+ }
677
+ else{ factor=L[1][1];} //=+-det(A) or 1
678
+ Inv=insert(Inv,factor);
679
+ Inv=insert(Inv,matrix(I));
680
+
681
+ return(Inv);
682
+ }
683
+ example
684
+ { "EXAMPLE"; echo=2;
685
+ ring r=0,(x,y),lp;
686
+ matrix A[3][3]=x,y,1,1,x2,y,x,6,0;
687
+ print(A);
688
+ list Inv=inverse_B(A);
689
+ print(Inv[1]);
690
+ print(Inv[2]);
691
+ print(Inv[1]*A);
692
+ }
693
+
694
+ //////////////////////////////////////////////////////////////////////////////
695
+ proc det_B(matrix A)
696
+ "USAGE: det_B(A); A any matrix
697
+ RETURN: returns the determinant of A
698
+ NOTE: the computation uses the busadj algorithm
699
+ EXAMPLE: example det_B; shows an example"
700
+ {
701
+ int n=nrows(A);
702
+ list L;
703
+
704
+ if(ncols(A) != n){ return(0);}
705
+
706
+ L=busadj(A);
707
+ return((-1)^n*L[1][1]);
708
+ }
709
+ example
710
+ { "EXAMPLE"; echo=2;
711
+ ring r=0,(x),dp;
712
+ matrix A[10][10]=random(2,10,10)+unitmat(10)*x;
713
+ print(A);
714
+ det_B(A);
715
+ }
716
+
717
+ //////////////////////////////////////////////////////////////////////////////
718
+ proc inverse_L(matrix A)
719
+ "USAGE: inverse_L(A); A = square matrix
720
+ RETURN: list Inv representing a left inverse of A, i.e
721
+ - Inv[1] = matrix I and
722
+ - Inv[2] = poly p
723
+ such that I*A = unitmat(n)*p;
724
+ NOTE: p=1 if 1/det(A) is computable and p=det(A) if not;
725
+ the computation computes first det(A) and then uses lift
726
+ SEE ALSO: inverse, inverse_B
727
+ EXAMPLE: example inverse_L; shows an example"
728
+ {
729
+ int n=nrows(A);
730
+ matrix I;
731
+ matrix E[n][n]=unitmat(n);
732
+ poly factor;
733
+ poly d=1;
734
+ list Inv;
735
+
736
+ if (ncols(A)!=n){
737
+ "// input is not a square matrix";
738
+ return(I);
739
+ }
740
+
741
+ d=det(A);
742
+ if(d==0){
743
+ "// matrix is not invertible";
744
+ return(Inv);
745
+ }
746
+
747
+ // test if 1/det(A) exists
748
+ if(reduce(1,std(d))!=0){ E=E*d;}
749
+
750
+ I=lift(A,E);
751
+ if(I==unitmat(n)-unitmat(n)){ //catch error in lift
752
+ "// matrix is not invertible";
753
+ return(Inv);
754
+ }
755
+
756
+ factor=d; //=det(A) or 1
757
+ Inv=insert(Inv,factor);
758
+ Inv=insert(Inv,I);
759
+
760
+ return(Inv);
761
+ }
762
+ example
763
+ { "EXAMPLE"; echo=2;
764
+ ring r=0,(x,y),lp;
765
+ matrix A[3][3]=x,y,1,1,x2,y,x,6,0;
766
+ print(A);
767
+ list Inv=inverse_L(A);
768
+ print(Inv[1]);
769
+ print(Inv[2]);
770
+ print(Inv[1]*A);
771
+ }
772
+
773
+ //////////////////////////////////////////////////////////////////////////////
774
+ proc gaussred(matrix A)
775
+ "USAGE: gaussred(A); A any constant matrix
776
+ RETURN: list Z: Z[1]=P , Z[2]=U , Z[3]=S , Z[4]=rank(A)
777
+ gives a row reduced matrix S, a permutation matrix P and a
778
+ normalized lower triangular matrix U, with P*A=U*S
779
+ NOTE: This procedure is designed for teaching purposes mainly.
780
+ The straight forward implementation in the interpreted library
781
+ is not very efficient (no standard basis computation).
782
+ EXAMPLE: example gaussred; shows an example"
783
+ {
784
+ int i,j,l,k,jp,rang;
785
+ poly c,pivo;
786
+ list Z;
787
+ int n = nrows(A);
788
+ int m = ncols(A);
789
+ int mr= n; //max. rang
790
+ matrix P[n][n] = unitmat(n);
791
+ matrix U[n][n] = P;
792
+
793
+ if(!const_mat(A)){
794
+ "// input is not a constant matrix";
795
+ return(Z);
796
+ }
797
+
798
+ if(n>m){mr=m;} //max. rang
799
+
800
+ for(i=1;i<=mr;i=i+1){
801
+ if((i+k)>m){break;}
802
+
803
+ //Test: Diagonalelement=0
804
+ if(A[i,i+k]==0){
805
+ jp=i;pivo=0;
806
+ for(j=i+1;j<=n;j=j+1){
807
+ c=absValue(A[j,i+k]);
808
+ if(pivo<c){ pivo=c;jp=j;}
809
+ }
810
+ if(jp != i){ //Zeilentausch
811
+ for(j=1;j<=m;j=j+1){ //Zeilentausch in A (und U) (i-te mit jp-ter)
812
+ c=A[i,j];
813
+ A[i,j]=A[jp,j];
814
+ A[jp,j]=c;
815
+ }
816
+ for(j=1;j<=n;j=j+1){ //Zeilentausch in P
817
+ c=P[i,j];
818
+ P[i,j]=P[jp,j];
819
+ P[jp,j]=c;
820
+ }
821
+ }
822
+ if(pivo==0){k++;continue;} //eine von selbst auftauchende Stufe !
823
+ } //i sollte im naechsten Lauf nicht erhoeht sein
824
+
825
+ //Eliminationsschritt
826
+ for(j=i+1;j<=n;j=j+1){
827
+ c=A[j,i+k]/A[i,i+k];
828
+ for(l=i+k+1;l<=m;l=l+1){
829
+ A[j,l]=A[j,l]-A[i,l]*c;
830
+ }
831
+ A[j,i+k]=0; // nur wichtig falls k>0 ist
832
+ A[j,i]=c; // bildet U
833
+ }
834
+ rang=i;
835
+ }
836
+
837
+ for(i=1;i<=mr;i=i+1){
838
+ for(j=i+1;j<=n;j=j+1){
839
+ U[j,i]=A[j,i];
840
+ A[j,i]=0;
841
+ }
842
+ }
843
+
844
+ Z=insert(Z,rang);
845
+ Z=insert(Z,A);
846
+ Z=insert(Z,U);
847
+ Z=insert(Z,P);
848
+
849
+ return(Z);
850
+ }
851
+ example
852
+ { "EXAMPLE";echo=2;
853
+ ring r=0,(x),dp;
854
+ matrix A[5][4]=1,3,-1,4,2,5,-1,3,1,3,-1,4,0,4,-3,1,-3,1,-5,-2;
855
+ print(A);
856
+ list Z=gaussred(A); //construct P,U,S s.t. P*A=U*S
857
+ print(Z[1]); //P
858
+ print(Z[2]); //U
859
+ print(Z[3]); //S
860
+ print(Z[4]); //rank
861
+ print(Z[1]*A); //P*A
862
+ print(Z[2]*Z[3]); //U*S
863
+ }
864
+
865
+ //////////////////////////////////////////////////////////////////////////////
866
+ proc gaussred_pivot(matrix A)
867
+ "USAGE: gaussred_pivot(A); A any constant matrix
868
+ RETURN: list Z: Z[1]=P , Z[2]=U , Z[3]=S , Z[4]=rank(A)
869
+ gives a row reduced matrix S, a permutation matrix P and a
870
+ normalized lower triangular matrix U, with P*A=U*S
871
+ NOTE: with row pivoting
872
+ EXAMPLE: example gaussred_pivot; shows an example"
873
+ {
874
+ int i,j,l,k,jp,rang;
875
+ poly c,pivo;
876
+ list Z;
877
+ int n=nrows(A);
878
+ int m=ncols(A);
879
+ int mr=n; //max. rang
880
+ matrix P[n][n]=unitmat(n);
881
+ matrix U[n][n]=P;
882
+
883
+ if(!const_mat(A)){
884
+ "// input is not a constant matrix";
885
+ return(Z);
886
+ }
887
+
888
+ if(n>m){mr=m;} //max. rang
889
+
890
+ for(i=1;i<=mr;i=i+1){
891
+ if((i+k)>m){break;}
892
+
893
+ //Pivotisierung
894
+ pivo=absValue(A[i,i+k]);jp=i;
895
+ for(j=i+1;j<=n;j=j+1){
896
+ c=absValue(A[j,i+k]);
897
+ if(pivo<c){ pivo=c;jp=j;}
898
+ }
899
+ if(jp != i){ //Zeilentausch
900
+ for(j=1;j<=m;j=j+1){ //Zeilentausch in A (und U) (i-te mit jp-ter)
901
+ c=A[i,j];
902
+ A[i,j]=A[jp,j];
903
+ A[jp,j]=c;
904
+ }
905
+ for(j=1;j<=n;j=j+1){ //Zeilentausch in P
906
+ c=P[i,j];
907
+ P[i,j]=P[jp,j];
908
+ P[jp,j]=c;
909
+ }
910
+ }
911
+ if(pivo==0){k++;continue;} //eine von selbst auftauchende Stufe !
912
+ //i sollte im naechsten Lauf nicht erhoeht sein
913
+ //Eliminationsschritt
914
+ for(j=i+1;j<=n;j=j+1){
915
+ c=A[j,i+k]/A[i,i+k];
916
+ for(l=i+k+1;l<=m;l=l+1){
917
+ A[j,l]=A[j,l]-A[i,l]*c;
918
+ }
919
+ A[j,i+k]=0; // nur wichtig falls k>0 ist
920
+ A[j,i]=c; // bildet U
921
+ }
922
+ rang=i;
923
+ }
924
+
925
+ for(i=1;i<=mr;i=i+1){
926
+ for(j=i+1;j<=n;j=j+1){
927
+ U[j,i]=A[j,i];
928
+ A[j,i]=0;
929
+ }
930
+ }
931
+
932
+ Z=insert(Z,rang);
933
+ Z=insert(Z,A);
934
+ Z=insert(Z,U);
935
+ Z=insert(Z,P);
936
+
937
+ return(Z);
938
+ }
939
+ example
940
+ { "EXAMPLE";echo=2;
941
+ ring r=0,(x),dp;
942
+ matrix A[5][4] = 1, 3,-1,4,
943
+ 2, 5,-1,3,
944
+ 1, 3,-1,4,
945
+ 0, 4,-3,1,
946
+ -3,1,-5,-2;
947
+ list Z=gaussred_pivot(A); //construct P,U,S s.t. P*A=U*S
948
+ print(Z[1]); //P
949
+ print(Z[2]); //U
950
+ print(Z[3]); //S
951
+ print(Z[4]); //rank
952
+ print(Z[1]*A); //P*A
953
+ print(Z[2]*Z[3]); //U*S
954
+ }
955
+
956
+ //////////////////////////////////////////////////////////////////////////////
957
+ proc gauss_nf(matrix A)
958
+ "USAGE: gauss_nf(A); A any constant matrix
959
+ RETURN: matrix; gauss normal form of A (uses gaussred)
960
+ EXAMPLE: example gauss_nf; shows an example"
961
+ {
962
+ list Z;
963
+ if(!const_mat(A)){
964
+ "// input is not a constant matrix";
965
+ return(A);
966
+ }
967
+ Z = gaussred(A);
968
+ return(Z[3]);
969
+ }
970
+ example
971
+ { "EXAMPLE";echo=2;
972
+ ring r = 0,(x),dp;
973
+ matrix A[4][4] = 1,4,4,7,2,5,5,4,4,1,1,3,0,2,2,7;
974
+ print(gauss_nf(A));
975
+ }
976
+
977
+ //////////////////////////////////////////////////////////////////////////////
978
+ proc mat_rk(matrix A)
979
+ "USAGE: mat_rk(A); A any constant matrix
980
+ RETURN: int, rank of A
981
+ EXAMPLE: example mat_rk; shows an example"
982
+ {
983
+ list Z;
984
+ if(!const_mat(A)){
985
+ "// input is not a constant matrix";
986
+ return(-1);
987
+ }
988
+ Z = gaussred(A);
989
+ return(Z[4]);
990
+ }
991
+ example
992
+ { "EXAMPLE";echo=2;
993
+ ring r = 0,(x),dp;
994
+ matrix A[4][4] = 1,4,4,7,2,5,5,4,4,1,1,3,0,2,2,7;
995
+ mat_rk(A);
996
+ }
997
+
998
+ //////////////////////////////////////////////////////////////////////////////
999
+ proc U_D_O(matrix A)
1000
+ "USAGE: U_D_O(A); constant invertible matrix A
1001
+ RETURN: list Z: Z[1]=P , Z[2]=U , Z[3]=D , Z[4]=O
1002
+ gives a permutation matrix P,
1003
+ a normalized lower triangular matrix U ,
1004
+ a diagonal matrix D, and
1005
+ a normalized upper triangular matrix O
1006
+ with P*A=U*D*O
1007
+ NOTE: Z[1]=-1 means that A is not regular (proc uses gaussred)
1008
+ EXAMPLE: example U_D_O; shows an example"
1009
+ {
1010
+ int i,j;
1011
+ list Z,L;
1012
+ int n=nrows(A);
1013
+ matrix O[n][n]=unitmat(n);
1014
+ matrix D[n][n];
1015
+
1016
+ if (ncols(A)!=n){
1017
+ "// input is not a square matrix";
1018
+ return(Z);
1019
+ }
1020
+ if(!const_mat(A)){
1021
+ "// input is not a constant matrix";
1022
+ return(Z);
1023
+ }
1024
+
1025
+ L=gaussred(A);
1026
+
1027
+ if(L[4]!=n){
1028
+ "// input is not an invertible matrix";
1029
+ Z=insert(Z,-1); //hint for calling procedures
1030
+ return(Z);
1031
+ }
1032
+
1033
+ D=L[3];
1034
+
1035
+ for(i=1; i<=n; i++){
1036
+ for(j=i+1; j<=n; j++){
1037
+ O[i,j] = D[i,j]/D[i,i];
1038
+ D[i,j] = 0;
1039
+ }
1040
+ }
1041
+
1042
+ Z=insert(Z,O);
1043
+ Z=insert(Z,D);
1044
+ Z=insert(Z,L[2]);
1045
+ Z=insert(Z,L[1]);
1046
+ return(Z);
1047
+ }
1048
+ example
1049
+ { "EXAMPLE";echo=2;
1050
+ ring r = 0,(x),dp;
1051
+ matrix A[5][5] = 10, 4, 0, -9, 8,
1052
+ -3, 6, -6, -4, 9,
1053
+ 0, 3, -1, -9, -8,
1054
+ -4,-2, -6, -10,10,
1055
+ -9, 5, -1, -6, 5;
1056
+ list Z = U_D_O(A); //construct P,U,D,O s.t. P*A=U*D*O
1057
+ print(Z[1]); //P
1058
+ print(Z[2]); //U
1059
+ print(Z[3]); //D
1060
+ print(Z[4]); //O
1061
+ print(Z[1]*A); //P*A
1062
+ print(Z[2]*Z[3]*Z[4]); //U*D*O
1063
+ }
1064
+
1065
+ //////////////////////////////////////////////////////////////////////////////
1066
+ proc pos_def(matrix A)
1067
+ "USAGE: pos_def(A); A = constant, symmetric square matrix
1068
+ RETURN: int:
1069
+ 1 if A is positive definit ,
1070
+ 0 if not,
1071
+ -1 if unknown
1072
+ EXAMPLE: example pos_def; shows an example"
1073
+ {
1074
+ int j;
1075
+ list Z;
1076
+ int n = nrows(A);
1077
+ matrix H[n][n];
1078
+
1079
+ if (ncols(A)!=n){
1080
+ "// input is not a square matrix";
1081
+ return(0);
1082
+ }
1083
+ if(!const_mat(A)){
1084
+ "// input is not a constant matrix";
1085
+ return(-1);
1086
+ }
1087
+ if(deg(std(A-transpose(A))[1])!=-1){
1088
+ "// input is not a hermitian (symmetric) matrix";
1089
+ return(-1);
1090
+ }
1091
+
1092
+ Z=U_D_O(A);
1093
+
1094
+ if(Z[1]==-1){
1095
+ return(0);
1096
+ } //A not regular, therefore not pos. definit
1097
+
1098
+ H=Z[1];
1099
+ //es fand Zeilentausch statt: also nicht positiv definit
1100
+ if(deg(std(H-unitmat(n))[1])!=-1){
1101
+ return(0);
1102
+ }
1103
+
1104
+ H=Z[3];
1105
+
1106
+ for(j=1;j<=n;j=j+1){
1107
+ if(H[j,j]<=0){
1108
+ return(0);
1109
+ } //eigenvalue<=0, not pos.definit
1110
+ }
1111
+
1112
+ return(1); //positiv definit;
1113
+ }
1114
+ example
1115
+ { "EXAMPLE"; echo=2;
1116
+ ring r = 0,(x),dp;
1117
+ matrix A[5][5] = 20, 4, 0, -9, 8,
1118
+ 4, 12, -6, -4, 9,
1119
+ 0, -6, -2, -9, -8,
1120
+ -9, -4, -9, -20, 10,
1121
+ 8, 9, -8, 10, 10;
1122
+ pos_def(A);
1123
+ matrix B[3][3] = 3, 2, 0,
1124
+ 2, 12, 4,
1125
+ 0, 4, 2;
1126
+ pos_def(B);
1127
+ }
1128
+
1129
+ //////////////////////////////////////////////////////////////////////////////
1130
+ proc linsolve(matrix A, matrix b)
1131
+ "USAGE: linsolve(A,b); A a constant nxm-matrix, b a constant nx1-matrix
1132
+ RETURN: a 1xm matrix X, solution of inhomogeneous linear system A*X = b
1133
+ return the 0-matrix if system is not solvable
1134
+ NOTE: uses gaussred
1135
+ EXAMPLE: example linsolve; shows an example"
1136
+ {
1137
+ int i,j,k,rc,r;
1138
+ poly c;
1139
+ list Z;
1140
+ int n = nrows(A);
1141
+ int m = ncols(A);
1142
+ int n_b= nrows(b);
1143
+ matrix Ab[n][m+1];
1144
+ matrix X[m][1];
1145
+
1146
+ if(ncols(b)!=1){
1147
+ "// right hand side b is not a nx1 matrix";
1148
+ return(X);
1149
+ }
1150
+
1151
+ if(!const_mat(A)){
1152
+ "// input hand is not a constant matrix";
1153
+ return(X);
1154
+ }
1155
+
1156
+ if(n_b>n){
1157
+ for(i=n; i<=n_b; i++){
1158
+ if(b[i,1]!=0){
1159
+ "// right hand side b not in Image(A)";
1160
+ return X;
1161
+ }
1162
+ }
1163
+ }
1164
+
1165
+ if(n_b<n){
1166
+ matrix copy[n_b][1]=b;
1167
+ matrix b[n][1]=0;
1168
+ for(i=1;i<=n_b;i=i+1){
1169
+ b[i,1]=copy[i,1];
1170
+ }
1171
+ }
1172
+
1173
+ r=mat_rk(A);
1174
+
1175
+ //1. b constant vector
1176
+ if(const_mat(b)){
1177
+ //extend A with b
1178
+ for(i=1; i<=n; i++){
1179
+ for(j=1; j<=m; j++){
1180
+ Ab[i,j]=A[i,j];
1181
+ }
1182
+ Ab[i,m+1]=b[i,1];
1183
+ }
1184
+
1185
+ //Gauss reduction
1186
+ Z = gaussred(Ab);
1187
+ Ab = Z[3]; //normal form
1188
+ rc = Z[4]; //rank(Ab)
1189
+ //print(Ab);
1190
+
1191
+ if(r<rc){
1192
+ "// no solution";
1193
+ return(X);
1194
+ }
1195
+ k=m;
1196
+ for(i=r;i>=1;i=i-1){
1197
+
1198
+ j=1;
1199
+ while(Ab[i,j]==0){j=j+1;}// suche Ecke
1200
+
1201
+ for(;k>j;k=k-1){ X[k]=0;}//springe zur Ecke
1202
+
1203
+
1204
+ c=Ab[i,m+1]; //i-te Komponene von b
1205
+ for(j=m;j>k;j=j-1){
1206
+ c=c-X[j,1]*Ab[i,j];
1207
+ }
1208
+ if(Ab[i,k]==0){
1209
+ X[k,1]=1; //willkuerlich
1210
+ }
1211
+ else{
1212
+ X[k,1]=c/Ab[i,k];
1213
+ }
1214
+ k=k-1;
1215
+ if(k==0){break;}
1216
+ }
1217
+
1218
+
1219
+ }//endif (const b)
1220
+ else{ //b not constant
1221
+ "// !not implemented!";
1222
+
1223
+ }
1224
+
1225
+ return(X);
1226
+ }
1227
+ example
1228
+ { "EXAMPLE";echo=2;
1229
+ ring r=0,(x),dp;
1230
+ matrix A[3][2] = -4,-6,
1231
+ 2, 3,
1232
+ -5, 7;
1233
+ matrix b[3][1] = 10,
1234
+ -5,
1235
+ 2;
1236
+ matrix X = linsolve(A,b);
1237
+ print(X);
1238
+ print(A*X);
1239
+ }
1240
+ //////////////////////////////////////////////////////////////////////////////
1241
+
1242
+ ///////////////////////////////////////////////////////////////////////////////
1243
+ // PROCEDURES for Jordan normal form
1244
+ // AUTHOR: Mathias Schulze, email: mschulze@mathematik.uni-kl.de
1245
+ ///////////////////////////////////////////////////////////////////////////////
1246
+
1247
+ static proc rowcolswap(matrix M,int i,int j)
1248
+ {
1249
+ if(system("with","eigenval"))
1250
+ {
1251
+ return(system("rowcolswap",M,i,j));
1252
+ }
1253
+ //--------------------------------------------
1254
+ if(i==j)
1255
+ {
1256
+ return(M);
1257
+ }
1258
+ poly p;
1259
+ for(int k=1;k<=nrows(M);k++)
1260
+ {
1261
+ p=M[i,k];
1262
+ M[i,k]=M[j,k];
1263
+ M[j,k]=p;
1264
+ }
1265
+ for(k=1;k<=ncols(M);k++)
1266
+ {
1267
+ p=M[k,i];
1268
+ M[k,i]=M[k,j];
1269
+ M[k,j]=p;
1270
+ }
1271
+ return(M);
1272
+ }
1273
+ //////////////////////////////////////////////////////////////////////////////
1274
+
1275
+ static proc rowelim(matrix M,int i,int j,int k)
1276
+ {
1277
+ if(system("with","eigenval"))
1278
+ {
1279
+ return(system("rowelim",M,i,j,k));
1280
+ }
1281
+ // -----------------------
1282
+ if(jet(M[i,k],0)==0||jet(M[j,k],0)==0)
1283
+ {
1284
+ return(M);
1285
+ }
1286
+ number n=number(jet(M[i,k],0))/number(jet(M[j,k],0));
1287
+ for(int l=1;l<=ncols(M);l++)
1288
+ {
1289
+ M[i,l]=M[i,l]-n*M[j,l];
1290
+ }
1291
+ for(l=1;l<=nrows(M);l++)
1292
+ {
1293
+ M[l,j]=M[l,j]+n*M[l,i];
1294
+ }
1295
+ return(M);
1296
+ }
1297
+ ///////////////////////////////////////////////////////////////////////////////
1298
+
1299
+ static proc colelim(matrix M,int i,int j,int k)
1300
+ {
1301
+ if(jet(M[k,i],0)==0||jet(M[k,j],0)==0)
1302
+ {
1303
+ return(M);
1304
+ }
1305
+ number n=number(jet(M[k,i],0))/number(jet(M[k,j],0));
1306
+ for(int l=1;l<=nrows(M);l++)
1307
+ {
1308
+ M[l,i]=M[l,i]-n*M[l,j];
1309
+ }
1310
+ for(l=1;l<=ncols(M);l++)
1311
+ {
1312
+ M[j,l]=M[j,l]+n*M[i,l];
1313
+ }
1314
+ return(M);
1315
+ }
1316
+ ///////////////////////////////////////////////////////////////////////////////
1317
+
1318
+ proc hessenberg(matrix M)
1319
+ "USAGE: hessenberg(M); matrix M
1320
+ ASSUME: M constant square matrix
1321
+ RETURN: matrix H; Hessenberg form of M
1322
+ EXAMPLE: example hessenberg; shows examples
1323
+ SEE ALSO: system, hessenberg
1324
+ "
1325
+ {
1326
+ if(system("with","eigenval"))
1327
+ {
1328
+ return(system("hessenberg",M));
1329
+ }
1330
+
1331
+ int n=ncols(M);
1332
+ int i,j;
1333
+ for(int k=1;k<n-1;k++)
1334
+ {
1335
+ j=k+1;
1336
+ while(j<n&&jet(M[j,k],0)==0)
1337
+ {
1338
+ j++;
1339
+ }
1340
+ if(jet(M[j,k],0)!=0)
1341
+ {
1342
+ M=rowcolswap(M,j,k+1);
1343
+ for(i=j+1;i<=n;i++)
1344
+ {
1345
+ M=rowelim(M,i,k+1,k);
1346
+ }
1347
+ }
1348
+ }
1349
+ return(M);
1350
+ }
1351
+ example
1352
+ { "EXAMPLE:"; echo=2;
1353
+ ring R=0,x,dp;
1354
+ matrix M[3][3]=3,2,1,0,2,1,0,0,3;
1355
+ print(M);
1356
+ print(hessenberg(M));
1357
+ }
1358
+ ///////////////////////////////////////////////////////////////////////////////
1359
+
1360
+ proc eigenvals(matrix M)
1361
+ "USAGE: eigenvals(M); matrix M
1362
+ ASSUME: eigenvalues of M in basefield
1363
+ RETURN:
1364
+ @format
1365
+ list l;
1366
+ ideal l[1];
1367
+ number l[1][i]; i-th eigenvalue of M
1368
+ intvec l[2];
1369
+ int l[2][i]; multiplicity of i-th eigenvalue of M
1370
+ @end format
1371
+ EXAMPLE: example eigenvals; shows examples
1372
+ KEYWORDS: eigenvalue
1373
+ SEE ALSO: system, eigenvals
1374
+ "
1375
+ {
1376
+ if(system("with","eigenval"))
1377
+ {
1378
+ return(system("eigenvals",jet(M,0)));
1379
+ }
1380
+
1381
+ M=jet(hessenberg(M),0);
1382
+ int n=ncols(M);
1383
+ int k;
1384
+ ideal e;
1385
+ intvec m;
1386
+ number e0;
1387
+ intvec v;
1388
+ list l;
1389
+ int i,j;
1390
+ j=1;
1391
+ while(j<=n)
1392
+ {
1393
+ v=j;
1394
+ j++;
1395
+ if(j<=n)
1396
+ {
1397
+ while(j<n&&M[j,j-1]!=0)
1398
+ {
1399
+ v=v,j;
1400
+ j++;
1401
+ }
1402
+ if(M[j,j-1]!=0)
1403
+ {
1404
+ v=v,j;
1405
+ j++;
1406
+ }
1407
+ }
1408
+ if(size(v)==1)
1409
+ {
1410
+ k++;
1411
+ e[k]=M[v,v];
1412
+ m[k]=1;
1413
+ }
1414
+ else
1415
+ {
1416
+ l=factorize(det(submat(M,v,v)-var(1)));
1417
+ for(i=size(l[1]);i>=1;i--)
1418
+ {
1419
+ e0=number(jet(l[1][i]/var(1),0));
1420
+ if(e0!=0)
1421
+ {
1422
+ k++;
1423
+ e[k]=(e0*var(1)-l[1][i])/e0;
1424
+ m[k]=l[2][i];
1425
+ }
1426
+ }
1427
+ }
1428
+ }
1429
+ return(spnf(list(e,m)));
1430
+ }
1431
+ example
1432
+ { "EXAMPLE:"; echo=2;
1433
+ ring R=0,x,dp;
1434
+ matrix M[3][3]=3,2,1,0,2,1,0,0,3;
1435
+ print(M);
1436
+ eigenvals(M);
1437
+ }
1438
+ ///////////////////////////////////////////////////////////////////////////////
1439
+
1440
+ proc minipoly(matrix M,list #)
1441
+ "USAGE: minipoly(M); matrix M
1442
+ ASSUME: eigenvalues of M in basefield
1443
+ RETURN:
1444
+ @format
1445
+ list l; minimal polynomial of M
1446
+ ideal l[1];
1447
+ number l[1][i]; i-th root of minimal polynomial of M
1448
+ intvec l[2];
1449
+ int l[2][i]; multiplicity of i-th root of minimal polynomial of M
1450
+ @end format
1451
+ EXAMPLE: example minipoly; shows examples
1452
+ "
1453
+ {
1454
+ if(nrows(M)==0)
1455
+ {
1456
+ ERROR("non empty expected");
1457
+ }
1458
+ if(ncols(M)!=nrows(M))
1459
+ {
1460
+ ERROR("square matrix expected");
1461
+ }
1462
+
1463
+ M=jet(M,0);
1464
+
1465
+ if(size(#)==0)
1466
+ {
1467
+ #=eigenvals(M);
1468
+ }
1469
+ def e0,m0=#[1..2];
1470
+
1471
+ intvec m1;
1472
+ matrix N0,N1;
1473
+ for(int i=1;i<=ncols(e0);i++)
1474
+ {
1475
+ m1[i]=1;
1476
+ N0=M-e0[i];
1477
+ N1=N0;
1478
+ while(size(syz(N1))<m0[i])
1479
+ {
1480
+ m1[i]=m1[i]+1;
1481
+ N1=N1*N0;
1482
+ }
1483
+ }
1484
+
1485
+ return(list(e0,m1));
1486
+ }
1487
+ example
1488
+ { "EXAMPLE:"; echo=2;
1489
+ ring R=0,x,dp;
1490
+ matrix M[3][3]=3,2,1,0,2,1,0,0,3;
1491
+ print(M);
1492
+ minipoly(M);
1493
+ }
1494
+ ///////////////////////////////////////////////////////////////////////////////
1495
+
1496
+ proc spnf(list #)
1497
+ "USAGE: spnf(list(a[,m])); ideal a, intvec m
1498
+ ASSUME: ncols(a)==size(m)
1499
+ RETURN: list l:
1500
+ l[1] an ideal, the generators of a; sorted and with multiple entries displayed only once@*
1501
+ l[2] an intvec, l[2][i] provides the multiplicity of l[1][i]
1502
+ EXAMPLE: example spnf; shows examples
1503
+ "
1504
+ {
1505
+ list sp=#;
1506
+ ideal a=sp[1];
1507
+ int n=ncols(a);
1508
+ intvec m;
1509
+ list V;
1510
+ module v;
1511
+ int i,j;
1512
+ for(i=2;i<=size(sp);i++)
1513
+ {
1514
+ if(typeof(sp[i])=="intvec")
1515
+ {
1516
+ m=sp[i];
1517
+ }
1518
+ if(typeof(sp[i])=="module")
1519
+ {
1520
+ v=sp[i];
1521
+ for(j=n;j>=1;j--)
1522
+ {
1523
+ V[j]=module(v[j]);
1524
+ }
1525
+ }
1526
+ if(typeof(sp[i])=="list")
1527
+ {
1528
+ V=sp[i];
1529
+ }
1530
+ }
1531
+ if(m==0)
1532
+ {
1533
+ for(i=n;i>=1;i--)
1534
+ {
1535
+ m[i]=1;
1536
+ }
1537
+ }
1538
+
1539
+ int k;
1540
+ ideal a0;
1541
+ intvec m0;
1542
+ list V0;
1543
+ number a1;
1544
+ int m1;
1545
+ for(i=n;i>=1;i--)
1546
+ {
1547
+ if(m[i]!=0)
1548
+ {
1549
+ for(j=i-1;j>=1;j--)
1550
+ {
1551
+ if(m[j]!=0)
1552
+ {
1553
+ if(number(a[i])>number(a[j]))
1554
+ {
1555
+ a1=number(a[i]);
1556
+ a[i]=a[j];
1557
+ a[j]=a1;
1558
+ m1=m[i];
1559
+ m[i]=m[j];
1560
+ m[j]=m1;
1561
+ if(size(V)>0)
1562
+ {
1563
+ v=V[i];
1564
+ V[i]=V[j];
1565
+ V[j]=v;
1566
+ }
1567
+ }
1568
+ if(number(a[i])==number(a[j]))
1569
+ {
1570
+ m[i]=m[i]+m[j];
1571
+ m[j]=0;
1572
+ if(size(V)>0)
1573
+ {
1574
+ V[i]=V[i]+V[j];
1575
+ }
1576
+ }
1577
+ }
1578
+ }
1579
+ k++;
1580
+ a0[k]=a[i];
1581
+ m0[k]=m[i];
1582
+ if(size(V)>0)
1583
+ {
1584
+ V0[k]=V[i];
1585
+ }
1586
+ }
1587
+ }
1588
+
1589
+ if(size(V0)>0)
1590
+ {
1591
+ n=size(V0);
1592
+ module U=std(V0[n]);
1593
+ for(i=n-1;i>=1;i--)
1594
+ {
1595
+ V0[i]=simplify(reduce(V0[i],U),1);
1596
+ if(i>=2)
1597
+ {
1598
+ U=std(U+V0[i]);
1599
+ }
1600
+ }
1601
+ }
1602
+
1603
+ if(k>0)
1604
+ {
1605
+ sp=a0,m0;
1606
+ if(size(V0)>0)
1607
+ {
1608
+ sp[3]=V0;
1609
+ }
1610
+ }
1611
+ return(sp);
1612
+ }
1613
+ example
1614
+ { "EXAMPLE:"; echo=2;
1615
+ ring R=0,(x,y),ds;
1616
+ list sp=list(ideal(-1/2,-3/10,-3/10,-1/10,-1/10,0,1/10,1/10,3/10,3/10,1/2));
1617
+ spprint(spnf(sp));
1618
+ }
1619
+ ///////////////////////////////////////////////////////////////////////////////
1620
+
1621
+ proc spprint(list sp)
1622
+ "USAGE: spprint(sp); list sp (helper routine for spnf)
1623
+ RETURN: string s; spectrum sp
1624
+ EXAMPLE: example spprint; shows examples
1625
+ SEE ALSO: gmssing_lib, spnf
1626
+ "
1627
+ {
1628
+ string s;
1629
+ for(int i=1;i<size(sp[2]);i++)
1630
+ {
1631
+ s=s+"("+string(sp[1][i])+","+string(sp[2][i])+"),";
1632
+ }
1633
+ s=s+"("+string(sp[1][i])+","+string(sp[2][i])+")";
1634
+ return(s);
1635
+ }
1636
+ example
1637
+ { "EXAMPLE:"; echo=2;
1638
+ ring R=0,(x,y),ds;
1639
+ list sp=list(ideal(-1/2,-3/10,-1/10,0,1/10,3/10,1/2),intvec(1,2,2,1,2,2,1));
1640
+ spprint(sp);
1641
+ }
1642
+ ///////////////////////////////////////////////////////////////////////////////
1643
+
1644
+ proc jordan(matrix M,list #)
1645
+ "USAGE: jordan(M); matrix M
1646
+ ASSUME: eigenvalues of M in basefield
1647
+ RETURN:
1648
+ @format
1649
+ list l; Jordan data of M
1650
+ ideal l[1];
1651
+ number l[1][i]; eigenvalue of i-th Jordan block of M
1652
+ intvec l[2];
1653
+ int l[2][i]; size of i-th Jordan block of M
1654
+ intvec l[3];
1655
+ int l[3][i]; multiplicity of i-th Jordan block of M
1656
+ @end format
1657
+ EXAMPLE: example jordan; shows examples
1658
+ "
1659
+ {
1660
+ if(nrows(M)==0)
1661
+ {
1662
+ ERROR("non empty expected");
1663
+ }
1664
+ if(ncols(M)!=nrows(M))
1665
+ {
1666
+ ERROR("square matrix expected");
1667
+ }
1668
+
1669
+ M=jet(M,0);
1670
+
1671
+ if(size(#)==0)
1672
+ {
1673
+ #=eigenvals(M);
1674
+ }
1675
+ def e0,m0=#[1..2];
1676
+
1677
+ int i;
1678
+ for(i=1;i<=ncols(e0);i++)
1679
+ {
1680
+ if(deg(e0[i])>0)
1681
+ {
1682
+
1683
+ ERROR("eigenvalues in coefficient field expected");
1684
+ return(list());
1685
+ }
1686
+ }
1687
+
1688
+ int j,k;
1689
+ matrix N0,N1;
1690
+ module K0;
1691
+ list K;
1692
+ ideal e;
1693
+ intvec s,m;
1694
+
1695
+ for(i=1;i<=ncols(e0);i++)
1696
+ {
1697
+ N0=M-e0[i]*matrix(freemodule(ncols(M)));
1698
+
1699
+ N1=N0;
1700
+ K0=0;
1701
+ K=module();
1702
+ while(size(K0)<m0[i])
1703
+ {
1704
+ K0=syz(N1);
1705
+ K=K+list(K0);
1706
+ N1=N1*N0;
1707
+ }
1708
+
1709
+ for(j=2;j<size(K);j++)
1710
+ {
1711
+ if(2*size(K[j])-size(K[j-1])-size(K[j+1])>0)
1712
+ {
1713
+ k++;
1714
+ e[k]=e0[i];
1715
+ s[k]=j-1;
1716
+ m[k]=2*size(K[j])-size(K[j-1])-size(K[j+1]);
1717
+ }
1718
+ }
1719
+ if(size(K[j])-size(K[j-1])>0)
1720
+ {
1721
+ k++;
1722
+ e[k]=e0[i];
1723
+ s[k]=j-1;
1724
+ m[k]=size(K[j])-size(K[j-1]);
1725
+ }
1726
+ }
1727
+
1728
+ return(list(e,s,m));
1729
+ }
1730
+ example
1731
+ { "EXAMPLE:"; echo=2;
1732
+ ring R=0,x,dp;
1733
+ matrix M[3][3]=3,2,1,0,2,1,0,0,3;
1734
+ print(M);
1735
+ jordan(M);
1736
+ }
1737
+ ///////////////////////////////////////////////////////////////////////////////
1738
+
1739
+ proc jordanbasis(matrix M,list #)
1740
+ "USAGE: jordanbasis(M); matrix M
1741
+ ASSUME: eigenvalues of M in basefield
1742
+ RETURN:
1743
+ @format
1744
+ list l:
1745
+ module l[1]; inverse(l[1])*M*l[1] in Jordan normal form
1746
+ intvec l[2];
1747
+ int l[2][i]; weight filtration index of l[1][i]
1748
+ @end format
1749
+ EXAMPLE: example jordanbasis; shows examples
1750
+ "
1751
+ {
1752
+ if(nrows(M)==0)
1753
+ {
1754
+ ERROR("non empty matrix expected");
1755
+ }
1756
+ if(ncols(M)!=nrows(M))
1757
+ {
1758
+ ERROR("square matrix expected");
1759
+ }
1760
+
1761
+ M=jet(M,0);
1762
+
1763
+ if(size(#)==0)
1764
+ {
1765
+ #=eigenvals(M);
1766
+ }
1767
+ def e,m=#[1..2];
1768
+
1769
+ for(int i=1;i<=ncols(e);i++)
1770
+ {
1771
+ if(deg(e[i])>0)
1772
+ {
1773
+ ERROR("eigenvalues in coefficient field expected");
1774
+ return(freemodule(ncols(M)));
1775
+ }
1776
+ }
1777
+
1778
+ int j,k,l,n;
1779
+ matrix N0,N1;
1780
+ module K0,K1;
1781
+ list K;
1782
+ matrix u[ncols(M)][1];
1783
+ module U;
1784
+ intvec w;
1785
+
1786
+ for(i=1;i<=ncols(e);i++)
1787
+ {
1788
+ N0=M-e[i]*matrix(freemodule(ncols(M)));
1789
+
1790
+ N1=N0;
1791
+ K0=0;
1792
+ K=list();
1793
+ while(size(K0)<m[i])
1794
+ {
1795
+ K0=syz(N1);
1796
+ K=K+list(K0);
1797
+ N1=N1*N0;
1798
+ }
1799
+
1800
+ K1=0;
1801
+ for(j=1;j<size(K);j++)
1802
+ {
1803
+ K0=K[j];
1804
+ K[j]=interred(reduce(K[j],std(K1+module(N0*K[j+1]))));
1805
+ K1=K0;
1806
+ }
1807
+ K[j]=interred(reduce(K[j],std(K1)));
1808
+
1809
+ for(l=size(K);l>=1;l--)
1810
+ {
1811
+ for(k=size(K[l]);k>0;k--)
1812
+ {
1813
+ u=K[l][k];
1814
+ for(j=l;j>=1;j--)
1815
+ {
1816
+ U=U+module(u);
1817
+ n++;
1818
+ w[n]=2*j-l-1;
1819
+ u=N0*u;
1820
+ }
1821
+ }
1822
+ }
1823
+ }
1824
+
1825
+ return(list(U,w));
1826
+ }
1827
+ example
1828
+ { "EXAMPLE:"; echo=2;
1829
+ ring R=0,x,dp;
1830
+ matrix M[3][3]=3,2,1,0,2,1,0,0,3;
1831
+ print(M);
1832
+ list l=jordanbasis(M);
1833
+ print(l[1]);
1834
+ print(l[2]);
1835
+ print(inverse(l[1])*M*l[1]);
1836
+ }
1837
+ ///////////////////////////////////////////////////////////////////////////////
1838
+
1839
+ proc jordanmatrix(list jd)
1840
+ "USAGE: jordanmatrix(list(e,s,m)); ideal e, intvec s, intvec m
1841
+ ASSUME: ncols(e)==size(s)==size(m)
1842
+ RETURN:
1843
+ @format
1844
+ matrix J; Jordan matrix with list(e,s,m)==jordan(J)
1845
+ @end format
1846
+ EXAMPLE: example jordanmatrix; shows examples
1847
+ "
1848
+ {
1849
+ ideal e=jd[1];
1850
+ intvec s=jd[2];
1851
+ intvec m=jd[3];
1852
+ if(ncols(e)!=size(s)||ncols(e)!=size(m))
1853
+ {
1854
+ ERROR("arguments of equal size expected");
1855
+ }
1856
+
1857
+ int i,j,k,l;
1858
+ int n=int((transpose(matrix(s))*matrix(m))[1,1]);
1859
+ matrix J[n][n];
1860
+ for(k=1;k<=ncols(e);k++)
1861
+ {
1862
+ for(l=1;l<=m[k];l++)
1863
+ {
1864
+ j++;
1865
+ J[j,j]=e[k];
1866
+ for(i=s[k];i>=2;i--)
1867
+ {
1868
+ J[j+1,j]=1;
1869
+ j++;
1870
+ J[j,j]=e[k];
1871
+ }
1872
+ }
1873
+ }
1874
+
1875
+ return(J);
1876
+ }
1877
+ example
1878
+ { "EXAMPLE:"; echo=2;
1879
+ ring R=0,x,dp;
1880
+ ideal e=ideal(2,3);
1881
+ intvec s=1,2;
1882
+ intvec m=1,1;
1883
+ print(jordanmatrix(list(e,s,m)));
1884
+ }
1885
+ ///////////////////////////////////////////////////////////////////////////////
1886
+
1887
+ proc jordannf(matrix M,list #)
1888
+ "USAGE: jordannf(M); matrix M
1889
+ ASSUME: eigenvalues of M in basefield
1890
+ RETURN: matrix J; Jordan normal form of M
1891
+ EXAMPLE: example jordannf; shows examples
1892
+ "
1893
+ {
1894
+ return(jordanmatrix(jordan(M,#)));
1895
+ }
1896
+ example
1897
+ { "EXAMPLE:"; echo=2;
1898
+ ring R=0,x,dp;
1899
+ matrix M[3][3]=3,2,1,0,2,1,0,0,3;
1900
+ print(M);
1901
+ print(jordannf(M));
1902
+ }
1903
+
1904
+ ///////////////////////////////////////////////////////////////////////////////
1905
+
1906
+ /*
1907
+ ///////////////////////////////////////////////////////////////////////////////
1908
+ // Auskommentierte zusaetzliche Beispiele
1909
+ //
1910
+ ///////////////////////////////////////////////////////////////////////////////
1911
+ // Singular for ix86-Linux version 1-3-10 (2000121517) Dec 15 2000 17:55:12
1912
+ // Rechnungen auf AMD700 mit 632 MB
1913
+
1914
+ LIB "linalg.lib";
1915
+
1916
+ 1. Sparse integer Matrizen
1917
+ --------------------------
1918
+ ring r1=0,(x),dp;
1919
+ system("--random", 12345678);
1920
+ int n = 70;
1921
+ matrix m = sparsemat(n,n,50,100);
1922
+ option(prot,mem);
1923
+
1924
+ int t=timer;
1925
+ matrix im = inverse(m,1)[1];
1926
+ timer-t;
1927
+ print(im*m);
1928
+ //list l0 = watchdog(100,"inverse("+"m"+",3)");
1929
+ //bricht bei 100 sec ab und gibt l0[1]: string Killed zurueck
1930
+
1931
+ //inverse(m,1): std 5sec 5,5 MB
1932
+ //inverse(m,2): interred 12sec
1933
+ //inverse(m,2): lift nach 180 sec 13MB abgebrochen
1934
+ //n=60: linalgorig: 3 linalg: 5
1935
+ //n=70: linalgorig: 6,7 linalg: 11,12
1936
+ // aber linalgorig rechnet falsch!
1937
+
1938
+ 2. Sparse poly Matrizen
1939
+ -----------------------
1940
+ ring r=(0),(a,b,c),dp;
1941
+ system("--random", 12345678);
1942
+ int n=6;
1943
+ matrix m = sparsematrix(n,n,2,0,50,50,9); //matrix of polys of deg <=2
1944
+ option(prot,mem);
1945
+
1946
+ int t=timer;
1947
+ matrix im = inverse(m);
1948
+ timer-t;
1949
+ print(im*m);
1950
+ //inverse(m,1): std 0sec 1MB
1951
+ //inverse(m,2): interred 0sec 1MB
1952
+ //inverse(m,2): lift nach 2000 sec 33MB abgebrochen
1953
+
1954
+ 3. Sparse Matrizen mit Parametern
1955
+ ---------------------------------
1956
+ //liborig rechnet hier falsch!
1957
+ ring r=(0),(a,b),dp;
1958
+ system("--random", 12345678);
1959
+ int n=7;
1960
+ matrix m = sparsematrix(n,n,1,0,40,50,9);
1961
+ ring r1 = (0,a,b),(x),dp;
1962
+ matrix m = imap(r,m);
1963
+ option(prot,mem);
1964
+
1965
+ int t=timer;
1966
+ matrix im = inverse(m);
1967
+ timer-t;
1968
+ print(im*m);
1969
+ //inverse(m)=inverse(m,3):15 sec inverse(m,1)=1sec inverse(m,2):>120sec
1970
+ //Bei Parametern vergeht die Zeit beim Normieren!
1971
+
1972
+ 3. Sparse Matrizen mit Variablen und Parametern
1973
+ -----------------------------------------------
1974
+ ring r=(0),(a,b),dp;
1975
+ system("--random", 12345678);
1976
+ int n=6;
1977
+ matrix m = sparsematrix(n,n,1,0,35,50,9);
1978
+ ring r1 = (0,a),(b),dp;
1979
+ matrix m = imap(r,m);
1980
+ option(prot,mem);
1981
+
1982
+ int t=timer;
1983
+ matrix im = inverse(m,3);
1984
+ timer-t;
1985
+ print(im*m);
1986
+ //n=7: inverse(m,3):lange sec inverse(m,1)=1sec inverse(m,2):1sec
1987
+
1988
+ 4. Ueber Polynomring invertierbare Matrizen
1989
+ -------------------------------------------
1990
+ LIB"random.lib"; LIB"linalg.lib";
1991
+ system("--random", 12345678);
1992
+ int n =3;
1993
+ ring r= 0,(x,y,z),(C,dp);
1994
+ matrix A=triagmatrix(n,n,1,0,0,50,2);
1995
+ intmat B=sparsetriag(n,n,20,1);
1996
+ matrix M = A*transpose(B);
1997
+ M=M*transpose(M);
1998
+ M[1,1..ncols(M)]=M[1,1..n]+xyz*M[n,1..ncols(M)];
1999
+ print(M);
2000
+ //M hat det=1 nach Konstruktion
2001
+
2002
+ int t=timer;
2003
+ matrix iM=inverse(M);
2004
+ timer-t;
2005
+ print(iM*M); //test
2006
+
2007
+ //ACHTUNG: Interred liefert i.A. keine Inverse, Gegenbeispiel z.B.
2008
+ //mit n=3
2009
+ //eifacheres Gegenbeispiel:
2010
+ matrix M =
2011
+ 9yz+3y+3z+2, 9y2+6y+1,
2012
+ 9xyz+3xy+3xz-9z2+2x-6z-1,9xy2+6xy-9yz+x-3y-3z
2013
+ //det M=1, inverse(M,2); ->// ** matrix is not invertible
2014
+ //lead(M); 9xyz*gen(2) 9xy2*gen(2) nicht teilbar!
2015
+
2016
+ 5. charpoly:
2017
+ -----------
2018
+ //ring rp=(0,A,B,C),(x),dp;
2019
+ ring r=0,(A,B,C,x),dp;
2020
+ matrix m[12][12]=
2021
+ AC,BC,-3BC,0,-A2+B2,-3AC+1,B2, B2, 1, 0, -C2+1,0,
2022
+ 1, 1, 2C, 0,0, B, -A, -4C, 2A+1,0, 0, 0,
2023
+ 0, 0, 0, 1,0, 2C+1, -4C+1,-A, B+1, 0, B+1, 3B,
2024
+ AB,B2,0, 1,0, 1, 0, 1, A, 0, 1, B+1,
2025
+ 1, 0, 1, 0,0, 1, 0, -C2, 0, 1, 0, 1,
2026
+ 0, 0, 2, 1,2A, 1, 0, 0, 0, 0, 1, 1,
2027
+ 0, 1, 0, 1,1, 2, A, 3B+1,1, B2,1, 1,
2028
+ 0, 1, 0, 1,1, 1, 1, 1, 2, 0, 0, 0,
2029
+ 1, 0, 1, 0,0, 0, 1, 0, 1, 1, 0, 3,
2030
+ 1, 3B,B2+1,0,0, 1, 0, 1, 0, 0, 1, 0,
2031
+ 0, 0, 1, 0,0, 0, 0, 1, 0, 0, 0, 0,
2032
+ 0, 1, 0, 1,1, 3, 3B+1, 0, 1, 1, 1, 0;
2033
+ option(prot,mem);
2034
+
2035
+ int t=timer;
2036
+ poly q=charpoly(m,"x"); //1sec, charpoly_B 1sec, 16MB
2037
+ timer-t;
2038
+ //1sec, charpoly_B 1sec, 16MB (gleich in r und rp)
2039
+
2040
+ */