ngsolve 6.2.2501.post21.dev1__cp313-cp313-macosx_10_15_universal2.whl → 6.2.2501.post34.dev1__cp313-cp313-macosx_10_15_universal2.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 ngsolve might be problematic. Click here for more details.

Files changed (286) hide show
  1. ngsolve/webgui.py +1 -1
  2. {ngsolve-6.2.2501.post21.dev1.dist-info → ngsolve-6.2.2501.post34.dev1.dist-info}/METADATA +2 -2
  3. ngsolve-6.2.2501.post34.dev1.dist-info/RECORD +25 -0
  4. netgen/include/arnoldi.hpp +0 -55
  5. netgen/include/bandmatrix.hpp +0 -334
  6. netgen/include/basematrix.hpp +0 -957
  7. netgen/include/basevector.hpp +0 -1268
  8. netgen/include/bdbequations.hpp +0 -2752
  9. netgen/include/bdbintegrator.hpp +0 -1659
  10. netgen/include/bessel.hpp +0 -1064
  11. netgen/include/bilinearform.hpp +0 -963
  12. netgen/include/bla.hpp +0 -29
  13. netgen/include/blockalloc.hpp +0 -95
  14. netgen/include/blockjacobi.hpp +0 -316
  15. netgen/include/bspline.hpp +0 -114
  16. netgen/include/calcinverse.hpp +0 -141
  17. netgen/include/cg.hpp +0 -368
  18. netgen/include/chebyshev.hpp +0 -44
  19. netgen/include/cholesky.hpp +0 -720
  20. netgen/include/clapack.h +0 -7254
  21. netgen/include/code_generation.hpp +0 -296
  22. netgen/include/coefficient.hpp +0 -2006
  23. netgen/include/coefficient_impl.hpp +0 -18
  24. netgen/include/coefficient_stdmath.hpp +0 -157
  25. netgen/include/commutingAMG.hpp +0 -106
  26. netgen/include/comp.hpp +0 -79
  27. netgen/include/compatibility.hpp +0 -41
  28. netgen/include/complex_wrapper.hpp +0 -73
  29. netgen/include/compressedfespace.hpp +0 -110
  30. netgen/include/contact.hpp +0 -231
  31. netgen/include/diagonalmatrix.hpp +0 -154
  32. netgen/include/differentialoperator.hpp +0 -276
  33. netgen/include/diffop.hpp +0 -1286
  34. netgen/include/diffop_impl.hpp +0 -326
  35. netgen/include/discontinuous.hpp +0 -84
  36. netgen/include/dump.hpp +0 -949
  37. netgen/include/eigen.hpp +0 -60
  38. netgen/include/eigensystem.hpp +0 -18
  39. netgen/include/elasticity_equations.hpp +0 -595
  40. netgen/include/elementbyelement.hpp +0 -195
  41. netgen/include/elementtopology.hpp +0 -1760
  42. netgen/include/elementtransformation.hpp +0 -339
  43. netgen/include/evalfunc.hpp +0 -405
  44. netgen/include/expr.hpp +0 -1655
  45. netgen/include/facetfe.hpp +0 -175
  46. netgen/include/facetfespace.hpp +0 -178
  47. netgen/include/facethofe.hpp +0 -111
  48. netgen/include/facetsurffespace.hpp +0 -112
  49. netgen/include/fe_interfaces.hpp +0 -32
  50. netgen/include/fem.hpp +0 -87
  51. netgen/include/fesconvert.hpp +0 -14
  52. netgen/include/fespace.hpp +0 -1445
  53. netgen/include/finiteelement.hpp +0 -286
  54. netgen/include/globalinterfacespace.hpp +0 -77
  55. netgen/include/globalspace.hpp +0 -115
  56. netgen/include/gridfunction.hpp +0 -525
  57. netgen/include/h1amg.hpp +0 -41
  58. netgen/include/h1hofe.hpp +0 -188
  59. netgen/include/h1hofe_impl.hpp +0 -1262
  60. netgen/include/h1hofefo.hpp +0 -148
  61. netgen/include/h1hofefo_impl.hpp +0 -185
  62. netgen/include/h1hofespace.hpp +0 -167
  63. netgen/include/h1lofe.hpp +0 -1237
  64. netgen/include/h1lumping.hpp +0 -35
  65. netgen/include/hcurl_equations.hpp +0 -1352
  66. netgen/include/hcurlcurlfe.hpp +0 -2221
  67. netgen/include/hcurlcurlfespace.hpp +0 -78
  68. netgen/include/hcurlfe.hpp +0 -259
  69. netgen/include/hcurlfe_utils.hpp +0 -107
  70. netgen/include/hcurlhdiv_dshape.hpp +0 -857
  71. netgen/include/hcurlhdivfes.hpp +0 -308
  72. netgen/include/hcurlhofe.hpp +0 -175
  73. netgen/include/hcurlhofe_impl.hpp +0 -1871
  74. netgen/include/hcurlhofespace.hpp +0 -193
  75. netgen/include/hcurllofe.hpp +0 -1146
  76. netgen/include/hdiv_equations.hpp +0 -865
  77. netgen/include/hdivdivfe.hpp +0 -2923
  78. netgen/include/hdivdivsurfacespace.hpp +0 -76
  79. netgen/include/hdivfe.hpp +0 -206
  80. netgen/include/hdivfe_utils.hpp +0 -716
  81. netgen/include/hdivfes.hpp +0 -75
  82. netgen/include/hdivhofe.hpp +0 -447
  83. netgen/include/hdivhofe_impl.hpp +0 -1107
  84. netgen/include/hdivhofefo.hpp +0 -229
  85. netgen/include/hdivhofespace.hpp +0 -175
  86. netgen/include/hdivhosurfacefespace.hpp +0 -106
  87. netgen/include/hdivlofe.hpp +0 -773
  88. netgen/include/hidden.hpp +0 -74
  89. netgen/include/householder.hpp +0 -181
  90. netgen/include/hypre_ams_precond.hpp +0 -123
  91. netgen/include/hypre_precond.hpp +0 -73
  92. netgen/include/integrator.hpp +0 -2024
  93. netgen/include/integratorcf.hpp +0 -253
  94. netgen/include/interpolate.hpp +0 -49
  95. netgen/include/intrule.hpp +0 -2541
  96. netgen/include/irspace.hpp +0 -49
  97. netgen/include/jacobi.hpp +0 -136
  98. netgen/include/l2hofe.hpp +0 -193
  99. netgen/include/l2hofe_impl.hpp +0 -564
  100. netgen/include/l2hofefo.hpp +0 -542
  101. netgen/include/l2hofespace.hpp +0 -344
  102. netgen/include/la.hpp +0 -38
  103. netgen/include/linearform.hpp +0 -266
  104. netgen/include/matrix.hpp +0 -2140
  105. netgen/include/memusage.hpp +0 -41
  106. netgen/include/meshaccess.hpp +0 -1358
  107. netgen/include/mgpre.hpp +0 -204
  108. netgen/include/mptools.hpp +0 -2145
  109. netgen/include/multigrid.hpp +0 -42
  110. netgen/include/multivector.hpp +0 -447
  111. netgen/include/mumpsinverse.hpp +0 -187
  112. netgen/include/mycomplex.hpp +0 -361
  113. netgen/include/ng_lapack.hpp +0 -1661
  114. netgen/include/ngblas.hpp +0 -1099
  115. netgen/include/ngs_defines.hpp +0 -30
  116. netgen/include/ngs_stdcpp_include.hpp +0 -106
  117. netgen/include/ngs_utils.hpp +0 -121
  118. netgen/include/ngsobject.hpp +0 -1019
  119. netgen/include/ngsstream.hpp +0 -113
  120. netgen/include/ngstd.hpp +0 -72
  121. netgen/include/nodalhofe.hpp +0 -96
  122. netgen/include/nodalhofe_impl.hpp +0 -141
  123. netgen/include/normalfacetfe.hpp +0 -223
  124. netgen/include/normalfacetfespace.hpp +0 -98
  125. netgen/include/normalfacetsurfacefespace.hpp +0 -84
  126. netgen/include/order.hpp +0 -251
  127. netgen/include/parallel_matrices.hpp +0 -222
  128. netgen/include/paralleldofs.hpp +0 -340
  129. netgen/include/parallelngs.hpp +0 -23
  130. netgen/include/parallelvector.hpp +0 -269
  131. netgen/include/pardisoinverse.hpp +0 -200
  132. netgen/include/periodic.hpp +0 -125
  133. netgen/include/plateaufespace.hpp +0 -25
  134. netgen/include/pml.hpp +0 -275
  135. netgen/include/pmltrafo.hpp +0 -631
  136. netgen/include/postproc.hpp +0 -142
  137. netgen/include/precomp.hpp +0 -60
  138. netgen/include/preconditioner.hpp +0 -602
  139. netgen/include/prolongation.hpp +0 -235
  140. netgen/include/python_comp.hpp +0 -107
  141. netgen/include/python_fem.hpp +0 -89
  142. netgen/include/python_linalg.hpp +0 -58
  143. netgen/include/python_ngstd.hpp +0 -385
  144. netgen/include/recursive_pol.hpp +0 -4844
  145. netgen/include/recursive_pol_tet.hpp +0 -395
  146. netgen/include/recursive_pol_trig.hpp +0 -492
  147. netgen/include/reorderedfespace.hpp +0 -81
  148. netgen/include/sample_sort.hpp +0 -105
  149. netgen/include/scalarfe.hpp +0 -335
  150. netgen/include/shapefunction_utils.hpp +0 -113
  151. netgen/include/simd_complex.hpp +0 -284
  152. netgen/include/smoother.hpp +0 -253
  153. netgen/include/solve.hpp +0 -89
  154. netgen/include/sparsecholesky.hpp +0 -313
  155. netgen/include/sparsematrix.hpp +0 -1038
  156. netgen/include/sparsematrix_dyn.hpp +0 -91
  157. netgen/include/sparsematrix_impl.hpp +0 -920
  158. netgen/include/special_matrix.hpp +0 -461
  159. netgen/include/specialelement.hpp +0 -125
  160. netgen/include/statushandler.hpp +0 -33
  161. netgen/include/stringops.hpp +0 -12
  162. netgen/include/superluinverse.hpp +0 -136
  163. netgen/include/symbolicintegrator.hpp +0 -849
  164. netgen/include/symmetricmatrix.hpp +0 -144
  165. netgen/include/tangentialfacetfe.hpp +0 -224
  166. netgen/include/tangentialfacetfespace.hpp +0 -106
  167. netgen/include/tensor.hpp +0 -522
  168. netgen/include/tensorcoefficient.hpp +0 -446
  169. netgen/include/tensorproductintegrator.hpp +0 -113
  170. netgen/include/thcurlfe.hpp +0 -128
  171. netgen/include/thcurlfe_impl.hpp +0 -380
  172. netgen/include/thdivfe.hpp +0 -80
  173. netgen/include/thdivfe_impl.hpp +0 -426
  174. netgen/include/tpdiffop.hpp +0 -461
  175. netgen/include/tpfes.hpp +0 -133
  176. netgen/include/tpintrule.hpp +0 -224
  177. netgen/include/triangular.hpp +0 -465
  178. netgen/include/tscalarfe.hpp +0 -245
  179. netgen/include/tscalarfe_impl.hpp +0 -1029
  180. netgen/include/umfpackinverse.hpp +0 -148
  181. netgen/include/vector.hpp +0 -1219
  182. netgen/include/voxelcoefficientfunction.hpp +0 -41
  183. netgen/include/vtkoutput.hpp +0 -198
  184. netgen/include/vvector.hpp +0 -208
  185. netgen/include/webgui.hpp +0 -92
  186. netgen/libngbla.dylib +0 -0
  187. netgen/libngcomp.dylib +0 -0
  188. netgen/libngfem.dylib +0 -0
  189. netgen/libngla.dylib +0 -0
  190. netgen/libngsolve.dylib +0 -0
  191. netgen/libngstd.dylib +0 -0
  192. ngsolve/__init__.pyi +0 -231
  193. ngsolve/bla.pyi +0 -1139
  194. ngsolve/bvp.pyi +0 -32
  195. ngsolve/cmake/NGSolveConfig.cmake +0 -102
  196. ngsolve/cmake/ngsolve-targets-release.cmake +0 -69
  197. ngsolve/cmake/ngsolve-targets.cmake +0 -163
  198. ngsolve/comp/__init__.pyi +0 -5382
  199. ngsolve/comp/pml.pyi +0 -89
  200. ngsolve/config/__init__.py +0 -1
  201. ngsolve/config/__init__.pyi +0 -43
  202. ngsolve/config/__main__.py +0 -4
  203. ngsolve/config/config.py +0 -60
  204. ngsolve/config/config.pyi +0 -45
  205. ngsolve/demos/TensorProduct/__init__.py +0 -0
  206. ngsolve/demos/TensorProduct/tp_dg_1d_1d.py +0 -80
  207. ngsolve/demos/TensorProduct/tp_dg_1d_2d.py +0 -73
  208. ngsolve/demos/TensorProduct/tp_dg_2d_1d.py +0 -72
  209. ngsolve/demos/TensorProduct/tp_dg_2d_2d.py +0 -66
  210. ngsolve/demos/__init__.py +0 -0
  211. ngsolve/demos/howto/__init__.py +0 -0
  212. ngsolve/demos/howto/hhj.py +0 -44
  213. ngsolve/demos/howto/hybrid_dg.py +0 -53
  214. ngsolve/demos/howto/mixed.py +0 -30
  215. ngsolve/demos/howto/nonlin.py +0 -29
  216. ngsolve/demos/howto/pickling.py +0 -26
  217. ngsolve/demos/howto/pml.py +0 -31
  218. ngsolve/demos/howto/taskmanager.py +0 -20
  219. ngsolve/demos/howto/tdnns.py +0 -47
  220. ngsolve/demos/howto/timeDG-skeleton.py +0 -45
  221. ngsolve/demos/howto/timeDG.py +0 -38
  222. ngsolve/demos/howto/timeDGlap.py +0 -42
  223. ngsolve/demos/howto/timeDGwave.py +0 -61
  224. ngsolve/demos/intro/__init__.py +0 -0
  225. ngsolve/demos/intro/adaptive.py +0 -123
  226. ngsolve/demos/intro/cmagnet.py +0 -62
  227. ngsolve/demos/intro/elasticity.py +0 -76
  228. ngsolve/demos/intro/navierstokes.py +0 -74
  229. ngsolve/demos/intro/poisson.ipynb +0 -170
  230. ngsolve/demos/intro/poisson.py +0 -41
  231. ngsolve/demos/mpi/__init__.py +0 -0
  232. ngsolve/demos/mpi/mpi_cmagnet.py +0 -87
  233. ngsolve/demos/mpi/mpi_navierstokes.py +0 -117
  234. ngsolve/demos/mpi/mpi_poisson.py +0 -89
  235. ngsolve/demos/mpi/mpi_timeDG.py +0 -82
  236. ngsolve/directsolvers.pyi +0 -18
  237. ngsolve/eigenvalues.pyi +0 -30
  238. ngsolve/fem.pyi +0 -1707
  239. ngsolve/krylovspace.pyi +0 -309
  240. ngsolve/la.pyi +0 -1218
  241. ngsolve/ngslib.so +0 -0
  242. ngsolve/ngstd.pyi +0 -58
  243. ngsolve/nonlinearsolvers.pyi +0 -98
  244. ngsolve/preconditioners.pyi +0 -6
  245. ngsolve/solve.pyi +0 -108
  246. ngsolve/solvers.pyi +0 -14
  247. ngsolve/timestepping.pyi +0 -34
  248. ngsolve/timing.pyi +0 -57
  249. ngsolve/utils.pyi +0 -279
  250. ngsolve-6.2.2501.post21.dev1.data/data/Netgen.icns +0 -0
  251. ngsolve-6.2.2501.post21.dev1.data/data/bin/ngscxx +0 -17
  252. ngsolve-6.2.2501.post21.dev1.data/data/bin/ngsld +0 -13
  253. ngsolve-6.2.2501.post21.dev1.data/data/bin/ngsolve.tcl +0 -648
  254. ngsolve-6.2.2501.post21.dev1.data/data/bin/ngspy +0 -2
  255. ngsolve-6.2.2501.post21.dev1.data/data/share/ngsolve/beam.geo +0 -17
  256. ngsolve-6.2.2501.post21.dev1.data/data/share/ngsolve/beam.vol +0 -240
  257. ngsolve-6.2.2501.post21.dev1.data/data/share/ngsolve/chip.in2d +0 -41
  258. ngsolve-6.2.2501.post21.dev1.data/data/share/ngsolve/chip.vol +0 -614
  259. ngsolve-6.2.2501.post21.dev1.data/data/share/ngsolve/coil.geo +0 -12
  260. ngsolve-6.2.2501.post21.dev1.data/data/share/ngsolve/coil.vol +0 -2560
  261. ngsolve-6.2.2501.post21.dev1.data/data/share/ngsolve/coilshield.geo +0 -24
  262. ngsolve-6.2.2501.post21.dev1.data/data/share/ngsolve/coilshield.vol +0 -3179
  263. ngsolve-6.2.2501.post21.dev1.data/data/share/ngsolve/cube.geo +0 -19
  264. ngsolve-6.2.2501.post21.dev1.data/data/share/ngsolve/cube.vol +0 -1832
  265. ngsolve-6.2.2501.post21.dev1.data/data/share/ngsolve/d10_DGdoubleglazing.pde +0 -50
  266. ngsolve-6.2.2501.post21.dev1.data/data/share/ngsolve/d11_chip_nitsche.pde +0 -40
  267. ngsolve-6.2.2501.post21.dev1.data/data/share/ngsolve/d1_square.pde +0 -43
  268. ngsolve-6.2.2501.post21.dev1.data/data/share/ngsolve/d2_chip.pde +0 -35
  269. ngsolve-6.2.2501.post21.dev1.data/data/share/ngsolve/d3_helmholtz.pde +0 -22
  270. ngsolve-6.2.2501.post21.dev1.data/data/share/ngsolve/d4_cube.pde +0 -46
  271. ngsolve-6.2.2501.post21.dev1.data/data/share/ngsolve/d5_beam.pde +0 -74
  272. ngsolve-6.2.2501.post21.dev1.data/data/share/ngsolve/d6_shaft.pde +0 -73
  273. ngsolve-6.2.2501.post21.dev1.data/data/share/ngsolve/d7_coil.pde +0 -50
  274. ngsolve-6.2.2501.post21.dev1.data/data/share/ngsolve/d8_coilshield.pde +0 -49
  275. ngsolve-6.2.2501.post21.dev1.data/data/share/ngsolve/d9_hybridDG.pde +0 -72
  276. ngsolve-6.2.2501.post21.dev1.data/data/share/ngsolve/doubleglazing.in2d +0 -27
  277. ngsolve-6.2.2501.post21.dev1.data/data/share/ngsolve/doubleglazing.vol +0 -737
  278. ngsolve-6.2.2501.post21.dev1.data/data/share/ngsolve/piezo2d40round4.vol.gz +0 -0
  279. ngsolve-6.2.2501.post21.dev1.data/data/share/ngsolve/shaft.geo +0 -73
  280. ngsolve-6.2.2501.post21.dev1.data/data/share/ngsolve/shaft.vol +0 -4291
  281. ngsolve-6.2.2501.post21.dev1.data/data/share/ngsolve/square.in2d +0 -17
  282. ngsolve-6.2.2501.post21.dev1.data/data/share/ngsolve/square.vol +0 -149
  283. ngsolve-6.2.2501.post21.dev1.dist-info/RECORD +0 -304
  284. {ngsolve-6.2.2501.post21.dev1.dist-info → ngsolve-6.2.2501.post34.dev1.dist-info}/LICENSE +0 -0
  285. {ngsolve-6.2.2501.post21.dev1.dist-info → ngsolve-6.2.2501.post34.dev1.dist-info}/WHEEL +0 -0
  286. {ngsolve-6.2.2501.post21.dev1.dist-info → ngsolve-6.2.2501.post34.dev1.dist-info}/top_level.txt +0 -0
