ngsolve 6.2.2501.post16.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.post16.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.post16.dev1.data/data/Netgen.icns +0 -0
  251. ngsolve-6.2.2501.post16.dev1.data/data/bin/ngscxx +0 -17
  252. ngsolve-6.2.2501.post16.dev1.data/data/bin/ngsld +0 -13
  253. ngsolve-6.2.2501.post16.dev1.data/data/bin/ngsolve.tcl +0 -648
  254. ngsolve-6.2.2501.post16.dev1.data/data/bin/ngspy +0 -2
  255. ngsolve-6.2.2501.post16.dev1.data/data/share/ngsolve/beam.geo +0 -17
  256. ngsolve-6.2.2501.post16.dev1.data/data/share/ngsolve/beam.vol +0 -240
  257. ngsolve-6.2.2501.post16.dev1.data/data/share/ngsolve/chip.in2d +0 -41
  258. ngsolve-6.2.2501.post16.dev1.data/data/share/ngsolve/chip.vol +0 -614
  259. ngsolve-6.2.2501.post16.dev1.data/data/share/ngsolve/coil.geo +0 -12
  260. ngsolve-6.2.2501.post16.dev1.data/data/share/ngsolve/coil.vol +0 -2560
  261. ngsolve-6.2.2501.post16.dev1.data/data/share/ngsolve/coilshield.geo +0 -24
  262. ngsolve-6.2.2501.post16.dev1.data/data/share/ngsolve/coilshield.vol +0 -3179
  263. ngsolve-6.2.2501.post16.dev1.data/data/share/ngsolve/cube.geo +0 -19
  264. ngsolve-6.2.2501.post16.dev1.data/data/share/ngsolve/cube.vol +0 -1832
  265. ngsolve-6.2.2501.post16.dev1.data/data/share/ngsolve/d10_DGdoubleglazing.pde +0 -50
  266. ngsolve-6.2.2501.post16.dev1.data/data/share/ngsolve/d11_chip_nitsche.pde +0 -40
  267. ngsolve-6.2.2501.post16.dev1.data/data/share/ngsolve/d1_square.pde +0 -43
  268. ngsolve-6.2.2501.post16.dev1.data/data/share/ngsolve/d2_chip.pde +0 -35
  269. ngsolve-6.2.2501.post16.dev1.data/data/share/ngsolve/d3_helmholtz.pde +0 -22
  270. ngsolve-6.2.2501.post16.dev1.data/data/share/ngsolve/d4_cube.pde +0 -46
  271. ngsolve-6.2.2501.post16.dev1.data/data/share/ngsolve/d5_beam.pde +0 -74
  272. ngsolve-6.2.2501.post16.dev1.data/data/share/ngsolve/d6_shaft.pde +0 -73
  273. ngsolve-6.2.2501.post16.dev1.data/data/share/ngsolve/d7_coil.pde +0 -50
  274. ngsolve-6.2.2501.post16.dev1.data/data/share/ngsolve/d8_coilshield.pde +0 -49
  275. ngsolve-6.2.2501.post16.dev1.data/data/share/ngsolve/d9_hybridDG.pde +0 -72
  276. ngsolve-6.2.2501.post16.dev1.data/data/share/ngsolve/doubleglazing.in2d +0 -27
  277. ngsolve-6.2.2501.post16.dev1.data/data/share/ngsolve/doubleglazing.vol +0 -737
  278. ngsolve-6.2.2501.post16.dev1.data/data/share/ngsolve/piezo2d40round4.vol.gz +0 -0
  279. ngsolve-6.2.2501.post16.dev1.data/data/share/ngsolve/shaft.geo +0 -73
  280. ngsolve-6.2.2501.post16.dev1.data/data/share/ngsolve/shaft.vol +0 -4291
  281. ngsolve-6.2.2501.post16.dev1.data/data/share/ngsolve/square.in2d +0 -17
  282. ngsolve-6.2.2501.post16.dev1.data/data/share/ngsolve/square.vol +0 -149
  283. ngsolve-6.2.2501.post16.dev1.dist-info/RECORD +0 -304
  284. {ngsolve-6.2.2501.post16.dev1.dist-info → ngsolve-6.2.2501.post34.dev1.dist-info}/LICENSE +0 -0
  285. {ngsolve-6.2.2501.post16.dev1.dist-info → ngsolve-6.2.2501.post34.dev1.dist-info}/WHEEL +0 -0
  286. {ngsolve-6.2.2501.post16.dev1.dist-info → ngsolve-6.2.2501.post34.dev1.dist-info}/top_level.txt +0 -0
