ngsolve 6.2.2506.post216.dev0__cp314-cp314-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.
Files changed (306) hide show
  1. ngsolve-6.2.2506.post216.dev0.data/data/bin/ngs_nvcc +22 -0
  2. ngsolve-6.2.2506.post216.dev0.data/data/bin/ngs_nvlink +17 -0
  3. ngsolve-6.2.2506.post216.dev0.data/data/bin/ngscxx +15 -0
  4. ngsolve-6.2.2506.post216.dev0.data/data/bin/ngsld +11 -0
  5. ngsolve-6.2.2506.post216.dev0.data/data/bin/ngsolve.tcl +648 -0
  6. ngsolve-6.2.2506.post216.dev0.data/data/bin/ngspy +2 -0
  7. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/analytic_integrals.hpp +10 -0
  8. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/arnoldi.hpp +55 -0
  9. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/bandmatrix.hpp +334 -0
  10. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/basematrix.hpp +963 -0
  11. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/basevector.hpp +1268 -0
  12. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/bdbequations.hpp +2807 -0
  13. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/bdbintegrator.hpp +1660 -0
  14. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/bem_diffops.hpp +475 -0
  15. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/bessel.hpp +1064 -0
  16. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/bilinearform.hpp +966 -0
  17. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/bla.hpp +29 -0
  18. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/blockalloc.hpp +95 -0
  19. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/blockjacobi.hpp +328 -0
  20. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/bspline.hpp +116 -0
  21. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/calcinverse.hpp +141 -0
  22. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/cg.hpp +368 -0
  23. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/chebyshev.hpp +44 -0
  24. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/cholesky.hpp +720 -0
  25. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/clapack.h +7254 -0
  26. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/code_generation.hpp +296 -0
  27. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/coefficient.hpp +2033 -0
  28. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/coefficient_impl.hpp +19 -0
  29. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/coefficient_stdmath.hpp +167 -0
  30. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/commutingAMG.hpp +106 -0
  31. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/comp.hpp +79 -0
  32. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/compatibility.hpp +41 -0
  33. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/complex_wrapper.hpp +101 -0
  34. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/compressedfespace.hpp +110 -0
  35. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/contact.hpp +239 -0
  36. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/cuda_core.hpp +216 -0
  37. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/cuda_linalg.hpp +185 -0
  38. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/cuda_ngbla.hpp +317 -0
  39. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/cuda_ngstd.hpp +414 -0
  40. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/cuda_profiler.hpp +240 -0
  41. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/diagonalmatrix.hpp +160 -0
  42. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/differentialoperator.hpp +276 -0
  43. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/diffop.hpp +1286 -0
  44. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/diffop_impl.hpp +328 -0
  45. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/diffopwithfactor.hpp +123 -0
  46. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/discontinuous.hpp +84 -0
  47. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/dump.hpp +949 -0
  48. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/ectypes.hpp +121 -0
  49. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/eigen.hpp +60 -0
  50. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/eigensystem.hpp +18 -0
  51. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/elasticity_equations.hpp +595 -0
  52. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/elementbyelement.hpp +201 -0
  53. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/elementtopology.hpp +1760 -0
  54. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/elementtransformation.hpp +339 -0
  55. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/evalfunc.hpp +405 -0
  56. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/expr.hpp +1693 -0
  57. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/facetfe.hpp +175 -0
  58. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/facetfespace.hpp +180 -0
  59. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/facethofe.hpp +111 -0
  60. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/facetsurffespace.hpp +112 -0
  61. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/fe_interfaces.hpp +32 -0
  62. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/fem.hpp +87 -0
  63. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/fesconvert.hpp +14 -0
  64. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/fespace.hpp +1454 -0
  65. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/finiteelement.hpp +286 -0
  66. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/globalinterfacespace.hpp +77 -0
  67. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/globalspace.hpp +115 -0
  68. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/gridfunction.hpp +525 -0
  69. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/h1amg.hpp +124 -0
  70. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/h1hofe.hpp +188 -0
  71. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/h1hofe_impl.hpp +1262 -0
  72. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/h1hofefo.hpp +148 -0
  73. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/h1hofefo_impl.hpp +185 -0
  74. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/h1hofespace.hpp +167 -0
  75. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/h1lofe.hpp +1240 -0
  76. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/h1lumping.hpp +41 -0
  77. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hcurl_equations.hpp +1381 -0
  78. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hcurlcurlfe.hpp +2241 -0
  79. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hcurlcurlfespace.hpp +78 -0
  80. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hcurlfe.hpp +259 -0
  81. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hcurlfe_utils.hpp +107 -0
  82. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hcurlhdiv_dshape.hpp +857 -0
  83. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hcurlhdivfes.hpp +308 -0
  84. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hcurlhofe.hpp +175 -0
  85. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hcurlhofe_impl.hpp +1871 -0
  86. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hcurlhofespace.hpp +193 -0
  87. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hcurllofe.hpp +1146 -0
  88. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hdiv_equations.hpp +880 -0
  89. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hdivdivfe.hpp +2923 -0
  90. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hdivdivsurfacespace.hpp +76 -0
  91. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hdivfe.hpp +206 -0
  92. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hdivfe_utils.hpp +717 -0
  93. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hdivfes.hpp +75 -0
  94. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hdivhofe.hpp +447 -0
  95. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hdivhofe_impl.hpp +1107 -0
  96. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hdivhofefo.hpp +229 -0
  97. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hdivhofespace.hpp +177 -0
  98. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hdivhosurfacefespace.hpp +106 -0
  99. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hdivlofe.hpp +773 -0
  100. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hidden.hpp +74 -0
  101. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/householder.hpp +181 -0
  102. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hypre_ams_precond.hpp +123 -0
  103. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hypre_precond.hpp +73 -0
  104. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/integrator.hpp +2012 -0
  105. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/integratorcf.hpp +253 -0
  106. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/interpolate.hpp +49 -0
  107. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/intrule.hpp +2542 -0
  108. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/intrules_SauterSchwab.hpp +25 -0
  109. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/irspace.hpp +49 -0
  110. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/jacobi.hpp +153 -0
  111. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/kernels.hpp +724 -0
  112. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/l2hofe.hpp +194 -0
  113. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/l2hofe_impl.hpp +564 -0
  114. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/l2hofefo.hpp +542 -0
  115. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/l2hofespace.hpp +344 -0
  116. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/la.hpp +38 -0
  117. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/linalg_kernels.hpp +70 -0
  118. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/linearform.hpp +266 -0
  119. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/matrix.hpp +2145 -0
  120. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/memusage.hpp +41 -0
  121. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/meshaccess.hpp +1359 -0
  122. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/mgpre.hpp +204 -0
  123. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/mp_coefficient.hpp +145 -0
  124. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/mptools.hpp +2281 -0
  125. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/multigrid.hpp +42 -0
  126. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/multivector.hpp +447 -0
  127. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/mumpsinverse.hpp +187 -0
  128. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/mycomplex.hpp +361 -0
  129. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/ng_lapack.hpp +1661 -0
  130. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/ngblas.hpp +1232 -0
  131. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/ngs_defines.hpp +30 -0
  132. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/ngs_stdcpp_include.hpp +106 -0
  133. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/ngs_utils.hpp +121 -0
  134. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/ngsobject.hpp +1019 -0
  135. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/ngsstream.hpp +113 -0
  136. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/ngstd.hpp +72 -0
  137. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/nodalhofe.hpp +96 -0
  138. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/nodalhofe_impl.hpp +141 -0
  139. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/normalfacetfe.hpp +223 -0
  140. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/normalfacetfespace.hpp +98 -0
  141. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/normalfacetsurfacefespace.hpp +84 -0
  142. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/order.hpp +251 -0
  143. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/parallel_matrices.hpp +222 -0
  144. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/paralleldofs.hpp +340 -0
  145. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/parallelngs.hpp +23 -0
  146. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/parallelvector.hpp +269 -0
  147. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/pardisoinverse.hpp +200 -0
  148. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/periodic.hpp +129 -0
  149. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/plateaufespace.hpp +25 -0
  150. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/pml.hpp +275 -0
  151. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/pmltrafo.hpp +631 -0
  152. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/postproc.hpp +142 -0
  153. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/potentialtools.hpp +22 -0
  154. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/precomp.hpp +60 -0
  155. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/preconditioner.hpp +602 -0
  156. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/prolongation.hpp +380 -0
  157. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/python_comp.hpp +107 -0
  158. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/python_fem.hpp +89 -0
  159. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/python_linalg.hpp +58 -0
  160. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/python_ngstd.hpp +386 -0
  161. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/recursive_pol.hpp +4896 -0
  162. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/recursive_pol_tet.hpp +395 -0
  163. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/recursive_pol_trig.hpp +492 -0
  164. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/reorderedfespace.hpp +81 -0
  165. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/sample_sort.hpp +105 -0
  166. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/scalarfe.hpp +335 -0
  167. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/shapefunction_utils.hpp +113 -0
  168. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/simd_complex.hpp +329 -0
  169. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/smoother.hpp +253 -0
  170. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/solve.hpp +89 -0
  171. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/sparsecholesky.hpp +317 -0
  172. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/sparsefactorization_interface.hpp +159 -0
  173. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/sparsematrix.hpp +1052 -0
  174. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/sparsematrix_dyn.hpp +90 -0
  175. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/sparsematrix_impl.hpp +1055 -0
  176. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/special_matrix.hpp +463 -0
  177. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/specialelement.hpp +125 -0
  178. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/statushandler.hpp +33 -0
  179. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/stringops.hpp +12 -0
  180. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/superluinverse.hpp +136 -0
  181. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/symbolicintegrator.hpp +850 -0
  182. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/symmetricmatrix.hpp +144 -0
  183. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/tangentialfacetfe.hpp +224 -0
  184. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/tangentialfacetfespace.hpp +91 -0
  185. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/tensor.hpp +522 -0
  186. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/tensorcoefficient.hpp +446 -0
  187. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/tensorproductintegrator.hpp +113 -0
  188. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/thcurlfe.hpp +128 -0
  189. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/thcurlfe_impl.hpp +380 -0
  190. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/thdivfe.hpp +80 -0
  191. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/thdivfe_impl.hpp +492 -0
  192. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/tpdiffop.hpp +461 -0
  193. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/tpfes.hpp +133 -0
  194. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/tpintrule.hpp +224 -0
  195. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/triangular.hpp +465 -0
  196. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/tscalarfe.hpp +245 -0
  197. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/tscalarfe_impl.hpp +1029 -0
  198. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/umfpackinverse.hpp +148 -0
  199. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/unifiedvector.hpp +103 -0
  200. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/vector.hpp +1452 -0
  201. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/voxelcoefficientfunction.hpp +41 -0
  202. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/vtkoutput.hpp +198 -0
  203. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/vvector.hpp +208 -0
  204. ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/webgui.hpp +92 -0
  205. ngsolve-6.2.2506.post216.dev0.data/data/lib/cmake/ngsolve/NGSolveConfig.cmake +102 -0
  206. ngsolve-6.2.2506.post216.dev0.data/data/lib/cmake/ngsolve/ngsolve-targets-release.cmake +89 -0
  207. ngsolve-6.2.2506.post216.dev0.data/data/lib/cmake/ngsolve/ngsolve-targets.cmake +180 -0
  208. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/netgen_mesher.libs/libngbla.so +0 -0
  209. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/netgen_mesher.libs/libngcomp.so +0 -0
  210. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/netgen_mesher.libs/libngfem.so +0 -0
  211. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/netgen_mesher.libs/libngla.so +0 -0
  212. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/netgen_mesher.libs/libngsbem.so +0 -0
  213. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/netgen_mesher.libs/libngscudalib.so +0 -0
  214. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/netgen_mesher.libs/libngsolve.so +0 -0
  215. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/netgen_mesher.libs/libngstd.so +0 -0
  216. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/TensorProductTools.py +210 -0
  217. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/__console.py +94 -0
  218. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/__expr.py +181 -0
  219. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/__init__.py +148 -0
  220. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/_scikit_build_core_dependencies.py +30 -0
  221. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/bvp.py +78 -0
  222. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/config/__init__.py +1 -0
  223. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/config/__main__.py +4 -0
  224. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/config/config.py +60 -0
  225. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/TensorProduct/__init__.py +0 -0
  226. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/TensorProduct/tp_dg_1d_1d.py +80 -0
  227. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/TensorProduct/tp_dg_1d_2d.py +73 -0
  228. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/TensorProduct/tp_dg_2d_1d.py +72 -0
  229. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/TensorProduct/tp_dg_2d_2d.py +66 -0
  230. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/__init__.py +0 -0
  231. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/__init__.py +0 -0
  232. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/hhj.py +44 -0
  233. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/hybrid_dg.py +53 -0
  234. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/mixed.py +30 -0
  235. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/nonlin.py +29 -0
  236. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/pickling.py +26 -0
  237. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/pml.py +31 -0
  238. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/taskmanager.py +20 -0
  239. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/tdnns.py +47 -0
  240. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/timeDG-skeleton.py +45 -0
  241. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/timeDG.py +38 -0
  242. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/timeDGlap.py +42 -0
  243. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/timeDGwave.py +61 -0
  244. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/intro/__init__.py +0 -0
  245. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/intro/adaptive.py +123 -0
  246. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/intro/cmagnet.py +59 -0
  247. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/intro/elasticity.py +76 -0
  248. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/intro/navierstokes.py +74 -0
  249. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/intro/poisson.ipynb +170 -0
  250. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/intro/poisson.py +41 -0
  251. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/mpi/__init__.py +0 -0
  252. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/mpi/mpi_cmagnet.py +87 -0
  253. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/mpi/mpi_navierstokes.py +117 -0
  254. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/mpi/mpi_poisson.py +89 -0
  255. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/mpi/mpi_timeDG.py +82 -0
  256. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/directsolvers.py +14 -0
  257. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/eigenvalues.py +364 -0
  258. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/internal.py +89 -0
  259. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/krylovspace.py +1182 -0
  260. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/meshes.py +748 -0
  261. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/ngs2petsc.py +310 -0
  262. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/ngscuda.so +0 -0
  263. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/ngscxx.py +42 -0
  264. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/ngslib.so +0 -0
  265. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/nonlinearsolvers.py +203 -0
  266. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/preconditioners.py +11 -0
  267. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/solve_implementation.py +168 -0
  268. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/solvers/__init__.py +7 -0
  269. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/solvers/cudss.py +112 -0
  270. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/timestepping.py +185 -0
  271. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/timing.py +108 -0
  272. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/utils.py +167 -0
  273. ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/webgui.py +671 -0
  274. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/beam.geo +17 -0
  275. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/beam.vol +240 -0
  276. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/chip.in2d +41 -0
  277. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/chip.vol +614 -0
  278. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/coil.geo +12 -0
  279. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/coil.vol +2560 -0
  280. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/coilshield.geo +24 -0
  281. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/coilshield.vol +3179 -0
  282. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/cube.geo +19 -0
  283. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/cube.vol +1832 -0
  284. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/d10_DGdoubleglazing.pde +50 -0
  285. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/d11_chip_nitsche.pde +40 -0
  286. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/d1_square.pde +43 -0
  287. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/d2_chip.pde +35 -0
  288. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/d3_helmholtz.pde +22 -0
  289. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/d4_cube.pde +46 -0
  290. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/d5_beam.pde +74 -0
  291. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/d6_shaft.pde +73 -0
  292. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/d7_coil.pde +50 -0
  293. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/d8_coilshield.pde +49 -0
  294. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/d9_hybridDG.pde +72 -0
  295. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/doubleglazing.in2d +27 -0
  296. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/doubleglazing.vol +737 -0
  297. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/piezo2d40round4.vol.gz +0 -0
  298. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/shaft.geo +73 -0
  299. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/shaft.vol +4291 -0
  300. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/square.in2d +17 -0
  301. ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/square.vol +149 -0
  302. ngsolve-6.2.2506.post216.dev0.dist-info/METADATA +14 -0
  303. ngsolve-6.2.2506.post216.dev0.dist-info/RECORD +306 -0
  304. ngsolve-6.2.2506.post216.dev0.dist-info/WHEEL +5 -0
  305. ngsolve-6.2.2506.post216.dev0.dist-info/licenses/LICENSE +504 -0
  306. ngsolve-6.2.2506.post216.dev0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,2145 @@