@@ -1,1038 +0,0 @@
1
- #ifndef FILE_NGS_SPARSEMATRIX
2
- #define FILE_NGS_SPARSEMATRIX
3
-
4
- /**************************************************************************/
5
- /* File: sparsematrix.hpp */
6
- /* Author: Joachim Schoeberl */
7
- /* Date: 01. Oct. 94, 15 Jan. 02 */
8
- /**************************************************************************/
9
-
10
-
11
- #include "vvector.hpp"
12
- #include "basematrix.hpp"
13
-
14
- namespace ngla
15
- {
16
-
17
- template<class TM>
18
- class SparseMatrixTM ;
19
-
20
- template<class TM,
21
- class TV_ROW = typename mat_traits<TM>::TV_ROW,
22
- class TV_COL = typename mat_traits<TM>::TV_COL>
23
- class SparseMatrix;
24
-
25
-
26
- template<class TM,
27
- class TV = typename mat_traits<TM>::TV_ROW>
28
- class SparseMatrixSymmetric;
29
-
30
-
31
-
32
- class BaseJacobiPrecond;
33
-
34
- template<class TM,
35
- class TV_ROW = typename mat_traits<TM>::TV_ROW,
36
- class TV_COL = typename mat_traits<TM>::TV_COL>
37
- class JacobiPrecond;
38
-
39
- template<class TM,
40
- class TV = typename mat_traits<TM>::TV_ROW>
41
- class JacobiPrecondSymmetric;
42
-
43
-
44
- class BaseBlockJacobiPrecond;
45
-
46
- template<class TM,
47
- class TV_ROW = typename mat_traits<TM>::TV_ROW,
48
- class TV_COL = typename mat_traits<TM>::TV_COL>
49
- class BlockJacobiPrecond;
50
-
51
- template<class TM,
52
- class TV = typename mat_traits<TM>::TV_ROW>
53
- class BlockJacobiPrecondSymmetric;
54
-
55
-
56
-
57
-
58
-
59
-
60
- #ifdef USE_PARDISO
61
- const INVERSETYPE default_inversetype = PARDISO;
62
- #else
63
- #ifdef USE_MUMPS
64
- const INVERSETYPE default_inversetype = MUMPS;
65
- #else
66
- #ifdef USE_UMFPACK
67
- const INVERSETYPE default_inversetype = UMFPACK;
68
- #else
69
- const INVERSETYPE default_inversetype = SPARSECHOLESKY;
70
- #endif
71
- #endif
72
- #endif
73
-
74
-
75
- /**
76
- The graph of a sparse matrix.
77
- */
78
- class NGS_DLL_HEADER MatrixGraph : public BaseMatrix
79
- {
80
- public:
81
- typedef int ColIdx;
82
- protected:
83
- /// number of rows
84
- size_t size;
85
- /// with of matrix
86
- size_t width;
87
- /// non-zero elements
88
- size_t nze;
89
-
90
- /// column numbers
91
- // Array<int, size_t> colnr;
92
- NumaDistributedArray<ColIdx> colnr;
93
-
94
- /// pointer to first in row
95
- Array<size_t> firsti;
96
-
97
- /// row has same non-zero elements as previous row
98
- Array<size_t> same_nze;
99
-
100
- /// balancing for multi-threading
101
- Partitioning balance;
102
-
103
- /// owner of arrays ?
104
- bool owner;
105
-
106
- public:
107
- /// arbitrary number of els/row
108
- MatrixGraph (FlatArray<int> elsperrow, size_t awidth);
109
- /// matrix of height as, uniform number of els/row
110
- MatrixGraph (size_t as, int max_elsperrow);
111
- /// shadow matrix graph
112
- MatrixGraph (const MatrixGraph & graph); // , bool stealgraph = false);
113
- /// move-constuctor
114
- MatrixGraph (MatrixGraph && graph);
115
- ///
116
- MatrixGraph (size_t size, size_t width,
117
- FlatTable<int> rowelements, FlatTable<int> colelements, bool symmetric);
118
- ///
119
- // MatrixGraph (const Table<int> & dof2dof, bool symmetric);
120
- virtual ~MatrixGraph ();
121
-
122
- /// eliminate unused columne indices (was never implemented)
123
- void Compress();
124
-
125
- /// returns position of Element (i, j), exception for unused
126
- size_t GetPosition (size_t i, size_t j) const;
127
-
128
- /// returns position of Element (i, j), -1 for unused
129
- size_t GetPositionTest (size_t i, size_t j) const;
130
-
131
- /// find positions of n sorted elements, overwrite pos, exception for unused
132
- void GetPositionsSorted (size_t row, size_t n, int * pos) const;
133
-
134
- /// returns position of new element
135
- size_t CreatePosition (size_t i, size_t j);
136
-
137
- size_t Size() const { return size; }
138
-
139
- size_t NZE() const { return nze; }
140
-
141
- // full col-index array
142
- FlatArray<ColIdx> GetColIndices() const { return colnr; }
143
-
144
- // col-indices of the i-th row
145
- FlatArray<ColIdx> GetRowIndices(size_t i) const
146
- { return FlatArray<ColIdx> (firsti[i+1]-firsti[i], colnr+firsti[i]); }
147
-
148
- size_t First (int i) const { return firsti[i]; }
149
- FlatArray<size_t> GetFirstArray () const { return firsti; }
150
-
151
- void FindSameNZE();
152
- void CalcBalancing ();
153
- const Partitioning & GetBalancing() const { return balance; }
154
-
155
- void EmbedHeight (size_t starti, size_t newheight);
156
- void EmbedWidth (size_t starti, size_t newwidth);
157
-
158
- ostream & Print (ostream & ost) const;
159
-
160
- virtual Array<MemoryUsage> GetMemoryUsage () const;
161
-
162
- const MemoryTracer & GetMemoryTracer() const
163
- {
164
- return mem_tracer;
165
- }
166
-
167
- virtual AutoVector CreateRowVector () const
168
- { throw Exception("MatrixGraph::CreateRowVector called"); }
169
-
170
- virtual AutoVector CreateColVector () const
171
- { throw Exception("MatrixGraph::CreateRowVector called"); }
172
-
173
- private:
174
-
175
- MemoryTracer mem_tracer = {"MatrixGraph",
176
- colnr, "colnr",
177
- firsti, "firsti",
178
- same_nze, "same_nze"
179
- };
180
- };
181
-
182
-
183
-
184
-
185
-
186
-
187
-
188
-
189
- /// base class for all sparse matrices
190
- class NGS_DLL_HEADER BaseSparseMatrix : public MatrixGraph
191
- {
192
- protected:
193
- /// sparse direct solver
194
- mutable INVERSETYPE inversetype = default_inversetype;
195
- Flags inverseflags;
196
- bool spd = false;
197
-
198
- public:
199
- using MatrixGraph::MatrixGraph;
200
- using MatrixGraph::ColIdx;
201
- /*
202
- BaseSparseMatrix (int as, int max_elsperrow)
203
- : MatrixGraph (as, max_elsperrow)
204
- { ; }
205
-
206
- BaseSparseMatrix (const Array<int> & elsperrow, int awidth)
207
- : MatrixGraph (elsperrow, awidth)
208
- { ; }
209
-
210
- BaseSparseMatrix (int size, int width, const Table<int> & rowelements,
211
- const Table<int> & colelements, bool symmetric)
212
- : MatrixGraph (size, width, rowelements, colelements, symmetric)
213
- { ; }
214
- */
215
-
216
- BaseSparseMatrix (const MatrixGraph & agraph)
217
- : MatrixGraph (agraph)
218
- { ; }
219
-
220
- BaseSparseMatrix (const BaseSparseMatrix & amat)
221
- : MatrixGraph (amat)
222
- { ; }
223
-
224
- BaseSparseMatrix (BaseSparseMatrix && amat)
225
- : MatrixGraph (std::move(amat))
226
- { ; }
227
-
228
- virtual ~BaseSparseMatrix ();
229
-
230
- BaseSparseMatrix & operator= (double s)
231
- {
232
- AsVector() = s;
233
- return *this;
234
- }
235
-
236
- BaseSparseMatrix & Add (double s, const BaseSparseMatrix & m2)
237
- {
238
- AsVector() += s * m2.AsVector();
239
- return *this;
240
- }
241
-
242
- virtual shared_ptr<BaseSparseMatrix> CreateSparseMatrix() const override
243
- {
244
- return dynamic_pointer_cast<BaseSparseMatrix>(const_cast<BaseSparseMatrix*>(this)->shared_from_this());
245
- }
246
-
247
- virtual shared_ptr<BaseJacobiPrecond> CreateJacobiPrecond (shared_ptr<BitArray> inner = nullptr) const
248
- {
249
- throw Exception ("BaseSparseMatrix::CreateJacobiPrecond");
250
- }
251
-
252
- virtual shared_ptr<BaseBlockJacobiPrecond>
253
- CreateBlockJacobiPrecond (shared_ptr<Table<int>> blocks,
254
- const BaseVector * constraint = 0,
255
- bool parallel = 1,
256
- shared_ptr<BitArray> freedofs = NULL) const
257
- {
258
- throw Exception ("BaseSparseMatrix::CreateBlockJacobiPrecond");
259
- }
260
-
261
- virtual shared_ptr<BaseSparseMatrix> CreateTranspose() const
262
- {
263
- throw Exception ("BaseSparseMatrix::CreateTranspose");
264
- }
265
-
266
- virtual shared_ptr<BaseMatrix>
267
- InverseMatrix (shared_ptr<BitArray> subset = nullptr) const override
268
- {
269
- throw Exception ("BaseSparseMatrix::CreateInverse called");
270
- }
271
-
272
- virtual shared_ptr<BaseMatrix>
273
- InverseMatrix (shared_ptr<const Array<int>> clusters) const override
274
- {
275
- throw Exception ("BaseSparseMatrix::CreateInverse called");
276
- }
277
-
278
- virtual shared_ptr<BaseSparseMatrix> Restrict (const SparseMatrixTM<double> & prol,
279
- shared_ptr<BaseSparseMatrix> cmat = nullptr ) const
280
- {
281
- throw Exception ("BaseSparseMatrix::Restrict");
282
- }
283
-
284
- virtual shared_ptr<BaseSparseMatrix> Reorder (const Array<size_t> & reorder) const
285
- {
286
- throw Exception ("BaseSparseMatrix::Reorder");
287
- }
288
-
289
- virtual INVERSETYPE SetInverseType ( INVERSETYPE ainversetype ) const override
290
- {
291
-
292
- INVERSETYPE old_invtype = inversetype;
293
- inversetype = ainversetype;
294
- return old_invtype;
295
- }
296
-
297
- virtual INVERSETYPE SetInverseType ( string ainversetype ) const override;
298
-
299
- virtual INVERSETYPE GetInverseType () const override
300
- { return inversetype; }
301
- virtual void SetInverseFlags (const Flags & flags) override
302
- { inverseflags = flags; }
303
- virtual const Flags & GetInverseFlags () const { return inverseflags; }
304
-
305
- void SetSPD (bool aspd = true) { spd = aspd; }
306
- bool IsSPD () const { return spd; }
307
- virtual size_t NZE () const override { return nze; }
308
- virtual tuple<int,int> EntrySizes() const = 0;
309
-
310
- virtual shared_ptr<BaseMatrix> DeleteZeroElements(double tol) const override
311
- {
312
- throw Exception ("DeleteZeroElements not overloaded");
313
- }
314
- };
315
-
316
-
317
- template <typename TSCAL>
318
- class NGS_DLL_HEADER S_BaseSparseMatrix : public BaseSparseMatrix
319
- {
320
- protected:
321
- int entry_height, entry_width;
322
- // in general entry_size=entry_height*entry_width, but matrix entry type could
323
- // also be a diagonal matrix
324
- int entry_size;
325
- VFlatVector<TSCAL> asvec;
326
- using MatrixGraph::ColIdx;
327
- public:
328
- using BaseSparseMatrix::BaseSparseMatrix;
329
- /*
330
- void SetEntrySize (int eh, int ew, int es)
331
- {
332
- entry_height = eh;
333
- entry_width = ew;
334
- entry_size = es;
335
- }
336
- */
337
-
338
- virtual BaseVector & AsVector() override
339
- {
340
- return asvec;
341
- }
342
-
343
- virtual const BaseVector & AsVector() const override
344
- {
345
- return asvec;
346
- }
347
-
348
- // tuple<int,int> EntryShape() const { return { entry_height, entry_width }; }
349
-
350
- FlatVector<TSCAL> GetRowValue (int row, int j)
351
- {
352
- TSCAL * p = asvec(entry_size * (firsti[row] + j)).Data(0);
353
- return FlatVector<TSCAL> (entry_size, p);
354
- }
355
-
356
- FlatMatrix<TSCAL> GetRowValueMat (int row, int j) const
357
- {
358
- // TSCAL * p = asvec(entry_size * (firsti[row] + j)).Data(0);
359
- TSCAL * p = &asvec(entry_size * (firsti[row] + j));
360
- return FlatMatrix<TSCAL> (entry_height, entry_width, p);
361
- }
362
- };
363
-
364
-
365
- /// A general, sparse matrix
366
- template<class TM>
367
- class NGS_DLL_HEADER SparseMatrixTM : public S_BaseSparseMatrix<typename mat_traits<TM>::TSCAL>
368
- {
369
- protected:
370
- // Array<TM, size_t> data;
371
- NumaDistributedArray<TM> data;
372
- TM nul;
373
- bool hermitian = false;
374
-
375
- typedef S_BaseSparseMatrix<typename mat_traits<TM>::TSCAL> BASE;
376
- using BASE::firsti;
377
- using BASE::colnr;
378
- using BASE::owner;
379
- using BASE::size;
380
- using BASE::width;
381
- using BASE::nze;
382
- using BASE::balance;
383
- using BASE::asvec;
384
- public:
385
- using BASE::CreatePosition;
386
- using BASE::GetPositionTest;
387
- using BASE::FindSameNZE;
388
- // using BASE::SetEntrySize;
389
- using BASE::AsVector;
390
- using typename BASE::ColIdx;
391
-
392
- void SetEntrySize()
393
- {
394
- // BASE::SetEntrySize (ngbla::Height<TM>(), ngbla::Width<TM>(), sizeof(TM)/sizeof(TSCAL));
395
- BASE::entry_height = ngbla::Height<TM>();
396
- BASE::entry_width = ngbla::Width<TM>();
397
- BASE::entry_size = sizeof(TM)/sizeof(TSCAL);
398
- BASE::is_complex = ngbla::IsComplex<TM>();
399
- }
400
-
401
- public:
402
- typedef TM TENTRY;
403
- typedef typename mat_traits<TM>::TSCAL TSCAL;
404
-
405
- SparseMatrixTM (int as, int max_elsperrow)
406
- : BASE (as, max_elsperrow),
407
- data(nze), nul(TSCAL(0))
408
- {
409
- // SetEntrySize (mat_traits<TM>::HEIGHT, mat_traits<TM>::WIDTH, sizeof(TM)/sizeof(TSCAL));
410
- // SetEntrySize (Height<TM>(), Width<TM>(), sizeof(TM)/sizeof(TSCAL));
411
- SetEntrySize ();
412
- asvec.AssignMemory (nze*sizeof(TM)/sizeof(TSCAL), (void*)data.Addr(0));
413
- GetMemoryTracer().Track(*static_cast<MatrixGraph*>(this), "MatrixGraph",
414
- data, "data");
415
- GetMemoryTracer().SetName("SparseMatrix");
416
- }
417
-
418
- SparseMatrixTM (const Array<int> & elsperrow, int awidth)
419
- : BASE (elsperrow, awidth),
420
- data(nze), nul(TSCAL(0))
421
- {
422
- // SetEntrySize (mat_traits<TM>::HEIGHT, mat_traits<TM>::WIDTH, sizeof(TM)/sizeof(TSCAL));
423
- SetEntrySize ();
424
- asvec.AssignMemory (nze*sizeof(TM)/sizeof(TSCAL), (void*)data.Addr(0));
425
- GetMemoryTracer().Track(*static_cast<MatrixGraph*>(this), "MatrixGraph",
426
- data, "data");
427
- GetMemoryTracer().SetName("SparseMatrix");
428
-
429
- }
430
-
431
- SparseMatrixTM (int size, int width, const Table<int> & rowelements,
432
- const Table<int> & colelements, bool symmetric)
433
- : BASE (size, width, rowelements, colelements, symmetric),
434
- data(nze), nul(TSCAL(0))
435
- {
436
- // SetEntrySize (mat_traits<TM>::HEIGHT, mat_traits<TM>::WIDTH, sizeof(TM)/sizeof(TSCAL));
437
- SetEntrySize ();
438
- asvec.AssignMemory (nze*sizeof(TM)/sizeof(TSCAL), (void*)data.Addr(0));
439
- GetMemoryTracer().Track(*static_cast<MatrixGraph*>(this), "MatrixGraph",
440
- data, "data");
441
- GetMemoryTracer().SetName("SparseMatrix");
442
-
443
- }
444
-
445
- SparseMatrixTM (const MatrixGraph & agraph)
446
- : BASE (agraph),
447
- data(nze), nul(TSCAL(0))
448
- {
449
- // SetEntrySize (mat_traits<TM>::HEIGHT, mat_traits<TM>::WIDTH, sizeof(TM)/sizeof(TSCAL));
450
- SetEntrySize ();
451
- asvec.AssignMemory (nze*sizeof(TM)/sizeof(TSCAL), (void*)data.Addr(0));
452
- FindSameNZE();
453
- GetMemoryTracer().Track(*static_cast<MatrixGraph*>(this), "MatrixGraph",
454
- data, "data");
455
- GetMemoryTracer().SetName("SparseMatrix");
456
- }
457
-
458
- SparseMatrixTM (MatrixGraph && agraph)
459
- : BASE (std::move(agraph)),
460
- data(nze), nul(TSCAL(0))
461
- {
462
- // SetEntrySize (mat_traits<TM>::HEIGHT, mat_traits<TM>::WIDTH, sizeof(TM)/sizeof(TSCAL));
463
- SetEntrySize ();
464
- asvec.AssignMemory (nze*sizeof(TM)/sizeof(TSCAL), (void*)data.Addr(0));
465
- FindSameNZE();
466
- GetMemoryTracer().Track(*static_cast<MatrixGraph*>(this), "MatrixGraph",
467
- data, "data");
468
- GetMemoryTracer().SetName("SparseMatrix");
469
- }
470
-
471
- SparseMatrixTM (const SparseMatrixTM & amat)
472
- : BASE (amat),
473
- data(nze), nul(TSCAL(0))
474
- {
475
- // SetEntrySize (mat_traits<TM>::HEIGHT, mat_traits<TM>::WIDTH, sizeof(TM)/sizeof(TSCAL));
476
- SetEntrySize ();
477
- asvec.AssignMemory (nze*sizeof(TM)/sizeof(TSCAL), (void*)data.Addr(0));
478
- AsVector() = amat.AsVector();
479
- GetMemoryTracer().Track(*static_cast<MatrixGraph*>(this), "MatrixGraph",
480
- data, "data");
481
- GetMemoryTracer().SetName("SparseMatrix");
482
- }
483
-
484
- SparseMatrixTM (SparseMatrixTM && amat)
485
- : BASE (std::move(amat)), nul(TSCAL(0))
486
- {
487
- // SetEntrySize (mat_traits<TM>::HEIGHT, mat_traits<TM>::WIDTH, sizeof(TM)/sizeof(TSCAL));
488
- SetEntrySize ();
489
- GetMemoryTracer().Track(*static_cast<MatrixGraph*>(this), "MatrixGraph",
490
- data, "data");
491
- GetMemoryTracer().SetName("SparseMatrix");
492
- data.Swap(amat.data);
493
- asvec.AssignMemory (nze*sizeof(TM)/sizeof(TSCAL), (void*)data.Addr(0));
494
- }
495
-
496
- static shared_ptr<SparseMatrixTM> CreateFromCOO (FlatArray<int> i, FlatArray<int> j,
497
- FlatArray<TM> val, size_t h, size_t w);
498
-
499
- virtual ~SparseMatrixTM ();
500
-
501
- size_t Height() const { return size; }
502
- size_t Width() const { return width; }
503
- virtual int VHeight() const override { return size; }
504
- virtual int VWidth() const override { return width; }
505
- virtual tuple<size_t, size_t> Shape() const override { return { size, width }; }
506
-
507
-
508
- bool IsHermitian() const { return hermitian; }
509
- void SetHermitian(bool herm) { hermitian = herm; }
510
-
511
- TM & operator[] (size_t i) { return data[i]; }
512
- const TM & operator[] (size_t i) const { return data[i]; }
513
-
514
- TM & operator() (size_t row, size_t col)
515
- {
516
- return data[CreatePosition(row, col)];
517
- }
518
-
519
- const TM & operator() (size_t row, size_t col) const
520
- {
521
- size_t pos = GetPositionTest (row,col);
522
- if (pos != numeric_limits<size_t>::max())
523
- return data[pos];
524
- else
525
- return nul;
526
- }
527
-
528
- void PrefetchRow (size_t rownr) const;
529
-
530
- // full value array
531
- FlatVector<TM> GetValues() const { return FlatVector<TM> (data.Size(), data.Addr(0)); }
532
-
533
- FlatVector<TM> GetRowValues(int i) const
534
- { return FlatVector<TM> (firsti[i+1]-firsti[i], data+firsti[i]); }
535
-
536
- static bool IsRegularIndex (int index) { return index >= 0; }
537
- virtual void AddElementMatrix(FlatArray<int> dnums1,
538
- FlatArray<int> dnums2,
539
- BareSliceMatrix<TSCAL> elmat,
540
- bool use_atomic = false);
541
-
542
- virtual void AddElementMatrixSymmetric(FlatArray<int> dnums,
543
- BareSliceMatrix<TSCAL> elmat,
544
- bool use_atomic = false);
545
-
546
-
547
- virtual void SetZero() override;
548
-
549
-
550
- ///
551
- virtual ostream & Print (ostream & ost) const override;
552
-
553
- ///
554
- virtual Array<MemoryUsage> GetMemoryUsage () const override;
555
-
556
- virtual AutoVector CreateVector () const override;
557
- virtual AutoVector CreateRowVector () const override;
558
- virtual AutoVector CreateColVector () const override;
559
-
560
- // virtual tuple<int,int> EntrySizes() const override { return { mat_traits<TM>::HEIGHT, mat_traits<TM>::WIDTH }; }
561
- virtual tuple<int,int> EntrySizes() const override { return { ngbla::Height<TM>(), ngbla::Width<TM>() }; }
562
-
563
- shared_ptr<BaseSparseMatrix>
564
- CreateTransposeTM (const function<shared_ptr<SparseMatrixTM<decltype(ngbla::Trans(TM()))>>(const Array<int>&, int)> & creator) const;
565
-
566
- public:
567
- using BaseMatrix::GetMemoryTracer;
568
- };
569
-
570
-
571
-
572
-
573
- template<class TM, class TV_ROW, class TV_COL>
574
- class NGS_DLL_HEADER SparseMatrix : public SparseMatrixTM<TM>
575
- {
576
- public:
577
- using SparseMatrixTM<TM>::firsti;
578
- using SparseMatrixTM<TM>::colnr;
579
- using SparseMatrixTM<TM>::data;
580
- using SparseMatrixTM<TM>::balance;
581
- using typename SparseMatrixTM<TM>::ColIdx;
582
-
583
- typedef typename mat_traits<TM>::TSCAL TSCAL;
584
- typedef TV_ROW TVX;
585
- typedef TV_COL TVY;
586
-
587
- ///
588
- SparseMatrix (int as, int max_elsperrow)
589
- : SparseMatrixTM<TM> (as, max_elsperrow) { ; }
590
-
591
- SparseMatrix (const Array<int> & aelsperrow)
592
- : SparseMatrixTM<TM> (aelsperrow, aelsperrow.Size()) { ; }
593
-
594
- SparseMatrix (const Array<int> & aelsperrow, int awidth)
595
- : SparseMatrixTM<TM> (aelsperrow, awidth) { ; }
596
-
597
- SparseMatrix (int height, int width, const Table<int> & rowelements,
598
- const Table<int> & colelements, bool symmetric)
599
- : SparseMatrixTM<TM> (height, width, rowelements, colelements, symmetric) { ; }
600
-
601
- SparseMatrix (const MatrixGraph & agraph);
602
- SparseMatrix (MatrixGraph && agraph);
603
-
604
- SparseMatrix (const SparseMatrix & amat)
605
- : SparseMatrixTM<TM> (amat) { ; }
606
-
607
- SparseMatrix (const SparseMatrixTM<TM> & amat)
608
- : SparseMatrixTM<TM> (amat) { ; }
609
-
610
- SparseMatrix (SparseMatrixTM<TM> && amat)
611
- : SparseMatrixTM<TM> (std::move(amat)) { ; }
612
-
613
- virtual shared_ptr<BaseMatrix> CreateMatrix () const override;
614
- // virtual BaseMatrix * CreateMatrix (const Array<int> & elsperrow) const;
615
- ///
616
- virtual AutoVector CreateVector () const override;
617
- virtual AutoVector CreateRowVector () const override;
618
- virtual AutoVector CreateColVector () const override;
619
-
620
-
621
- BaseMatrix::OperatorInfo GetOperatorInfo () const override
622
- { return { string("SparseMatrix")+typeid(TM).name(), this->Height(), this->Width() }; }
623
-
624
- virtual shared_ptr<BaseJacobiPrecond>
625
- CreateJacobiPrecond (shared_ptr<BitArray> inner) const override;
626
-
627
- virtual shared_ptr<BaseBlockJacobiPrecond>
628
- CreateBlockJacobiPrecond (shared_ptr<Table<int>> blocks,
629
- const BaseVector * constraint = 0,
630
- bool parallel = 1,
631
- shared_ptr<BitArray> freedofs = NULL) const override;
632
-
633
- virtual shared_ptr<BaseMatrix> InverseMatrix (shared_ptr<BitArray> subset = nullptr) const override;
634
- virtual shared_ptr<BaseMatrix> InverseMatrix (shared_ptr<const Array<int>> clusters) const override;
635
-
636
- virtual shared_ptr<BaseSparseMatrix> Restrict (const SparseMatrixTM<double> & prol,
637
- shared_ptr<BaseSparseMatrix> cmat = nullptr) const override;
638
-
639
- virtual shared_ptr<BaseSparseMatrix> Reorder (const Array<size_t> & reorder) const override;
640
-
641
- virtual shared_ptr<BaseSparseMatrix> CreateTranspose() const override
642
- {
643
- return this->CreateTransposeTM
644
- ( [](const Array<int> & elsperrow, int width) -> shared_ptr<SparseMatrixTM<decltype(Trans(TM()))>>
645
- { return make_shared<SparseMatrix<decltype(Trans(TM())), TV_COL, TV_ROW>> (elsperrow, width); } );
646
- }
647
-
648
- virtual shared_ptr<BaseMatrix> DeleteZeroElements(double tol) const override;
649
-
650
- ///
651
- inline TVY RowTimesVector (int row, const FlatVector<TVX> vec) const
652
- {
653
- typedef typename mat_traits<TVY>::TSCAL TTSCAL;
654
- TVY sum = TTSCAL(0);
655
- for (size_t j = firsti[row]; j < firsti[row+1]; j++)
656
- sum += data[j] * vec(colnr[j]);
657
- return sum;
658
- }
659
-
660
- ///
661
- void AddRowTransToVector (int row, TVY el, FlatVector<TVX> vec) const
662
- {
663
- size_t first = firsti[row];
664
- size_t last = firsti[row+1];
665
-
666
- const ColIdx * colpi = colnr.Addr(0);
667
- const TM * datap = data.Addr(0);
668
-
669
- for (size_t j = first; j < last; j++)
670
- vec[colpi[j]] += Trans(datap[j]) * el;
671
- }
672
-
673
- ///
674
- void AddRowConjTransToVector (int row, TVY el, FlatVector<TVX> vec) const
675
- {
676
- size_t first = firsti[row];
677
- size_t last = firsti[row+1];
678
-
679
- const ColIdx * colpi = colnr.Addr(0);
680
- const TM * datap = data.Addr(0);
681
-
682
- for (size_t j = first; j < last; j++)
683
- vec[colpi[j]] += Conj(Trans(datap[j])) * el;
684
- }
685
-
686
-
687
- virtual void MultAdd (double s, const BaseVector & x, BaseVector & y) const override;
688
- virtual void MultTransAdd (double s, const BaseVector & x, BaseVector & y) const override;
689
- virtual void MultAdd (Complex s, const BaseVector & x, BaseVector & y) const override;
690
- virtual void MultTransAdd (Complex s, const BaseVector & x, BaseVector & y) const override;
691
- virtual void MultConjTransAdd (Complex s, const BaseVector & x, BaseVector & y) const override;
692
-
693
- virtual void MultAdd (FlatVector<double> alpha, const MultiVector & x, MultiVector & y) const override;
694
-
695
-
696
- virtual void MultAdd1 (double s, const BaseVector & x, BaseVector & y,
697
- const BitArray * ainner = NULL,
698
- const Array<int> * acluster = NULL) const override;
699
-
700
- virtual void DoArchive (Archive & ar) override;
701
- };
702
-
703
-
704
-
705
- /// A symmetric sparse matrix
706
- template<class TM, class TV>
707
- class NGS_DLL_HEADER SparseMatrixSymmetric : public SparseMatrix<TM,TV,TV>
708
- {
709
-
710
- public:
711
- using SparseMatrixTM<TM>::firsti;
712
- using SparseMatrixTM<TM>::colnr;
713
- using SparseMatrixTM<TM>::data;
714
- using BaseSparseMatrix::ColIdx;
715
-
716
- typedef typename mat_traits<TM>::TSCAL TSCAL;
717
- typedef TV TV_COL;
718
- typedef TV TV_ROW;
719
- typedef TV TVY;
720
- typedef TV TVX;
721
-
722
- SparseMatrixSymmetric (int as, int max_elsperrow)
723
- : SparseMatrix<TM,TV,TV> (as, max_elsperrow)
724
- { ; }
725
-
726
- SparseMatrixSymmetric (const Array<int> & elsperrow)
727
- : SparseMatrix<TM,TV,TV> (elsperrow, elsperrow.Size())
728
- { ; }
729
-
730
- SparseMatrixSymmetric (int size, const Table<int> & rowelements)
731
- : SparseMatrix<TM,TV,TV> (size, size, rowelements, rowelements, true)
732
- { ; }
733
-
734
- SparseMatrixSymmetric (const MatrixGraph & agraph);
735
- SparseMatrixSymmetric (MatrixGraph && agraph);
736
-
737
- SparseMatrixSymmetric (const SparseMatrixSymmetric & amat)
738
- : SparseMatrix<TM,TV,TV> (amat)
739
- {
740
- this->AsVector() = amat.AsVector();
741
- }
742
-
743
- SparseMatrixSymmetric (const SparseMatrixTM<TM> & amat)
744
- : SparseMatrix<TM,TV,TV> (amat)
745
- {
746
- this->AsVector() = amat.AsVector();
747
- }
748
-
749
- ///
750
- virtual ~SparseMatrixSymmetric ();
751
-
752
- SparseMatrixSymmetric & operator= (double s)
753
- {
754
- this->AsVector() = s;
755
- return *this;
756
- }
757
-
758
- virtual shared_ptr<BaseMatrix> CreateMatrix () const override
759
- {
760
- return make_shared<SparseMatrixSymmetric> (*this);
761
- }
762
-
763
- /*
764
- virtual BaseMatrix * CreateMatrix (const Array<int> & elsperrow) const
765
- {
766
- return new SparseMatrix<TM,TV,TV>(elsperrow);
767
- }
768
- */
769
-
770
- virtual void AddElementMatrix(FlatArray<int> dnums1,
771
- FlatArray<int> dnums2,
772
- BareSliceMatrix<TSCAL> elmat,
773
- bool use_atomic = false) override
774
- {
775
- this->AddElementMatrixSymmetric (dnums1, elmat, use_atomic);
776
- }
777
-
778
- virtual shared_ptr<BaseJacobiPrecond> CreateJacobiPrecond (shared_ptr<BitArray> inner) const override;
779
- virtual shared_ptr<BaseBlockJacobiPrecond>
780
- CreateBlockJacobiPrecond (shared_ptr<Table<int>> blocks,
781
- const BaseVector * constraint = 0,
782
- bool parallel = 1,
783
- shared_ptr<BitArray> freedofs = NULL) const override;
784
-
785
- virtual shared_ptr<BaseSparseMatrix> Restrict (const SparseMatrixTM<double> & prol,
786
- shared_ptr<BaseSparseMatrix> cmat = nullptr) const override;
787
-
788
- ///
789
- virtual void MultAdd (double s, const BaseVector & x, BaseVector & y) const override;
790
-
791
- virtual void MultTransAdd (double s, const BaseVector & x, BaseVector & y) const override
792
- {
793
- MultAdd (s, x, y);
794
- }
795
-
796
-
797
- /*
798
- y += s L * x
799
- */
800
- virtual void MultAdd1 (double s, const BaseVector & x, BaseVector & y,
801
- const BitArray * ainner = NULL,
802
- const Array<int> * acluster = NULL) const override;
803
-
804
-
805
- /*
806
- y += s (D + L^T) * x
807
- */
808
- virtual void MultAdd2 (double s, const BaseVector & x, BaseVector & y,
809
- const BitArray * ainner = NULL,
810
- const Array<int> * acluster = NULL) const override;
811
-
812
-
813
-
814
-
815
-
816
- using SparseMatrix<TM,TV,TV>::RowTimesVector;
817
- using SparseMatrix<TM,TV,TV>::AddRowTransToVector;
818
-
819
-
820
- TV_COL RowTimesVectorNoDiag (int row, const FlatVector<TVX> vec) const
821
- {
822
- size_t last = firsti[row+1];
823
- size_t first = firsti[row];
824
- if (last == first) return TVY(0);
825
- if (colnr[last-1] == row) last--;
826
-
827
- typedef typename mat_traits<TVY>::TSCAL TTSCAL;
828
- TVY sum = TTSCAL(0);
829
-
830
- for (size_t j = first; j < last; j++)
831
- sum += data[j] * vec(colnr[j]);
832
- return sum;
833
- }
834
-
835
- void AddRowTransToVectorNoDiag (int row, TVY el, FlatVector<TVX> vec) const
836
- {
837
- size_t first = firsti[row];
838
- size_t last = firsti[row+1];
839
-
840
- if (first == last) return;
841
- if (this->colnr[last-1] == row) last--;
842
-
843
- for (size_t j = first; j < last; j++)
844
- vec[colnr[j]] += Trans(data[j]) * el;
845
- }
846
-
847
- BaseSparseMatrix & AddMerge (double s, const SparseMatrixSymmetric & m2);
848
-
849
- virtual shared_ptr<BaseMatrix> InverseMatrix (shared_ptr<BitArray> subset = nullptr) const override;
850
- virtual shared_ptr<BaseMatrix> InverseMatrix (shared_ptr<const Array<int>> clusters) const override;
851
- };
852
-
853
- [[deprecated("Use sparsematrix->CreateTranspose() instead!")]]
854
- NGS_DLL_HEADER shared_ptr<SparseMatrixTM<double>> TransposeMatrix (const SparseMatrixTM<double> & mat);
855
-
856
- NGS_DLL_HEADER shared_ptr<SparseMatrixTM<double>>
857
- MatAdd (double sa, const SparseMatrixTM<double> & mata,
858
- double sb, const SparseMatrixTM<double> & matb);
859
-
860
- NGS_DLL_HEADER shared_ptr<SparseMatrixTM<double>>
861
- MatMult (const SparseMatrixTM<double> & mata, const SparseMatrixTM<double> & matb);
862
- NGS_DLL_HEADER shared_ptr<SparseMatrixTM<Complex>>
863
- MatMult (const SparseMatrixTM<Complex> & mata, const SparseMatrixTM<Complex> & matb);
864
-
865
- #ifdef GOLD
866
- #include <sparsematrix_spec.hpp>
867
- #endif
868
-
869
- shared_ptr<BaseMatrix> CreateSparseMatrixInverse(shared_ptr<const BaseSparseMatrix> A,
870
- shared_ptr<BitArray> subset,
871
- shared_ptr<const Array<int>> clusters);
872
-
873
- #ifdef FILE_SPARSEMATRIX_CPP
874
- #define SPARSEMATRIX_EXTERN
875
- #else
876
- #define SPARSEMATRIX_EXTERN extern
877
-
878
-
879
- SPARSEMATRIX_EXTERN template class SparseMatrix<double>;
880
- SPARSEMATRIX_EXTERN template class SparseMatrix<Complex>;
881
- SPARSEMATRIX_EXTERN template class SparseMatrix<double, Complex, Complex>;
882
-
883
- SPARSEMATRIX_EXTERN template class SparseMatrixSymmetric<double>;
884
- SPARSEMATRIX_EXTERN template class SparseMatrixSymmetric<Complex>;
885
- SPARSEMATRIX_EXTERN template class SparseMatrixSymmetric<double, Complex>;
886
-
887
- #define INST_SPMS(N) \
888
- SPARSEMATRIX_EXTERN template class SparseMatrix<Mat<N, N, double>>; \
889
- SPARSEMATRIX_EXTERN template class SparseMatrix<Mat<1, N, double>>; \
890
- SPARSEMATRIX_EXTERN template class SparseMatrix<Mat<N, 1, double>>; \
891
- SPARSEMATRIX_EXTERN template class SparseMatrix<Mat<N, N, Complex>>; \
892
- SPARSEMATRIX_EXTERN template class SparseMatrix<Mat<1, N, Complex>>; \
893
- SPARSEMATRIX_EXTERN template class SparseMatrix<Mat<N, 1, Complex>>; \
894
- SPARSEMATRIX_EXTERN template class SparseMatrixSymmetric<Mat<N, N, double>>; \
895
- SPARSEMATRIX_EXTERN template class SparseMatrixSymmetric<Mat<N, N, Complex>>;
896
-
897
-
898
- #if MAX_SYS_DIM >= 1
899
- INST_SPMS(1);
900
- #endif
901
- #if MAX_SYS_DIM >= 2
902
- INST_SPMS(2);
903
- #endif
904
- #if MAX_SYS_DIM >= 3
905
- INST_SPMS(3);
906
- #endif
907
- #if MAX_SYS_DIM >= 4
908
- INST_SPMS(4);
909
- #endif
910
- #if MAX_SYS_DIM >= 5
911
- INST_SPMS(5);
912
- #endif
913
- #if MAX_SYS_DIM >= 6
914
- INST_SPMS(6);
915
- #endif
916
- #if MAX_SYS_DIM >= 7
917
- INST_SPMS(7);
918
- #endif
919
- #if MAX_SYS_DIM >= 8
920
- INST_SPMS(8);
921
- #endif
922
-
923
- #undef INST_SPMS
924
- #undef SPARSEMATRIX_EXTERN
925
-
926
-
927
- #endif
928
-
929
-
930
-
931
- template <typename TSCAL>
932
- class NGS_DLL_HEADER SparseBlockMatrix : public S_BaseSparseMatrix<TSCAL>
933
- {
934
- size_t bheight, bwidth;
935
- NumaDistributedArray<TSCAL> data;
936
-
937
- typedef S_BaseSparseMatrix<TSCAL> BASE;
938
- using BASE::firsti;
939
- using BASE::colnr;
940
- using BASE::owner;
941
- using BASE::size;
942
- using BASE::width;
943
- using BASE::nze;
944
- using BASE::balance;
945
- using BASE::asvec;
946
-
947
- public:
948
- using BASE::CreatePosition;
949
- using BASE::GetPositionTest;
950
- using BASE::FindSameNZE;
951
- // using BASE::SetEntrySize;
952
- using BASE::AsVector;
953
-
954
- SparseBlockMatrix (const MatrixGraph & agraph, size_t abheight, size_t abwidth)
955
- : BASE (agraph), bheight(abheight), bwidth(abwidth),
956
- data(nze*bheight*bwidth)
957
- {
958
- // SetEntrySize (bheight, bwidth, bheight*bwidth);
959
- BASE::entry_height = bheight;
960
- BASE::entry_width = bwidth;
961
- BASE::entry_size = bheight*bwidth;
962
- BASE::is_complex = ngbla::IsComplex<TSCAL>();
963
-
964
- asvec.AssignMemory (nze*bheight*bwidth, (void*)data.Addr(0));
965
- // FindSameNZE();
966
- GetMemoryTracer().Track(*static_cast<MatrixGraph*>(this), "MatrixGraph",
967
- data, "data");
968
- GetMemoryTracer().SetName("SparseMatrix");
969
- }
970
-
971
- SparseBlockMatrix (MatrixGraph && agraph, size_t abheight, size_t abwidth)
972
- : BASE (std::move(agraph)), bheight(abheight), bwidth(abwidth),
973
- data(nze*bheight*bwidth)
974
- {
975
- // SetEntrySize (bheight, bwidth, bheight*bwidth);
976
- BASE::entry_height = bheight;
977
- BASE::entry_width = bwidth;
978
- BASE::entry_size = bheight*bwidth;
979
- BASE::is_complex = ngbla::IsComplex<TSCAL>();
980
-
981
- asvec.AssignMemory (nze*bheight*bwidth, (void*)data.Addr(0));
982
- // FindSameNZE();
983
- GetMemoryTracer().Track(*static_cast<MatrixGraph*>(this), "MatrixGraph",
984
- data, "data");
985
- GetMemoryTracer().SetName("SparseMatrix");
986
- }
987
-
988
-
989
-
990
- tuple<int,int> EntrySizes() const override { return { bheight, bwidth }; }
991
-
992
- AutoVector CreateRowVector () const override
993
- {
994
- return AutoVector(make_shared<S_BaseVectorPtr<TSCAL>> (this->width, this->bwidth));
995
- }
996
-
997
- AutoVector CreateColVector () const override
998
- {
999
- return AutoVector(make_shared<S_BaseVectorPtr<TSCAL>> (this->size, this->bheight));
1000
- }
1001
-
1002
- virtual void MultAdd (double s, const BaseVector & x, BaseVector & y) const override;
1003
-
1004
-
1005
- void SetZero() override
1006
- {
1007
- data = TSCAL(0);
1008
- }
1009
-
1010
- virtual void AddElementMatrix(FlatArray<int> dnums1,
1011
- FlatArray<int> dnums2,
1012
- BareSliceMatrix<TSCAL> elmat,
1013
- bool use_atomic = false);
1014
-
1015
- ostream & Print (ostream & ost) const override;
1016
-
1017
-
1018
- const MemoryTracer & GetMemoryTracer() const
1019
- {
1020
- return mem_tracer;
1021
- }
1022
-
1023
- private:
1024
- MemoryTracer mem_tracer =
1025
- {"MatrixGraph",
1026
- colnr, "colnr",
1027
- firsti, "firsti"
1028
- // same_nze, "same_nze"
1029
- };
1030
-
1031
- };
1032
-
1033
-
1034
-
1035
-
1036
- }
1037
-
1038
- #endif