ngsolve 6.2.2506.post216.dev0__cp314-cp314-manylinux_2_28_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ngsolve-6.2.2506.post216.dev0.data/data/bin/ngs_nvcc +22 -0
- ngsolve-6.2.2506.post216.dev0.data/data/bin/ngs_nvlink +17 -0
- ngsolve-6.2.2506.post216.dev0.data/data/bin/ngscxx +15 -0
- ngsolve-6.2.2506.post216.dev0.data/data/bin/ngsld +11 -0
- ngsolve-6.2.2506.post216.dev0.data/data/bin/ngsolve.tcl +648 -0
- ngsolve-6.2.2506.post216.dev0.data/data/bin/ngspy +2 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/analytic_integrals.hpp +10 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/arnoldi.hpp +55 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/bandmatrix.hpp +334 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/basematrix.hpp +963 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/basevector.hpp +1268 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/bdbequations.hpp +2807 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/bdbintegrator.hpp +1660 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/bem_diffops.hpp +475 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/bessel.hpp +1064 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/bilinearform.hpp +966 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/bla.hpp +29 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/blockalloc.hpp +95 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/blockjacobi.hpp +328 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/bspline.hpp +116 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/calcinverse.hpp +141 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/cg.hpp +368 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/chebyshev.hpp +44 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/cholesky.hpp +720 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/clapack.h +7254 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/code_generation.hpp +296 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/coefficient.hpp +2033 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/coefficient_impl.hpp +19 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/coefficient_stdmath.hpp +167 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/commutingAMG.hpp +106 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/comp.hpp +79 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/compatibility.hpp +41 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/complex_wrapper.hpp +101 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/compressedfespace.hpp +110 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/contact.hpp +239 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/cuda_core.hpp +216 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/cuda_linalg.hpp +185 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/cuda_ngbla.hpp +317 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/cuda_ngstd.hpp +414 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/cuda_profiler.hpp +240 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/diagonalmatrix.hpp +160 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/differentialoperator.hpp +276 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/diffop.hpp +1286 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/diffop_impl.hpp +328 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/diffopwithfactor.hpp +123 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/discontinuous.hpp +84 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/dump.hpp +949 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/ectypes.hpp +121 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/eigen.hpp +60 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/eigensystem.hpp +18 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/elasticity_equations.hpp +595 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/elementbyelement.hpp +201 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/elementtopology.hpp +1760 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/elementtransformation.hpp +339 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/evalfunc.hpp +405 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/expr.hpp +1693 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/facetfe.hpp +175 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/facetfespace.hpp +180 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/facethofe.hpp +111 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/facetsurffespace.hpp +112 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/fe_interfaces.hpp +32 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/fem.hpp +87 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/fesconvert.hpp +14 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/fespace.hpp +1454 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/finiteelement.hpp +286 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/globalinterfacespace.hpp +77 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/globalspace.hpp +115 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/gridfunction.hpp +525 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/h1amg.hpp +124 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/h1hofe.hpp +188 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/h1hofe_impl.hpp +1262 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/h1hofefo.hpp +148 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/h1hofefo_impl.hpp +185 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/h1hofespace.hpp +167 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/h1lofe.hpp +1240 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/h1lumping.hpp +41 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hcurl_equations.hpp +1381 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hcurlcurlfe.hpp +2241 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hcurlcurlfespace.hpp +78 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hcurlfe.hpp +259 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hcurlfe_utils.hpp +107 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hcurlhdiv_dshape.hpp +857 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hcurlhdivfes.hpp +308 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hcurlhofe.hpp +175 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hcurlhofe_impl.hpp +1871 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hcurlhofespace.hpp +193 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hcurllofe.hpp +1146 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hdiv_equations.hpp +880 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hdivdivfe.hpp +2923 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hdivdivsurfacespace.hpp +76 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hdivfe.hpp +206 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hdivfe_utils.hpp +717 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hdivfes.hpp +75 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hdivhofe.hpp +447 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hdivhofe_impl.hpp +1107 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hdivhofefo.hpp +229 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hdivhofespace.hpp +177 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hdivhosurfacefespace.hpp +106 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hdivlofe.hpp +773 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hidden.hpp +74 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/householder.hpp +181 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hypre_ams_precond.hpp +123 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/hypre_precond.hpp +73 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/integrator.hpp +2012 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/integratorcf.hpp +253 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/interpolate.hpp +49 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/intrule.hpp +2542 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/intrules_SauterSchwab.hpp +25 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/irspace.hpp +49 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/jacobi.hpp +153 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/kernels.hpp +724 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/l2hofe.hpp +194 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/l2hofe_impl.hpp +564 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/l2hofefo.hpp +542 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/l2hofespace.hpp +344 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/la.hpp +38 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/linalg_kernels.hpp +70 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/linearform.hpp +266 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/matrix.hpp +2145 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/memusage.hpp +41 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/meshaccess.hpp +1359 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/mgpre.hpp +204 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/mp_coefficient.hpp +145 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/mptools.hpp +2281 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/multigrid.hpp +42 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/multivector.hpp +447 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/mumpsinverse.hpp +187 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/mycomplex.hpp +361 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/ng_lapack.hpp +1661 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/ngblas.hpp +1232 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/ngs_defines.hpp +30 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/ngs_stdcpp_include.hpp +106 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/ngs_utils.hpp +121 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/ngsobject.hpp +1019 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/ngsstream.hpp +113 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/ngstd.hpp +72 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/nodalhofe.hpp +96 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/nodalhofe_impl.hpp +141 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/normalfacetfe.hpp +223 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/normalfacetfespace.hpp +98 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/normalfacetsurfacefespace.hpp +84 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/order.hpp +251 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/parallel_matrices.hpp +222 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/paralleldofs.hpp +340 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/parallelngs.hpp +23 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/parallelvector.hpp +269 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/pardisoinverse.hpp +200 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/periodic.hpp +129 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/plateaufespace.hpp +25 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/pml.hpp +275 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/pmltrafo.hpp +631 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/postproc.hpp +142 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/potentialtools.hpp +22 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/precomp.hpp +60 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/preconditioner.hpp +602 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/prolongation.hpp +380 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/python_comp.hpp +107 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/python_fem.hpp +89 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/python_linalg.hpp +58 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/python_ngstd.hpp +386 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/recursive_pol.hpp +4896 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/recursive_pol_tet.hpp +395 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/recursive_pol_trig.hpp +492 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/reorderedfespace.hpp +81 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/sample_sort.hpp +105 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/scalarfe.hpp +335 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/shapefunction_utils.hpp +113 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/simd_complex.hpp +329 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/smoother.hpp +253 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/solve.hpp +89 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/sparsecholesky.hpp +317 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/sparsefactorization_interface.hpp +159 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/sparsematrix.hpp +1052 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/sparsematrix_dyn.hpp +90 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/sparsematrix_impl.hpp +1055 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/special_matrix.hpp +463 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/specialelement.hpp +125 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/statushandler.hpp +33 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/stringops.hpp +12 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/superluinverse.hpp +136 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/symbolicintegrator.hpp +850 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/symmetricmatrix.hpp +144 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/tangentialfacetfe.hpp +224 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/tangentialfacetfespace.hpp +91 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/tensor.hpp +522 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/tensorcoefficient.hpp +446 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/tensorproductintegrator.hpp +113 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/thcurlfe.hpp +128 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/thcurlfe_impl.hpp +380 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/thdivfe.hpp +80 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/thdivfe_impl.hpp +492 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/tpdiffop.hpp +461 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/tpfes.hpp +133 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/tpintrule.hpp +224 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/triangular.hpp +465 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/tscalarfe.hpp +245 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/tscalarfe_impl.hpp +1029 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/umfpackinverse.hpp +148 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/unifiedvector.hpp +103 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/vector.hpp +1452 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/voxelcoefficientfunction.hpp +41 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/vtkoutput.hpp +198 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/vvector.hpp +208 -0
- ngsolve-6.2.2506.post216.dev0.data/data/include/netgen/webgui.hpp +92 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/cmake/ngsolve/NGSolveConfig.cmake +102 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/cmake/ngsolve/ngsolve-targets-release.cmake +89 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/cmake/ngsolve/ngsolve-targets.cmake +180 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/netgen_mesher.libs/libngbla.so +0 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/netgen_mesher.libs/libngcomp.so +0 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/netgen_mesher.libs/libngfem.so +0 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/netgen_mesher.libs/libngla.so +0 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/netgen_mesher.libs/libngsbem.so +0 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/netgen_mesher.libs/libngscudalib.so +0 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/netgen_mesher.libs/libngsolve.so +0 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/netgen_mesher.libs/libngstd.so +0 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/TensorProductTools.py +210 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/__console.py +94 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/__expr.py +181 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/__init__.py +148 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/_scikit_build_core_dependencies.py +30 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/bvp.py +78 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/config/__init__.py +1 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/config/__main__.py +4 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/config/config.py +60 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/TensorProduct/__init__.py +0 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/TensorProduct/tp_dg_1d_1d.py +80 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/TensorProduct/tp_dg_1d_2d.py +73 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/TensorProduct/tp_dg_2d_1d.py +72 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/TensorProduct/tp_dg_2d_2d.py +66 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/__init__.py +0 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/__init__.py +0 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/hhj.py +44 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/hybrid_dg.py +53 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/mixed.py +30 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/nonlin.py +29 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/pickling.py +26 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/pml.py +31 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/taskmanager.py +20 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/tdnns.py +47 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/timeDG-skeleton.py +45 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/timeDG.py +38 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/timeDGlap.py +42 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/howto/timeDGwave.py +61 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/intro/__init__.py +0 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/intro/adaptive.py +123 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/intro/cmagnet.py +59 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/intro/elasticity.py +76 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/intro/navierstokes.py +74 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/intro/poisson.ipynb +170 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/intro/poisson.py +41 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/mpi/__init__.py +0 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/mpi/mpi_cmagnet.py +87 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/mpi/mpi_navierstokes.py +117 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/mpi/mpi_poisson.py +89 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/demos/mpi/mpi_timeDG.py +82 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/directsolvers.py +14 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/eigenvalues.py +364 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/internal.py +89 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/krylovspace.py +1182 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/meshes.py +748 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/ngs2petsc.py +310 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/ngscuda.so +0 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/ngscxx.py +42 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/ngslib.so +0 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/nonlinearsolvers.py +203 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/preconditioners.py +11 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/solve_implementation.py +168 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/solvers/__init__.py +7 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/solvers/cudss.py +112 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/timestepping.py +185 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/timing.py +108 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/utils.py +167 -0
- ngsolve-6.2.2506.post216.dev0.data/data/lib/python3.14/site-packages/ngsolve/webgui.py +671 -0
- ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/beam.geo +17 -0
- ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/beam.vol +240 -0
- ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/chip.in2d +41 -0
- ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/chip.vol +614 -0
- ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/coil.geo +12 -0
- ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/coil.vol +2560 -0
- ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/coilshield.geo +24 -0
- ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/coilshield.vol +3179 -0
- ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/cube.geo +19 -0
- ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/cube.vol +1832 -0
- ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/d10_DGdoubleglazing.pde +50 -0
- ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/d11_chip_nitsche.pde +40 -0
- ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/d1_square.pde +43 -0
- ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/d2_chip.pde +35 -0
- ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/d3_helmholtz.pde +22 -0
- ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/d4_cube.pde +46 -0
- ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/d5_beam.pde +74 -0
- ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/d6_shaft.pde +73 -0
- ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/d7_coil.pde +50 -0
- ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/d8_coilshield.pde +49 -0
- ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/d9_hybridDG.pde +72 -0
- ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/doubleglazing.in2d +27 -0
- ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/doubleglazing.vol +737 -0
- ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/piezo2d40round4.vol.gz +0 -0
- ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/shaft.geo +73 -0
- ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/shaft.vol +4291 -0
- ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/square.in2d +17 -0
- ngsolve-6.2.2506.post216.dev0.data/data/share/ngsolve/square.vol +149 -0
- ngsolve-6.2.2506.post216.dev0.dist-info/METADATA +14 -0
- ngsolve-6.2.2506.post216.dev0.dist-info/RECORD +306 -0
- ngsolve-6.2.2506.post216.dev0.dist-info/WHEEL +5 -0
- ngsolve-6.2.2506.post216.dev0.dist-info/licenses/LICENSE +504 -0
- ngsolve-6.2.2506.post216.dev0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,1693 @@
|
|
|
1
|
+
#ifndef FILE_NGBLA_EXPR
|
|
2
|
+
#define FILE_NGBLA_EXPR
|
|
3
|
+
|
|
4
|
+
/**************************************************************************/
|
|
5
|
+
/* File: expr.hpp */
|
|
6
|
+
/* Author: Joachim Schoeberl */
|
|
7
|
+
/* Date: 01. Jan. 02 */
|
|
8
|
+
/**************************************************************************/
|
|
9
|
+
|
|
10
|
+
#include <core/array.hpp>
|
|
11
|
+
#include <core/localheap.hpp>
|
|
12
|
+
#include <core/exception.hpp>
|
|
13
|
+
|
|
14
|
+
#include <cstddef>
|
|
15
|
+
#include <ngs_stdcpp_include.hpp> // for INLINE
|
|
16
|
+
#include "complex_wrapper.hpp"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
#if defined(NETGEN_ENABLE_CHECK_RANGE) && !defined(__CUDA_ARCH__)
|
|
20
|
+
#define NETGEN_CHECK_SHAPE(a,b) \
|
|
21
|
+
{ if(a.Shape() != b.Shape()) \
|
|
22
|
+
ngcore::ThrowException(__FILE__ ":" NETGEN_CORE_NGEXEPTION_STR(__LINE__) "\t: shapes don't match"); }
|
|
23
|
+
#else // defined(NETGEN_ENABLE_CHECK_RANGE) && !defined(__CUDA_ARCH__)
|
|
24
|
+
#define NETGEN_CHECK_SHAPE(a,b)
|
|
25
|
+
#endif // defined(NETGEN_ENABLE_CHECK_RANGE) && !defined(__CUDA_ARCH__)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
template <typename T>
|
|
29
|
+
struct SafeIndex
|
|
30
|
+
{
|
|
31
|
+
T i;
|
|
32
|
+
INLINE SafeIndex(T ai) : i(ai) { };
|
|
33
|
+
INLINE operator T() const { return i; }
|
|
34
|
+
INLINE auto operator++() { return ++i; }
|
|
35
|
+
INLINE auto operator++(int) { return i++; }
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
namespace ngcore
|
|
39
|
+
{
|
|
40
|
+
template <typename T>
|
|
41
|
+
struct IsSafe<SafeIndex<T>> {
|
|
42
|
+
constexpr operator bool() const { return true; } };
|
|
43
|
+
} // namespace ngcore
|
|
44
|
+
|
|
45
|
+
/*
|
|
46
|
+
namespace std {
|
|
47
|
+
template <typename T>
|
|
48
|
+
struct is_integral<SafeIndex<T>> {
|
|
49
|
+
static constexpr bool value = true;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
namespace ngbla
|
|
55
|
+
{
|
|
56
|
+
using namespace std;
|
|
57
|
+
using namespace ngcore;
|
|
58
|
+
using namespace ngstd;
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
enum ORDERING { ColMajor, RowMajor };
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
struct unused_dist
|
|
65
|
+
{
|
|
66
|
+
unused_dist () = default;
|
|
67
|
+
unused_dist (size_t d) { };
|
|
68
|
+
template <int S>
|
|
69
|
+
unused_dist (IC<S> d) { };
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
template <typename T = double, ORDERING ORD = RowMajor, typename TH=size_t, typename TW=size_t, typename TDIST=size_t>
|
|
73
|
+
class MatrixView;
|
|
74
|
+
|
|
75
|
+
template <typename T = double, ORDERING ORD = RowMajor>
|
|
76
|
+
using FlatMatrix = MatrixView<T,ORD,size_t, size_t, unused_dist>;
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
// template <typename T = double, ORDERING ORD = RowMajor> class FlatMatrix;
|
|
80
|
+
template <typename T = double, ORDERING ORD = RowMajor> class Matrix;
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
template <int H, int W, typename T> class Mat;
|
|
84
|
+
template <int H, typename T> class DiagMat;
|
|
85
|
+
template <int S, typename T> class Vec;
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
template <typename T>
|
|
89
|
+
struct is_scalar_type { static constexpr bool value = false; };
|
|
90
|
+
|
|
91
|
+
template <typename T>
|
|
92
|
+
constexpr bool IsScalar ()
|
|
93
|
+
{
|
|
94
|
+
return is_scalar_type<T>::value;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
/*
|
|
102
|
+
Matrix expression templates
|
|
103
|
+
*/
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
template <typename TM, enable_if_t<!IsScalar<TM>(),bool> = true>
|
|
107
|
+
inline auto Access (const TM & mat, int i, int j)
|
|
108
|
+
{
|
|
109
|
+
return mat(i,j);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
template <typename TM, enable_if_t<IsScalar<TM>(),bool> = true>
|
|
113
|
+
inline auto Access (const TM & mat, int i, int j)
|
|
114
|
+
{
|
|
115
|
+
return mat;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
template <typename T> struct is_scalar_type;
|
|
122
|
+
|
|
123
|
+
template<> struct is_scalar_type<int> { static constexpr bool value = true; };
|
|
124
|
+
template<> struct is_scalar_type<double> { static constexpr bool value = true; };
|
|
125
|
+
template<> struct is_scalar_type<Complex> { static constexpr bool value = true; };
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
Trait to obtain vector and scalar types for given matrix types.
|
|
131
|
+
Is specified for double, Complex, AutoDiff<doube>, AutoDiff<Complex>
|
|
132
|
+
*/
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
template <class T> class mat_traits;
|
|
138
|
+
|
|
139
|
+
template <class T>
|
|
140
|
+
class mat_traits
|
|
141
|
+
{
|
|
142
|
+
public:
|
|
143
|
+
/// matrix element
|
|
144
|
+
typedef T TELEM;
|
|
145
|
+
/// field of matrix element
|
|
146
|
+
typedef T TSCAL;
|
|
147
|
+
/// type of column vector
|
|
148
|
+
typedef T TV_COL;
|
|
149
|
+
/// type of row vector
|
|
150
|
+
typedef T TV_ROW;
|
|
151
|
+
/// matrix height
|
|
152
|
+
// enum { HEIGHT = 1 };
|
|
153
|
+
/// matrix with
|
|
154
|
+
// enum { WIDTH = 1 };
|
|
155
|
+
// static constexpr int HEIGHT = 1;
|
|
156
|
+
// static constexpr int WIDTH = 1;
|
|
157
|
+
///
|
|
158
|
+
// enum { IS_COMPLEX = 0 };
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
template <class T>
|
|
162
|
+
class mat_traits<const T> : public mat_traits<T> { };
|
|
163
|
+
template <class T>
|
|
164
|
+
class mat_traits<T&> : public mat_traits<T> { };
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
/*
|
|
168
|
+
template <int D>
|
|
169
|
+
class mat_traits<ngcore::INT<D> >
|
|
170
|
+
{
|
|
171
|
+
public:
|
|
172
|
+
typedef int TELEM;
|
|
173
|
+
typedef int TSCAL;
|
|
174
|
+
typedef int TV_COL;
|
|
175
|
+
typedef int TV_ROW;
|
|
176
|
+
// enum { HEIGHT = D };
|
|
177
|
+
// enum { WIDTH = 1 };
|
|
178
|
+
// enum { IS_COMPLEX = 0 };
|
|
179
|
+
};
|
|
180
|
+
*/
|
|
181
|
+
|
|
182
|
+
template <>
|
|
183
|
+
class mat_traits<Complex>
|
|
184
|
+
{
|
|
185
|
+
public:
|
|
186
|
+
typedef Complex TELEM;
|
|
187
|
+
typedef Complex TSCAL;
|
|
188
|
+
typedef Complex TV_COL;
|
|
189
|
+
typedef Complex TV_ROW;
|
|
190
|
+
// static constexpr int HEIGHT = 1;
|
|
191
|
+
// static constexpr int WIDTH = 1;
|
|
192
|
+
// enum { IS_COMPLEX = 1 };
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
/// Height of matrix
|
|
198
|
+
template <class TM>
|
|
199
|
+
inline auto Height (const TM & m)
|
|
200
|
+
{
|
|
201
|
+
return m.Height();
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/// Width of matrix
|
|
205
|
+
template <class TM>
|
|
206
|
+
inline auto Width (const TM & m)
|
|
207
|
+
{
|
|
208
|
+
return m.Width();
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
template <> inline constexpr auto Height<double> (const double&) { return 1; }
|
|
212
|
+
template <> inline constexpr auto Height<Complex> (const Complex&) { return 1; }
|
|
213
|
+
template <> inline constexpr auto Width<double> (const double&) { return 1; }
|
|
214
|
+
template <> inline constexpr auto Width<Complex> (const Complex&) { return 1; }
|
|
215
|
+
|
|
216
|
+
/*
|
|
217
|
+
template <class TM>
|
|
218
|
+
inline constexpr size_t Height () { return Height(TM()); }
|
|
219
|
+
template <class TM>
|
|
220
|
+
inline constexpr size_t Width () { return Width(TM()); }
|
|
221
|
+
*/
|
|
222
|
+
|
|
223
|
+
template <class TM>
|
|
224
|
+
inline constexpr auto Height () { return TM::Height(); }
|
|
225
|
+
template <class TM>
|
|
226
|
+
inline constexpr auto Width () { return TM::Width(); }
|
|
227
|
+
|
|
228
|
+
template <> inline constexpr auto Height<double> () { return 1; }
|
|
229
|
+
template <> inline constexpr auto Height<Complex> () { return 1; }
|
|
230
|
+
template <> inline constexpr auto Width<double> () { return 1; }
|
|
231
|
+
template <> inline constexpr auto Width<Complex> () { return 1; }
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
template <class TM>
|
|
235
|
+
inline constexpr bool IsComplex () { return IsComplex<typename mat_traits<TM>::TSCAL>(); }
|
|
236
|
+
template <> inline constexpr bool IsComplex<double> () { return false; }
|
|
237
|
+
template <> inline constexpr bool IsComplex<Complex> () { return true; }
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
template <class TA> class RowsArrayExpr;
|
|
242
|
+
template <class TA> class ColsArrayExpr;
|
|
243
|
+
template <class TA> class SubMatrixExpr;
|
|
244
|
+
template <class TA> class RowExpr;
|
|
245
|
+
template <class TA> class ColExpr;
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
Expr is the base class for all matrix template expressions.
|
|
252
|
+
Barton and Nackman Trick for template polymorphism, function Spec.
|
|
253
|
+
|
|
254
|
+
provides Height and Width of matrix.
|
|
255
|
+
IsLinear allows linear matrix element access.
|
|
256
|
+
*/
|
|
257
|
+
|
|
258
|
+
#ifdef NETGEN_ENABLE_CHECK_RANGE
|
|
259
|
+
struct undefined_size
|
|
260
|
+
{
|
|
261
|
+
size_t size;
|
|
262
|
+
|
|
263
|
+
undefined_size() = default;
|
|
264
|
+
constexpr undefined_size(size_t s) : size(s) { }
|
|
265
|
+
template <int S>
|
|
266
|
+
explicit constexpr undefined_size(IC<S> s) : size(s) { }
|
|
267
|
+
explicit constexpr operator size_t() const { return size; }
|
|
268
|
+
explicit constexpr operator int() const { return size; }
|
|
269
|
+
explicit constexpr operator ptrdiff_t() const { return size; }
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
inline ostream & operator<< (ostream & ost, undefined_size s) { ost << "undefined("<<size_t(s)<<")"; return ost; }
|
|
274
|
+
inline constexpr auto operator/ (undefined_size ud, size_t i) { return undefined_size(size_t(ud)/i); }
|
|
275
|
+
inline constexpr auto operator- (undefined_size ud, size_t i) { return undefined_size(size_t(ud)-i); }
|
|
276
|
+
inline constexpr auto operator+ (undefined_size ud, size_t i) { return undefined_size(size_t(ud)+i); }
|
|
277
|
+
inline constexpr auto operator* (undefined_size ud, size_t i) { return undefined_size(size_t(ud)*i); }
|
|
278
|
+
inline constexpr auto operator* (size_t i, undefined_size ud) { return undefined_size(size_t(ud)*i); }
|
|
279
|
+
inline constexpr bool operator< (size_t i, undefined_size ud) { return i < size_t(ud); }
|
|
280
|
+
inline constexpr bool operator< (undefined_size ud, size_t i) { return size_t(ud) < i; }
|
|
281
|
+
inline constexpr bool operator>= (size_t i, undefined_size ud) { return i >= size_t(ud); }
|
|
282
|
+
inline constexpr bool operator>= (undefined_size ud, size_t i) { return size_t(ud) >= i; }
|
|
283
|
+
inline constexpr bool operator== (size_t i, undefined_size ud) { return i == size_t(ud); }
|
|
284
|
+
inline constexpr bool operator== (undefined_size ud, size_t i) { return size_t(ud) == i; }
|
|
285
|
+
inline constexpr bool operator== (undefined_size ud, undefined_size ud2) { return size_t(ud) == size_t(ud2); }
|
|
286
|
+
inline constexpr bool operator!= (size_t i, undefined_size ud) { return i != size_t(ud); }
|
|
287
|
+
inline constexpr bool operator!= (undefined_size ud, size_t i) { return size_t(ud) != i; }
|
|
288
|
+
inline constexpr bool operator!= (undefined_size ud, undefined_size ud2) { return size_t(ud) != size_t(ud2); }
|
|
289
|
+
|
|
290
|
+
#else
|
|
291
|
+
struct undefined_size
|
|
292
|
+
{
|
|
293
|
+
undefined_size() = default;
|
|
294
|
+
INLINE undefined_size(size_t s) { }
|
|
295
|
+
template <int S>
|
|
296
|
+
INLINE explicit constexpr undefined_size(IC<S> s) { }
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
inline ostream & operator<< (ostream & ost, undefined_size s) { ost << "undefined"; return ost; }
|
|
300
|
+
inline auto operator/ (undefined_size ud, size_t i) { return ud; }
|
|
301
|
+
inline auto operator- (undefined_size ud, size_t i) { return ud; }
|
|
302
|
+
inline auto operator+ (undefined_size ud, size_t i) { return ud; }
|
|
303
|
+
#endif
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
INLINE constexpr auto CombinedSize(undefined_size s1, undefined_size s2) {
|
|
307
|
+
NETGEN_CHECK_SAME(size_t(s1), size_t(s2)); return s1; }
|
|
308
|
+
INLINE constexpr auto CombinedSize(undefined_size s1, size_t s2) {
|
|
309
|
+
NETGEN_CHECK_SAME(size_t(s1), size_t(s2)); return s2; }
|
|
310
|
+
INLINE constexpr auto CombinedSize(size_t s1, undefined_size s2) {
|
|
311
|
+
NETGEN_CHECK_SAME(size_t(s1), size_t(s2)); return s1; }
|
|
312
|
+
INLINE constexpr auto CombinedSize(size_t s1, size_t s2) {
|
|
313
|
+
NETGEN_CHECK_SAME(size_t(s1), size_t(s2)); return s1; }
|
|
314
|
+
template <int S1> INLINE constexpr auto CombinedSize(IC<S1> s1, undefined_size s2) {
|
|
315
|
+
NETGEN_CHECK_SAME(size_t(s1), size_t(s2)); return s1; }
|
|
316
|
+
template <int S1> INLINE constexpr auto CombinedSize(IC<S1> s1, size_t s2) {
|
|
317
|
+
NETGEN_CHECK_SAME(size_t(s1), size_t(s2)); return s1; }
|
|
318
|
+
template <int S1, int S2> INLINE constexpr auto CombinedSize(IC<S1> s1, IC<S2> s2) {
|
|
319
|
+
NETGEN_CHECK_SAME(size_t(s1), size_t(s2)); return s1; }
|
|
320
|
+
template <int S2> INLINE constexpr auto CombinedSize(undefined_size s1, IC<S2> s2) {
|
|
321
|
+
NETGEN_CHECK_SAME(size_t(s1), size_t(s2)); return s2; }
|
|
322
|
+
template <int S2> INLINE constexpr auto CombinedSize(size_t s1, IC<S2> s2) {
|
|
323
|
+
NETGEN_CHECK_SAME(size_t(s1), size_t(s2)); return s2; }
|
|
324
|
+
|
|
325
|
+
template <typename T1, typename T2>
|
|
326
|
+
INLINE constexpr auto CombinedSize(tuple<T1> tup1, tuple<T2> tup2)
|
|
327
|
+
{ return tuple(CombinedSize(get<0>(tup1), get<0>(tup2))); }
|
|
328
|
+
|
|
329
|
+
template <typename T11, typename T12, typename T21, typename T22>
|
|
330
|
+
INLINE constexpr auto CombinedSize(tuple<T11,T12> tup1, tuple<T21,T22> tup2)
|
|
331
|
+
{ return tuple(CombinedSize(get<0>(tup1), get<0>(tup2)),
|
|
332
|
+
CombinedSize(get<1>(tup1), get<1>(tup2))); }
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
template <typename T>
|
|
340
|
+
class Expr
|
|
341
|
+
{
|
|
342
|
+
public:
|
|
343
|
+
constexpr Expr () = default;
|
|
344
|
+
|
|
345
|
+
/// cast to specific type
|
|
346
|
+
INLINE T & Spec() { return static_cast<T&> (*this); }
|
|
347
|
+
|
|
348
|
+
/// cast to specific type
|
|
349
|
+
INLINE const T & Spec() const { return static_cast<const T&> (*this); }
|
|
350
|
+
|
|
351
|
+
INLINE auto View() const { return static_cast<const T&> (*this).View(); }
|
|
352
|
+
INLINE decltype(auto) ViewRW() { return static_cast<T&>(*this).ViewRW(); }
|
|
353
|
+
INLINE auto Shape() const { return Spec().T::Shape(); }
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
INLINE auto Height() const { return Spec().T::Height(); }
|
|
357
|
+
INLINE auto Width() const { return Spec().T::Width(); }
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
void Dump (ostream & ost) const { Spec().T::Dump(ost); }
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
INLINE auto Row (size_t r) const
|
|
364
|
+
{
|
|
365
|
+
// return RowExpr<const T> (static_cast<const T&> (*this), r);
|
|
366
|
+
return RowExpr<const T> (this->View(), r);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
INLINE auto Col (size_t r) const
|
|
370
|
+
{
|
|
371
|
+
// return ColExpr<const T> (static_cast<const T&> (*this), r);
|
|
372
|
+
return ColExpr<const T> (this->View(), r);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
INLINE SubMatrixExpr<T>
|
|
377
|
+
Rows (size_t first, size_t next) const
|
|
378
|
+
{
|
|
379
|
+
// return SubMatrixExpr<T> (static_cast<T&> (*this), first, 0, next-first, Width());
|
|
380
|
+
return SubMatrixExpr<T> (this->View(), first, 0, next-first, Width());
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
INLINE SubMatrixExpr<T>
|
|
384
|
+
Cols (size_t first, size_t next) const
|
|
385
|
+
{
|
|
386
|
+
// return SubMatrixExpr<T> (static_cast<T&> (*this), 0, first, Height(), next-first);
|
|
387
|
+
return SubMatrixExpr<T> (this->View(), 0, first, Height(), next-first);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
INLINE SubMatrixExpr<T>
|
|
391
|
+
Rows (IntRange range) const
|
|
392
|
+
{
|
|
393
|
+
return Rows (range.First(), range.Next());
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
INLINE SubMatrixExpr<T>
|
|
397
|
+
Cols (IntRange range) const
|
|
398
|
+
{
|
|
399
|
+
return Cols (range.First(), range.Next());
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
INLINE RowsArrayExpr<T>
|
|
404
|
+
Rows (FlatArray<int> rows) const
|
|
405
|
+
{
|
|
406
|
+
return RowsArrayExpr<T> (static_cast<const T&> (*this), rows);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
INLINE ColsArrayExpr<T>
|
|
410
|
+
Cols (FlatArray<int> cols) const
|
|
411
|
+
{
|
|
412
|
+
return ColsArrayExpr<T> (static_cast<const T&> (*this), cols);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
};
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
Caller knows that matrix expression is a symmetric matrix.
|
|
427
|
+
Thus, only one half of the matrix needs to be computed.
|
|
428
|
+
*/
|
|
429
|
+
template <typename T>
|
|
430
|
+
class SymExpr : public Expr<SymExpr<T> >
|
|
431
|
+
{
|
|
432
|
+
T a;
|
|
433
|
+
public:
|
|
434
|
+
|
|
435
|
+
SymExpr (T aa) : a(aa) { ; }
|
|
436
|
+
|
|
437
|
+
INLINE auto operator() (size_t i) const { return a(i); }
|
|
438
|
+
INLINE auto operator() (size_t i, size_t j) const { return a(i,j); }
|
|
439
|
+
INLINE auto Height() const { return a.Height(); }
|
|
440
|
+
INLINE auto Width() const { return a.Width(); }
|
|
441
|
+
|
|
442
|
+
auto View() const { return *this; }
|
|
443
|
+
auto Shape() const { return a.Shape(); }
|
|
444
|
+
|
|
445
|
+
static constexpr bool IsLinear() { return T::IsLinear(); }
|
|
446
|
+
void Dump (ostream & ost) const
|
|
447
|
+
{ ost << "Sym ("; a.Dump(ost); ost << ")"; }
|
|
448
|
+
};
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
Declare that matrix expression is symmetric
|
|
453
|
+
*/
|
|
454
|
+
template <typename T>
|
|
455
|
+
inline SymExpr<T> Symmetric (const Expr<T> & a)
|
|
456
|
+
{
|
|
457
|
+
return SymExpr<T> (a.View());
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
template <typename TA>
|
|
464
|
+
class LocalHeapExpr : public Expr<LocalHeapExpr<TA> >
|
|
465
|
+
{
|
|
466
|
+
const TA & a;
|
|
467
|
+
LocalHeap * lh;
|
|
468
|
+
public:
|
|
469
|
+
INLINE LocalHeapExpr (const TA & aa, LocalHeap & alh) : a(aa), lh(&alh) { ; }
|
|
470
|
+
INLINE const TA & A() const { return a; }
|
|
471
|
+
INLINE auto Height() const { return a.Height(); }
|
|
472
|
+
INLINE auto Width() const { return a.Width(); }
|
|
473
|
+
INLINE LocalHeap & GetLocalHeap() const { return *lh; }
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
template <typename TA>
|
|
477
|
+
INLINE LocalHeapExpr<TA> operator| (const Expr<TA> & a, LocalHeap & lh)
|
|
478
|
+
{
|
|
479
|
+
return LocalHeapExpr<TA> (a.Spec(), lh);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
template <class TA> class MatExpr;
|
|
484
|
+
template <class TA, class TB> class MultExpr;
|
|
485
|
+
template <class TA> class MinusExpr;
|
|
486
|
+
template <class TA> class TransExpr;
|
|
487
|
+
template <class TA, class TS> class ScaleExpr;
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
template <typename TOP, typename T, typename TB, typename Enable=int>
|
|
492
|
+
class assign_trait
|
|
493
|
+
{
|
|
494
|
+
public:
|
|
495
|
+
static INLINE T & Assign (MatExpr<T> & self, const Expr<TB> & v)
|
|
496
|
+
{
|
|
497
|
+
// NETGEN_CHECK_RANGE(self.Height(), v.Height(), v.Height()+1);
|
|
498
|
+
// NETGEN_CHECK_RANGE(self.Width(), v.Width(), v.Width()+1);
|
|
499
|
+
// NETGEN_CHECK_SHAPE(self.Spec(), v);
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
auto src = v.View();
|
|
503
|
+
decltype(auto) dest = self.ViewRW();
|
|
504
|
+
|
|
505
|
+
auto h = CombinedSize (src.Height(), dest.Height()); // checks if same
|
|
506
|
+
auto w = CombinedSize (src.Width(), dest.Width()); // checks if same
|
|
507
|
+
|
|
508
|
+
if (T::COL_MAJOR)
|
|
509
|
+
{
|
|
510
|
+
if (h > 0)
|
|
511
|
+
for (size_t j = 0; j < w; j++)
|
|
512
|
+
for (size_t i = 0; i < h; i++)
|
|
513
|
+
TOP()(dest(i,j), src(i,j));
|
|
514
|
+
return self.Spec();
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
|
|
518
|
+
if constexpr (TB::IsLinear())
|
|
519
|
+
{
|
|
520
|
+
if (T::IsLinear())
|
|
521
|
+
{
|
|
522
|
+
auto hw = h*w;
|
|
523
|
+
for (SafeIndex<size_t> i : Range(hw))
|
|
524
|
+
TOP()(dest(i), src(i));
|
|
525
|
+
}
|
|
526
|
+
else
|
|
527
|
+
{
|
|
528
|
+
if (w > 0)
|
|
529
|
+
for (SafeIndex<size_t> i = 0, k = 0; i < h; i++)
|
|
530
|
+
for (SafeIndex<size_t> j = 0; j < w; j++, k++)
|
|
531
|
+
TOP() (dest(i,j), src(k));
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
else
|
|
535
|
+
{
|
|
536
|
+
if (w > 0)
|
|
537
|
+
{
|
|
538
|
+
if (T::IsLinear())
|
|
539
|
+
for (SafeIndex<size_t> i = 0, k = 0; i < h; i++)
|
|
540
|
+
for (SafeIndex<size_t> j = 0; j < w; j++, k++)
|
|
541
|
+
TOP() (dest(k), src(i,j));
|
|
542
|
+
else
|
|
543
|
+
{
|
|
544
|
+
for (SafeIndex<size_t> i = 0; i < h; i++)
|
|
545
|
+
for (SafeIndex<size_t> j = 0; j < w; j++)
|
|
546
|
+
TOP() (dest(i,j), src(i,j));
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
return self.Spec();
|
|
551
|
+
|
|
552
|
+
}
|
|
553
|
+
};
|
|
554
|
+
|
|
555
|
+
|
|
556
|
+
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
The base class for matrices.
|
|
562
|
+
*/
|
|
563
|
+
template <class T>
|
|
564
|
+
class MatExpr : public Expr<T>
|
|
565
|
+
{
|
|
566
|
+
public:
|
|
567
|
+
|
|
568
|
+
constexpr MatExpr () = default;
|
|
569
|
+
|
|
570
|
+
using Expr<T>::Spec;
|
|
571
|
+
using Expr<T>::Height;
|
|
572
|
+
using Expr<T>::Width;
|
|
573
|
+
|
|
574
|
+
enum { COL_MAJOR = 0 }; // matrix is stored col-major
|
|
575
|
+
|
|
576
|
+
|
|
577
|
+
template<typename TOP, typename TB>
|
|
578
|
+
INLINE auto & Assign (const Expr<TB> & v)
|
|
579
|
+
{
|
|
580
|
+
return assign_trait<TOP, T, TB>::Assign (*this, v);
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
|
|
584
|
+
class As
|
|
585
|
+
{
|
|
586
|
+
public:
|
|
587
|
+
template <typename T1, typename T2>
|
|
588
|
+
INLINE void operator() (T1 && v1, const T2 & v2) { v1 = v2; }
|
|
589
|
+
static constexpr bool IsPos() { return true; }
|
|
590
|
+
static constexpr bool IsAdd() { return false; }
|
|
591
|
+
};
|
|
592
|
+
class AsAdd
|
|
593
|
+
{
|
|
594
|
+
public:
|
|
595
|
+
template <typename T1, typename T2>
|
|
596
|
+
INLINE void operator() (T1 && v1, const T2 & v2) { v1 += v2; }
|
|
597
|
+
static constexpr bool IsPos() { return true; }
|
|
598
|
+
static constexpr bool IsAdd() { return true; }
|
|
599
|
+
};
|
|
600
|
+
class AsSub
|
|
601
|
+
{
|
|
602
|
+
public:
|
|
603
|
+
template <typename T1, typename T2>
|
|
604
|
+
INLINE void operator() (T1 && v1, const T2 & v2) { v1 -= v2; }
|
|
605
|
+
static constexpr bool IsPos() { return false; }
|
|
606
|
+
static constexpr bool IsAdd() { return true; }
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
|
|
610
|
+
|
|
611
|
+
|
|
612
|
+
|
|
613
|
+
/*
|
|
614
|
+
TODO: move to traits ...
|
|
615
|
+
|
|
616
|
+
// x += s*y
|
|
617
|
+
template <typename OP, typename TA,
|
|
618
|
+
enable_if_t<std::is_same<OP,AsAdd>::value,bool> = true,
|
|
619
|
+
enable_if_t<is_constructible_v<SliceVector<double>,typename pair<T,TA>::first_type>,bool> = true,
|
|
620
|
+
enable_if_t<is_constructible_v<SliceVector<double>,TA>,bool> = true>
|
|
621
|
+
INLINE T & Assign (const Expr<ScaleExpr<TA,double>> & scaled)
|
|
622
|
+
{
|
|
623
|
+
AddVector (scaled.View().S(),
|
|
624
|
+
make_SliceVector(scaled.View().A()),
|
|
625
|
+
make_SliceVector(this->Spec()));
|
|
626
|
+
return Spec();
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
|
|
630
|
+
// x += s*(m*y)
|
|
631
|
+
template <typename OP, typename TA, typename TB,
|
|
632
|
+
enable_if_t<std::is_same_v<OP,AsAdd>,bool> = true,
|
|
633
|
+
enable_if_t<IsConvertibleToSliceMatrix<TA,double>(),bool> = true,
|
|
634
|
+
enable_if_t<is_convertible_v<TB,FlatVector<double>>,bool> = true,
|
|
635
|
+
enable_if_t<is_convertible<typename pair<T,TB>::first_type,FlatVector<double>>::value,bool> = true>
|
|
636
|
+
INLINE T & Assign (const Expr<ScaleExpr<MultExpr<TA, TB>,double>> & prod)
|
|
637
|
+
{
|
|
638
|
+
MultAddMatVec (prod.Spec().S(),
|
|
639
|
+
make_SliceMatrix(prod.Spec().A().A()),
|
|
640
|
+
prod.Spec().A().B(),
|
|
641
|
+
Spec());
|
|
642
|
+
return Spec();
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
// x += (s*m)*y
|
|
646
|
+
template <typename OP, typename TA, typename TB,
|
|
647
|
+
typename enable_if<std::is_same<OP,AsAdd>::value,int>::type = 0,
|
|
648
|
+
typename enable_if<IsConvertibleToSliceMatrix<TA,double>(),int>::type = 0,
|
|
649
|
+
typename enable_if<is_convertible<TB,FlatVector<double>>::value,int>::type = 0,
|
|
650
|
+
typename enable_if<is_convertible<typename pair<T,TB>::first_type,FlatVector<double>>::value,int>::type = 0>
|
|
651
|
+
INLINE T & Assign (const Expr<MultExpr<ScaleExpr<TA,double>, TB>> & prod)
|
|
652
|
+
{
|
|
653
|
+
MultAddMatVec (prod.Spec().A().S(),
|
|
654
|
+
make_SliceMatrix(prod.Spec().A().A()),
|
|
655
|
+
prod.Spec().B(),
|
|
656
|
+
Spec());
|
|
657
|
+
return Spec();
|
|
658
|
+
}
|
|
659
|
+
*/
|
|
660
|
+
|
|
661
|
+
|
|
662
|
+
template<typename TB>
|
|
663
|
+
INLINE T & operator= (const Expr<TB> & v)
|
|
664
|
+
{
|
|
665
|
+
Assign<As> (v);
|
|
666
|
+
return Spec();
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
INLINE T & operator= (const T & v)
|
|
670
|
+
{
|
|
671
|
+
Assign<As> (v);
|
|
672
|
+
return Spec();
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
template<typename TB>
|
|
676
|
+
INLINE T & operator+= (const Expr<TB> & v)
|
|
677
|
+
{
|
|
678
|
+
Assign<AsAdd> (v);
|
|
679
|
+
return Spec();
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
template<typename TB>
|
|
683
|
+
INLINE MatExpr<T> & operator-= (const Expr<TB> & v)
|
|
684
|
+
{
|
|
685
|
+
Assign<AsSub> (v);
|
|
686
|
+
return Spec();
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
|
|
691
|
+
|
|
692
|
+
template<typename TB>
|
|
693
|
+
INLINE T & operator+= (const Expr<SymExpr<TB> > & v)
|
|
694
|
+
{
|
|
695
|
+
NETGEN_CHECK_RANGE(Height(), v.Height(), v.Height()+1);
|
|
696
|
+
NETGEN_CHECK_RANGE(Width(), v.Width(), v.Width()+1);
|
|
697
|
+
size_t h = Height();
|
|
698
|
+
for (size_t i = 0; i < h; i++)
|
|
699
|
+
{
|
|
700
|
+
for (size_t j = 0; j < i; j++)
|
|
701
|
+
{
|
|
702
|
+
double val = v.Spec()(i,j);
|
|
703
|
+
Spec()(i,j) += val;
|
|
704
|
+
Spec()(j,i) += val;
|
|
705
|
+
}
|
|
706
|
+
Spec()(i,i) += v.Spec()(i,i);
|
|
707
|
+
}
|
|
708
|
+
return Spec();
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
|
|
712
|
+
|
|
713
|
+
template <class SCAL2>
|
|
714
|
+
INLINE T & operator*= (SCAL2 s)
|
|
715
|
+
{
|
|
716
|
+
if (T::IsLinear())
|
|
717
|
+
{
|
|
718
|
+
size_t hw = Height() * Width();
|
|
719
|
+
for (size_t i = 0; i < hw; i++)
|
|
720
|
+
Spec()(i) *= s;
|
|
721
|
+
}
|
|
722
|
+
else
|
|
723
|
+
for (size_t i = 0; i < Height(); i++)
|
|
724
|
+
for (size_t j = 0; j < Width(); j++)
|
|
725
|
+
Spec()(i,j) *= s;
|
|
726
|
+
|
|
727
|
+
return Spec();
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
template <class SCAL2>
|
|
731
|
+
INLINE T & operator/= (SCAL2 s)
|
|
732
|
+
{
|
|
733
|
+
return (*this) *= (1./s);
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
|
|
737
|
+
void Dump (ostream & ost) const
|
|
738
|
+
{ ost << "Matexpr (h=" << Height() << ", w=" << Width() << ")"; }
|
|
739
|
+
|
|
740
|
+
};
|
|
741
|
+
|
|
742
|
+
|
|
743
|
+
|
|
744
|
+
|
|
745
|
+
|
|
746
|
+
|
|
747
|
+
|
|
748
|
+
/* *************************** SumExpr **************************** */
|
|
749
|
+
|
|
750
|
+
/**
|
|
751
|
+
Sum of 2 matrix expressions
|
|
752
|
+
*/
|
|
753
|
+
|
|
754
|
+
template <class TA, class TB>
|
|
755
|
+
class SumExpr : public Expr<SumExpr<TA,TB> >
|
|
756
|
+
{
|
|
757
|
+
TA a;
|
|
758
|
+
TB b;
|
|
759
|
+
public:
|
|
760
|
+
|
|
761
|
+
static constexpr bool IsLinear() { return TA::IsLinear() && TB::IsLinear(); }
|
|
762
|
+
|
|
763
|
+
INLINE SumExpr (TA aa, TB ab) : a(aa), b(ab) { ; }
|
|
764
|
+
|
|
765
|
+
template <typename ...I>
|
|
766
|
+
INLINE auto operator() (I... i) const { return a(i...)+b(i...); }
|
|
767
|
+
|
|
768
|
+
INLINE auto Height() const { return CombinedSize(a.Height(), b.Height()); }
|
|
769
|
+
INLINE auto Width() const { return CombinedSize(a.Width(), b.Width()); }
|
|
770
|
+
|
|
771
|
+
INLINE auto View() const { return SumExpr(a,b); }
|
|
772
|
+
INLINE auto Shape() const { return CombinedSize(a.Shape(), b.Shape()); }
|
|
773
|
+
|
|
774
|
+
void Dump (ostream & ost) const
|
|
775
|
+
{ ost << "("; a.Dump(ost); ost << ") + ("; b.Dump(ost); ost << ")"; }
|
|
776
|
+
};
|
|
777
|
+
|
|
778
|
+
template <typename TA, typename TB>
|
|
779
|
+
INLINE auto
|
|
780
|
+
operator+ (const Expr<TA> & a, const Expr<TB> & b)
|
|
781
|
+
{
|
|
782
|
+
NETGEN_CHECK_SHAPE(a, b);
|
|
783
|
+
return SumExpr(a.View(), b.View());
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
|
|
787
|
+
|
|
788
|
+
|
|
789
|
+
/* *************************** SubExpr **************************** */
|
|
790
|
+
|
|
791
|
+
|
|
792
|
+
/**
|
|
793
|
+
Matrix-expr minus Matrix-expr
|
|
794
|
+
*/
|
|
795
|
+
|
|
796
|
+
template <class TA, class TB>
|
|
797
|
+
class SubExpr : public Expr<SubExpr<TA,TB> >
|
|
798
|
+
{
|
|
799
|
+
TA a;
|
|
800
|
+
TB b;
|
|
801
|
+
public:
|
|
802
|
+
|
|
803
|
+
static constexpr bool IsLinear() { return TA::IsLinear() && TB::IsLinear(); }
|
|
804
|
+
|
|
805
|
+
INLINE SubExpr (TA aa, TB ab) : a(aa), b(ab) { ; }
|
|
806
|
+
|
|
807
|
+
template <typename ...I>
|
|
808
|
+
INLINE auto operator() (I... i) const { return a(i...)-b(i...); }
|
|
809
|
+
|
|
810
|
+
INLINE auto View() const { return SubExpr(a,b); }
|
|
811
|
+
INLINE auto Shape() const { return CombinedSize(a.Shape(), b.Shape()); }
|
|
812
|
+
|
|
813
|
+
INLINE auto Height() const { return CombinedSize(a.Height(), b.Height()); }
|
|
814
|
+
INLINE auto Width() const { return CombinedSize(a.Width(), b.Width()); }
|
|
815
|
+
};
|
|
816
|
+
|
|
817
|
+
|
|
818
|
+
template <typename TA, typename TB>
|
|
819
|
+
inline auto operator- (const Expr<TA> & a, const Expr<TB> & b)
|
|
820
|
+
{
|
|
821
|
+
NETGEN_CHECK_SHAPE(a, b);
|
|
822
|
+
return SubExpr(a.View(), b.View());
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
|
|
829
|
+
|
|
830
|
+
|
|
831
|
+
/* *************************** MinusExpr **************************** */
|
|
832
|
+
|
|
833
|
+
|
|
834
|
+
/**
|
|
835
|
+
minus Matrix-expr
|
|
836
|
+
*/
|
|
837
|
+
|
|
838
|
+
template <class TA>
|
|
839
|
+
class MinusExpr : public Expr<MinusExpr<TA> >
|
|
840
|
+
{
|
|
841
|
+
TA a;
|
|
842
|
+
public:
|
|
843
|
+
MinusExpr (const MinusExpr&) = default;
|
|
844
|
+
MinusExpr (TA aa) : a(aa) { ; }
|
|
845
|
+
|
|
846
|
+
template <typename ...I>
|
|
847
|
+
INLINE auto operator() (I... i) const { return -a(i...); }
|
|
848
|
+
|
|
849
|
+
INLINE auto View() const { return MinusExpr(a); }
|
|
850
|
+
INLINE auto Shape() const { return a.Shape(); }
|
|
851
|
+
|
|
852
|
+
INLINE auto Height() const { return a.Height(); }
|
|
853
|
+
INLINE auto Width() const { return a.Width(); }
|
|
854
|
+
INLINE TA A() const { return a; }
|
|
855
|
+
|
|
856
|
+
static constexpr bool IsLinear() { return TA::IsLinear(); }
|
|
857
|
+
void Dump (ostream & ost) const
|
|
858
|
+
{ ost << "-("; a.Dump(ost); ost << ")"; }
|
|
859
|
+
|
|
860
|
+
};
|
|
861
|
+
|
|
862
|
+
template <typename TA>
|
|
863
|
+
INLINE auto operator- (const Expr<TA> & a)
|
|
864
|
+
{
|
|
865
|
+
return MinusExpr (a.View());
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
|
|
869
|
+
/* *************************** PW_Mult_Expr **************************** */
|
|
870
|
+
|
|
871
|
+
template <class TA, class TB>
|
|
872
|
+
class PW_Mult_Expr : public Expr<PW_Mult_Expr<TA,TB> >
|
|
873
|
+
{
|
|
874
|
+
TA a;
|
|
875
|
+
TB b;
|
|
876
|
+
public:
|
|
877
|
+
static constexpr bool IsLinear() { return TA::IsLinear() && TB::IsLinear(); }
|
|
878
|
+
|
|
879
|
+
INLINE PW_Mult_Expr (TA aa, TB ab) : a(aa), b(ab) { ; }
|
|
880
|
+
|
|
881
|
+
INLINE auto operator() (size_t i) const { return a(i)*b(i); }
|
|
882
|
+
INLINE auto operator() (size_t i, size_t j) const { return a(i,j)*b(i,j); }
|
|
883
|
+
|
|
884
|
+
INLINE auto Height() const { return a.Height(); }
|
|
885
|
+
INLINE auto Width() const { return a.Width(); }
|
|
886
|
+
|
|
887
|
+
INLINE auto View() const { return *this; }
|
|
888
|
+
INLINE auto Shape() const { return CombinedSize(a.Shape(), b.Shape()); }
|
|
889
|
+
void Dump (ostream & ost) const
|
|
890
|
+
{ ost << "("; a.Dump(ost); ost << ") + ("; b.Dump(ost); ost << ")"; }
|
|
891
|
+
};
|
|
892
|
+
|
|
893
|
+
template <typename TA, typename TB>
|
|
894
|
+
INLINE auto pw_mult (const Expr<TA> & a, const Expr<TB> & b)
|
|
895
|
+
{
|
|
896
|
+
NETGEN_CHECK_SHAPE(a, b);
|
|
897
|
+
return PW_Mult_Expr (a.View(), b.View());
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
|
|
901
|
+
/* *************************** PW_Inv_Expr **************************** */
|
|
902
|
+
|
|
903
|
+
template <class TA>
|
|
904
|
+
class PW_Inv_Expr : public Expr<PW_Inv_Expr<TA> >
|
|
905
|
+
{
|
|
906
|
+
TA a;
|
|
907
|
+
public:
|
|
908
|
+
static constexpr bool IsLinear() { return TA::IsLinear(); }
|
|
909
|
+
INLINE PW_Inv_Expr (TA aa) : a(aa) { ; }
|
|
910
|
+
|
|
911
|
+
INLINE auto operator() (size_t i) const { return 1.0/a(i); }
|
|
912
|
+
INLINE auto operator() (size_t i, size_t j) const { return 1.0/a(i,j); }
|
|
913
|
+
|
|
914
|
+
INLINE size_t Height() const { return a.Height(); }
|
|
915
|
+
INLINE size_t Width() const { return a.Width(); }
|
|
916
|
+
INLINE auto View () const { return *this; }
|
|
917
|
+
void Dump (ostream & ost) const
|
|
918
|
+
{ ost << "1/("; a.Dump(ost); ost << ")"; }
|
|
919
|
+
};
|
|
920
|
+
|
|
921
|
+
template <typename TA>
|
|
922
|
+
INLINE auto pw_inv (const Expr<TA> & a)
|
|
923
|
+
{
|
|
924
|
+
return PW_Inv_Expr (a.View());
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
|
|
928
|
+
|
|
929
|
+
/* *************************** ScaleExpr **************************** */
|
|
930
|
+
|
|
931
|
+
|
|
932
|
+
/**
|
|
933
|
+
Scalar times Matrix-expr
|
|
934
|
+
*/
|
|
935
|
+
template <class TA, class TS>
|
|
936
|
+
class ScaleExpr : public Expr<ScaleExpr<TA,TS> >
|
|
937
|
+
{
|
|
938
|
+
TA a;
|
|
939
|
+
TS s;
|
|
940
|
+
public:
|
|
941
|
+
static constexpr bool IsLinear() { return TA::IsLinear(); }
|
|
942
|
+
|
|
943
|
+
ScaleExpr (const ScaleExpr&) = default;
|
|
944
|
+
INLINE ScaleExpr (TA aa, TS as) : a(aa), s(as) { ; }
|
|
945
|
+
|
|
946
|
+
// INLINE auto operator() (size_t i) const { return s * a(i); }
|
|
947
|
+
// INLINE auto operator() (size_t i, size_t j) const { return s * a(i,j); }
|
|
948
|
+
|
|
949
|
+
template <typename ...I>
|
|
950
|
+
INLINE auto operator() (I... i) const { return s*a(i...); }
|
|
951
|
+
|
|
952
|
+
INLINE auto Height() const { return a.Height(); }
|
|
953
|
+
INLINE auto Width() const { return a.Width(); }
|
|
954
|
+
|
|
955
|
+
INLINE auto View() const { return *this; }
|
|
956
|
+
INLINE auto Shape() const { return a.Shape(); }
|
|
957
|
+
|
|
958
|
+
INLINE TA A() const { return a; }
|
|
959
|
+
INLINE TS S() const { return s; }
|
|
960
|
+
|
|
961
|
+
void Dump (ostream & ost) const
|
|
962
|
+
{ ost << "Scale, s=" << s << " * "; a.Dump(ost); }
|
|
963
|
+
};
|
|
964
|
+
|
|
965
|
+
|
|
966
|
+
template <typename TS, typename TA,
|
|
967
|
+
typename enable_if<IsScalar<TS>(),int>::type = 0>
|
|
968
|
+
INLINE auto operator* (TS s, const Expr<TA> & a)
|
|
969
|
+
{
|
|
970
|
+
return ScaleExpr (a.View(), s);
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
|
|
974
|
+
|
|
975
|
+
/* ************************* MultExpr ************************* */
|
|
976
|
+
|
|
977
|
+
|
|
978
|
+
/**
|
|
979
|
+
Matrix-expr timex Matrix-expr
|
|
980
|
+
*/
|
|
981
|
+
template <class TA, class TB> class MultExpr : public Expr<MultExpr<TA,TB> >
|
|
982
|
+
{
|
|
983
|
+
TA a;
|
|
984
|
+
TB b;
|
|
985
|
+
public:
|
|
986
|
+
|
|
987
|
+
INLINE MultExpr (TA aa, TB ab) : a(aa), b(ab) { ; }
|
|
988
|
+
|
|
989
|
+
/*
|
|
990
|
+
INLINE auto operator() (size_t i) const
|
|
991
|
+
{ return operator()(i,0); }
|
|
992
|
+
|
|
993
|
+
INLINE auto operator() (size_t i, size_t j) const // -> decltype (a(0,0)*b(0,0))
|
|
994
|
+
{
|
|
995
|
+
size_t wa = a.Width();
|
|
996
|
+
|
|
997
|
+
if (wa >= 1)
|
|
998
|
+
{
|
|
999
|
+
auto sum = a(i,0) * b(0,j);
|
|
1000
|
+
for (size_t k = 1; k < wa; k++)
|
|
1001
|
+
sum += a(i,k) * b(k,j);
|
|
1002
|
+
return sum;
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
decltype (a(0,0)*b(0,0)) sum (0);
|
|
1006
|
+
return sum;
|
|
1007
|
+
}
|
|
1008
|
+
*/
|
|
1009
|
+
template <typename ...J>
|
|
1010
|
+
INLINE auto operator() (size_t i, J... j) const
|
|
1011
|
+
{
|
|
1012
|
+
size_t wa = a.Width();
|
|
1013
|
+
|
|
1014
|
+
if (wa >= 1)
|
|
1015
|
+
{
|
|
1016
|
+
auto sum = a(i,SafeIndex(0)) * b(0,j...);
|
|
1017
|
+
for (size_t k = 1; k < wa; k++)
|
|
1018
|
+
sum += a(i,SafeIndex(k)) * b(k,j...);
|
|
1019
|
+
return sum;
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
decltype (a(0,0)*b(0,j...)) sum (0);
|
|
1023
|
+
return sum;
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
INLINE auto View() const { return MultExpr(a,b); }
|
|
1027
|
+
INLINE auto Shape() const
|
|
1028
|
+
{
|
|
1029
|
+
if constexpr (tuple_size<decltype(b.Shape())>() == 1)
|
|
1030
|
+
return tuple(get<0>(a.Shape()));
|
|
1031
|
+
else
|
|
1032
|
+
return tuple(get<0>(a.Shape()), get<1>(b.Shape()));
|
|
1033
|
+
/*
|
|
1034
|
+
// too complicated ?
|
|
1035
|
+
return tuple_cat(tuple(get<0>(a.Shape())),
|
|
1036
|
+
std::apply([](auto&&, const auto&... args) {return std::tie(args...);}, b.Shape()) );
|
|
1037
|
+
*/
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
INLINE TA A() const { return a; }
|
|
1041
|
+
INLINE TB B() const { return b; }
|
|
1042
|
+
INLINE auto Height() const { return a.Height(); }
|
|
1043
|
+
INLINE auto Width() const { return b.Width(); }
|
|
1044
|
+
static constexpr bool IsLinear() { return false; }
|
|
1045
|
+
};
|
|
1046
|
+
|
|
1047
|
+
|
|
1048
|
+
template <int H, typename SCALA, class TB> class MultExpr<DiagMat<H,SCALA>,TB>
|
|
1049
|
+
: public Expr<MultExpr<DiagMat<H,SCALA>,TB> >
|
|
1050
|
+
{
|
|
1051
|
+
DiagMat<H,SCALA> a;
|
|
1052
|
+
TB b;
|
|
1053
|
+
public:
|
|
1054
|
+
|
|
1055
|
+
MultExpr (DiagMat<H,SCALA> aa, TB ab) : a(aa), b(ab) { ; }
|
|
1056
|
+
|
|
1057
|
+
INLINE auto operator() (size_t i) const { return a[i] * b(i); }
|
|
1058
|
+
INLINE auto operator() (size_t i, size_t j) const { return a[i] * b(i,j); }
|
|
1059
|
+
|
|
1060
|
+
INLINE auto View() const { return *this; }
|
|
1061
|
+
INLINE auto Shape() const
|
|
1062
|
+
{
|
|
1063
|
+
typedef decltype(b.Shape()) TBSHAPE;
|
|
1064
|
+
if constexpr (tuple_size<TBSHAPE>() == 1)
|
|
1065
|
+
return tuple<size_t> (H);
|
|
1066
|
+
else
|
|
1067
|
+
return tuple<size_t,size_t> (H, b.Width());
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
INLINE const auto A() const { return a; }
|
|
1071
|
+
INLINE const auto B() const { return b; }
|
|
1072
|
+
INLINE auto Height() const { return a.Height(); }
|
|
1073
|
+
INLINE auto Width() const { return b.Width(); }
|
|
1074
|
+
|
|
1075
|
+
static constexpr bool IsLinear() { return false; }
|
|
1076
|
+
};
|
|
1077
|
+
|
|
1078
|
+
|
|
1079
|
+
template <typename TA, typename TB>
|
|
1080
|
+
INLINE auto operator* (const Expr<TA> & a, const Expr<TB> & b)
|
|
1081
|
+
{
|
|
1082
|
+
return MultExpr (a.View(), b.View());
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
|
|
1086
|
+
/* ************************** Trans *************************** */
|
|
1087
|
+
|
|
1088
|
+
template <typename TA,
|
|
1089
|
+
typename enable_if<IsScalar<TA>(),int>::type = 0>
|
|
1090
|
+
INLINE auto Trans (TA a) { return a; }
|
|
1091
|
+
|
|
1092
|
+
|
|
1093
|
+
/**
|
|
1094
|
+
Transpose of Matrix-expr
|
|
1095
|
+
*/
|
|
1096
|
+
template <class TA> class TransExpr : public MatExpr<TransExpr<TA> >
|
|
1097
|
+
{
|
|
1098
|
+
TA a;
|
|
1099
|
+
public:
|
|
1100
|
+
INLINE TransExpr (TA aa) : a(aa) { ; }
|
|
1101
|
+
|
|
1102
|
+
INLINE auto Height() const { return a.Width(); }
|
|
1103
|
+
INLINE auto Width() const { return a.Height(); }
|
|
1104
|
+
|
|
1105
|
+
INLINE auto operator() (size_t i, size_t j) const { return Trans (a(j,i)); }
|
|
1106
|
+
INLINE auto operator() (size_t i) const { return Trans(a(0,0)); }
|
|
1107
|
+
// auto Row (int i) const -> decltype (a.Col(i)) { return a.Col(i); }
|
|
1108
|
+
// auto Col (int i) const -> decltype (a.Row(i)) { return a.Row(i); }
|
|
1109
|
+
|
|
1110
|
+
INLINE auto View() const { return *this; }
|
|
1111
|
+
INLINE auto Shape() const { return tuple (a.Width(), a.Height()); }
|
|
1112
|
+
|
|
1113
|
+
static constexpr bool IsLinear() { return false; }
|
|
1114
|
+
INLINE const TA & A() const { return a; }
|
|
1115
|
+
};
|
|
1116
|
+
|
|
1117
|
+
|
|
1118
|
+
/// Transpose
|
|
1119
|
+
template <typename TA>
|
|
1120
|
+
INLINE auto Trans (const Expr<TA> & a)
|
|
1121
|
+
{
|
|
1122
|
+
return TransExpr (a.View());
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
template <typename TA, typename TB>
|
|
1126
|
+
INLINE auto Trans (const Expr<MultExpr<TA,TB>> & expr)
|
|
1127
|
+
{
|
|
1128
|
+
return Trans(expr.Spec().B()) * Trans(expr.Spec().A());
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
template <typename TA>
|
|
1132
|
+
INLINE auto Trans (const Expr<TransExpr<TA>> & expr)
|
|
1133
|
+
{
|
|
1134
|
+
return expr.Spec().A();
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
/* ************************* Real/Imag ************************ */
|
|
1138
|
+
|
|
1139
|
+
INLINE double Real(double a) { return a; }
|
|
1140
|
+
INLINE double Imag(double a) { return 0; }
|
|
1141
|
+
|
|
1142
|
+
INLINE double Real(Complex a) { return a.real(); }
|
|
1143
|
+
INLINE double Imag(Complex a) { return a.imag(); }
|
|
1144
|
+
|
|
1145
|
+
template <class TA>
|
|
1146
|
+
class RealExpr : public Expr<RealExpr<TA> >
|
|
1147
|
+
{
|
|
1148
|
+
TA a;
|
|
1149
|
+
public:
|
|
1150
|
+
RealExpr (TA aa) : a(aa) { ; }
|
|
1151
|
+
|
|
1152
|
+
INLINE auto operator() (size_t i) const { return Real(a(i)); }
|
|
1153
|
+
INLINE auto operator() (size_t i, size_t j) const { return Real(a(i,j)); }
|
|
1154
|
+
INLINE auto Height() const { return a.Height(); }
|
|
1155
|
+
INLINE auto Width() const { return a.Width(); }
|
|
1156
|
+
INLINE auto View() const { return *this; }
|
|
1157
|
+
INLINE auto Shape() const { return a.Shape(); }
|
|
1158
|
+
static constexpr bool IsLinear() { return TA::IsLinear(); }
|
|
1159
|
+
};
|
|
1160
|
+
|
|
1161
|
+
template <typename TA>
|
|
1162
|
+
INLINE auto Real(const Expr<TA> & a)
|
|
1163
|
+
{
|
|
1164
|
+
return RealExpr(a.View());
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
|
|
1168
|
+
template <class TA>
|
|
1169
|
+
class ImagExpr : public Expr<ImagExpr<TA> >
|
|
1170
|
+
{
|
|
1171
|
+
TA a;
|
|
1172
|
+
public:
|
|
1173
|
+
ImagExpr (TA aa) : a(aa) { ; }
|
|
1174
|
+
|
|
1175
|
+
INLINE auto operator() (size_t i) const { return Imag(a(i)); }
|
|
1176
|
+
INLINE auto operator() (size_t i, size_t j) const { return Imag(a(i,j)); }
|
|
1177
|
+
INLINE auto Height() const { return a.Height(); }
|
|
1178
|
+
INLINE auto Width() const { return a.Width(); }
|
|
1179
|
+
INLINE auto View() const { return *this; }
|
|
1180
|
+
INLINE auto Shape() const { return a.Shape(); }
|
|
1181
|
+
static constexpr bool IsLinear() { return TA::IsLinear(); }
|
|
1182
|
+
};
|
|
1183
|
+
|
|
1184
|
+
template <typename TA>
|
|
1185
|
+
INLINE auto Imag(const Expr<TA> & a)
|
|
1186
|
+
{
|
|
1187
|
+
return ImagExpr (a.View());
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
|
|
1191
|
+
|
|
1192
|
+
/* ************************* SubMatrix ************************ */
|
|
1193
|
+
|
|
1194
|
+
template <class TA>
|
|
1195
|
+
class SubMatrixExpr : public MatExpr<SubMatrixExpr<TA> >
|
|
1196
|
+
{
|
|
1197
|
+
TA a;
|
|
1198
|
+
size_t first_row, first_col;
|
|
1199
|
+
size_t height, width;
|
|
1200
|
+
public:
|
|
1201
|
+
SubMatrixExpr (TA aa, size_t fr, size_t fc, size_t ah, size_t aw)
|
|
1202
|
+
: a(aa), first_row(fr), first_col(fc), height(ah), width(aw) { ; }
|
|
1203
|
+
|
|
1204
|
+
INLINE size_t Height() const { return height; }
|
|
1205
|
+
INLINE size_t Width() const { return width; }
|
|
1206
|
+
|
|
1207
|
+
// auto operator() (size_t i, size_t j) { return a(i+first_row, j+first_col); }
|
|
1208
|
+
// auto operator() (size_t i) { return a(i+first_row); }
|
|
1209
|
+
INLINE decltype(auto) operator() (size_t i, int j) const { return a(i+first_row, j+first_col); }
|
|
1210
|
+
INLINE decltype(auto) operator() (size_t i) const { return a(i+first_row); }
|
|
1211
|
+
|
|
1212
|
+
typedef typename TA::TELEM TELEM;
|
|
1213
|
+
typedef typename TA::TSCAL TSCAL;
|
|
1214
|
+
|
|
1215
|
+
static constexpr bool IsLinear() { return false; }
|
|
1216
|
+
|
|
1217
|
+
enum { COL_MAJOR = TA::COL_MAJOR };
|
|
1218
|
+
|
|
1219
|
+
template<typename TB>
|
|
1220
|
+
INLINE const SubMatrixExpr & operator= (const Expr<TB> & m)
|
|
1221
|
+
{
|
|
1222
|
+
MatExpr<SubMatrixExpr<TA> >::operator= (m);
|
|
1223
|
+
return *this;
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
INLINE auto View() const { return SubMatrixExpr(a, first_row, first_col, height, width); }
|
|
1227
|
+
INLINE auto ViewRW() { return SubMatrixExpr(a, first_row, first_col, height, width); }
|
|
1228
|
+
INLINE tuple<size_t,size_t> Shape() const { return { height, width }; }
|
|
1229
|
+
};
|
|
1230
|
+
|
|
1231
|
+
|
|
1232
|
+
template <class TA>
|
|
1233
|
+
class RowExpr : public MatExpr<RowExpr<TA> >
|
|
1234
|
+
{
|
|
1235
|
+
TA a;
|
|
1236
|
+
size_t row;
|
|
1237
|
+
public:
|
|
1238
|
+
RowExpr (TA aa, size_t r)
|
|
1239
|
+
: a(aa), row(r) { ; }
|
|
1240
|
+
|
|
1241
|
+
INLINE size_t Height() const { return 1; }
|
|
1242
|
+
INLINE size_t Width() const { return a.Width(); }
|
|
1243
|
+
|
|
1244
|
+
INLINE auto operator() (size_t i, size_t j) -> decltype(a(0,0)) { return a(row,i); }
|
|
1245
|
+
INLINE auto operator() (size_t i) -> decltype(a(0,0)) { return a(row,i); }
|
|
1246
|
+
INLINE auto operator() (size_t i, size_t j) const { return a(row,i); }
|
|
1247
|
+
INLINE auto operator() (size_t i) const { return a(row,i); }
|
|
1248
|
+
|
|
1249
|
+
static constexpr bool IsLinear() { return false; }
|
|
1250
|
+
|
|
1251
|
+
template<typename TB>
|
|
1252
|
+
INLINE const RowExpr & operator= (const Expr<TB> & m)
|
|
1253
|
+
{
|
|
1254
|
+
MatExpr<RowExpr<TA> >::operator= (m);
|
|
1255
|
+
return *this;
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
INLINE auto View() const { return *this; }
|
|
1259
|
+
INLINE tuple<size_t> Shape() const { return a.Width(); }
|
|
1260
|
+
};
|
|
1261
|
+
|
|
1262
|
+
|
|
1263
|
+
|
|
1264
|
+
template <class TA>
|
|
1265
|
+
class ColExpr : public MatExpr<ColExpr<TA> >
|
|
1266
|
+
{
|
|
1267
|
+
TA a;
|
|
1268
|
+
size_t col;
|
|
1269
|
+
public:
|
|
1270
|
+
ColExpr (TA aa, size_t c)
|
|
1271
|
+
: a(aa), col(c) { ; }
|
|
1272
|
+
|
|
1273
|
+
INLINE size_t Height() const { return a.Height(); }
|
|
1274
|
+
INLINE size_t Width() const { return 1; }
|
|
1275
|
+
|
|
1276
|
+
INLINE auto operator() (size_t i, size_t j) -> decltype(a(0,0)) { return a(i,col); }
|
|
1277
|
+
INLINE auto operator() (size_t i) -> decltype(a(0,0)) { return a(i,col); }
|
|
1278
|
+
INLINE auto operator() (size_t i, size_t j) const { return a(i,col); }
|
|
1279
|
+
INLINE auto operator() (size_t i) const { return a(i,col); }
|
|
1280
|
+
|
|
1281
|
+
static constexpr bool IsLinear() { return false; }
|
|
1282
|
+
|
|
1283
|
+
template<typename TB>
|
|
1284
|
+
INLINE const ColExpr & operator= (const Expr<TB> & m)
|
|
1285
|
+
{
|
|
1286
|
+
MatExpr<ColExpr<TA> >::operator= (m);
|
|
1287
|
+
return *this;
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
INLINE auto View() const { return *this; }
|
|
1291
|
+
INLINE tuple<size_t> Shape() const { return a.Height(); }
|
|
1292
|
+
};
|
|
1293
|
+
|
|
1294
|
+
|
|
1295
|
+
|
|
1296
|
+
|
|
1297
|
+
|
|
1298
|
+
/* ************************* RowsArray ************************ */
|
|
1299
|
+
|
|
1300
|
+
/**
|
|
1301
|
+
RowsArray
|
|
1302
|
+
*/
|
|
1303
|
+
template <class TA> class RowsArrayExpr : public MatExpr<RowsArrayExpr<TA> >
|
|
1304
|
+
{
|
|
1305
|
+
const TA & a;
|
|
1306
|
+
FlatArray<int> rows;
|
|
1307
|
+
public:
|
|
1308
|
+
typedef typename TA::TELEM TELEM;
|
|
1309
|
+
typedef typename TA::TSCAL TSCAL;
|
|
1310
|
+
static constexpr bool IsLinear() { return false; }
|
|
1311
|
+
|
|
1312
|
+
INLINE RowsArrayExpr (const TA & aa, FlatArray<int> arows) : a(aa), rows(arows) { ; }
|
|
1313
|
+
|
|
1314
|
+
INLINE auto Height() const { return rows.Size(); }
|
|
1315
|
+
INLINE auto Width() const { return a.Width(); }
|
|
1316
|
+
|
|
1317
|
+
INLINE auto operator() (size_t i, size_t j) const-> decltype(a(rows[i],j)) { return a(rows[i], j); }
|
|
1318
|
+
INLINE auto operator() (size_t i) const-> decltype(a(rows[i])) { return a(rows[i]); }
|
|
1319
|
+
|
|
1320
|
+
INLINE auto Row (size_t i) const { return a.Row(rows[i]); }
|
|
1321
|
+
INLINE auto View() const { return RowsArrayExpr(a, rows); }
|
|
1322
|
+
INLINE auto ViewRW() { return RowsArrayExpr(a, rows); }
|
|
1323
|
+
INLINE auto Shape() const
|
|
1324
|
+
{
|
|
1325
|
+
typedef decltype(a.Shape()) TASHAPE;
|
|
1326
|
+
if constexpr (tuple_size<TASHAPE>() == 1)
|
|
1327
|
+
return tuple<size_t> (rows.Size());
|
|
1328
|
+
else
|
|
1329
|
+
return tuple<size_t,size_t> (rows.Size(), a.Width());
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
template<typename TB>
|
|
1333
|
+
INLINE const RowsArrayExpr & operator= (const Expr<TB> & m)
|
|
1334
|
+
{
|
|
1335
|
+
MatExpr<RowsArrayExpr<TA> >::operator= (m);
|
|
1336
|
+
return *this;
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
INLINE const RowsArrayExpr & operator= (const RowsArrayExpr & m)
|
|
1340
|
+
{
|
|
1341
|
+
MatExpr<RowsArrayExpr<TA> >::operator= (m);
|
|
1342
|
+
return *this;
|
|
1343
|
+
}
|
|
1344
|
+
};
|
|
1345
|
+
|
|
1346
|
+
|
|
1347
|
+
/**
|
|
1348
|
+
ColsArray
|
|
1349
|
+
*/
|
|
1350
|
+
template <class TA> class ColsArrayExpr : public MatExpr<ColsArrayExpr<TA> >
|
|
1351
|
+
{
|
|
1352
|
+
const TA & a;
|
|
1353
|
+
FlatArray<int> cols;
|
|
1354
|
+
public:
|
|
1355
|
+
typedef typename TA::TELEM TELEM;
|
|
1356
|
+
static constexpr bool IsLinear() { return false; }
|
|
1357
|
+
typedef typename TA::TSCAL TSCAL;
|
|
1358
|
+
|
|
1359
|
+
INLINE ColsArrayExpr (const TA & aa, FlatArray<int> acols) : a(aa), cols(acols) { ; }
|
|
1360
|
+
|
|
1361
|
+
INLINE size_t Height() const { return a.Height(); }
|
|
1362
|
+
INLINE size_t Width() const { return cols.Size(); }
|
|
1363
|
+
|
|
1364
|
+
INLINE auto operator() (size_t i, size_t j) const -> decltype(a(i, cols[j])) { return a(i, cols[j]); }
|
|
1365
|
+
INLINE auto operator() (size_t i) const -> decltype(a(i, cols[0])) { return a(i, cols[0]); }
|
|
1366
|
+
|
|
1367
|
+
INLINE auto View() const { return *this; }
|
|
1368
|
+
INLINE auto ViewRW() { return *this; }
|
|
1369
|
+
INLINE tuple<size_t,size_t> Shape() const { return { a.Height(), cols.Size() }; }
|
|
1370
|
+
|
|
1371
|
+
template<typename TB>
|
|
1372
|
+
INLINE const ColsArrayExpr & operator= (const Expr<TB> & m)
|
|
1373
|
+
{
|
|
1374
|
+
MatExpr<ColsArrayExpr<TA> >::operator= (m);
|
|
1375
|
+
return *this;
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
};
|
|
1379
|
+
|
|
1380
|
+
|
|
1381
|
+
|
|
1382
|
+
|
|
1383
|
+
/* ************************* Conjugate *********************** */
|
|
1384
|
+
|
|
1385
|
+
|
|
1386
|
+
INLINE double Conj (double a)
|
|
1387
|
+
{
|
|
1388
|
+
return a;
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
INLINE Complex Conj (Complex a)
|
|
1392
|
+
{
|
|
1393
|
+
return conj(a);
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
/**
|
|
1397
|
+
Conjugate of Matrix-expr
|
|
1398
|
+
*/
|
|
1399
|
+
// Attention NOT transpose !!! elemwise conjugate !!!
|
|
1400
|
+
template <class TA> class ConjExpr : public Expr<ConjExpr<TA> >
|
|
1401
|
+
{
|
|
1402
|
+
TA a;
|
|
1403
|
+
public:
|
|
1404
|
+
// typedef typename TA::TELEM TELEM;
|
|
1405
|
+
// typedef typename TA::TSCAL TSCAL;
|
|
1406
|
+
|
|
1407
|
+
INLINE ConjExpr (TA aa) : a(aa) { ; }
|
|
1408
|
+
|
|
1409
|
+
INLINE auto Height() const { return a.Height(); }
|
|
1410
|
+
INLINE auto Width() const { return a.Width(); }
|
|
1411
|
+
|
|
1412
|
+
INLINE auto View() const { return *this; }
|
|
1413
|
+
INLINE auto Shape() const { return a.Shape(); }
|
|
1414
|
+
|
|
1415
|
+
INLINE auto operator() (size_t i, size_t j) const { return Conj(a(i,j)); }
|
|
1416
|
+
INLINE auto operator() (size_t i) const { return Conj(a(i)); }
|
|
1417
|
+
|
|
1418
|
+
static constexpr bool IsLinear() { return TA::IsLinear(); }
|
|
1419
|
+
};
|
|
1420
|
+
|
|
1421
|
+
|
|
1422
|
+
/// Conjugate
|
|
1423
|
+
template <typename TA>
|
|
1424
|
+
INLINE auto Conj (const Expr<TA> & a)
|
|
1425
|
+
{
|
|
1426
|
+
if constexpr (IsComplex<decltype(a.Spec()(0))>())
|
|
1427
|
+
return ConjExpr (a.View());
|
|
1428
|
+
else
|
|
1429
|
+
return a.View();
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
|
|
1433
|
+
|
|
1434
|
+
/* ************************* Truncate ************************* */
|
|
1435
|
+
|
|
1436
|
+
INLINE double Truncate (double v, double eps = 1e-12)
|
|
1437
|
+
{
|
|
1438
|
+
return (fabs(v) < eps) ? 0 : v;
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
INLINE Complex Truncate (Complex v, double eps = 1e-12)
|
|
1442
|
+
{
|
|
1443
|
+
return Complex(Truncate(Real(v), eps), Truncate(Imag(v),eps));
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
template <class TA> class TruncateExpr : public Expr<TruncateExpr<TA> >
|
|
1447
|
+
{
|
|
1448
|
+
TA a;
|
|
1449
|
+
double eps;
|
|
1450
|
+
public:
|
|
1451
|
+
INLINE TruncateExpr (TA aa, double aeps) : a(aa), eps(aeps) { ; }
|
|
1452
|
+
|
|
1453
|
+
INLINE auto Height() const { return a.Height(); }
|
|
1454
|
+
INLINE auto Width() const { return a.Width(); }
|
|
1455
|
+
|
|
1456
|
+
INLINE auto operator() (size_t i, size_t j) const { return Truncate(a(i,j), eps); }
|
|
1457
|
+
INLINE auto operator() (size_t i) const { return Truncate(a(i), eps); }
|
|
1458
|
+
INLINE auto View() const { return *this; }
|
|
1459
|
+
|
|
1460
|
+
static constexpr bool IsLinear() { return TA::IsLinear(); }
|
|
1461
|
+
};
|
|
1462
|
+
|
|
1463
|
+
/// Conjugate
|
|
1464
|
+
template <typename TA>
|
|
1465
|
+
INLINE TruncateExpr<TA>
|
|
1466
|
+
Truncate (const Expr<TA> & a, double eps = 1e-12)
|
|
1467
|
+
{
|
|
1468
|
+
return TruncateExpr<TA> (a.View(), eps);
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
|
|
1472
|
+
/* ************************* InnerProduct ********************** */
|
|
1473
|
+
|
|
1474
|
+
template <typename TA, typename TB,
|
|
1475
|
+
typename enable_if<IsScalar<TA>(),int>::type = 0,
|
|
1476
|
+
typename enable_if<IsScalar<TB>(),int>::type = 0>
|
|
1477
|
+
INLINE auto InnerProduct (TA a, TB b) { return a*b; }
|
|
1478
|
+
|
|
1479
|
+
|
|
1480
|
+
|
|
1481
|
+
|
|
1482
|
+
/**
|
|
1483
|
+
Inner product
|
|
1484
|
+
*/
|
|
1485
|
+
|
|
1486
|
+
template <class TA, class TB>
|
|
1487
|
+
INLINE auto InnerProduct (const Expr<TA> & a, const Expr<TB> & b)
|
|
1488
|
+
-> decltype (InnerProduct(a.Spec()(0), b.Spec()(0)))
|
|
1489
|
+
{
|
|
1490
|
+
auto h = CombinedSize(a.Height(), b.Height());
|
|
1491
|
+
auto w = CombinedSize(a.Width(), b.Width());
|
|
1492
|
+
|
|
1493
|
+
if (h*w == 0) return 0;
|
|
1494
|
+
|
|
1495
|
+
auto sum = InnerProduct (a.Spec()(0), b.Spec()(0));
|
|
1496
|
+
for (size_t i = 1; i < h*w; i++)
|
|
1497
|
+
sum += InnerProduct (a.Spec()(i), b.Spec()(i));
|
|
1498
|
+
return sum;
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
|
|
1502
|
+
/* ************************* OuterProduct ********************** */
|
|
1503
|
+
|
|
1504
|
+
template <class TA, class TB>
|
|
1505
|
+
class OuterProductExpr : public Expr<OuterProductExpr<TA,TB>>
|
|
1506
|
+
{
|
|
1507
|
+
TA a;
|
|
1508
|
+
TB b;
|
|
1509
|
+
public:
|
|
1510
|
+
OuterProductExpr (TA aa, TB ab) : a(aa), b(ab) { ; }
|
|
1511
|
+
|
|
1512
|
+
// INLINE auto operator() (size_t i) const { return a[i] * b(i); }
|
|
1513
|
+
INLINE auto operator() (size_t i, size_t j) const { return a[i] * b[j]; }
|
|
1514
|
+
|
|
1515
|
+
INLINE auto View() const { return *this; }
|
|
1516
|
+
INLINE auto Shape() const
|
|
1517
|
+
{
|
|
1518
|
+
return tuple<size_t,size_t> (a.Size(), b.Width());
|
|
1519
|
+
}
|
|
1520
|
+
|
|
1521
|
+
INLINE const auto A() const { return a; }
|
|
1522
|
+
INLINE const auto B() const { return b; }
|
|
1523
|
+
INLINE auto Height() const { return a.Size(); }
|
|
1524
|
+
INLINE auto Width() const { return b.Size(); }
|
|
1525
|
+
|
|
1526
|
+
static constexpr bool IsLinear() { return false; }
|
|
1527
|
+
};
|
|
1528
|
+
|
|
1529
|
+
|
|
1530
|
+
template <typename TA, typename TB>
|
|
1531
|
+
INLINE auto OuterProduct (const Expr<TA> & a, const Expr<TB> & b)
|
|
1532
|
+
{
|
|
1533
|
+
return OuterProductExpr (a.View(), b.View());
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
|
|
1537
|
+
|
|
1538
|
+
/* **************************** Trace **************************** */
|
|
1539
|
+
|
|
1540
|
+
|
|
1541
|
+
/**
|
|
1542
|
+
Calculates the trace of a matrix expression.
|
|
1543
|
+
*/
|
|
1544
|
+
template <class TA>
|
|
1545
|
+
INLINE auto Trace (const Expr<TA> & a) // -> decltype (a.Spec()(0,0))
|
|
1546
|
+
{
|
|
1547
|
+
typedef decltype( RemoveConst(a.Spec()(0,0)) ) TRES;
|
|
1548
|
+
TRES sum = 0;
|
|
1549
|
+
for (size_t i = 0; i < Height(a); i++)
|
|
1550
|
+
sum += a.Spec()(i,i);
|
|
1551
|
+
return sum;
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
/* **************************** L2Norm **************************** */
|
|
1555
|
+
|
|
1556
|
+
/// Euclidean norm squared
|
|
1557
|
+
INLINE double L2Norm2 (double v)
|
|
1558
|
+
{
|
|
1559
|
+
return v*v;
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1562
|
+
INLINE double L2Norm2 (Complex v)
|
|
1563
|
+
{
|
|
1564
|
+
return v.real()*v.real()+v.imag()*v.imag();
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
template <class TA>
|
|
1568
|
+
INLINE auto L2Norm2 (const Expr<TA> & v)
|
|
1569
|
+
{
|
|
1570
|
+
decltype(L2Norm2(v.Spec()(0))) sum = 0.0;
|
|
1571
|
+
if (TA::IsLinear())
|
|
1572
|
+
for (size_t i = 0; i < v.Height()*v.Width(); i++)
|
|
1573
|
+
sum += L2Norm2 (v.Spec()(i));
|
|
1574
|
+
else
|
|
1575
|
+
for (size_t i = 0; i < v.Height(); i++)
|
|
1576
|
+
for (size_t j = 0; j < v.Width(); j++)
|
|
1577
|
+
sum += L2Norm2 (v.Spec()(i,j));
|
|
1578
|
+
|
|
1579
|
+
return sum;
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1582
|
+
/**
|
|
1583
|
+
Calculates the Euclidean norm
|
|
1584
|
+
*/
|
|
1585
|
+
template <class TA>
|
|
1586
|
+
INLINE auto L2Norm (const Expr<TA> & v) // -> decltype(L2Norm2(v))
|
|
1587
|
+
{
|
|
1588
|
+
return sqrt (L2Norm2(v));
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
|
|
1592
|
+
|
|
1593
|
+
/* **************************** MaxNorm **************************** */
|
|
1594
|
+
|
|
1595
|
+
/// Euclidean norm squared
|
|
1596
|
+
INLINE double MaxNorm (double v)
|
|
1597
|
+
{
|
|
1598
|
+
return fabs(v);
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
INLINE double MaxNorm (Complex v)
|
|
1602
|
+
{
|
|
1603
|
+
return fabs(v);
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
|
|
1607
|
+
template <class TA>
|
|
1608
|
+
INLINE double MaxNorm (const Expr<TA> & v)
|
|
1609
|
+
{
|
|
1610
|
+
double sum = 0;
|
|
1611
|
+
|
|
1612
|
+
if constexpr (TA::IsLinear())
|
|
1613
|
+
for (size_t i = 0; i < v.Height()*v.Width(); i++)
|
|
1614
|
+
sum = max(sum, MaxNorm( v.Spec()(i)) );
|
|
1615
|
+
else
|
|
1616
|
+
for (size_t i = 0; i < v.Height(); i++)
|
|
1617
|
+
for (size_t j = 0; j < v.Width(); j++)
|
|
1618
|
+
sum = max(sum, MaxNorm ( v.Spec()(i,j)) );
|
|
1619
|
+
|
|
1620
|
+
return sum;
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1623
|
+
|
|
1624
|
+
/* *************************** Output ****************************** */
|
|
1625
|
+
|
|
1626
|
+
|
|
1627
|
+
|
|
1628
|
+
/// Print matrix-expr
|
|
1629
|
+
template<typename T>
|
|
1630
|
+
ostream & operator<< (ostream & s, const Expr<T> & v)
|
|
1631
|
+
{
|
|
1632
|
+
int width = s.width();
|
|
1633
|
+
if (width == 0) width = 8;
|
|
1634
|
+
s.width(0);
|
|
1635
|
+
for (size_t i = 0; i < v.Height(); i++)
|
|
1636
|
+
{
|
|
1637
|
+
for (size_t j = 0 ; j < v.Width(); j++)
|
|
1638
|
+
s << " " << setw(width-1) << v.Spec()(i,j);
|
|
1639
|
+
s << endl;
|
|
1640
|
+
}
|
|
1641
|
+
return s;
|
|
1642
|
+
}
|
|
1643
|
+
|
|
1644
|
+
|
|
1645
|
+
|
|
1646
|
+
|
|
1647
|
+
|
|
1648
|
+
template <typename TA,
|
|
1649
|
+
enable_if_t<IsScalar<TA>(),bool> = true>
|
|
1650
|
+
INLINE auto Inv (TA val) { return 1.0/val; }
|
|
1651
|
+
|
|
1652
|
+
|
|
1653
|
+
|
|
1654
|
+
/* ********************** Determinant *********************** */
|
|
1655
|
+
|
|
1656
|
+
|
|
1657
|
+
/**
|
|
1658
|
+
Calculates the determinant of a Matrix.
|
|
1659
|
+
*/
|
|
1660
|
+
|
|
1661
|
+
template <class T>
|
|
1662
|
+
inline typename T::TELEM Det (const MatExpr<T> & m)
|
|
1663
|
+
{
|
|
1664
|
+
const T & sm = m.Spec();
|
|
1665
|
+
switch (sm.Height())
|
|
1666
|
+
{
|
|
1667
|
+
case 1:
|
|
1668
|
+
{
|
|
1669
|
+
return sm(0,0);
|
|
1670
|
+
}
|
|
1671
|
+
case 2:
|
|
1672
|
+
{
|
|
1673
|
+
return ( sm(0,0)*sm(1,1) - sm(0,1)*sm(1,0) );
|
|
1674
|
+
}
|
|
1675
|
+
case 3:
|
|
1676
|
+
{
|
|
1677
|
+
return
|
|
1678
|
+
sm(0) * (sm(4) * sm(8) - sm(5) * sm(7)) +
|
|
1679
|
+
sm(1) * (sm(5) * sm(6) - sm(3) * sm(8)) +
|
|
1680
|
+
sm(2) * (sm(3) * sm(7) - sm(4) * sm(6));
|
|
1681
|
+
}
|
|
1682
|
+
default:
|
|
1683
|
+
{
|
|
1684
|
+
cerr << "general det not implemented" << endl;
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1688
|
+
return typename T::TELEM (0);
|
|
1689
|
+
}
|
|
1690
|
+
|
|
1691
|
+
}
|
|
1692
|
+
|
|
1693
|
+
#endif
|