1
+ #ifndef FILE_MATRIX_EXPR
2
+ #define FILE_MATRIX_EXPR
3
+
4
+ /**************************************************************************/
5
+ /* File: matrix.hpp */
6
+ /* Author: Joachim Schoeberl */
7
+ /* Date: 01. Jan. 02 */
8
+ /**************************************************************************/
9
+
10
+
11
+ #include "expr.hpp"
12
+ #include "vector.hpp"
13
+
14
+ namespace ngbla
15
+ {
16
+
17
+
18
+ template <typename T = double, ORDERING ORD = RowMajor>
19
+ using SliceMatrix = MatrixView<T,ORD,size_t, size_t, size_t>;
20
+
21
+ template <typename T, typename TELEM=typename std::remove_reference_t<T>::TELEM>
22
+ constexpr bool IsConvertibleToSliceMatrix ()
23
+ {
24
+ /*
25
+ return is_convertible_v<T,SliceMatrix<TELEM, RowMajor>> ||
26
+ is_convertible_v<T,SliceMatrix<TELEM, ColMajor>>;
27
+ */
28
+ return is_constructible_v<SliceMatrix<TELEM, RowMajor>,T> ||
29
+ is_constructible_v<SliceMatrix<TELEM, ColMajor>,T>;
30
+ }
31
+
32
+ template <typename T = double, ORDERING ORD = RowMajor>
33
+ using BareSliceMatrix = MatrixView<T,ORD,undefined_size, undefined_size, size_t>;
34
+
35
+ template <typename T, typename TELEM=typename std::remove_reference_t<T>::TELEM>
36
+ constexpr bool IsConvertibleToBareSliceMatrix ()
37
+ {
38
+ // return is_convertible_v<T,BareSliceMatrix<TELEM, RowMajor>> ||
39
+ // is_convertible_v<T,BareSliceMatrix<TELEM, ColMajor>>;
40
+ return is_constructible_v<BareSliceMatrix<TELEM, RowMajor>,T> ||
41
+ is_constructible_v<BareSliceMatrix<TELEM, ColMajor>,T>;
42
+
43
+ }
44
+
45
+
46
+
47
+
48
+ template <int H, int W, typename T> class Mat;
49
+ template <typename T> class DoubleSliceMatrix;
50
+
51
+
52
+ #ifdef OLDFLATMATRIX
53
+ /**
54
+ A simple matrix.
55
+ Has height, width and data-pointer.
56
+ No memory allocation/deallocation. User must provide memory.
57
+ */
58
+ template <typename T, ORDERING ORD>
59
+ class FlatMatrix : public MatExpr<FlatMatrix<T,ORD> >
60
+ {
61
+ protected:
62
+ typedef MatExpr<FlatMatrix<T,ORD>> BASE;
63
+ /// the height
64
+ size_t h;
65
+ /// the width
66
+ size_t w;
67
+ /// the data
68
+ T * __restrict data;
69
+ public:
70
+
71
+ /// element type
72
+ typedef T TELEM;
73
+ /// scalar type of elements (double or Complex)
74
+ typedef typename mat_traits<T>::TSCAL TSCAL;
75
+ static constexpr bool IsLinear() { return ORD==RowMajor; }
76
+ /// nothing done in default constructor
77
+ INLINE FlatMatrix () = default;
78
+
79
+ /// set height, width, and mem
80
+ INLINE FlatMatrix (size_t ah, size_t aw, T * adata)
81
+ : h(ah), w(aw), data(adata) { ; }
82
+
83
+ /// set height = width, and mem
84
+ INLINE FlatMatrix (size_t ah, T * adata)
85
+ : h(ah), w(ah), data(adata) { ; }
86
+
87
+ /// allocates at local heap
88
+ INLINE FlatMatrix (size_t ah, size_t aw, LocalHeap & lh)
89
+ : h(ah), w(aw), data (lh.Alloc<T>(ah*aw)) { ; }
90
+
91
+ /// allocates at local heap
92
+ INLINE FlatMatrix (size_t ah, LocalHeap & lh)
93
+ : h(ah), w(ah), data(lh.Alloc<T>(ah*ah)) { ; }
94
+
95
+ /// copy constructor. copies pointers, not contents
96
+ FlatMatrix (const FlatMatrix & m) = default;
97
+ /// allocate and compute
98
+ template<typename TB>
99
+ INLINE FlatMatrix (const LocalHeapExpr<TB> & m2)
100
+ {
101
+ h = m2.A().Height();
102
+ w = m2.A().Width();
103
+ LocalHeap & lh = m2.GetLocalHeap();
104
+ data = lh.Alloc<T> (h*w);
105
+ // CMCPMatExpr<FlatMatrix<T,ORD> >::operator= (m2.A());
106
+ this->operator= (m2.A());
107
+ }
108
+ /*
109
+ /// useful to put FlatMatrix over other matrix
110
+ template <typename T2>
111
+ INLINE explicit FlatMatrix (const MatExpr<T2> & m)
112
+ : h(m.Height()), w(m.Width()),
113
+ data(const_cast<T*>(m.Spec().Data()))
114
+ {
115
+ static_assert(ORD == m.Ordering());
116
+ }
117
+ */
118
+
119
+ template <int W, enable_if_t<ORD==RowMajor, int> =0>
120
+ INLINE FlatMatrix (MatrixView<T,RowMajor,size_t,IC<W>,IC<W>> m)
121
+ : h(m.Height()), w(m.Width()), data(m.Data()) { }
122
+
123
+
124
+ /// useful to put FlatMatrix over other Mat
125
+ template <int H, int W>
126
+ INLINE FlatMatrix (const Mat<H,W,TSCAL> & m)
127
+ : h(H), w(W), data(const_cast<T*>(m.Data()))
128
+ { ; }
129
+
130
+ // do nothing
131
+ // ~FlatMatrix () throw() { ; }
132
+
133
+ /// set size, and assign mem
134
+ INLINE void AssignMemory (size_t ah, size_t aw, LocalHeap & lh)
135
+ {
136
+ h = ah;
137
+ w = aw;
138
+ data = lh.Alloc<T>(h*w);
139
+ }
140
+
141
+ /// set size, and assign mem
142
+ INLINE void AssignMemory (size_t ah, size_t aw, T * mem)
143
+ {
144
+ h = ah;
145
+ w = aw;
146
+ data = mem;
147
+ }
148
+
149
+
150
+ /// assign contents
151
+ template<typename TBxx>
152
+ INLINE FlatMatrix & operator= (const Expr<TBxx> & m)
153
+ {
154
+ BASE::operator= (m);
155
+ return *this;
156
+ }
157
+
158
+ /// copy contents
159
+ INLINE FlatMatrix & operator= (const FlatMatrix & m)
160
+ {
161
+ // for (size_t i = 0; i < h*w; i++) data[i] = m(i);
162
+ AsVector() = m.AsVector();
163
+ return *this;
164
+ }
165
+
166
+ /// assign constant
167
+ INLINE FlatMatrix & operator= (TSCAL s)
168
+ {
169
+ // for (auto i : Range(h*w)) data[i] = s;
170
+ AsVector() = s;
171
+ return *this;
172
+ }
173
+
174
+
175
+ INLINE auto View() const { return FlatMatrix(*this); }
176
+ INLINE auto ViewRW() { return *this; }
177
+ INLINE tuple<size_t, size_t> Shape() const { return { h, w }; }
178
+ static constexpr auto Ordering() { return ORD; }
179
+
180
+ /// copy size and pointers
181
+ INLINE FlatMatrix & Assign (const FlatMatrix & m)
182
+ {
183
+ h = m.h;
184
+ w = m.w;
185
+ data = m.data;
186
+ return *this;
187
+ }
188
+
189
+
190
+ /// access operator, linear access
191
+ INLINE TELEM & operator() (size_t i) const
192
+ {
193
+ NETGEN_CHECK_RANGE(i, 0, Height()*Width());
194
+ return data[i];
195
+ }
196
+
197
+ /// access operator
198
+ template <typename I, typename J>
199
+ INLINE TELEM & operator() (I i, J j) const
200
+ {
201
+ NETGEN_CHECK_RANGE(i, 0, Height());
202
+ NETGEN_CHECK_RANGE(j, 0, Width());
203
+ return data[i*w+j];
204
+ }
205
+
206
+ /// the height
207
+ INLINE auto Height () const { return h; }
208
+ /// the width
209
+ INLINE auto Width () const { return w; }
210
+ ///
211
+ INLINE auto Dist () const { return w; }
212
+
213
+ INLINE T * Data () const { return data; }
214
+
215
+ INLINE FlatVector<T> Row (size_t i) const
216
+ {
217
+ return FlatVector<T> (w, data+i*w);
218
+ }
219
+
220
+ INLINE SliceVector<T> Col (size_t i) const
221
+ {
222
+ return SliceVector<T> (h, w, data+i);
223
+ }
224
+
225
+ INLINE SliceVector<T> Diag () const
226
+ {
227
+ return SliceVector<T> (h, w+1, &data[0]);
228
+ }
229
+
230
+ SliceVector<T> Diag (int offset) const
231
+ {
232
+ int dp = std::max(offset, 0);
233
+ int dm = std::min(offset, 0);
234
+ return SliceVector<T> (std::min(w-dp, h+dm), Dist()+1, data+dp-dm*Dist());
235
+ }
236
+
237
+
238
+ using BASE::Rows;
239
+ using BASE::Cols;
240
+
241
+ INLINE FlatMatrix Rows (size_t first, size_t next) const
242
+ {
243
+ return FlatMatrix (next-first, w, data+first*w);
244
+ }
245
+
246
+ INLINE FlatMatrix Rows (size_t next) const
247
+ {
248
+ return FlatMatrix (next, w, data);
249
+ }
250
+
251
+ INLINE SliceMatrix<T> Cols (size_t first, size_t next) const
252
+ {
253
+ return SliceMatrix<T> (h, next-first, w, data+first);
254
+ }
255
+
256
+ INLINE SliceMatrix<T> Cols (size_t next) const
257
+ {
258
+ return SliceMatrix<T> (h, next, w, data);
259
+ }
260
+
261
+ INLINE FlatMatrix Rows (IntRange range) const
262
+ {
263
+ return FlatMatrix (range.Next()-range.First(), w, data+range.First()*w);
264
+ }
265
+
266
+ INLINE SliceMatrix<T> Cols (IntRange range) const
267
+ {
268
+ return SliceMatrix<T> (h, range.Next()-range.First(), w, data+range.First());
269
+ }
270
+
271
+ BareSliceMatrix<T> RowSlice(size_t first, size_t adist) const
272
+ {
273
+ return BareSliceMatrix<T> (Height()/adist, w, w*adist, data+first*w);
274
+ }
275
+
276
+ INLINE auto SplitRows (size_t split) const
277
+ {
278
+ return tuple(Rows(0,split), Rows(split, Height()));
279
+ }
280
+
281
+ INLINE auto SplitCols (size_t split) const
282
+ {
283
+ return tuple(Cols(0,split), Cols(split, Width()));
284
+ }
285
+
286
+
287
+ auto Bare() const
288
+ {
289
+ return make_BareSliceMatrix(*this);
290
+ }
291
+
292
+ /*
293
+ INLINE operator SliceMatrix<T> () const
294
+ {
295
+ return SliceMatrix<T> (h, w, w, data);
296
+ }
297
+ */
298
+ auto AsVector() const
299
+ {
300
+ return FlatVector<T> (h*w, data);
301
+ }
302
+
303
+ auto Reshape(size_t h2, size_t w2)
304
+ {
305
+ return FlatMatrix{h2,w2,data};
306
+ }
307
+ };
308
+
309
+
310
+
311
+
312
+
313
+ template <typename T>
314
+ class FlatMatrix<T,ColMajor> : public MatExpr<FlatMatrix<T,ColMajor> >
315
+ {
316
+ protected:
317
+ typedef MatExpr<FlatMatrix<T,ColMajor>> BASE;
318
+ size_t h;
319
+ size_t w;
320
+ T * __restrict data;
321
+ public:
322
+ static constexpr bool IsLinear() { return false; }
323
+ /// element type
324
+ typedef T TELEM;
325
+ /// scalar type of elements (double or Complex)
326
+ typedef typename mat_traits<T>::TSCAL TSCAL;
327
+
328
+ /// nothing done in default constructor
329
+ INLINE FlatMatrix () { ; }
330
+
331
+ /// set height, width, and mem
332
+ INLINE FlatMatrix (int ah, int aw, T * adata)
333
+ : h(ah), w(aw), data(adata) { ; }
334
+
335
+ /// set height = width, and mem
336
+ INLINE FlatMatrix (int ah, T * adata)
337
+ : h(ah), w(ah), data(adata) { ; }
338
+
339
+ /// allocates at local heap
340
+ INLINE FlatMatrix (int ah, int aw, LocalHeap & lh)
341
+ : h(ah), w(aw), data (lh.Alloc<T>(ah*aw)) { ; }
342
+
343
+ /// allocates at local heap
344
+ INLINE FlatMatrix (int ah, LocalHeap & lh)
345
+ : h(ah), w(ah), data(lh.Alloc<T>(ah*ah)) { ; }
346
+
347
+ /// copy constructor. copies pointers, not contents
348
+ INLINE FlatMatrix (const FlatMatrix & m)
349
+ : h(m.h), w(m.w) , data(m.data)
350
+ { ; }
351
+
352
+ /// allocate and compute
353
+ template<typename TB>
354
+ INLINE FlatMatrix (const LocalHeapExpr<TB> & m2)
355
+ {
356
+ h = m2.A().Height();
357
+ w = m2.A().Width();
358
+ LocalHeap & lh = m2.GetLocalHeap();
359
+ data = lh.Alloc<T> (h*w);
360
+ BASE::operator= (m2.A());
361
+ }
362
+
363
+ /// set size, and assign mem
364
+ INLINE void AssignMemory (int ah, int aw, LocalHeap & lh)
365
+ {
366
+ h = ah;
367
+ w = aw;
368
+ data = lh.Alloc<T>(h*w);
369
+ }
370
+
371
+ /// set size, and assign mem
372
+ INLINE void AssignMemory (int ah, int aw, T * mem)
373
+ {
374
+ h = ah;
375
+ w = aw;
376
+ data = mem;
377
+ }
378
+
379
+ /// assign contents
380
+ template<typename TBxx>
381
+ INLINE FlatMatrix & operator= (const Expr<TBxx> & m)
382
+ {
383
+ BASE::operator= (m);
384
+ return *this;
385
+ }
386
+
387
+ /// copy contents
388
+ INLINE FlatMatrix & operator= (const FlatMatrix & m)
389
+ {
390
+ for (size_t i = 0; i < size_t(h)*size_t(w); i++) data[i] = m(i);
391
+ return *this;
392
+ }
393
+
394
+ /// assign constant
395
+ INLINE FlatMatrix & operator= (TSCAL s)
396
+ {
397
+ for (size_t i = 0; i < size_t(h)*size_t(w); i++) data[i] = s;
398
+ return *this;
399
+ }
400
+
401
+ INLINE auto View() const { return FlatMatrix(*this); }
402
+ INLINE auto ViewRW() { return *this; }
403
+ INLINE tuple<size_t, size_t> Shape() const { return { h, w }; }
404
+
405
+ /// copy size and pointers
406
+ INLINE FlatMatrix & Assign (const FlatMatrix & m)
407
+ {
408
+ h = m.h;
409
+ w = m.w;
410
+ data = m.data;
411
+ return *this;
412
+ }
413
+
414
+ /// access operator, linear access
415
+ INLINE TELEM & operator() (size_t i) const
416
+ {
417
+ NETGEN_CHECK_RANGE(i, 0, Height()*Width());
418
+ return data[i];
419
+ }
420
+
421
+ /// access operator
422
+ INLINE TELEM & operator() (size_t i, size_t j) const
423
+ {
424
+ NETGEN_CHECK_RANGE(i, 0, Height());
425
+ NETGEN_CHECK_RANGE(j, 0, Width());
426
+ return data[j*size_t(h)+i];
427
+ }
428
+
429
+ /// the height
430
+ INLINE size_t Height () const { return h; }
431
+
432
+ /// the width
433
+ INLINE size_t Width () const { return w; }
434
+
435
+ INLINE size_t Dist () const { return h; }
436
+
437
+ INLINE T * Data () const { return data; }
438
+
439
+ INLINE FlatVector<T> Col (size_t i) const
440
+ {
441
+ return FlatVector<T> (h, &data[i*size_t(h)]);
442
+ }
443
+
444
+ INLINE SliceVector<T> Row (size_t i) const
445
+ {
446
+ return SliceVector<T> (w, h, &data[i]);
447
+ }
448
+
449
+ SliceVector<T> Diag () const
450
+ {
451
+ return SliceVector<T> (h, w+1, &data[0]);
452
+ }
453
+
454
+ INLINE FlatMatrix Cols (size_t first, size_t next) const
455
+ {
456
+ return FlatMatrix (h, next-first, data+first*h);
457
+ }
458
+
459
+ INLINE FlatMatrix Cols (IntRange range) const
460
+ {
461
+ return FlatMatrix (h, range.Size(), data+range.First()*h);
462
+ }
463
+
464
+
465
+ INLINE SliceMatrix<T,ColMajor> Rows (size_t first, size_t next) const
466
+ {
467
+ return SliceMatrix<T,ColMajor> (next-first, w, h, data+first);
468
+ }
469
+
470
+ INLINE SliceMatrix<T,ColMajor> Rows (IntRange range) const
471
+ {
472
+ return SliceMatrix<T,ColMajor> (range.Size(), w, h, data+range.First());
473
+ }
474
+
475
+ INLINE auto SplitRows (size_t split) const
476
+ {
477
+ return tuple(Rows(0,split), Rows(split, Height()));
478
+ }
479
+
480
+ INLINE auto SplitCols (size_t split) const
481
+ {
482
+ return tuple(Cols(0,split), Cols(split, Width()));
483
+ }
484
+ };
485
+
486
+
487
+ #endif
488
+
489
+
490
+
491
+
492
+
493
+
494
+
495
+
496
+
497
+ /**
498
+ A Matrix class with memory allocation/deallocation
499
+ */
500
+ template <typename T, ORDERING ORD>
501
+ class Matrix : public FlatMatrix<T,ORD>
502
+ {
503
+ public:
504
+
505
+ /// element type
506
+ typedef T TELEM;
507
+ /// scalar type of elements (double or Complex)
508
+ typedef typename mat_traits<T>::TSCAL TSCAL;
509
+
510
+ /// default constructor
511
+ Matrix () : FlatMatrix<T,ORD> (0, 0, nullptr) { ; }
512
+
513
+ /// allocate matrix of size ah * ah
514
+ Matrix (size_t ah) : FlatMatrix<T,ORD> (ah, new T[ah*ah]) { ; }
515
+
516
+ /// allocate matrix of size ah * aw
517
+ Matrix (size_t ah, size_t aw) : FlatMatrix<T,ORD> (ah, aw, new T[ah*aw]) { ; }
518
+
519
+ /// allocate and copy matrix
520
+ INLINE Matrix (const Matrix & m2)
521
+ : FlatMatrix<T,ORD> (m2.Height(), m2.Width(), new T[m2.Height()*m2.Width()])
522
+ {
523
+ FlatMatrix<T,ORD>::operator= (m2);
524
+ }
525
+
526
+ /// move matrix
527
+ INLINE Matrix (Matrix && m2)
528
+ : FlatMatrix<T,ORD> (m2.h, m2.w, m2.data)
529
+ { m2.data = nullptr; m2.w = 0; m2.h = 0; }
530
+
531
+ /// allocate and compute
532
+ template<typename TB>
533
+ INLINE Matrix (const Expr<TB> & m2)
534
+ : FlatMatrix<T,ORD> (m2.Height(), m2.Width(), new T[m2.Height()*m2.Width()])
535
+ {
536
+ MatExpr<FlatMatrix<T,ORD> >::operator= (m2); // .View()); // does it work with view ?
537
+ }
538
+
539
+ Matrix (initializer_list<initializer_list<T>> llist)
540
+ : FlatMatrix<T,ORD> (0,0,nullptr)
541
+ {
542
+ int h = llist.size();
543
+ int w = 0;
544
+ for (auto row : llist)
545
+ w = std::max(w, int(row.size()));
546
+
547
+ SetSize (h, w);
548
+ (*this) = T(0.0);
549
+
550
+ int r = 0;
551
+ for (auto row : llist)
552
+ {
553
+ int c = 0;
554
+ for (auto col : row)
555
+ (*this)(r,c++) = col;
556
+ r++;
557
+ }
558
+ }
559
+
560
+
561
+
562
+ /// delete memory
563
+ ~Matrix() { delete [] this->data; }
564
+
565
+ template <typename ARCHIVE>
566
+ void DoArchive (ARCHIVE & ar)
567
+ {
568
+ ar & this->h & this->w;
569
+ if(ar.Input())
570
+ SetSize(this->h, this->w);
571
+ ar.Do(this->data, this->h*this->w);
572
+ }
573
+
574
+ /// sets new size of matrix
575
+ void SetSize(size_t ah, size_t aw)
576
+ {
577
+ if (this->h == ah && this->w == aw) return;
578
+ delete [] this->data;
579
+ this->h = ah;
580
+ this->w = aw;
581
+ this->data = new T[this->h * this->w];
582
+ }
583
+
584
+ /// sets new size of matrix
585
+ void SetSize(size_t ah)
586
+ {
587
+ if (this->h == ah && this->w == ah) return;
588
+ delete [] this->data;
589
+ this->h = ah;
590
+ this->w = ah;
591
+ this->data = new T[this->h * this->w];
592
+ }
593
+
594
+
595
+ void ChangeSize (size_t newh, size_t neww)
596
+ {
597
+ Matrix tmp(newh, neww);
598
+ auto minh = std::min(newh, this->Height());
599
+ auto minw = std::min(neww, this->Width());
600
+ tmp.Rows (minh).Cols(minw) = this->Rows(minh).Cols(minw);
601
+ (*this) = std::move(tmp);
602
+ }
603
+
604
+ /// assign matrix, sizes must match
605
+ template<typename TB>
606
+ INLINE Matrix & operator= (const Expr<TB> & m)
607
+ {
608
+ SetSize (m.Height(), m.Width());
609
+ MatExpr<FlatMatrix<T,ORD> >::operator= (m);
610
+ return *this;
611
+ }
612
+
613
+
614
+ /// fill matrix with scalar
615
+ Matrix & operator= (TSCAL s)
616
+ {
617
+ FlatMatrix<T,ORD>::operator= (s);
618
+ return *this;
619
+ }
620
+
621
+
622
+ /// fill matrix with scalar
623
+ Matrix & operator= (const Matrix & m2)
624
+ {
625
+ SetSize (m2.Height(), m2.Width());
626
+ FlatMatrix<T,ORD>::operator= (m2);
627
+ return *this;
628
+ }
629
+
630
+ Matrix & operator= (Matrix && m2)
631
+ {
632
+ this->h = m2.h;
633
+ this->w = m2.w;
634
+ ngcore::Swap (this->data, m2.data);
635
+ return *this;
636
+ }
637
+
638
+ template<typename M2>
639
+ Matrix & operator+= (const M2 & m)
640
+ {
641
+ MatExpr<FlatMatrix<T,ORD> >::operator+= (m);
642
+ return *this;
643
+ }
644
+ };
645
+
646
+
647
+
648
+
649
+ /**
650
+ A matrix of fixed size.
651
+ Useful as entry type in system matrices,...
652
+ */
653
+ template <int H, int W = H, typename T = double>
654
+ class Mat : public MatExpr<Mat<H,W,T> >
655
+ {
656
+ // T data[(H*W>0) ? H*W : 1];
657
+ HTArray<H*W,T> data;
658
+ public:
659
+ typedef T TELEM;
660
+ typedef typename mat_traits<T>::TSCAL TSCAL;
661
+ typedef Vec<H, typename mat_traits<T>::TV_COL> TV_COL;
662
+ typedef Vec<W, typename mat_traits<T>::TV_ROW> TV_ROW;
663
+ static constexpr bool IsLinear() { return true; }
664
+ /// do not initialize
665
+ constexpr Mat () = default;
666
+ Mat (const Mat &) = default;
667
+
668
+
669
+ auto & HTData() const { return data; }
670
+ template <typename T2>
671
+ Mat (const Mat<H,W,T2> & m2) : data(m2.HTData()) { ; }
672
+
673
+ /// assign values
674
+ template<typename TB>
675
+ INLINE Mat (const Expr<TB> & m)
676
+ {
677
+ MatExpr<Mat>::operator= (m);
678
+ }
679
+
680
+ /// fill with scalar
681
+ INLINE Mat (TSCAL s)
682
+ {
683
+ for (size_t i = 0; i < H*W; i++)
684
+ data[i] = s;
685
+ }
686
+
687
+ Mat (initializer_list<initializer_list<T>> llist)
688
+ {
689
+ int r = 0;
690
+ for (auto row : llist)
691
+ {
692
+ int c = 0;
693
+ for (auto col : row)
694
+ (*this)(r,c++) = col;
695
+ r++;
696
+ }
697
+ }
698
+
699
+ template <typename ...TTUP>
700
+ Mat (tuple<TTUP...> tup)
701
+ {
702
+ constexpr int s = tuple_size<decltype(tup)>();
703
+ Iterate<s> ([this, tup] (auto i) { this->data[i] = std::get<i>(tup); });
704
+ }
705
+
706
+ template <class... T2>
707
+ Mat (T v0, T v1, T2... rest)
708
+ : Mat(tuple(v0, v1, rest...)) { }
709
+
710
+ /// assign values
711
+ template<typename TB>
712
+ INLINE Mat & operator= (const Expr<TB> & m)
713
+ {
714
+ MatExpr<Mat>::operator= (m);
715
+ return *this;
716
+ }
717
+
718
+ /// copy matrix
719
+ Mat & operator= (const Mat &) = default;
720
+ /*
721
+ INLINE Mat & operator= (const Mat & m)
722
+ {
723
+ for (int i = 0; i < H*W; i++)
724
+ data[i] = m.data[i];
725
+ return *this;
726
+ }
727
+ */
728
+
729
+ /// fill values
730
+ INLINE Mat & operator= (TSCAL s)
731
+ {
732
+ for (size_t i = 0; i < H*W; i++)
733
+ data[i] = s;
734
+ return *this;
735
+ }
736
+
737
+ INLINE auto View() const { return Mat<H,W,const T>{*this}; }
738
+ INLINE auto & ViewRW() { return *this; }
739
+ INLINE auto Shape() const { return tuple(IC<H>(), IC<W>()); }
740
+
741
+ INLINE T* Data() noexcept { return data.Ptr(); }
742
+ INLINE const T* Data() const noexcept { return data.Ptr(); }
743
+ /// linear access
744
+ INLINE TELEM & operator() (size_t i) { return data[i]; }
745
+ /// access element
746
+ INLINE TELEM & operator() (size_t i, size_t j) { return data[i*W+j]; }
747
+ /// linear access
748
+ INLINE const TELEM & operator() (size_t i) const { return data[i]; }
749
+ /// access element
750
+ INLINE const TELEM & operator() (size_t i, size_t j) const { return data[i*W+j]; }
751
+
752
+ /// the height
753
+ INLINE static constexpr auto Height () { return IC<H>(); }
754
+ /// the width
755
+ INLINE static constexpr auto Width () { return IC<W>(); }
756
+
757
+ ///
758
+ INLINE FlatVec<W,T> Row (size_t i)
759
+ {
760
+ return FlatVec<W,T> (&(*this)(i,0));
761
+ }
762
+
763
+ ///
764
+ INLINE FlatVec<W,const T> Row (size_t i) const
765
+ {
766
+ return FlatVec<W,const T> (&(*this)(i,0));
767
+ }
768
+
769
+ ///
770
+ INLINE auto Col (size_t i)
771
+ {
772
+ // return FixSliceVector<W,T> (H, &(*this)(0,i));
773
+ return FlatSliceVec<H,W,T> (&(*this)(0,i));
774
+ }
775
+
776
+ ///
777
+ /*
778
+ INLINE const FixSliceVector<W,const T> Col (size_t i) const
779
+ {
780
+ return FixSliceVector<W,const T> (H, &(*this)(0,i));
781
+ }
782
+ */
783
+ INLINE const FlatSliceVec<H,W,const T> Col (size_t i) const
784
+ {
785
+ return FlatSliceVec<H,W,const T> (&(*this)(0,i));
786
+ }
787
+
788
+ INLINE auto Rows (size_t i, size_t j)
789
+ {
790
+ return MatrixView<T, RowMajor, size_t, IC<W>, IC<W>> (j-i, IC<W>(), IC<W>(), Data()+i*Width());
791
+ }
792
+
793
+ INLINE auto Rows (IntRange r)
794
+ {
795
+ return Rows (r.First(), r.Next());
796
+ }
797
+
798
+ INLINE auto Cols (size_t i, size_t j)
799
+ {
800
+ return MatrixView<T, RowMajor, IC<H>, size_t, IC<W>> (IC<H>(), j-i, IC<W>(), Data()+i);
801
+ }
802
+
803
+ INLINE auto Cols (IntRange r)
804
+ {
805
+ return Cols (r.First(), r.Next());
806
+ }
807
+
808
+ INLINE auto Rows (size_t i, size_t j) const
809
+ {
810
+ return MatrixView<const T, RowMajor, size_t, IC<W>, IC<W>> (j-i, IC<W>(), IC<W>(), Data()+i*Width());
811
+ }
812
+
813
+ INLINE auto Rows (IntRange r) const
814
+ {
815
+ return Rows (r.First(), r.Next());
816
+ }
817
+
818
+ INLINE auto Cols (size_t i, size_t j) const
819
+ {
820
+ return MatrixView<const T, RowMajor, IC<H>, size_t, IC<W>> (IC<H>(), j-i, IC<W>(), Data()+i);
821
+ }
822
+
823
+ INLINE auto Cols (IntRange r) const
824
+ {
825
+ return Cols (r.First(), r.Next());
826
+ }
827
+
828
+ auto AsVector()
829
+ {
830
+ return FlatVec<H*W,T> (data.Ptr());
831
+ }
832
+
833
+ auto AsVector() const
834
+ {
835
+ return FlatVec<H*W,const T> (data.Ptr());
836
+ }
837
+
838
+ template <typename ARCHIVE>
839
+ void DoArchive(ARCHIVE& ar)
840
+ {
841
+ ar.Do(&data[0], H*W);
842
+ }
843
+ };
844
+
845
+ template <int H, int W, typename T>
846
+ class mat_traits<Mat<H,W,T>>
847
+ {
848
+ public:
849
+ /// matrix element
850
+ typedef T TELEM;
851
+ /// field of matrix element
852
+ typedef typename mat_traits<T>::TSCAL TSCAL;
853
+ /// type of column vector
854
+ typedef typename Mat<H,W,T>::TV_COL TV_COL;
855
+ /// type of row vector
856
+ typedef typename Mat<H,W,T>::TV_ROW TV_ROW;
857
+ /// matrix height
858
+ // enum { HEIGHT = H };
859
+ static constexpr int HEIGHT = H;
860
+ /// matrix with
861
+ // enum { WIDTH = W };
862
+ static constexpr int WIDTH = W;
863
+ ///
864
+ // enum { IS_COMPLEX = mat_traits<TSCAL>::IS_COMPLEX };
865
+ };
866
+
867
+
868
+
869
+
870
+
871
+
872
+ /**
873
+ A diagonal matrix of fixed size.
874
+ */
875
+ template <int H, typename T = double>
876
+ class DiagMat : public MatExpr<DiagMat<H,T> >
877
+ {
878
+ T data[(H>0) ? H : 1];
879
+ public:
880
+ typedef T TELEM;
881
+ typedef typename mat_traits<T>::TSCAL TSCAL;
882
+ typedef Vec<H, typename mat_traits<T>::TV_COL> TV_COL;
883
+ typedef Vec<H, typename mat_traits<T>::TV_ROW> TV_ROW;
884
+ enum { HEIGHT = H };
885
+ enum { WIDTH = H };
886
+
887
+ /// do not initialize
888
+ DiagMat () { ; }
889
+
890
+ /// copy matrix
891
+ DiagMat (const DiagMat & m)
892
+ : MatExpr<DiagMat> ()
893
+ {
894
+ (*this) = m;
895
+ }
896
+
897
+ /// assign values
898
+ template<typename TB>
899
+ DiagMat (const Expr<TB> & m)
900
+ {
901
+ (*this) = m;
902
+ }
903
+
904
+ /// fill with scalar
905
+ DiagMat (TSCAL s)
906
+ {
907
+ for (int i = 0; i < H; i++)
908
+ data[i] = s;
909
+ }
910
+
911
+ /// assign values
912
+ template<typename TB>
913
+ DiagMat & operator= (const Expr<TB> & m)
914
+ {
915
+ for (int i = 0; i < H; i++)
916
+ data[i] = m.Spec()(i,i);
917
+ return *this;
918
+ }
919
+
920
+ /// copy matrix
921
+ DiagMat & operator= (const DiagMat & m)
922
+ {
923
+ for (int i = 0; i < H; i++)
924
+ data[i] = m.data[i];
925
+ return *this;
926
+ }
927
+
928
+ /// fill values
929
+ DiagMat & operator= (TSCAL s)
930
+ {
931
+ for (int i = 0; i < H; i++)
932
+ data[i] = s;
933
+ return *this;
934
+ }
935
+
936
+ // auto View() const { return DiagMat<H,const T>(*this); }
937
+ INLINE auto View() const { return *this; }
938
+ INLINE tuple<size_t, size_t> Shape() const { return { H,H }; }
939
+
940
+ /// linear access
941
+ TELEM & operator() (int i) { return data[i]; }
942
+ /// access element
943
+ // TELEM & operator() (int i, int j) { return (i==j) ? data[i] : 0; }
944
+ /// linear access
945
+ TELEM operator() (int i) const { return data[i]; }
946
+ TELEM operator[] (int i) const { return data[i]; }
947
+ /// access element
948
+ TELEM operator() (int i, int j) const { return (i==j) ? data[i] : 0; }
949
+
950
+ /// the height
951
+ constexpr size_t Height () const { return H; }
952
+ /// the width
953
+ constexpr size_t Width () const { return H; }
954
+
955
+ static constexpr bool IsLinear() { return false; }
956
+ };
957
+
958
+
959
+
960
+ template <int W, typename T = double, int DIST=W>
961
+ using FlatMatrixFixWidth = MatrixView<T,RowMajor,size_t,IC<W>,IC<DIST>>;
962
+
963
+
964
+ /**
965
+ A Matrix class with memory allocation/deallocation
966
+ */
967
+ template <int W, typename T = double>
968
+ class MatrixFixWidth : public FlatMatrixFixWidth<W,T>
969
+ {
970
+ public:
971
+ typedef typename mat_traits<T>::TSCAL TSCAL;
972
+
973
+ INLINE MatrixFixWidth () : FlatMatrixFixWidth<W,T> (0, nullptr) { ; }
974
+
975
+ /// allocate matrix of size ah * ah
976
+ INLINE MatrixFixWidth (int ah) : FlatMatrixFixWidth<W,T> (ah, new T[ah*W]) { ; }
977
+
978
+ /// delete memory
979
+ INLINE ~MatrixFixWidth() { delete [] this->data; }
980
+
981
+ /// sets new size of matrix
982
+ INLINE void SetSize(int ah)
983
+ {
984
+ if (this->h == ah) return;
985
+ delete [] this->data;
986
+ this->h = ah;
987
+ this->data = new T[this->h * W];
988
+ }
989
+
990
+ /// assign matrix, sizes must match
991
+ template<typename TB>
992
+ INLINE MatrixFixWidth & operator= (const Expr<TB> & m)
993
+ {
994
+ FlatMatrixFixWidth<W,T>::operator= (m);
995
+ return *this;
996
+ }
997
+
998
+ INLINE MatrixFixWidth & operator= (const MatrixFixWidth & m)
999
+ {
1000
+ FlatMatrixFixWidth<W,T>::operator= (m);
1001
+ return *this;
1002
+ }
1003
+
1004
+
1005
+ INLINE MatrixFixWidth & operator= (MatrixFixWidth && m)
1006
+ {
1007
+ this->h = m.h;
1008
+ ngcore::Swap (this->data, m.data);
1009
+ return *this;
1010
+ }
1011
+
1012
+ /// fill matrix with scalar
1013
+ INLINE MatrixFixWidth & operator= (TSCAL s)
1014
+ {
1015
+ FlatMatrixFixWidth<W,T>::operator= (s);
1016
+ return *this;
1017
+ }
1018
+ };
1019
+
1020
+
1021
+
1022
+
1023
+
1024
+
1025
+
1026
+ /**
1027
+ A Matrix which height is known at compile time
1028
+ No memory allocation/deallocation. User must provide memory.
1029
+ Matrix is stored colum-wise
1030
+ */
1031
+
1032
+
1033
+ template <int H, typename T = double, int DIST=H>
1034
+ using FlatMatrixFixHeight = MatrixView<T,ColMajor,IC<H>,size_t,IC<DIST>>;
1035
+
1036
+
1037
+ /**
1038
+ A Matrix class with memory allocation/deallocation
1039
+ */
1040
+ template <int H, typename T = double>
1041
+ class MatrixFixHeight : public FlatMatrixFixHeight<H,T>
1042
+ {
1043
+ public:
1044
+ typedef typename mat_traits<T>::TSCAL TSCAL;
1045
+
1046
+ /// allocate matrix of size ah * ah
1047
+ MatrixFixHeight (int aw) : FlatMatrixFixHeight<H,T> (aw, new T[aw*H]) { ; }
1048
+
1049
+ /// delete memory
1050
+ ~MatrixFixHeight() { delete [] this->data; }
1051
+
1052
+ /// sets new size of matrix
1053
+ void SetSize(int aw)
1054
+ {
1055
+ if (this->w == aw) return;
1056
+ delete [] this->data;
1057
+ this->w = aw;
1058
+ this->data = new T[H*this->w];
1059
+ }
1060
+
1061
+ /// assign matrix, sizes must match
1062
+ template<typename TB>
1063
+ MatrixFixHeight & operator= (const Expr<TB> & m)
1064
+ {
1065
+ int k = 0;
1066
+ for (int j = 0; j < this->w; j++)
1067
+ for (int i = 0; i < H; i++)
1068
+ {
1069
+ this->data[k] = m.Spec()(i,j);
1070
+ k++;
1071
+ }
1072
+ return *this;
1073
+ }
1074
+
1075
+ /// fill matrix with scalar
1076
+ MatrixFixHeight & operator= (TSCAL s)
1077
+ {
1078
+ FlatMatrixFixHeight<H,T>::operator= (s);
1079
+ return *this;
1080
+ }
1081
+ };
1082
+
1083
+
1084
+
1085
+
1086
+
1087
+ template <typename T, ORDERING ORD, typename TH, typename TW, typename TDIST>
1088
+ class MatrixView : public MatExpr<MatrixView<T,ORD,TH,TW,TDIST>>
1089
+ {
1090
+ protected:
1091
+ typedef MatExpr<MatrixView<T,ORD,TH,TW,TDIST>> BASE;
1092
+ /// the height
1093
+ NO_UNIQUE_ADDRESS TH h;
1094
+ /// the width
1095
+ NO_UNIQUE_ADDRESS TW w;
1096
+ /// the distance
1097
+ NO_UNIQUE_ADDRESS TDIST dist;
1098
+ /// the data
1099
+ T * __restrict data;
1100
+ public:
1101
+
1102
+ /// element type
1103
+ typedef T TELEM;
1104
+ /// scalar type of elements (double or Complex)
1105
+ typedef typename mat_traits<T>::TSCAL TSCAL;
1106
+ static constexpr bool IsLinear() { return false; }
1107
+ //
1108
+ MatrixView() = default;
1109
+ // : h{0}, w{0}, dist{0}, data{nullptr} { }
1110
+ MatrixView(const MatrixView &) = default;
1111
+
1112
+ template <typename T2, typename TH2, typename TW2, typename TDIST2,
1113
+ enable_if_t<is_convertible<T2*,T*>::value, int> =0,
1114
+ enable_if_t<is_constructible<TH,TH2>::value, int> =0,
1115
+ enable_if_t<is_constructible<TW,TW2>::value, int> =0,
1116
+ enable_if_t<is_constructible<TDIST,TDIST2>::value, int> =0>
1117
+ INLINE MatrixView (const MatrixView<T2, ORD, TH2, TW2, TDIST2> & m2)
1118
+ : h{TH(m2.Height())}, w{TW(m2.Width())}, dist{TDIST(m2.Dist())}, data{m2.Data()} { }
1119
+
1120
+ template <typename T2, typename TH2, typename TW2, typename TDIST2,
1121
+ enable_if_t<is_convertible<T2*,T*>::value, int> =0,
1122
+ enable_if_t<is_constructible<TH,TH2>::value, int> =0,
1123
+ enable_if_t<is_constructible<TW,TW2>::value, int> =0,
1124
+ enable_if_t<is_same<unused_dist,TDIST2>::value, int> =0>
1125
+ INLINE MatrixView (const MatrixView<T2, ORD, TH2, TW2, TDIST2> & m2)
1126
+ : h{TH(m2.Height())}, w{TW(m2.Width())}, dist{TDIST(m2.Dist())}, data{m2.Data()} { }
1127
+
1128
+
1129
+ /// set height, width, dist, and mem
1130
+ INLINE MatrixView (TH ah, TW aw, TDIST adist, T * adata)
1131
+ : h(ah), w(aw), dist(adist), data(adata) { ; }
1132
+
1133
+ /// set height, width, dist, and mem
1134
+ INLINE MatrixView (TH ah, TW aw, T * adata)
1135
+ : h(ah), w(aw), data(adata)
1136
+ {
1137
+ static_assert(std::is_same<TDIST, unused_dist>(), "MatrixView needs dist");
1138
+ }
1139
+
1140
+ INLINE MatrixView (size_t ah, size_t aw, LocalHeap & lh)
1141
+ : h(ah), w(aw), data (lh.Alloc<T>(ah*aw))
1142
+ {
1143
+ static_assert(std::is_same<TDIST, unused_dist>(), "MatrixView(lh) needs dist");
1144
+ }
1145
+
1146
+ template<typename TB>
1147
+ INLINE MatrixView (const LocalHeapExpr<TB> & m2)
1148
+ {
1149
+ static_assert(std::is_same<TDIST, unused_dist>(), "MatrixView(lh-expr) needs dist");
1150
+ h = m2.A().Height();
1151
+ w = m2.A().Width();
1152
+ LocalHeap & lh = m2.GetLocalHeap();
1153
+ data = lh.Alloc<T> (h*w);
1154
+ this->operator= (m2.A());
1155
+ }
1156
+
1157
+
1158
+ INLINE MatrixView (size_t s, T * adata)
1159
+ : data(adata)
1160
+ {
1161
+ if constexpr (is_IC<TW>() && is_IC<TDIST>())
1162
+ h = s;
1163
+ else if constexpr (is_IC<TH>() && is_IC<TDIST>())
1164
+ w = s;
1165
+ else if constexpr (is_IC<TH>() && is_IC<TW>())
1166
+ dist = s;
1167
+ else if constexpr (is_same<TDIST,unused_dist>())
1168
+ h = w = s;
1169
+ // else
1170
+ // static_assert(false, "illegal 1-size ctor of MatrixView");
1171
+ }
1172
+
1173
+ INLINE MatrixView (size_t s, LocalHeap & lh)
1174
+ {
1175
+ if constexpr (is_IC<TW>() && is_IC<TDIST>())
1176
+ h = s;
1177
+ else if constexpr (is_IC<TH>() && is_IC<TDIST>())
1178
+ w = s;
1179
+ else if constexpr (is_IC<TH>() && is_IC<TW>())
1180
+ dist = s;
1181
+ else if constexpr (is_same<TDIST,unused_dist>())
1182
+ h = w = s;
1183
+
1184
+ data = lh.Alloc<T>(h*w);
1185
+ // else
1186
+ // static_assert(false, "illegal 1-size ctor of MatrixView");
1187
+ }
1188
+
1189
+
1190
+ template <typename T2>
1191
+ static auto ICOrVal (size_t val)
1192
+ {
1193
+ if constexpr (is_IC<T2>())
1194
+ return T2();
1195
+ else
1196
+ return val;
1197
+ }
1198
+
1199
+ /*
1200
+ MatrixView (FlatMatrix<T,ORD> mat)
1201
+ : h(ICOrVal<TH>(mat.Height())),
1202
+ w(ICOrVal<TW>(mat.Width())),
1203
+ dist(ICOrVal<TDIST>(mat.Dist())), data(mat.Data())
1204
+ { ; }
1205
+ */
1206
+
1207
+ /*
1208
+ template<int W, int DIST>
1209
+ MatrixView (FlatMatrixFixInner<W,T,DIST,ORD> mat)
1210
+ : h(mat.Height()), w(mat.Width()), dist(mat.Dist()), data(mat.Data())
1211
+ { ; }
1212
+ */
1213
+
1214
+ template<int H, int W>
1215
+ INLINE MatrixView (const Mat<H,W,T> & mat)
1216
+ : h(mat.Height()), w(mat.Width()), dist(mat.Width()), data(const_cast<T*>(mat.Data()))
1217
+ {
1218
+ static_assert(ORD==RowMajor);
1219
+ }
1220
+ /*
1221
+ template<int H, int W>
1222
+ INLINE MatrixView(const Mat<H,W,const T> & mat)
1223
+ : h(mat.Height()), w(mat.Width()), dist(mat.Width()), data(const_cast<T*>(mat.Data()))
1224
+ {
1225
+ static_assert(ORD==RowMajor);
1226
+ }
1227
+ */
1228
+
1229
+
1230
+ /// assign contents
1231
+ template<typename TB>
1232
+ INLINE MatrixView & operator= (const Expr<TB> & m)
1233
+ {
1234
+ BASE::operator= (m);
1235
+ return *this;
1236
+ }
1237
+
1238
+ INLINE MatrixView & operator= (const MatrixView & m)
1239
+ {
1240
+ BASE::operator= (m);
1241
+ return *this;
1242
+ }
1243
+
1244
+ /// assign constant
1245
+ INLINE MatrixView & operator= (TSCAL s)
1246
+ {
1247
+ if (InnerSize() == 0) return *this;
1248
+ for (size_t i = 0; i < OuterSize(); i++)
1249
+ for (size_t j = 0; j < InnerSize(); j++)
1250
+ data[i*Dist()+j] = s;
1251
+ return *this;
1252
+ }
1253
+
1254
+ INLINE auto View() const { return *this; }
1255
+ INLINE auto ViewRW() { return *this; }
1256
+ INLINE auto Shape() const { return tuple(h,w); }
1257
+
1258
+ INLINE TELEM * Addr(size_t i, size_t j) const
1259
+ {
1260
+ if constexpr (ORD==RowMajor)
1261
+ return data+i*Dist()+j;
1262
+ else
1263
+ return data+j*Dist()+i;
1264
+ }
1265
+
1266
+
1267
+ /// access operator
1268
+ INLINE TELEM & operator() (size_t i, size_t j) const
1269
+ {
1270
+ NETGEN_CHECK_RANGE(i, 0, Height());
1271
+ NETGEN_CHECK_RANGE(j, 0, Width());
1272
+ return *Addr(i,j);
1273
+ }
1274
+
1275
+ /// access operator, linear access
1276
+ INLINE TELEM & operator() (size_t i) const
1277
+ {
1278
+ NETGEN_CHECK_RANGE(i, 0, Height()*Dist());
1279
+ return data[i];
1280
+ }
1281
+
1282
+ INLINE auto RowDist() const
1283
+ {
1284
+ if constexpr (ORD==RowMajor)
1285
+ return IC<1>();
1286
+ else
1287
+ return Dist();
1288
+ }
1289
+
1290
+ INLINE auto ColDist() const
1291
+ {
1292
+ if constexpr (ORD==RowMajor)
1293
+ return Dist();
1294
+ else
1295
+ return IC<1>();
1296
+ }
1297
+
1298
+
1299
+ INLINE auto Height () const { return h; }
1300
+ INLINE auto Width () const { return w; }
1301
+ INLINE auto Dist () const
1302
+ {
1303
+ if constexpr (std::is_same<TDIST, unused_dist>())
1304
+ {
1305
+ if constexpr (ORD==RowMajor)
1306
+ return Width();
1307
+ else
1308
+ return Height();
1309
+ }
1310
+ else
1311
+ return dist;
1312
+ }
1313
+
1314
+ INLINE T* Data() const { return data; }
1315
+ INLINE auto InnerSize () const
1316
+ {
1317
+ if constexpr (ORD==RowMajor)
1318
+ return Width();
1319
+ else
1320
+ return Height();
1321
+ }
1322
+
1323
+ INLINE auto OuterSize () const
1324
+ {
1325
+ if constexpr (ORD==RowMajor)
1326
+ return Height();
1327
+ else
1328
+ return Width();
1329
+ }
1330
+
1331
+ using BASE::Rows;
1332
+ using BASE::Cols;
1333
+
1334
+ MatrixView<T,ORD> AddSize (size_t h, size_t w) const
1335
+ {
1336
+ NETGEN_CHECK_RANGE(h, Height(), Height()+1);
1337
+ NETGEN_CHECK_RANGE(w, Width(), Width()+1);
1338
+ return MatrixView<T,ORD,size_t,size_t,size_t> (h, w, dist, data);
1339
+ }
1340
+
1341
+ INLINE auto SplitRows (size_t split) const
1342
+ {
1343
+ return tuple(Rows(0,split), Rows(split, Height()));
1344
+ }
1345
+
1346
+ INLINE auto SplitCols (size_t split) const
1347
+ {
1348
+ return tuple(Cols(0,split), Cols(split, Width()));
1349
+ }
1350
+
1351
+ INLINE auto Row (size_t i) const
1352
+ {
1353
+ return VectorView(Width(), RowDist(), Addr(i,0));
1354
+ }
1355
+
1356
+ INLINE auto Col (size_t i) const
1357
+ {
1358
+ return VectorView(Height(), ColDist(), Addr(0,i));
1359
+ }
1360
+
1361
+ INLINE auto Cols (size_t first, size_t next) const
1362
+ {
1363
+ if constexpr (ORD==RowMajor)
1364
+ return MatrixView<T,ORD,TH,size_t,size_t> (h, next-first, Dist(), Addr(0,first));
1365
+ else
1366
+ return MatrixView<T,ORD,TH,size_t,TDIST> (h, next-first, Dist(), Addr(0,first));
1367
+ }
1368
+
1369
+ INLINE auto Cols (size_t next) const
1370
+ {
1371
+ return Cols(0, next);
1372
+ }
1373
+
1374
+
1375
+ INLINE auto Rows (size_t first, size_t next) const
1376
+ {
1377
+ if constexpr (ORD==RowMajor)
1378
+ return MatrixView<T,ORD,size_t,TW,TDIST> (next-first, w, Dist(), Addr(first, 0));
1379
+ else
1380
+ return MatrixView<T,ORD,size_t,TW,size_t> (next-first, w, Dist(), Addr(first, 0));
1381
+ }
1382
+
1383
+ INLINE auto Rows (IntRange range) const
1384
+ {
1385
+ return Rows (range.First(), range.Next());
1386
+ }
1387
+
1388
+ INLINE auto Rows (size_t next) const
1389
+ {
1390
+ return Rows (0, next);
1391
+ }
1392
+
1393
+ template <int R>
1394
+ INLINE auto Rows() const
1395
+ {
1396
+ if constexpr (ORD==RowMajor)
1397
+ return MatrixView<T,ORD,IC<R>,TW,TDIST> (IC<R>(), w, Dist(), Addr(0,0));
1398
+ else
1399
+ return MatrixView<T,ORD,IC<R>,TW,size_t> (IC<R>(), w, Dist(), Addr(0,0));
1400
+ }
1401
+
1402
+ INLINE auto Cols (IntRange range) const
1403
+ {
1404
+ return Cols (range.First(), range.Next());
1405
+ }
1406
+
1407
+ /*
1408
+ ///
1409
+ INLINE operator const FlatMatrix<T,ORD>() const
1410
+ {
1411
+ // static_assert( Dist() == InnerSize() );
1412
+ return FlatMatrix<T,ORD> (Height(), Width(), data);
1413
+ }
1414
+ */
1415
+
1416
+ auto AsVector() const
1417
+ {
1418
+ // static_assert( Dist() == InnerSize() );
1419
+ return FlatVector<T> (h*w, data);
1420
+ }
1421
+
1422
+ auto Bare() const
1423
+ {
1424
+ return make_BareSliceMatrix(*this);
1425
+ }
1426
+
1427
+ INLINE auto RemoveConst() const
1428
+ { return MatrixView<typename remove_const<T>::type,ORD,TH,TW,TDIST>
1429
+ (h,w,dist, const_cast<typename remove_const<T>::type*> (data)); }
1430
+
1431
+ void IncPtr (size_t inc) { data += inc; } // should be only for bare
1432
+
1433
+
1434
+ const auto RowSlice(size_t first, size_t adist) const
1435
+ {
1436
+ static_assert (ORD==RowMajor);
1437
+ // NETGEN_CHECK_RANGE(first, 0, Height()); // too restrictive
1438
+ NETGEN_CHECK_RANGE(first, 0, adist);
1439
+ return BareSliceMatrix<T,ORD> (Height()/adist, Width(), Dist()*adist, data+first*Dist());
1440
+ }
1441
+
1442
+
1443
+ INLINE SliceVector<T> Diag () const
1444
+ {
1445
+ if (ORD == RowMajor)
1446
+ return SliceVector<T> (h, Dist()+1, data);
1447
+ else
1448
+ return SliceVector<T> (w, Dist()+1, data);
1449
+ }
1450
+
1451
+ INLINE SliceVector<T> Diag (int offset) const
1452
+ {
1453
+ // return SliceVector<T> (h, dist+1, data);
1454
+ int dp = std::max(offset, 0);
1455
+ int dm = std::min(offset, 0);
1456
+ if (ORD == RowMajor)
1457
+ return SliceVector<T> (min(w-dp, h+dm), Dist()+1, data+dp-dm*Dist());
1458
+ else
1459
+ return SliceVector<T> (min(w-dp, h+dm), Dist()+1, data-dm+dp*Dist());
1460
+ }
1461
+
1462
+ // [[deprecated("Use placenement ctor: new(ptr) Matrix(n, lh); instead!")]]
1463
+ void AssignMemory (size_t s, LocalHeap & lh)
1464
+ {
1465
+ new (this) MatrixView(s, lh);
1466
+ }
1467
+
1468
+ void AssignMemory (size_t ah, size_t aw, T * data)
1469
+ {
1470
+ static_assert(std::is_same<TDIST, unused_dist>(), "MatrixView::AssignMemory needs unused-dist");
1471
+ new (this) MatrixView(ah, aw, data);
1472
+ }
1473
+
1474
+ void AssignMemory (size_t ah, size_t aw, LocalHeap & lh)
1475
+ {
1476
+ static_assert(std::is_same<TDIST, unused_dist>(), "MatrixView::AssignMemory needs unused-dist");
1477
+ new (this) MatrixView(ah, aw, lh);
1478
+ }
1479
+
1480
+ auto Assign (const MatrixView & m)
1481
+ {
1482
+ data = m.data;
1483
+ h = m.h;
1484
+ w = m.w;
1485
+ dist = m.dist;
1486
+ return *this;
1487
+ }
1488
+
1489
+ auto Swap (MatrixView & m)
1490
+ {
1491
+ ngcore::Swap (data, m.data);
1492
+ ngcore::Swap (h, m.h);
1493
+ ngcore::Swap (w, m.w);
1494
+ ngcore::Swap (dist, m.dist);
1495
+ return *this;
1496
+ }
1497
+
1498
+ auto Reshape(size_t h2, size_t w2)
1499
+ {
1500
+ static_assert(std::is_same<TDIST, unused_dist>(), "MatrixView::Reshape needs unused-dist");
1501
+ return FlatMatrix<T,ORD>{h2,w2,data};
1502
+ }
1503
+
1504
+
1505
+ // template <typename TH2, typename TW2>
1506
+ // operator MatrixView<T,ORD,TH2,TW2,size_t>() const { return { Height(), Width(), Dist(), Data() }; }
1507
+ };
1508
+
1509
+
1510
+
1511
+
1512
+
1513
+
1514
+
1515
+
1516
+ template <typename T, ORDERING ORDER>
1517
+ SliceMatrix<T,ORDER> make_SliceMatrix (FlatMatrix<T,ORDER> mat) { return mat; }
1518
+
1519
+ template <int H, int W, typename T>
1520
+ SliceMatrix<T,RowMajor> make_SliceMatrix (const Mat<H,W,T> &mat) { return const_cast<Mat<H,W,T>&>(mat); }
1521
+
1522
+ /*
1523
+ template <typename T, ORDERING ORDER, typename TH, typename TW, typename TD>
1524
+ SliceMatrix<T,ORDER> make_SliceMatrix (MatrixView<T,ORDER,TH,TW,TD> mat) { return mat; }
1525
+ */
1526
+ template <typename T, ORDERING ORDER, typename ...Args>
1527
+ SliceMatrix<T,ORDER> make_SliceMatrix (MatrixView<T, ORDER, Args...> mat) { return mat; }
1528
+
1529
+
1530
+ template <typename T, ORDERING ORDER>
1531
+ BareSliceMatrix<T,ORDER> make_BareSliceMatrix (FlatMatrix<T,ORDER> mat) { return mat; }
1532
+
1533
+ template <int H, int W, typename T>
1534
+ BareSliceMatrix<T,RowMajor> make_BareSliceMatrix (const Mat<H,W,T> &mat) { return const_cast<Mat<H,W,T>&>(mat); }
1535
+
1536
+ template <typename T, ORDERING ORDER, typename TH, typename TW, typename TDIST>
1537
+ BareSliceMatrix<T,ORDER> make_BareSliceMatrix (MatrixView<T,ORDER,TH,TW,TDIST> mat) { return mat; }
1538
+
1539
+
1540
+
1541
+
1542
+
1543
+
1544
+
1545
+
1546
+ template <typename T = double>
1547
+ class DoubleSliceMatrix : public MatExpr<DoubleSliceMatrix<T> >
1548
+ {
1549
+ protected:
1550
+ /// the height
1551
+ size_t h;
1552
+ /// the width
1553
+ size_t w;
1554
+ /// the distance
1555
+ size_t distr, distc;
1556
+ /// the data
1557
+ T * data;
1558
+ public:
1559
+
1560
+ /// element type
1561
+ typedef T TELEM;
1562
+ /// scalar type of elements (double or Complex)
1563
+ typedef typename mat_traits<T>::TSCAL TSCAL;
1564
+
1565
+ static constexpr bool IsLinear() { return false; }
1566
+
1567
+ /// set height, width, and mem
1568
+ DoubleSliceMatrix (int ah, int aw, int adistr, int adistc, T * adata)
1569
+ : h(ah), w(aw), distr(adistr), distc(adistc), data(adata) { ; }
1570
+
1571
+ /// assign contents
1572
+ template<typename TB>
1573
+ DoubleSliceMatrix & operator= (const Expr<TB> & m)
1574
+ {
1575
+ return MatExpr<DoubleSliceMatrix>::operator= (m);
1576
+ }
1577
+
1578
+ /// assign constant
1579
+ DoubleSliceMatrix & operator= (TSCAL s)
1580
+ {
1581
+ for (size_t i = 0; i < h; i++)
1582
+ for (size_t j = 0; j < w; j++)
1583
+ data[i*distr+j*distc] = s;
1584
+ return *this;
1585
+ }
1586
+
1587
+ INLINE auto View() const { return *this; }
1588
+ INLINE auto ViewRW() { return *this; }
1589
+ INLINE tuple<size_t,size_t> Shape() const { return { h, w }; }
1590
+
1591
+ /// access operator
1592
+ TELEM & operator() (size_t i, size_t j) const
1593
+ {
1594
+ NETGEN_CHECK_RANGE(i, 0, Height());
1595
+ NETGEN_CHECK_RANGE(j, 0, Width());
1596
+ return data[i*distr+j*distc];
1597
+ }
1598
+
1599
+ /// access operator, linear access
1600
+ TELEM & operator() (size_t i) const
1601
+ {
1602
+ NETGEN_CHECK_RANGE(i, 0, Height()*Width());
1603
+ return data[i];
1604
+ }
1605
+
1606
+ size_t Height () const { return h; }
1607
+ size_t Width () const { return w; }
1608
+ size_t DistRow () const { return distr; }
1609
+ size_t DistCol () const { return distc; }
1610
+ T * Data () const { return data; }
1611
+
1612
+ const DoubleSliceMatrix Rows (size_t first, size_t next) const
1613
+ {
1614
+ return DoubleSliceMatrix (next-first, w, distr, distc, data+first*distr);
1615
+ }
1616
+
1617
+ const DoubleSliceMatrix<T> Cols (size_t first, size_t next) const
1618
+ {
1619
+ return DoubleSliceMatrix<T> (h, next-first, distr, distc, data+first*distc);
1620
+ }
1621
+
1622
+ const DoubleSliceMatrix Rows (IntRange range) const
1623
+ {
1624
+ return Rows(range.First(), range.Next());
1625
+ }
1626
+
1627
+ const DoubleSliceMatrix<T> Cols (IntRange range) const
1628
+ {
1629
+ return Cols(range.First(), range.Next());
1630
+ }
1631
+ };
1632
+
1633
+
1634
+ template <typename T>
1635
+ constexpr bool IsTrivialTranspose () { return IsScalar<T>(); }
1636
+
1637
+
1638
+ constexpr ORDERING operator! (ORDERING ordering)
1639
+ {
1640
+ return ordering == ColMajor ? RowMajor : ColMajor;
1641
+ }
1642
+
1643
+
1644
+
1645
+ template <typename T, ORDERING ord,
1646
+ typename enable_if<IsTrivialTranspose<T>(),int>::type = 0>
1647
+ INLINE auto Trans (FlatMatrix<T,ord> mat)
1648
+ {
1649
+ return FlatMatrix<T,!ord> (mat.Width(), mat.Height(), mat.Data());
1650
+ }
1651
+
1652
+ template <typename T, ORDERING ord,
1653
+ typename enable_if<IsTrivialTranspose<T>(),int>::type = 0>
1654
+ INLINE auto Trans (const Matrix<T,ord> & mat)
1655
+ {
1656
+ return FlatMatrix<T,!ord> (mat.Width(), mat.Height(), mat.Data());
1657
+ }
1658
+
1659
+
1660
+ template <typename T, ORDERING ord, typename TH, typename TW, typename TD,
1661
+ typename enable_if<IsTrivialTranspose<T>(),int>::type = 0>
1662
+ INLINE const auto Trans (MatrixView<T,ord,TH,TW,TD> mat)
1663
+ {
1664
+ return MatrixView<T,!ord,TW,TH,TD> (mat.Width(), mat.Height(), mat.Dist(), mat.Data());
1665
+ }
1666
+
1667
+
1668
+
1669
+
1670
+
1671
+
1672
+ template <class TM, class TSCAL>
1673
+ class Scalar2ElemMatrix
1674
+ {
1675
+ public:
1676
+ const BareSliceMatrix<TSCAL> mat;
1677
+ Scalar2ElemMatrix (const BareSliceMatrix<TSCAL> amat) : mat(amat) { ; }
1678
+
1679
+ /*
1680
+ enum { H = mat_traits<TM>::HEIGHT };
1681
+ enum { W = mat_traits<TM>::WIDTH };
1682
+ */
1683
+ enum { H = Height<TM>() };
1684
+ enum { W = Width<TM>() };
1685
+
1686
+ TM operator() (size_t i, size_t j) const
1687
+ {
1688
+ /*
1689
+ TM ret;
1690
+ for (size_t k = 0; k < H; k++)
1691
+ for (size_t l = 0; l < W; l++)
1692
+ Access(ret, k,l) = mat(i*H+k, j*W+l);
1693
+ return ret;
1694
+ */
1695
+ if constexpr (IsScalar<TM>())
1696
+ {
1697
+ return mat(i,j);
1698
+ }
1699
+ else
1700
+ {
1701
+ TM ret;
1702
+ for (size_t k = 0; k < H; k++)
1703
+ for (size_t l = 0; l < W; l++)
1704
+ ret(k,l) = mat(i*H+k, j*W+l);
1705
+ return ret;
1706
+ }
1707
+ }
1708
+
1709
+ Scalar2ElemMatrix Rows(size_t first, size_t next) const
1710
+ {
1711
+ return Scalar2ElemMatrix(mat.Rows(H*first, H*next));
1712
+ }
1713
+ };
1714
+
1715
+
1716
+
1717
+
1718
+
1719
+
1720
+ /**
1721
+ Identity Matrix of fixed size
1722
+ */
1723
+ template <size_t H>
1724
+ class Id : public MatExpr<Id<H> >
1725
+ {
1726
+ public:
1727
+ typedef double TELEM;
1728
+ typedef double TSCAL;
1729
+ typedef Vec<H, double> TV_COL;
1730
+ typedef Vec<H, double> TV_ROW;
1731
+ enum { HEIGHT = H };
1732
+ enum { WIDTH = H };
1733
+ static constexpr bool IsLinear() { return false; }
1734
+ /// nothing to do
1735
+ Id () { ; }
1736
+
1737
+ INLINE auto View() const { return Id(); }
1738
+ INLINE constexpr auto Height () const { return H; }
1739
+ INLINE constexpr auto Width () const { return H; }
1740
+ INLINE tuple<size_t, size_t> Shape() const { return { H,H }; }
1741
+ ///
1742
+ double operator() (int i) const
1743
+ {
1744
+ static_assert (true, "linear access of id");
1745
+ return 0;
1746
+ // cerr << "id, linear access" << endl; return 0;
1747
+ }
1748
+ ///
1749
+ double operator() (int i, int j) const { return (i == j) ? 1 : 0; }
1750
+
1751
+ };
1752
+
1753
+
1754
+
1755
+
1756
+ /// Variable size identity matrix
1757
+ class Identity : public MatExpr<Identity >
1758
+ {
1759
+ size_t size;
1760
+ public:
1761
+ typedef double TELEM;
1762
+ typedef double TSCAL;
1763
+ static constexpr bool IsLinear() { return false; }
1764
+
1765
+ INLINE Identity (size_t s) : size(s) { ; }
1766
+
1767
+ INLINE double operator() (int i) const
1768
+ {
1769
+ static_assert (true, "linear access of Identity");
1770
+ return 0;
1771
+ // cerr << "Identity, linear access" << endl; return 0;
1772
+ }
1773
+
1774
+ INLINE double operator() (int i, int j) const { return (i == j) ? 1 : 0; }
1775
+ INLINE auto View() const { return Identity(size); }
1776
+ INLINE tuple<size_t, size_t> Shape() const { return { size, size }; }
1777
+ INLINE auto Height () const { return size; }
1778
+ INLINE auto Width () const { return size; }
1779
+ };
1780
+
1781
+
1782
+
1783
+
1784
+
1785
+ template<int H, int W, typename T>
1786
+ inline std::ostream & operator<< (std::ostream & s, const Mat<H,W,T> & m)
1787
+ {
1788
+ for (int i = 0; i < H*W; i++)
1789
+ s << " " << setw(7) << m(i);
1790
+ return s;
1791
+ }
1792
+
1793
+
1794
+
1795
+ template <int H, int W, typename T>
1796
+ INLINE auto Trans (const Mat<H,W,T> & mat)
1797
+ -> Mat<W,H,decltype(Trans(mat(0,0)))>
1798
+ {
1799
+ Mat<W,H,decltype(Trans(mat(0,0)))> res;
1800
+ /*
1801
+ for (int i = 0; i < H; i++)
1802
+ for (int j = 0; j < W; j++)
1803
+ res(j,i) = mat(i,j);
1804
+ */
1805
+ Iterate<H> ([&] (auto i) {
1806
+ Iterate<W> ([&] (auto j) {
1807
+ res(j.value,i.value) = mat(i.value, j.value);
1808
+ });
1809
+ });
1810
+ return res;
1811
+ }
1812
+
1813
+ template <int H, int W, typename T>
1814
+ INLINE Mat<H,W,T> operator- (const Mat<H,W,T> & mat)
1815
+ {
1816
+ Mat<H,W,typename remove_const<T>::type> res;
1817
+ Iterate<H*W> ([&] (auto i) {
1818
+ res(i.value) = -mat(i.value);
1819
+ });
1820
+ return res;
1821
+ }
1822
+
1823
+
1824
+
1825
+ template <int H, int W, typename T>
1826
+ INLINE Mat<H,W,T> operator+ (const Mat<H,W,T> & ma, const Mat<H,W,T> & mb)
1827
+ {
1828
+ Mat<H,W,typename remove_const<T>::type> res;
1829
+ Iterate<H*W> ([&] (auto i) {
1830
+ res(i.value) = ma(i.value) + mb(i.value);
1831
+ });
1832
+ return res;
1833
+ }
1834
+
1835
+ template <int H, int W, typename T>
1836
+ INLINE Mat<H,W,T> operator- (const Mat<H,W,T> & ma, const Mat<H,W,T> & mb)
1837
+ {
1838
+ Mat<H,W,typename remove_const<T>::type> res;
1839
+ Iterate<H*W> ([&] (auto i) {
1840
+ res(i.value) = ma(i.value) - mb(i.value);
1841
+ });
1842
+ return res;
1843
+ }
1844
+
1845
+ template <int H, int W, typename T>
1846
+ INLINE Mat<H,W,T> & operator+= (Mat<H,W,T> & ma, const Mat<H,W,T> & mb)
1847
+ {
1848
+ Iterate<H*W> ([&] (auto i) {
1849
+ ma(i.value) += mb(i.value);
1850
+ });
1851
+ return ma;
1852
+ }
1853
+
1854
+ template <int H, int W, typename T>
1855
+ INLINE Mat<H,W,T> & operator-= (Mat<H,W,T> & ma, const Mat<H,W,T> & mb)
1856
+ {
1857
+ Iterate<H*W> ([&] (auto i) {
1858
+ ma(i.value) -= mb(i.value);
1859
+ });
1860
+ return ma;
1861
+ }
1862
+
1863
+
1864
+
1865
+ template <int H, int W, typename T>
1866
+ INLINE Mat<H,W,T> operator* (T scal, const Mat<H,W,T> & mat)
1867
+ {
1868
+ Mat<H,W,typename remove_const<T>::type> res;
1869
+ Iterate<H*W> ([&] (auto i) {
1870
+ res(i.value) = scal * mat(i.value);
1871
+ });
1872
+ return res;
1873
+ }
1874
+
1875
+
1876
+ template <int H, int W, int W2, typename T1, typename T2>
1877
+ INLINE auto operator* (const Mat<H,W,T1> & mat1, const Mat<W,W2,T2> & mat2)
1878
+ -> Mat<H,W2,decltype( RemoveConst(mat1(0,0)*mat2(0,0)))>
1879
+ {
1880
+ typedef decltype( RemoveConst(mat1(0,0)*mat2(0))) TRES;
1881
+ Mat<H,W2,TRES> res;
1882
+ for (int i = 0; i < H; i++)
1883
+ for (int j = 0; j < W2; j++)
1884
+ {
1885
+ TRES sum(0);
1886
+ for (int k = 0; k < W; k++)
1887
+ sum += mat1(i,k) * mat2(k,j);
1888
+ res(i,j) = sum;
1889
+ }
1890
+ return res;
1891
+ }
1892
+
1893
+
1894
+ template <int H, int W, int W2, typename T1, typename T2>
1895
+ INLINE auto operator* (const Mat<H,W,T1> & mat, const Vec<W2,T2> & vec)
1896
+ -> Vec<H, decltype(RemoveConst(mat(0,0)*vec(0)))>
1897
+ {
1898
+ static_assert(W == W2, "Mat * Vec dimension mismatch!");
1899
+ typedef decltype(RemoveConst(mat(0,0)*vec(0))) TRES;
1900
+ Vec<H, TRES> res = TRES(0);
1901
+ for (int i = 0; i < H; i++)
1902
+ for (int j = 0; j < W; j++)
1903
+ res(i) += mat(i,j) * vec(j);
1904
+ return res;
1905
+ }
1906
+
1907
+ template <int H, int W, int W2, typename T1, typename T2>
1908
+ INLINE auto operator* (const Mat<H,W,T1> & mat, const FlatVec<W2,T2> & vec)
1909
+ -> Vec<H, decltype(RemoveConst(mat(0,0)*vec(0)))>
1910
+ {
1911
+ static_assert(W == W2, "Mat * FlatVec dimension mismatch!");
1912
+ typedef decltype(RemoveConst(mat(0,0)*vec(0))) TRES;
1913
+ Vec<H, TRES> res = TRES(0);
1914
+ for (int i = 0; i < H; i++)
1915
+ for (int j = 0; j < W; j++)
1916
+ res(i) += mat(i,j) * vec(j);
1917
+ return res;
1918
+ }
1919
+
1920
+ template <int H, int W, typename T1, typename T2>
1921
+ INLINE auto operator* (const Mat<H,W,T1> & mat, FlatVector<T2> vec)
1922
+ -> Vec<H, decltype(RemoveConst(mat(0,0)*vec(0)))>
1923
+ {
1924
+ NETGEN_CHECK_RANGE(vec.Size(), W, W+1);
1925
+ typedef decltype(RemoveConst(mat(0,0)*vec(0))) TRES;
1926
+ Vec<H, TRES> res = TRES(0);
1927
+ for (int i = 0; i < H; i++)
1928
+ for (int j = 0; j < W; j++)
1929
+ res(i) += mat(i,j) * vec(j);
1930
+ return res;
1931
+ }
1932
+
1933
+ template <typename T>
1934
+ auto Det (Mat<0,0,T> m)
1935
+ {
1936
+ return T(1.0);
1937
+ }
1938
+
1939
+
1940
+ template <typename T>
1941
+ auto Det (Mat<1,1,T> m)
1942
+ {
1943
+ return m(0,0);
1944
+ }
1945
+
1946
+ template <typename T>
1947
+ auto Det (Mat<2,2,T> m)
1948
+ {
1949
+ return m(0,0)*m(1,1) - m(0,1)*m(1,0);
1950
+ }
1951
+
1952
+ template <typename T>
1953
+ auto Det (Mat<3,3,T> m)
1954
+ {
1955
+ return
1956
+ m(0) * (m(4) * m(8) - m(5) * m(7)) +
1957
+ m(1) * (m(5) * m(6) - m(3) * m(8)) +
1958
+ m(2) * (m(3) * m(7) - m(4) * m(6));
1959
+ }
1960
+
1961
+
1962
+
1963
+
1964
+
1965
+ template <int H, int W, typename T>
1966
+ INLINE Mat<H,W,T> Adj (Mat<H,W,T> m)
1967
+ {
1968
+ cerr << "Adj<" << H << "," << W << "> not implemented" << endl;
1969
+ return m;
1970
+ }
1971
+
1972
+
1973
+ template <typename T>
1974
+ INLINE Mat<0,0,T> Adj (Mat<0,0,T> m)
1975
+ {
1976
+ return Mat<0,0,T>();
1977
+ }
1978
+
1979
+ template <typename T>
1980
+ INLINE Mat<1,1,T> Adj (Mat<1,1,T> m)
1981
+ {
1982
+ Mat<1,1,T> adj;
1983
+ adj(0,0) = T(1); // m(0,0);
1984
+ return adj;
1985
+ }
1986
+
1987
+ template <typename T>
1988
+ INLINE Mat<2,2,T> Adj (Mat<2,2,T> m)
1989
+ {
1990
+ Mat<2,2,T> adj;
1991
+ adj(0,0) = m(1,1);
1992
+ adj(0,1) = -m(0,1);
1993
+ adj(1,0) = -m(1,0);
1994
+ adj(1,1) = m(0,0);
1995
+ return adj;
1996
+ }
1997
+
1998
+
1999
+ template <typename T>
2000
+ INLINE Mat<3,3,T> Adj (Mat<3,3,T> m)
2001
+ {
2002
+ Mat<3,3,T> adj;
2003
+ adj(0,0) = m(4)*m(8)-m(5)*m(7);
2004
+ adj(0,1) = -(m(1) * m(8) - m(2) * m(7));
2005
+ adj(0,2) = m(1) * m(5) - m(2) * m(4);
2006
+
2007
+ adj(1,0) = m(5)*m(6)-m(3)*m(8);
2008
+ adj(1,1) = m(0) * m(8) - m(2) * m(6);
2009
+ adj(1,2) = -(m(0) * m(5) - m(2) * m(3));
2010
+
2011
+ adj(2,0) = (m(3)*m(7)-m(4)*m(6));
2012
+ adj(2,1) = -(m(0) * m(7) - m(1) * m(6));
2013
+ adj(2,2) = (m(0) * m(4) - m(1) * m(3));
2014
+ return adj;
2015
+ }
2016
+
2017
+
2018
+
2019
+ template <int H, int W, typename T>
2020
+ INLINE Mat<H,W,T> Cof (Mat<H,W,T> m)
2021
+ {
2022
+ cerr << "Cof<" << H << "," << W << "> not implemented" << endl;
2023
+ return m;
2024
+ }
2025
+
2026
+ template <typename T>
2027
+ INLINE Mat<0,0,T> Cof (Mat<0,0,T> m)
2028
+ {
2029
+ return Mat<0,0,T>();
2030
+ }
2031
+
2032
+ template <typename T>
2033
+ INLINE Mat<1,1,T> Cof (Mat<1,1,T> m)
2034
+ {
2035
+ Mat<1,1,T> cof;
2036
+ cof(0,0) = T(1); // m(0,0);
2037
+ return cof;
2038
+ }
2039
+
2040
+ template <typename T>
2041
+ INLINE Mat<2,2,T> Cof (Mat<2,2,T> m)
2042
+ {
2043
+ Mat<2,2,T> cof;
2044
+ cof(0,0) = m(1,1);
2045
+ cof(0,1) = -m(1,0);
2046
+ cof(1,0) = -m(0,1);
2047
+ cof(1,1) = m(0,0);
2048
+ return cof;
2049
+ }
2050
+
2051
+
2052
+ template <typename T>
2053
+ INLINE Mat<3,3,T> Cof (Mat<3,3,T> m)
2054
+ {
2055
+ Mat<3,3,T> cof;
2056
+ cof(0,0) = m(1,1)*m(2,2)-m(2,1)*m(1,2);
2057
+ cof(0,1) = -m(1,0)*m(2,2)+m(2,0)*m(1,2);
2058
+ cof(0,2) = m(1,0)*m(2,1)-m(2,0)*m(1,1);
2059
+
2060
+ cof(1,0) = -m(0,1)*m(2,2)+m(2,1)*m(0,2);
2061
+ cof(1,1) = m(0,0)*m(2,2)-m(2,0)*m(0,2);
2062
+ cof(1,2) = -m(0,0)*m(2,1)+m(2,0)*m(0,1);
2063
+
2064
+ cof(2,0) = m(0,1)*m(1,2)-m(1,1)*m(0,2);
2065
+ cof(2,1) = -m(0,0)*m(1,2)+m(1,0)*m(0,2);
2066
+ cof(2,2) = m(0,0)*m(1,1)-m(1,0)*m(0,1);
2067
+ return cof;
2068
+ }
2069
+
2070
+
2071
+ template <typename T>
2072
+ INLINE Mat<4,4,T> Cof (Mat<4,4,T> m)
2073
+ {
2074
+ Mat<4,4,T> cof;
2075
+ cof(0,0) = (m(1,1)*m(2,2)*m(3,3)+m(1,2)*m(2,3)*m(3,1)+m(1,3)*m(2,1)*m(3,2) - m(1,1)*m(3,2)*m(2,3) - m(2,1)*m(1,2)*m(3,3) - m(3,1)*m(2,2)*m(1,3));
2076
+ cof(0,1) = -(m(1,0)*m(2,2)*m(3,3)+m(1,2)*m(2,3)*m(3,0)+m(1,3)*m(2,0)*m(3,2) - m(1,0)*m(3,2)*m(2,3) - m(2,0)*m(1,2)*m(3,3) - m(3,0)*m(2,2)*m(1,3));
2077
+ cof(0,2) = (m(1,0)*m(2,1)*m(3,3)+m(1,1)*m(2,3)*m(3,0)+m(1,3)*m(2,0)*m(3,1) - m(1,0)*m(3,1)*m(2,3) - m(2,0)*m(1,1)*m(3,3) - m(3,0)*m(2,1)*m(1,3));
2078
+ cof(0,3) = -(m(1,0)*m(2,1)*m(3,2)+m(1,1)*m(2,2)*m(3,0)+m(1,2)*m(2,0)*m(3,1) - m(1,0)*m(3,1)*m(2,2) - m(2,0)*m(1,1)*m(3,2) - m(3,0)*m(2,1)*m(1,2));
2079
+
2080
+ cof(1,0) = -(m(0,1)*m(2,2)*m(3,3)+m(0,2)*m(2,3)*m(3,1)+m(0,3)*m(2,1)*m(3,2) - m(0,1)*m(3,2)*m(2,3) - m(2,1)*m(0,2)*m(3,3) - m(3,1)*m(2,2)*m(0,3));
2081
+ cof(1,1) = (m(0,0)*m(2,2)*m(3,3)+m(0,2)*m(2,3)*m(3,0)+m(0,3)*m(2,0)*m(3,2) - m(0,0)*m(3,2)*m(2,3) - m(2,0)*m(0,2)*m(3,3) - m(3,0)*m(2,2)*m(0,3));
2082
+ cof(1,2) = -(m(0,0)*m(2,1)*m(3,3)+m(0,1)*m(2,3)*m(3,0)+m(0,3)*m(2,0)*m(3,1) - m(0,0)*m(3,1)*m(2,3) - m(2,0)*m(0,1)*m(3,3) - m(3,0)*m(2,1)*m(0,3));
2083
+ cof(1,3) = (m(0,0)*m(2,1)*m(3,2)+m(0,1)*m(2,2)*m(3,0)+m(0,2)*m(2,0)*m(3,1) - m(0,0)*m(3,1)*m(2,2) - m(2,0)*m(0,1)*m(3,2) - m(3,0)*m(2,1)*m(0,2));
2084
+
2085
+ cof(2,0) = (m(0,1)*m(1,2)*m(3,3)+m(0,2)*m(1,3)*m(3,1)+m(0,3)*m(1,1)*m(3,2) - m(0,1)*m(3,2)*m(1,3) - m(1,1)*m(0,2)*m(3,3) - m(3,1)*m(1,2)*m(0,3));
2086
+ cof(2,1) = -(m(0,0)*m(1,2)*m(3,3)+m(0,2)*m(1,3)*m(3,0)+m(0,3)*m(1,0)*m(3,2) - m(0,0)*m(3,2)*m(1,3) - m(1,0)*m(0,2)*m(3,3) - m(3,0)*m(1,2)*m(0,3));
2087
+ cof(2,2) = (m(0,0)*m(1,1)*m(3,3)+m(0,1)*m(1,3)*m(3,0)+m(0,3)*m(1,0)*m(3,1) - m(0,0)*m(3,1)*m(1,3) - m(1,0)*m(0,1)*m(3,3) - m(3,0)*m(1,1)*m(0,3));
2088
+ cof(2,3) = -(m(0,0)*m(1,1)*m(3,2)+m(0,1)*m(1,2)*m(3,0)+m(0,2)*m(1,0)*m(3,1) - m(0,0)*m(3,1)*m(1,2) - m(1,0)*m(0,1)*m(3,2) - m(3,0)*m(1,1)*m(0,2));
2089
+
2090
+ cof(3,0) = -(m(0,1)*m(1,2)*m(2,3)+m(0,2)*m(1,3)*m(2,1)+m(0,3)*m(1,1)*m(2,2) - m(0,1)*m(2,2)*m(1,3) - m(1,1)*m(0,2)*m(2,3) - m(2,1)*m(1,2)*m(0,3));
2091
+ cof(3,1) = (m(0,0)*m(1,2)*m(2,3)+m(0,2)*m(1,3)*m(2,0)+m(0,3)*m(1,0)*m(2,2) - m(0,0)*m(2,2)*m(1,3) - m(1,0)*m(0,2)*m(2,3) - m(2,0)*m(1,2)*m(0,3));
2092
+ cof(3,2) = -(m(0,0)*m(1,1)*m(2,3)+m(0,1)*m(1,3)*m(2,0)+m(0,3)*m(1,0)*m(2,1) - m(0,0)*m(2,1)*m(1,3) - m(1,0)*m(0,1)*m(2,3) - m(2,0)*m(1,1)*m(0,3));
2093
+ cof(3,3) = (m(0,0)*m(1,1)*m(2,2)+m(0,1)*m(1,2)*m(2,0)+m(0,2)*m(1,0)*m(2,1) - m(0,0)*m(2,1)*m(1,2) - m(1,0)*m(0,1)*m(2,2) - m(2,0)*m(1,1)*m(0,2));
2094
+ return cof;
2095
+ }
2096
+
2097
+
2098
+ template <int H, int W, typename T>
2099
+ INLINE Mat<H,W,T> Inv (Mat<H,W,T> m)
2100
+ {
2101
+ return 1.0/Det(m) * Adj(m);
2102
+ }
2103
+
2104
+
2105
+
2106
+
2107
+ template <int H, int W, typename SCAL, typename TANY>
2108
+ inline void AtomicAdd (Mat<H,W,SCAL> & x, TANY y)
2109
+ {
2110
+ for (int i = 0; i < H; i++)
2111
+ for (int j = 0; j < W; j++)
2112
+ AtomicAdd (x(i,j), y(i,j));
2113
+ }
2114
+
2115
+ }
2116
+
2117
+
2118
+ namespace ngstd
2119
+ {
2120
+ template <typename ARCHIVE, int N, int M, typename T>
2121
+ inline auto & operator& (ARCHIVE & ar, ngbla::Mat<N,M,T> & m)
2122
+ {
2123
+ for (int i = 0; i < N*M; i++)
2124
+ ar & m(i);
2125
+ return ar;
2126
+ }
2127
+ }
2128
+
2129
+
2130
+
2131
+ namespace ngcore
2132
+ {
2133
+ template<typename T>
2134
+ struct MPI_typetrait;
2135
+
2136
+ template<int N, int M, typename T>
2137
+ struct MPI_typetrait<ngbla::Mat<N,M,T> > {
2138
+ static auto MPIType () {
2139
+ return MPI_typetrait<std::array<T,N*M>>::MPIType();
2140
+ }
2141
+ };
2142
+ }
2143
+
2144
+
2145
+ #endif