netgen/include/vector.hpp DELETED
@@ -1,1219 +0,0 @@
1
- #ifndef FILE_VECTOR_EXPR
2
- #define FILE_VECTOR_EXPR
3
-
4
- /**************************************************************************/
5
- /* File: vector.hpp */
6
- /* Author: Joachim Schoeberl */
7
- /* Date: 01. Jan. 02 */
8
- /**************************************************************************/
9
-
10
- #include "expr.hpp"
11
- #include <core/hashtable.hpp> // for SparseVector
12
-
13
- namespace ngbla
14
- {
15
-
16
- template <typename T=double, typename TS=size_t, typename TDIST=IC<1>> class VectorView;
17
-
18
-
19
- template <typename T, typename ...Args>
20
- INLINE void SetVector (typename mat_traits<T>::TSCAL val, VectorView<T,Args...> vec) NETGEN_NOEXCEPT
21
- {
22
- for (size_t i : Range(vec))
23
- vec[i] = val;
24
- }
25
-
26
-
27
-
28
- template <typename T = double>
29
- using FlatVector = VectorView<T,size_t,IC<1>>;
30
-
31
- template <typename T, typename TELEM=typename T::TELEM>
32
- constexpr bool IsConvertibleToFlatVector () {
33
- return is_constructible_v<FlatVector<TELEM>,T>;
34
- }
35
-
36
- template <typename T, typename TELEM=typename T::TELEM>
37
- auto make_FlatVector (const T & v) {
38
- return FlatVector<TELEM> (v);
39
- }
40
-
41
-
42
-
43
- template <typename T = double>
44
- using SliceVector = VectorView<T,size_t,size_t>;
45
-
46
- template <typename T, typename TELEM=typename T::TELEM>
47
- constexpr bool IsConvertibleToSliceVector () {
48
- return is_constructible_v<SliceVector<TELEM>,T>;
49
- }
50
-
51
- template <typename T, typename TELEM=typename T::TELEM>
52
- auto make_SliceVector (const T & v) {
53
- return SliceVector<TELEM> (v);
54
- }
55
-
56
-
57
-
58
-
59
- template <typename T = double>
60
- using BareSliceVector = VectorView<T,undefined_size,size_t>;
61
-
62
- template <typename T, typename TELEM=typename T::TELEM>
63
- constexpr bool IsConvertibleToBareSliceVector () {
64
- return is_constructible_v<BareSliceVector<TELEM>,T>;
65
- }
66
-
67
- template <typename T, typename TELEM=typename T::TELEM>
68
- auto make_BareSliceVector (const T & v) {
69
- return BareSliceVector<TELEM> (v);
70
- }
71
-
72
-
73
-
74
- template <typename T = double>
75
- using BareVector = VectorView<T,undefined_size,IC<1>>;
76
-
77
- template <typename T, typename TELEM=typename T::TELEM>
78
- constexpr bool IsConvertibleToBareVector () {
79
- return is_constructible_v<BareVector<TELEM>,T>;
80
- }
81
-
82
- template <typename T, typename TELEM=typename T::TELEM>
83
- auto make_BareVector (const T & v) {
84
- return BareVector<TELEM> (v);
85
- }
86
-
87
-
88
- template <typename T, typename TS>
89
- using LinearVector = VectorView<T,TS,IC<1>>;
90
-
91
-
92
-
93
-
94
-
95
-
96
- template <int S, class T> class Vec;
97
-
98
- template <int S, typename T = double>
99
- using FlatVec = VectorView<T,IC<S>,IC<1>>;
100
-
101
- template <int S, int D, typename T = double>
102
- using FlatSliceVec = VectorView<T,IC<S>,IC<D>>;
103
-
104
- template <int D, typename T = double>
105
- using FixSliceVec = VectorView<T,size_t,IC<D>>;
106
-
107
-
108
-
109
- template <class T> class SysVector;
110
- template <class T = double> class Vector;
111
- template <int DIST, typename T> class FixSliceVector;
112
-
113
- #ifdef WIN32
114
- // #pragma warning( disable : 4848) // support for standard attribute 'no_unique_address' in C++17 and earlier is a vendor extension
115
- // #define NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
116
-
117
- // Disable this optimization with MSVC because it creates inconsistent results with different versions.
118
- // Following code returns 8 for compilers up to MSVC version 19.31, and returns 16 from version 19.32, see https://godbolt.org/z/v6P5vsq1M
119
- #define NO_UNIQUE_ADDRESS
120
- /*
121
- struct Base{};
122
- struct Empty {};
123
-
124
- template <typename T, typename TS>
125
- class Class : public Base{
126
- T* data;
127
- [[msvc::no_unique_address]] TS size;
128
- };
129
-
130
- int f() {
131
- return sizeof(Class<void, Empty>);
132
- }
133
- */
134
-
135
- #else
136
- #define NO_UNIQUE_ADDRESS [[no_unique_address]]
137
- #endif
138
-
139
- template <typename T, typename TS, typename TDIST>
140
- class VectorView : public MatExpr<VectorView<T,TS,TDIST>>
141
- {
142
- protected:
143
- typedef MatExpr<VectorView> BASE;
144
- T * __restrict data;
145
- NO_UNIQUE_ADDRESS TS size;
146
- NO_UNIQUE_ADDRESS TDIST dist;
147
- public:
148
- typedef T TELEM;
149
- typedef typename mat_traits<T>::TSCAL TSCAL;
150
- typedef TDIST type_dist;
151
-
152
- /// linear element access ?
153
- static constexpr bool IsLinear() { return std::is_same<type_dist,IC<1>>(); }
154
-
155
- INLINE VectorView () = default;
156
- INLINE VectorView (const VectorView&) = default;
157
- INLINE VectorView (VectorView&&) = default;
158
-
159
- template <typename T2, typename TS2, typename TDIST2,
160
- enable_if_t<is_convertible<T2*,T*>::value, int> =0,
161
- enable_if_t<is_constructible<TS,TS2>::value, int> =0,
162
- enable_if_t<is_constructible<TDIST,TDIST2>::value, int> =0>
163
- INLINE VectorView (const VectorView<T2,TS2,TDIST2> & v2)
164
- : data{v2.Data()}, size{TS(v2.Size())}, dist{TDIST(v2.Dist())} { }
165
-
166
- INLINE explicit VectorView (T * adata)
167
- : data(adata)
168
- {
169
- ; // static_assert(std::is_same<type_dist,IC<1>>());
170
- }
171
- INLINE VectorView (TS asize, T * adata)
172
- : data(adata), size(asize)
173
- {
174
- static_assert(std::is_same<type_dist,IC<1>>());
175
- }
176
- INLINE VectorView (TS asize, TDIST adist, T * adata)
177
- : data(adata), size(asize), dist(adist) { }
178
-
179
- /// allocate FlatVector on local heap
180
- INLINE VectorView (size_t as, LocalHeap & lh)
181
- : data(lh.Alloc<T> (as)), size(as), dist(IC<1>()) { }
182
-
183
- template <typename EXPR>
184
- INLINE VectorView(LocalHeapExpr<EXPR>&& lhe)
185
- : VectorView(lhe.Height(), lhe.GetLocalHeap())
186
- {
187
- *this = lhe.A();
188
- }
189
-
190
- /// put FlatVector over fixed size vector
191
-
192
- template <int S>
193
- INLINE VectorView (Vec<S,T> & v)
194
- : data(v.Data()), size(v.Size()), dist(IC<1>()) { }
195
-
196
-
197
- /*
198
- template <int S>
199
- INLINE VectorView (Vec<S,T> & v)
200
- : data(const_cast<T*>(v.Data())), size(v.Size()), dist(IC<1>()) { }
201
- */
202
- template <int S>
203
- INLINE VectorView (const Vec<S,T> & v)
204
- : data(const_cast<T*>(v.Data())), size(v.Size()), dist(IC<1>()) { }
205
- /*
206
- template <int S>
207
- INLINE VectorView (Vec<S,const T> & v)
208
- : data(const_cast<T*>(v.Data())), size(v.Size()), dist(IC<1>()) { }
209
- template <int S>
210
- INLINE VectorView (const Vec<S,const T> & v)
211
- : data(const_cast<T*>(v.Data())), size(v.Size()), dist(IC<1>()) { }
212
- */
213
-
214
- INLINE auto Size() const { return size; }
215
- INLINE auto Dist() const { return dist; }
216
- INLINE auto Shape() const { return tuple(size); }
217
-
218
-
219
- INLINE auto Height () const { return size; }
220
- INLINE auto Width () const { return IC<1>(); }
221
-
222
- INLINE auto Range () const { return IntRange (0, size); }
223
-
224
- INLINE T * Addr(size_t i) const { return data+i*dist; }
225
- INLINE T * Data() const { return data; }
226
-
227
- INLINE auto View() const { return VectorView(*this); }
228
- INLINE auto ViewRW() { return this->View(); }
229
-
230
-
231
-
232
- /// assign memory for vector on local heap
233
- INLINE void AssignMemory (size_t as, LocalHeap & lh)
234
- {
235
- size = as;
236
- dist = IC<1>();
237
- data = lh.Alloc<T>(size);
238
- }
239
-
240
- /// assign memory for vector
241
- void AssignMemory (size_t as, T * mem)
242
- {
243
- size = as;
244
- dist = IC<1>();
245
- data = mem;
246
- }
247
-
248
- INLINE auto & operator= (const VectorView & v)
249
- {
250
- /*
251
- auto cs = CombinedSize(this->Size(), v.Size());
252
- for (size_t i = 0; i < cs; i++)
253
- data[i*dist] = v(i);
254
- */
255
- this->template Assign<typename BASE::As> (v);
256
- return *this;
257
- }
258
- INLINE auto & operator= (VectorView && v)
259
- {
260
- /*
261
- auto cs = CombinedSize(this->Size(), v.Size());
262
- for (size_t i = 0; i < cs; i++)
263
- data[i*dist] = v(i);
264
- */
265
- this->template Assign<typename BASE::As> (v);
266
- return *this;
267
- }
268
-
269
- /// copy vector. sizes must match
270
- template <typename ...Args>
271
- INLINE auto & operator= (const VectorView<Args...> & v)
272
- {
273
- // BASE::operator= (v);
274
- this->template Assign<typename BASE::As> (v);
275
- return *this;
276
- }
277
-
278
- template<typename TB>
279
- INLINE auto & operator= (const Expr<TB> & v)
280
- {
281
- // BASE::operator= (v);
282
- this->template Assign<typename BASE::As> (v);
283
- return *this;
284
- }
285
-
286
- /// assign constant value
287
- INLINE auto & operator= (TSCAL scal) const
288
- {
289
- SetVector (scal, *this);
290
- return *this;
291
- }
292
-
293
- template <int D, typename TSCAL2>
294
- INLINE auto & operator= (const Vec<D,TSCAL2> & v)
295
- {
296
- NETGEN_CHECK_RANGE(D,0,Size()+1);
297
- for (int i = 0; i < D; i++)
298
- data[i*dist] = v(i);
299
- return *this;
300
- }
301
-
302
- /// access element
303
- INLINE TELEM & operator[] (size_t i)
304
- {
305
- NETGEN_CHECK_RANGE(i,0,Size());
306
- return data[i*dist];
307
- }
308
-
309
- INLINE const TELEM & operator[] (size_t i) const
310
- {
311
- NETGEN_CHECK_RANGE(i,0,Size());
312
- return data[i*dist];
313
- }
314
-
315
-
316
- /// constant element access
317
- // template<typename I, typename std::enable_if<std::is_integral<I>::value, int>::type = 0>
318
- template<typename I, typename std::enable_if<std::is_convertible<I,size_t>::value, int>::type = 0>
319
- INLINE TELEM & operator() (I i) const
320
- {
321
- NETGEN_CHECK_RANGE(i,0,Size());
322
- return data[i*dist];
323
- }
324
-
325
- /// element access. index j is ignored
326
- INLINE TELEM & operator() (size_t i, size_t j) const
327
- {
328
- NETGEN_CHECK_RANGE(i,0,Size());
329
- return data[i*dist];
330
- }
331
-
332
- RowsArrayExpr<VectorView> operator() (FlatArray<int> rows) const
333
- {
334
- return RowsArrayExpr<VectorView> (*this, rows);
335
- }
336
-
337
- INLINE auto Range (size_t first, size_t next) const
338
- {
339
- NETGEN_CHECK_RANGE(next,first,Size()+1);
340
- return VectorView<T,size_t,TDIST> (next-first, dist, data+first*dist);
341
- }
342
-
343
- INLINE auto Range (size_t next) const
344
- {
345
- return Range(0, next);
346
- }
347
-
348
- INLINE auto Range (IntRange range) const
349
- {
350
- return Range (range.First(), range.Next());
351
- }
352
-
353
- /*
354
- template <int S>
355
- INLINE auto Range (IC<S> r) const
356
- {
357
- return VectorView<T,IC<S>,TDIST> (r, Dist(), Data());
358
- }
359
- */
360
-
361
- INLINE auto Slice(size_t first, size_t dist2) const
362
- {
363
- // return VectorView<T,decltype(declval<TS>()/size_t()), decltype(declval<TDIST>()*size_t())> (size/dist2, dist2*dist, Addr(first));
364
- return VectorView<T,decltype(declval<TS>()/size_t()), decltype(declval<TDIST>()*size_t())> ( (size-first+dist2-1)/dist2, dist2*dist, Addr(first));
365
- }
366
-
367
- INLINE auto Reversed() const
368
- {
369
- // return VectorView { Size(), -Dist(), Addr(Size()-1) };
370
- return VectorView<T,TS,decltype(-declval<TDIST>())> { Size(), -Dist(), Addr(Size()-1) };
371
- }
372
-
373
- INLINE auto operator+(int i) const { return VectorView(size-i, dist, data+i*dist); }
374
-
375
- INLINE auto RemoveConst() const { return VectorView<typename remove_const<T>::type,TS,TDIST>(size, dist, const_cast<typename remove_const<T>::type*> (data)); }
376
-
377
- INLINE auto AsMatrix (size_t h, size_t w) const
378
- {
379
- // todo: checking
380
- static_assert(std::is_same<TDIST,IC<1>>());
381
- return FlatMatrix<T> (h,w, data);
382
- }
383
-
384
- class Iterator
385
- {
386
- VectorView vec;
387
- size_t ind;
388
- public:
389
- INLINE Iterator (VectorView avec, size_t ai) : vec(avec), ind(ai) { ; }
390
- INLINE Iterator operator++ (int) { return Iterator(vec, ind++); }
391
- INLINE Iterator operator++ () { return Iterator(vec, ++ind); }
392
- INLINE TELEM operator*() const { return vec[ind]; }
393
- INLINE TELEM & operator*() { return vec[ind]; }
394
- INLINE bool operator != (Iterator d2) { return ind != d2.ind; }
395
- INLINE bool operator == (Iterator d2) { return ind == d2.ind; }
396
- };
397
-
398
- INLINE Iterator begin() const { return Iterator (*this, 0); }
399
- INLINE Iterator end() const { return Iterator (*this, size); }
400
-
401
- };
402
-
403
-
404
-
405
-
406
-
407
-
408
-
409
-
410
-
411
-
412
-
413
-
414
- /**
415
- A Vector class with memory allocation/deallocation
416
- */
417
- template <typename T>
418
- class Vector : public FlatVector<T>
419
- {
420
- // using FlatVector<T>::data;
421
- // using FlatVector<T>::size;
422
- public:
423
- typedef typename mat_traits<T>::TSCAL TSCAL;
424
-
425
- /// default constructor
426
- Vector () : FlatVector<T> (0, (T*)nullptr) { ; }
427
-
428
- /// allocate vector
429
- explicit Vector (size_t as) : FlatVector<T> (as, new T[as]) { ; }
430
-
431
-
432
- /// allocate and copy vector
433
- Vector (const Vector & v2)
434
- : FlatVector<T> (v2.Size(), new T[v2.Size()])
435
- {
436
- FlatVector<T>::operator= (v2);
437
- }
438
-
439
- Vector (Vector && v2)
440
- : FlatVector<T> (v2.size, v2.data)
441
- { v2.data = nullptr; v2.size = 0; }
442
-
443
- /// allocate and compute
444
- template<typename TB>
445
- Vector (const Expr<TB> & v2)
446
- : FlatVector<T> (v2.Height(), new T[v2.Height()])
447
- {
448
- FlatVector<T>::operator= (v2);
449
- }
450
-
451
-
452
- Vector (initializer_list<T> list)
453
- : FlatVector<T> (list.size(), new T[list.size()])
454
- {
455
- size_t cnt = 0;
456
- for (auto val : list)
457
- (*this)[cnt++] = val;
458
- }
459
-
460
-
461
- /// deallocate vector
462
- ~Vector() { delete [] this->data; }
463
-
464
- /// set vector to constant values
465
- Vector & operator= (TSCAL scal)
466
- {
467
- FlatVector<T>::operator= (scal);
468
- return *this;
469
- }
470
-
471
- /// set vector size
472
- void SetSize(size_t as)
473
- {
474
- if (this->size == as) return;
475
- delete [] this->data;
476
- this->size = as;
477
- if (as != 0)
478
- this->data = new T[this->size];
479
- else
480
- this->data = nullptr;
481
- }
482
-
483
- /// evaluate matrix expression
484
- template<typename TB>
485
- Vector & operator= (const Expr<TB> & v)
486
- {
487
- MatExpr<FlatVector<T> >::operator= (v);
488
- return *this;
489
- }
490
-
491
- Vector & operator= (const Vector & v2)
492
- {
493
- FlatVector<T>::operator= (static_cast<FlatVector<T> >(v2));
494
- // MatExpr<FlatVector<T> >::operator= (v2); // does not work, we don't know why
495
- return *this;
496
- }
497
-
498
- Vector & operator= (Vector && v2)
499
- {
500
- this->size = v2.size;
501
- Swap (this->data, v2.data);
502
- return *this;
503
- }
504
-
505
- Vector & operator= (initializer_list<T> list)
506
- {
507
- SetSize (list.size());
508
- size_t cnt = 0;
509
- for (auto val : list)
510
- (*this)[cnt++] = val;
511
- return *this;
512
- }
513
-
514
- };
515
-
516
-
517
-
518
-
519
- /**
520
- A Vector class with memory allocation/deallocation. At
521
- compile-time, a certain amount of vector entries is defined. If the
522
- dynamic size fits into this memory, the vector is allocated in this memory.
523
- Otherwise, dynamic memory is allocated.
524
- */
525
- template <int S, typename T = double>
526
- class VectorMem : public FlatVector<T>
527
- {
528
- T mem[S];
529
- public:
530
- /// the scalar type
531
- typedef typename mat_traits<T>::TSCAL TSCAL;
532
-
533
- /** allocate vector.
534
- If the dynamic size fits into the static size, use static memory. Otherwise use dynamic alloation
535
- */
536
- explicit INLINE VectorMem (size_t as) : FlatVector<T> (as, (as <= S) ?
537
- &mem[0] : new T[as]) { ; }
538
-
539
- /// deallocates dynamic memory
540
- INLINE ~VectorMem() { if (this->Size() > S) delete [] this->data; }
541
-
542
- /// assigns constant value
543
- INLINE VectorMem & operator= (TSCAL scal)
544
- {
545
- FlatVector<T>::operator= (scal);
546
- return *this;
547
- }
548
-
549
- /// evaluates matrix expression
550
- template<typename TB>
551
- INLINE VectorMem & operator= (const Expr<TB> & v)
552
- {
553
- MatExpr<FlatVector<T> >::operator= (v);
554
- return *this;
555
- }
556
- };
557
-
558
-
559
-
560
-
561
-
562
-
563
-
564
-
565
-
566
-
567
-
568
-
569
-
570
-
571
-
572
- // A system vector (not completely functional)
573
- template <typename T = double>
574
- class FlatSysVector : public MatExpr<FlatSysVector<T> >
575
- {
576
- protected:
577
- size_t s;
578
- size_t blocksize;
579
- T * __restrict data;
580
- public:
581
- typedef FlatVector<T> TELEM;
582
- typedef typename mat_traits<T>::TSCAL TSCAL;
583
-
584
- INLINE FlatSysVector (size_t as, size_t bs, T * adata)
585
- : s(as), blocksize(bs), data(adata) { ; }
586
-
587
- INLINE FlatSysVector (size_t as, size_t bs, LocalHeap & lh)
588
- : s(as), blocksize(bs), data (new (lh) T[as*bs])
589
- { ; }
590
-
591
- /*
592
- FlatSysVector (const FlatSysVector<TSCAL> & sv)
593
- : s(sv.Size()),
594
- blocksize(sv.BlockSize()),
595
- data (sv(0))
596
- {
597
- ;
598
- }
599
- */
600
-
601
- INLINE FlatSysVector & operator= (const FlatSysVector & v)
602
- {
603
- for (size_t i = 0; i < this->s * this->blocksize; i++)
604
- data[i] = v.data[i];
605
- return *this;
606
- }
607
-
608
- template<typename TB>
609
- INLINE FlatSysVector & operator= (const Expr<TB> & v)
610
- {
611
- return MatExpr<FlatSysVector>::operator= (v);
612
- }
613
-
614
- INLINE FlatSysVector & operator= (TSCAL s)
615
- {
616
- for (size_t i = 0; i < this->s*this->blocksize; i++)
617
- data[i] = s;
618
- return *this;
619
- }
620
-
621
-
622
-
623
- INLINE auto operator() (size_t i)
624
- {
625
- return FlatVector<T> (blocksize, &data[i*blocksize]);
626
- }
627
-
628
- INLINE auto operator() (size_t i) const
629
- {
630
- return FlatVector<T> (blocksize, &data[i*blocksize]);
631
- }
632
-
633
- INLINE const TELEM operator() (size_t i, size_t j) const
634
- {
635
- return FlatVector<T> (blocksize, &data[i*blocksize]);
636
- }
637
-
638
- INLINE SliceVector<T> Comp (size_t comp) const
639
- {
640
- return SliceVector<T> (s, blocksize, data+comp);
641
- }
642
-
643
- INLINE FlatSysVector<T> Range(size_t first, size_t last)
644
- { return FlatSysVector<T> (last-first, blocksize, data+(first*blocksize)); }
645
- INLINE /* const */ FlatSysVector<T> Range(size_t first, size_t last) const
646
- { return FlatSysVector<T> (last-first, blocksize, data+(first*blocksize)); }
647
-
648
- INLINE size_t Size () const { return s; }
649
- INLINE size_t Height () const { return s; }
650
- INLINE constexpr size_t Width () const { return 1; }
651
- };
652
-
653
-
654
-
655
- /**
656
- A vector of fixed size.
657
- Useful as entry type in system vectors.
658
- */
659
- template <int S, typename T = double>
660
- class Vec : public MatExpr<Vec<S,T> > // , protected BaseVec
661
- {
662
- /// the values
663
- // T data[S];
664
- HTArray<S,T> data;
665
- public:
666
- /// type of the elements
667
- typedef T TELEM;
668
- /// is the element double or complex ?
669
- typedef typename mat_traits<T>::TSCAL TSCAL;
670
- static constexpr bool IsLinear() { return true; }
671
-
672
-
673
- /// a vec is a S times 1 matrix, the according colume vector
674
- typedef Vec<S, typename mat_traits<T>::TV_COL> TV_COL;
675
- /// a vec is a S times 1 matrix, the according row vector
676
- typedef Vec<1, typename mat_traits<T>::TV_ROW> TV_ROW;
677
-
678
- enum { SIZE = S };
679
- /// height of matrix
680
- enum { HEIGHT = S };
681
- /// with of matrix
682
- enum { WIDTH = 1 };
683
-
684
- /// constructor, no initialization
685
- INLINE Vec () { ; }
686
- /// copy vector
687
- /*
688
- INLINE Vec (const Vec & v) : MatExpr<Vec> ()
689
- {
690
- for (size_t i = 0; i < S; i++)
691
- data[i] = v.data[i];
692
- }
693
- */
694
-
695
- Vec (const Vec &) = default;
696
- auto & HTData() const { return data; }
697
- template <typename T2>
698
- Vec (const Vec<S,T2> & v2) : data(v2.HTData()) { ; }
699
-
700
-
701
- /// initialize with values
702
- INLINE Vec (const TELEM & scal)
703
- {
704
- for (size_t i = 0; i < S; i++)
705
- data[i] = scal;
706
- }
707
-
708
- /// initialize with expression
709
- template<typename TB>
710
- INLINE Vec (const Expr<TB> & v)
711
- {
712
- (*this) = v;
713
- }
714
-
715
- /*
716
- template <int D>
717
- INLINE Vec(FlatSliceVec<S,D,T> fsv)
718
- {
719
- for (int i = 0; i < S; i++)
720
- data[i] = fsv(i);
721
- }
722
- */
723
- template <typename T2, typename S2, typename D2>
724
- INLINE Vec(VectorView<T2,S2,D2> fsv)
725
- {
726
- for (int i = 0; i < S; i++)
727
- data[i] = fsv(i);
728
- }
729
-
730
-
731
- // Helper function for variadic constructor
732
- template <int I, class... T2>
733
- void Set(const TELEM &v, T2... rest)
734
- {
735
- data[I] = v;
736
- Set<I+1>(rest...);
737
- }
738
-
739
- template <int I>
740
- void Set(const TELEM &v)
741
- {
742
- data[I] = v;
743
- }
744
-
745
- template <class... T2,
746
- enable_if_t<S==1+sizeof...(T2),bool> = true>
747
- Vec(const TELEM &v, T2... rest) {
748
- Set<0>(v, rest...);
749
- }
750
-
751
- /// copy vector
752
- INLINE Vec & operator= (const Vec & v)
753
- {
754
- for (size_t i = 0; i < S; i++)
755
- data[i] = v.data[i];
756
- return *this;
757
- }
758
-
759
-
760
- /// assign scalar value
761
- INLINE Vec & operator= (const TELEM & scal)
762
- {
763
- for (size_t i = 0; i < S; i++)
764
- data[i] = scal;
765
- return *this;
766
- }
767
-
768
- /// assign expression
769
- template<typename TB>
770
- INLINE Vec & operator= (const Expr<TB> & v)
771
- {
772
- for (size_t i = 0; i < S; i++)
773
- data[i] = v.Spec()(i);
774
- return *this;
775
- }
776
-
777
- // auto View() const { return FlatVec(const_cast<Vec&>(*this)); }
778
- // auto View() const { return Vec(*this); }
779
- INLINE auto View() const { return Vec<S,const T>{*this}; }
780
- INLINE auto Shape() const { return tuple { IC<S>() }; }
781
-
782
- /// access vector
783
- INLINE TELEM & operator() (size_t i)
784
- {
785
- NETGEN_CHECK_RANGE(i,0,Size());
786
- return data[i];
787
- }
788
-
789
- /// access vector
790
- INLINE const TELEM & operator() (size_t i) const
791
- {
792
- NETGEN_CHECK_RANGE(i,0,Size());
793
- return data[i];
794
- }
795
-
796
-
797
- /// access vector
798
- INLINE TELEM & operator[] (size_t i)
799
- {
800
- NETGEN_CHECK_RANGE(i,0,Size());
801
- return data[i];
802
- }
803
-
804
- /// access vector
805
- INLINE const TELEM & operator[] (size_t i) const
806
- {
807
- NETGEN_CHECK_RANGE(i,0,Size());
808
- return data[i];
809
- }
810
-
811
- /// access vector
812
- INLINE TELEM & operator() (size_t i, size_t j)
813
- {
814
- NETGEN_CHECK_RANGE(i,0,Size());
815
- return data[i];
816
- }
817
-
818
- /// access vector
819
- INLINE const TELEM & operator() (size_t i, size_t j) const
820
- {
821
- NETGEN_CHECK_RANGE(i,0,Size());
822
- return data[i];
823
- }
824
-
825
- /// vector size
826
- INLINE auto Size () const { return IC<S>(); }
827
- /// corresponding matrix height
828
- INLINE constexpr size_t Height () const { return S; }
829
- /// corresponding matrix with
830
- INLINE constexpr size_t Width () const { return 1; }
831
- INLINE T* Data() { return data.Ptr(); }
832
- INLINE const T* Data() const { return data.Ptr(); }
833
-
834
- INLINE /* const */ FlatVector<const T> Range(size_t first, size_t next) const
835
- { return FlatVector<const T> (next-first, data+first); }
836
-
837
- INLINE /* const */ FlatVector<T> Range(size_t first, size_t next)
838
- { return FlatVector<T> (next-first, data+first); }
839
-
840
- const T * begin() const { return data.Ptr(); }
841
- const T * end() const { return data.Ptr()+S; }
842
- T * begin() { return data.Ptr(); }
843
- T * end() { return data.Ptr()+S; }
844
- };
845
-
846
-
847
-
848
- template <typename T>
849
- class Vec<0,T> : public MatExpr<Vec<0,T> >
850
- {
851
- public:
852
- static constexpr bool IsLinear() { return true; }
853
- INLINE Vec () { }
854
- INLINE Vec (const Vec &d) { }
855
- INLINE Vec (T d) { }
856
- template<typename TB>
857
- INLINE Vec (const Expr<TB> & v) {;}
858
- INLINE auto View() const { return Vec(*this); }
859
- INLINE auto Shape() const { return tuple(IC<0>()); }
860
- INLINE constexpr size_t Size() const { return 0; }
861
- INLINE constexpr size_t Height() const { return 0; }
862
- INLINE constexpr size_t Width() const { return 1; }
863
- template<typename TB>
864
- INLINE Vec & operator= (const Expr<TB> & v) { return *this;}
865
- INLINE Vec & operator= (const T & /* scal */) { return *this; }
866
-
867
- INLINE T & operator[] (int i) const { return *(T*)(void*)(this); }
868
- INLINE T & operator() (int i) const { return *(T*)(void*)(this); }
869
- INLINE T & operator() (int i, int j) const { return *(T*)(void*)(this); }
870
- INLINE T* Data() { return nullptr; }
871
- INLINE const T* Data() const { return nullptr; }
872
- INLINE FlatVector<const T> Range(size_t first, size_t next) const
873
- { return FlatVector<const T> (next-first, (T*)nullptr); }
874
- INLINE FlatVector<T> Range(size_t first, size_t next)
875
- { return FlatVector<T> (next-first, (T*)nullptr); }
876
- };
877
-
878
-
879
- template <int S, typename T>
880
- class mat_traits<Vec<S,T>>
881
- {
882
- public:
883
- /// matrix element
884
- typedef T TELEM;
885
- /// field of matrix element
886
- typedef typename mat_traits<T>::TSCAL TSCAL;
887
- /// type of column vector
888
- typedef Vec<S, typename mat_traits<T>::TV_COL> TV_COL;
889
- /// a vec is a S times 1 matrix, the according row vector
890
- typedef Vec<1, typename mat_traits<T>::TV_ROW> TV_ROW;
891
- /// matrix height
892
- enum { HEIGHT = S };
893
- /// matrix with
894
- enum { WIDTH = 1 };
895
- ///
896
- // enum { IS_COMPLEX = mat_traits<TSCAL>::IS_COMPLEX };
897
- };
898
-
899
-
900
-
901
- template <typename T> struct ConstVecSize { static constexpr int VSIZE = -1; };
902
- template <int S, typename T> struct ConstVecSize<Vec<S,T>> { static constexpr int VSIZE = S; };
903
- template <int S, typename T> struct ConstVecSize<FlatVec<S,T>> { static constexpr int VSIZE = S; };
904
- template <int S, int D, typename T> struct ConstVecSize<FlatSliceVec<S,D,T>> { static constexpr int VSIZE = S; };
905
- template <typename T>
906
- constexpr auto ConstVectorSize() { return ConstVecSize<T>::VSIZE; }
907
-
908
- /// cross product of 3-vectors
909
- template <typename TA, typename TB,
910
- std::enable_if_t<ConstVecSize<TA>::VSIZE == 3, bool> = true,
911
- std::enable_if_t<ConstVecSize<TB>::VSIZE == 3, bool> = true>
912
- INLINE auto Cross (const TA & a, const TB & b)
913
- {
914
- typedef decltype (a(0)*b(0)) T;
915
- return Vec<3,T>({ a(1)*b(2)-a(2)*b(1), a(2)*b(0)-a(0)*b(2), a(0)*b(1)-a(1)*b(0) });
916
- }
917
-
918
- template <typename S>
919
- INLINE Vec<1,S> Cross (const Vec<2,S> & a, const Vec<2,S> & b)
920
- {
921
- return Vec<1,S> ( { a(0) * b(1) - a(1) * b(0) } );
922
- }
923
-
924
- template <typename S>
925
- INLINE Vec<0,S> Cross (const Vec<1,S> & a, const Vec<1,S> & b)
926
- {
927
- return Vec<0,S>();
928
- }
929
-
930
- /// output vector
931
- template<int S, typename T>
932
- inline ostream & operator<< (ostream & ost, const Vec<S,T> & v)
933
- {
934
- for (int i = 0; i < S; i++)
935
- ost << " " << setw(7) << v(i);
936
- return ost;
937
- }
938
-
939
-
940
- template<int S, typename T, typename TB>
941
- INLINE Vec<S,T> & operator+= (Vec<S,T> & v, const Expr<TB> & v2)
942
- {
943
- for (int i = 0; i < S; i++)
944
- v(i) += v2.Spec()(i,0);
945
- return v;
946
- }
947
-
948
- template<int S, typename T, typename TB>
949
- INLINE Vec<S,T> & operator-= (Vec<S,T> & v, const Expr<TB> & v2)
950
- {
951
- for (int i = 0; i < S; i++)
952
- v(i) -= v2.Spec()(i,0);
953
- return v;
954
- }
955
-
956
-
957
-
958
-
959
-
960
-
961
-
962
- /// output vector.
963
- template<int S, typename T>
964
- inline ostream & operator<< (ostream & ost, const FlatVec<S,T> & v)
965
- {
966
- for (int i = 0; i < S; i++)
967
- ost << " " << setw(7) << v(i);
968
- return ost;
969
- }
970
-
971
-
972
-
973
-
974
-
975
- template <class TV, class TSCAL> class Scalar2ElemVector
976
- {
977
- public:
978
- FlatVector<TSCAL> vec;
979
- Scalar2ElemVector (FlatVector<TSCAL> avec) : vec(avec) { }
980
-
981
- enum { H = mat_traits<TV>::HEIGHT };
982
-
983
- FlatVec<H,TSCAL> operator() (int i) const
984
- {
985
- return FlatVec<H,TSCAL> (&vec(i*H));
986
- }
987
-
988
- };
989
-
990
-
991
- template <class TSCAL> class Scalar2ElemVector<TSCAL,TSCAL>
992
- {
993
- public:
994
- FlatVector<TSCAL> vec;
995
- Scalar2ElemVector (FlatVector<TSCAL> avec) : vec(avec) { }
996
-
997
-
998
- const TSCAL & operator() (int i) const
999
- {
1000
- return vec(i);
1001
- }
1002
-
1003
- TSCAL & operator() (int i)
1004
- {
1005
- return vec(i);
1006
- }
1007
-
1008
- };
1009
-
1010
-
1011
- template <typename T=double>
1012
- class SparseVector
1013
- {
1014
- size_t size;
1015
- ClosedHashTable<size_t, T> data;
1016
- public:
1017
- SparseVector (size_t asize) : size(asize), data(10) { }
1018
- size_t Size() const { return size; }
1019
- T operator[] (size_t i) const { return data[i]; }
1020
- T & operator[] (size_t i) { return data[i]; }
1021
- T InnerProduct (FlatVector<T> v2) const
1022
- {
1023
- T sum = 0;
1024
- for (auto [i,v] : data)
1025
- sum += v * v2(i);
1026
- return sum;
1027
- }
1028
- auto & Data() const { return data; }
1029
- };
1030
-
1031
- template <typename T>
1032
- inline ostream & operator<< (ostream & ost, const SparseVector<T> & sv) {
1033
- for (auto [i,v] : sv.Data())
1034
- ost << i << ": " << v << ", ";
1035
- return ost;
1036
- }
1037
-
1038
-
1039
- template <class T>
1040
- class mat_traits<FlatVector<T> >
1041
- {
1042
- public:
1043
- typedef T TELEM;
1044
- typedef T TSCAL;
1045
- };
1046
-
1047
-
1048
- template <int S, typename T>
1049
- INLINE auto operator* (double a, const Vec<S,T> & vec)
1050
- {
1051
- // typedef decltype(RemoveConst(a*vec(0))) TRES;
1052
- typedef typename std::remove_const<decltype(a*std::declval<T>())>::type TRES;
1053
- Vec<S, TRES> res;
1054
- for (int i = 0; i < S; i++)
1055
- res(i) = a * vec(i);
1056
- return res;
1057
- }
1058
-
1059
- template <int S, typename T>
1060
- INLINE auto operator* (int a, const Vec<S,T> & vec) { return double(a)*vec; }
1061
-
1062
- template <int S, typename T>
1063
- INLINE auto operator* (Complex a, const Vec<S,T> & vec)
1064
- {
1065
- // typedef decltype(RemoveConst(a*vec(0))) TRES;
1066
- typedef typename std::remove_const<decltype(a*std::declval<T>())>::type TRES;
1067
- Vec<S, TRES> res;
1068
- for (int i = 0; i < S; i++)
1069
- res(i) = a * vec(i);
1070
- return res;
1071
- }
1072
-
1073
- // all other cases ...
1074
- template <int S, typename T,
1075
- typename enable_if<!is_convertible_v<T,Complex>,int>::type=0>
1076
- INLINE auto operator* (T a, const Vec<S,T> & vec)
1077
- {
1078
- // typedef decltype(RemoveConst(a*vec(0))) TRES;
1079
- typedef typename std::remove_const<decltype(a*std::declval<T>())>::type TRES;
1080
- Vec<S, TRES> res;
1081
- for (int i = 0; i < S; i++)
1082
- res(i) = a * vec(i);
1083
- return res;
1084
- }
1085
-
1086
- template <int S, typename T>
1087
- INLINE auto operator+ (const Vec<S,T> & a, const Vec<S,T> & b)
1088
- {
1089
- // typedef decltype(RemoveConst(a(0))) TRES;
1090
- typedef typename std::remove_const<T>::type TRES;
1091
- Vec<S,TRES> res;
1092
- for (int i = 0; i < S; i++)
1093
- res(i) = a(i)+b(i);
1094
- return res;
1095
- }
1096
-
1097
- template <int S, typename T>
1098
- INLINE auto operator- (const Vec<S,T> & a, const Vec<S,T> & b)
1099
- {
1100
- // typedef decltype(RemoveConst(a(0))) TRES;
1101
- typedef typename std::remove_const<T>::type TRES;
1102
- Vec<S,TRES> res;
1103
- for (int i = 0; i < S; i++)
1104
- res(i) = a(i)-b(i);
1105
- return res;
1106
- }
1107
-
1108
-
1109
- template <int S, typename T>
1110
- INLINE auto operator* (double a, FlatVec<S,T> vec)
1111
- // -> Vec<S, decltype(RemoveConst(a*vec(0)))>
1112
- {
1113
- // typedef decltype(RemoveConst(a*vec(0))) TRES;
1114
- typedef typename std::remove_const<decltype(a*std::declval<T>())>::type TRES;
1115
- Vec<S, TRES> res;
1116
- for (int i = 0; i < S; i++)
1117
- res(i) = a * vec(i);
1118
- return res;
1119
- }
1120
-
1121
-
1122
- template <int S, typename T>
1123
- INLINE auto operator* (Complex a, FlatVec<S,T> vec)
1124
- // -> Vec<S, decltype(RemoveConst(a*vec(0)))>
1125
- {
1126
- // typedef decltype(RemoveConst(a*vec(0))) TRES;
1127
- typedef typename std::remove_const<decltype(a*std::declval<T>())>::type TRES;
1128
- Vec<S, TRES> res;
1129
- for (int i = 0; i < S; i++)
1130
- res(i) = a * vec(i);
1131
- return res;
1132
- }
1133
-
1134
- template <int S, int D, typename T>
1135
- INLINE auto operator* (double a, FlatSliceVec<S,D,T> vec)
1136
- // -> Vec<S, decltype(RemoveConst(a*vec(0)))>
1137
- {
1138
- // typedef decltype(RemoveConst(a*vec(0))) TRES;
1139
- typedef typename std::remove_const<decltype(a*std::declval<T>())>::type TRES;
1140
- Vec<S, TRES> res;
1141
- for (int i = 0; i < S; i++)
1142
- res(i) = a * vec(i);
1143
- return res;
1144
- }
1145
-
1146
-
1147
- template <int S, int D, typename T>
1148
- INLINE auto operator* (Complex a, FlatSliceVec<S,D,T> vec)
1149
- // -> Vec<S, decltype(RemoveConst(a*vec(0)))>
1150
- {
1151
- // typedef decltype(RemoveConst(a*vec(0))) TRES;
1152
- typedef typename std::remove_const<decltype(a*std::declval<T>())>::type TRES;
1153
- Vec<S, TRES> res;
1154
- for (int i = 0; i < S; i++)
1155
- res(i) = a * vec(i);
1156
- return res;
1157
- }
1158
-
1159
-
1160
- template <int S, typename T>
1161
- INLINE auto operator+ (FlatVec<S,T> x, FlatVec<S,T> y) -> Vec<S,T>
1162
- {
1163
- Vec<S,T> tmp = x;
1164
- tmp += y;
1165
- return tmp;
1166
- }
1167
-
1168
- template <int S, typename T>
1169
- INLINE auto operator- (FlatVec<S,T> x, FlatVec<S,T> y) -> Vec<S,T>
1170
- {
1171
- Vec<S,T> tmp = x;
1172
- tmp -= y;
1173
- return tmp;
1174
- }
1175
-
1176
-
1177
-
1178
- template <int DIM, typename SCAL, typename TANY>
1179
- inline void AtomicAdd (Vec<DIM,SCAL> & x, TANY y)
1180
- {
1181
- for (int i = 0; i < DIM; i++)
1182
- AtomicAdd (x(i), y(i));
1183
- }
1184
-
1185
- template <int DIM, typename SCAL, typename TANY>
1186
- inline void AtomicAdd (FlatVec<DIM,SCAL> x, TANY y)
1187
- {
1188
- for (int i = 0; i < DIM; i++)
1189
- AtomicAdd (x(i), y(i));
1190
- }
1191
-
1192
-
1193
- }
1194
-
1195
- namespace ngstd
1196
- {
1197
- template <typename ARCHIVE, int S, typename T>
1198
- inline auto & operator& (ARCHIVE & ar, ngbla::Vec<S,T> & v)
1199
- {
1200
- for (int i = 0; i < S; i++)
1201
- ar & v(i);
1202
- return ar;
1203
- }
1204
- }
1205
-
1206
-
1207
- namespace ngcore
1208
- {
1209
- template<typename T> struct MPI_typetrait;
1210
-
1211
- template<int S, typename T>
1212
- struct MPI_typetrait<ngbla::Vec<S, T> > {
1213
- static auto MPIType () {
1214
- return MPI_typetrait<std::array<T,S>>::MPIType();
1215
- }
1216
- };
1217
- }
1218
-
1219
- #endif