@smake/eigen 1.0.2 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (435) hide show
  1. package/README.md +1 -1
  2. package/eigen/Eigen/AccelerateSupport +52 -0
  3. package/eigen/Eigen/Cholesky +18 -21
  4. package/eigen/Eigen/CholmodSupport +28 -28
  5. package/eigen/Eigen/Core +235 -326
  6. package/eigen/Eigen/Eigenvalues +16 -14
  7. package/eigen/Eigen/Geometry +21 -24
  8. package/eigen/Eigen/Householder +9 -8
  9. package/eigen/Eigen/IterativeLinearSolvers +8 -4
  10. package/eigen/Eigen/Jacobi +14 -14
  11. package/eigen/Eigen/KLUSupport +43 -0
  12. package/eigen/Eigen/LU +16 -20
  13. package/eigen/Eigen/MetisSupport +12 -12
  14. package/eigen/Eigen/OrderingMethods +54 -54
  15. package/eigen/Eigen/PaStiXSupport +23 -20
  16. package/eigen/Eigen/PardisoSupport +17 -14
  17. package/eigen/Eigen/QR +18 -21
  18. package/eigen/Eigen/QtAlignedMalloc +5 -13
  19. package/eigen/Eigen/SPQRSupport +21 -14
  20. package/eigen/Eigen/SVD +23 -18
  21. package/eigen/Eigen/Sparse +1 -4
  22. package/eigen/Eigen/SparseCholesky +18 -23
  23. package/eigen/Eigen/SparseCore +18 -17
  24. package/eigen/Eigen/SparseLU +12 -8
  25. package/eigen/Eigen/SparseQR +16 -14
  26. package/eigen/Eigen/StdDeque +5 -2
  27. package/eigen/Eigen/StdList +5 -2
  28. package/eigen/Eigen/StdVector +5 -2
  29. package/eigen/Eigen/SuperLUSupport +30 -24
  30. package/eigen/Eigen/ThreadPool +80 -0
  31. package/eigen/Eigen/UmfPackSupport +19 -17
  32. package/eigen/Eigen/Version +14 -0
  33. package/eigen/Eigen/src/AccelerateSupport/AccelerateSupport.h +423 -0
  34. package/eigen/Eigen/src/AccelerateSupport/InternalHeaderCheck.h +3 -0
  35. package/eigen/Eigen/src/Cholesky/InternalHeaderCheck.h +3 -0
  36. package/eigen/Eigen/src/Cholesky/LDLT.h +377 -401
  37. package/eigen/Eigen/src/Cholesky/LLT.h +332 -360
  38. package/eigen/Eigen/src/Cholesky/LLT_LAPACKE.h +81 -56
  39. package/eigen/Eigen/src/CholmodSupport/CholmodSupport.h +620 -521
  40. package/eigen/Eigen/src/CholmodSupport/InternalHeaderCheck.h +3 -0
  41. package/eigen/Eigen/src/Core/ArithmeticSequence.h +239 -0
  42. package/eigen/Eigen/src/Core/Array.h +341 -294
  43. package/eigen/Eigen/src/Core/ArrayBase.h +190 -203
  44. package/eigen/Eigen/src/Core/ArrayWrapper.h +127 -171
  45. package/eigen/Eigen/src/Core/Assign.h +30 -40
  46. package/eigen/Eigen/src/Core/AssignEvaluator.h +711 -589
  47. package/eigen/Eigen/src/Core/Assign_MKL.h +130 -125
  48. package/eigen/Eigen/src/Core/BandMatrix.h +268 -283
  49. package/eigen/Eigen/src/Core/Block.h +375 -398
  50. package/eigen/Eigen/src/Core/CommaInitializer.h +86 -97
  51. package/eigen/Eigen/src/Core/ConditionEstimator.h +51 -53
  52. package/eigen/Eigen/src/Core/CoreEvaluators.h +1356 -1026
  53. package/eigen/Eigen/src/Core/CoreIterators.h +73 -59
  54. package/eigen/Eigen/src/Core/CwiseBinaryOp.h +114 -132
  55. package/eigen/Eigen/src/Core/CwiseNullaryOp.h +726 -617
  56. package/eigen/Eigen/src/Core/CwiseTernaryOp.h +77 -103
  57. package/eigen/Eigen/src/Core/CwiseUnaryOp.h +56 -68
  58. package/eigen/Eigen/src/Core/CwiseUnaryView.h +132 -95
  59. package/eigen/Eigen/src/Core/DenseBase.h +632 -571
  60. package/eigen/Eigen/src/Core/DenseCoeffsBase.h +511 -624
  61. package/eigen/Eigen/src/Core/DenseStorage.h +512 -509
  62. package/eigen/Eigen/src/Core/DeviceWrapper.h +153 -0
  63. package/eigen/Eigen/src/Core/Diagonal.h +169 -210
  64. package/eigen/Eigen/src/Core/DiagonalMatrix.h +351 -274
  65. package/eigen/Eigen/src/Core/DiagonalProduct.h +12 -10
  66. package/eigen/Eigen/src/Core/Dot.h +172 -222
  67. package/eigen/Eigen/src/Core/EigenBase.h +75 -85
  68. package/eigen/Eigen/src/Core/Fill.h +138 -0
  69. package/eigen/Eigen/src/Core/FindCoeff.h +464 -0
  70. package/eigen/Eigen/src/Core/ForceAlignedAccess.h +90 -109
  71. package/eigen/Eigen/src/Core/Fuzzy.h +82 -105
  72. package/eigen/Eigen/src/Core/GeneralProduct.h +327 -263
  73. package/eigen/Eigen/src/Core/GenericPacketMath.h +1472 -360
  74. package/eigen/Eigen/src/Core/GlobalFunctions.h +194 -151
  75. package/eigen/Eigen/src/Core/IO.h +147 -139
  76. package/eigen/Eigen/src/Core/IndexedView.h +321 -0
  77. package/eigen/Eigen/src/Core/InnerProduct.h +260 -0
  78. package/eigen/Eigen/src/Core/InternalHeaderCheck.h +3 -0
  79. package/eigen/Eigen/src/Core/Inverse.h +56 -66
  80. package/eigen/Eigen/src/Core/Map.h +124 -142
  81. package/eigen/Eigen/src/Core/MapBase.h +256 -281
  82. package/eigen/Eigen/src/Core/MathFunctions.h +1620 -938
  83. package/eigen/Eigen/src/Core/MathFunctionsImpl.h +233 -71
  84. package/eigen/Eigen/src/Core/Matrix.h +491 -416
  85. package/eigen/Eigen/src/Core/MatrixBase.h +468 -453
  86. package/eigen/Eigen/src/Core/NestByValue.h +66 -85
  87. package/eigen/Eigen/src/Core/NoAlias.h +79 -85
  88. package/eigen/Eigen/src/Core/NumTraits.h +235 -148
  89. package/eigen/Eigen/src/Core/PartialReduxEvaluator.h +253 -0
  90. package/eigen/Eigen/src/Core/PermutationMatrix.h +461 -511
  91. package/eigen/Eigen/src/Core/PlainObjectBase.h +871 -894
  92. package/eigen/Eigen/src/Core/Product.h +260 -139
  93. package/eigen/Eigen/src/Core/ProductEvaluators.h +863 -714
  94. package/eigen/Eigen/src/Core/Random.h +161 -136
  95. package/eigen/Eigen/src/Core/RandomImpl.h +262 -0
  96. package/eigen/Eigen/src/Core/RealView.h +250 -0
  97. package/eigen/Eigen/src/Core/Redux.h +366 -336
  98. package/eigen/Eigen/src/Core/Ref.h +308 -209
  99. package/eigen/Eigen/src/Core/Replicate.h +94 -106
  100. package/eigen/Eigen/src/Core/Reshaped.h +398 -0
  101. package/eigen/Eigen/src/Core/ReturnByValue.h +49 -55
  102. package/eigen/Eigen/src/Core/Reverse.h +136 -145
  103. package/eigen/Eigen/src/Core/Select.h +70 -140
  104. package/eigen/Eigen/src/Core/SelfAdjointView.h +262 -285
  105. package/eigen/Eigen/src/Core/SelfCwiseBinaryOp.h +23 -20
  106. package/eigen/Eigen/src/Core/SkewSymmetricMatrix3.h +382 -0
  107. package/eigen/Eigen/src/Core/Solve.h +97 -111
  108. package/eigen/Eigen/src/Core/SolveTriangular.h +131 -129
  109. package/eigen/Eigen/src/Core/SolverBase.h +138 -101
  110. package/eigen/Eigen/src/Core/StableNorm.h +156 -160
  111. package/eigen/Eigen/src/Core/StlIterators.h +619 -0
  112. package/eigen/Eigen/src/Core/Stride.h +91 -88
  113. package/eigen/Eigen/src/Core/Swap.h +70 -38
  114. package/eigen/Eigen/src/Core/Transpose.h +295 -273
  115. package/eigen/Eigen/src/Core/Transpositions.h +272 -317
  116. package/eigen/Eigen/src/Core/TriangularMatrix.h +670 -755
  117. package/eigen/Eigen/src/Core/VectorBlock.h +59 -72
  118. package/eigen/Eigen/src/Core/VectorwiseOp.h +668 -630
  119. package/eigen/Eigen/src/Core/Visitor.h +480 -216
  120. package/eigen/Eigen/src/Core/arch/AVX/Complex.h +407 -293
  121. package/eigen/Eigen/src/Core/arch/AVX/MathFunctions.h +79 -388
  122. package/eigen/Eigen/src/Core/arch/AVX/PacketMath.h +2935 -491
  123. package/eigen/Eigen/src/Core/arch/AVX/Reductions.h +353 -0
  124. package/eigen/Eigen/src/Core/arch/AVX/TypeCasting.h +279 -22
  125. package/eigen/Eigen/src/Core/arch/AVX512/Complex.h +472 -0
  126. package/eigen/Eigen/src/Core/arch/AVX512/GemmKernel.h +1245 -0
  127. package/eigen/Eigen/src/Core/arch/AVX512/MathFunctions.h +85 -333
  128. package/eigen/Eigen/src/Core/arch/AVX512/MathFunctionsFP16.h +75 -0
  129. package/eigen/Eigen/src/Core/arch/AVX512/PacketMath.h +2490 -649
  130. package/eigen/Eigen/src/Core/arch/AVX512/PacketMathFP16.h +1413 -0
  131. package/eigen/Eigen/src/Core/arch/AVX512/Reductions.h +297 -0
  132. package/eigen/Eigen/src/Core/arch/AVX512/TrsmKernel.h +1167 -0
  133. package/eigen/Eigen/src/Core/arch/AVX512/TrsmUnrolls.inc +1219 -0
  134. package/eigen/Eigen/src/Core/arch/AVX512/TypeCasting.h +277 -0
  135. package/eigen/Eigen/src/Core/arch/AVX512/TypeCastingFP16.h +130 -0
  136. package/eigen/Eigen/src/Core/arch/AltiVec/Complex.h +521 -298
  137. package/eigen/Eigen/src/Core/arch/AltiVec/MathFunctions.h +39 -280
  138. package/eigen/Eigen/src/Core/arch/AltiVec/MatrixProduct.h +3686 -0
  139. package/eigen/Eigen/src/Core/arch/AltiVec/MatrixProductCommon.h +205 -0
  140. package/eigen/Eigen/src/Core/arch/AltiVec/MatrixProductMMA.h +901 -0
  141. package/eigen/Eigen/src/Core/arch/AltiVec/MatrixProductMMAbfloat16.h +742 -0
  142. package/eigen/Eigen/src/Core/arch/AltiVec/MatrixVectorProduct.inc +2818 -0
  143. package/eigen/Eigen/src/Core/arch/AltiVec/PacketMath.h +3391 -723
  144. package/eigen/Eigen/src/Core/arch/AltiVec/TypeCasting.h +153 -0
  145. package/eigen/Eigen/src/Core/arch/Default/BFloat16.h +866 -0
  146. package/eigen/Eigen/src/Core/arch/Default/ConjHelper.h +113 -14
  147. package/eigen/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +2634 -0
  148. package/eigen/Eigen/src/Core/arch/Default/GenericPacketMathFunctionsFwd.h +227 -0
  149. package/eigen/Eigen/src/Core/arch/Default/Half.h +1091 -0
  150. package/eigen/Eigen/src/Core/arch/Default/Settings.h +11 -13
  151. package/eigen/Eigen/src/Core/arch/GPU/Complex.h +244 -0
  152. package/eigen/Eigen/src/Core/arch/GPU/MathFunctions.h +104 -0
  153. package/eigen/Eigen/src/Core/arch/GPU/PacketMath.h +1712 -0
  154. package/eigen/Eigen/src/Core/arch/GPU/Tuple.h +268 -0
  155. package/eigen/Eigen/src/Core/arch/GPU/TypeCasting.h +77 -0
  156. package/eigen/Eigen/src/Core/arch/HIP/hcc/math_constants.h +23 -0
  157. package/eigen/Eigen/src/Core/arch/HVX/PacketMath.h +1088 -0
  158. package/eigen/Eigen/src/Core/arch/LSX/Complex.h +520 -0
  159. package/eigen/Eigen/src/Core/arch/LSX/GeneralBlockPanelKernel.h +23 -0
  160. package/eigen/Eigen/src/Core/arch/LSX/MathFunctions.h +43 -0
  161. package/eigen/Eigen/src/Core/arch/LSX/PacketMath.h +2866 -0
  162. package/eigen/Eigen/src/Core/arch/LSX/TypeCasting.h +526 -0
  163. package/eigen/Eigen/src/Core/arch/MSA/Complex.h +620 -0
  164. package/eigen/Eigen/src/Core/arch/MSA/MathFunctions.h +379 -0
  165. package/eigen/Eigen/src/Core/arch/MSA/PacketMath.h +1237 -0
  166. package/eigen/Eigen/src/Core/arch/NEON/Complex.h +531 -289
  167. package/eigen/Eigen/src/Core/arch/NEON/GeneralBlockPanelKernel.h +243 -0
  168. package/eigen/Eigen/src/Core/arch/NEON/MathFunctions.h +50 -73
  169. package/eigen/Eigen/src/Core/arch/NEON/PacketMath.h +5915 -579
  170. package/eigen/Eigen/src/Core/arch/NEON/TypeCasting.h +1642 -0
  171. package/eigen/Eigen/src/Core/arch/NEON/UnaryFunctors.h +57 -0
  172. package/eigen/Eigen/src/Core/arch/SSE/Complex.h +366 -334
  173. package/eigen/Eigen/src/Core/arch/SSE/MathFunctions.h +40 -514
  174. package/eigen/Eigen/src/Core/arch/SSE/PacketMath.h +2164 -675
  175. package/eigen/Eigen/src/Core/arch/SSE/Reductions.h +324 -0
  176. package/eigen/Eigen/src/Core/arch/SSE/TypeCasting.h +188 -35
  177. package/eigen/Eigen/src/Core/arch/SVE/MathFunctions.h +48 -0
  178. package/eigen/Eigen/src/Core/arch/SVE/PacketMath.h +674 -0
  179. package/eigen/Eigen/src/Core/arch/SVE/TypeCasting.h +52 -0
  180. package/eigen/Eigen/src/Core/arch/SYCL/InteropHeaders.h +227 -0
  181. package/eigen/Eigen/src/Core/arch/SYCL/MathFunctions.h +303 -0
  182. package/eigen/Eigen/src/Core/arch/SYCL/PacketMath.h +576 -0
  183. package/eigen/Eigen/src/Core/arch/SYCL/TypeCasting.h +83 -0
  184. package/eigen/Eigen/src/Core/arch/ZVector/Complex.h +434 -261
  185. package/eigen/Eigen/src/Core/arch/ZVector/MathFunctions.h +160 -53
  186. package/eigen/Eigen/src/Core/arch/ZVector/PacketMath.h +1073 -605
  187. package/eigen/Eigen/src/Core/functors/AssignmentFunctors.h +123 -117
  188. package/eigen/Eigen/src/Core/functors/BinaryFunctors.h +594 -322
  189. package/eigen/Eigen/src/Core/functors/NullaryFunctors.h +204 -118
  190. package/eigen/Eigen/src/Core/functors/StlFunctors.h +110 -97
  191. package/eigen/Eigen/src/Core/functors/TernaryFunctors.h +34 -7
  192. package/eigen/Eigen/src/Core/functors/UnaryFunctors.h +1158 -530
  193. package/eigen/Eigen/src/Core/products/GeneralBlockPanelKernel.h +2329 -1333
  194. package/eigen/Eigen/src/Core/products/GeneralMatrixMatrix.h +328 -364
  195. package/eigen/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h +191 -178
  196. package/eigen/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_BLAS.h +85 -82
  197. package/eigen/Eigen/src/Core/products/GeneralMatrixMatrix_BLAS.h +154 -73
  198. package/eigen/Eigen/src/Core/products/GeneralMatrixVector.h +396 -542
  199. package/eigen/Eigen/src/Core/products/GeneralMatrixVector_BLAS.h +80 -77
  200. package/eigen/Eigen/src/Core/products/Parallelizer.h +208 -92
  201. package/eigen/Eigen/src/Core/products/SelfadjointMatrixMatrix.h +331 -375
  202. package/eigen/Eigen/src/Core/products/SelfadjointMatrixMatrix_BLAS.h +206 -224
  203. package/eigen/Eigen/src/Core/products/SelfadjointMatrixVector.h +139 -146
  204. package/eigen/Eigen/src/Core/products/SelfadjointMatrixVector_BLAS.h +58 -61
  205. package/eigen/Eigen/src/Core/products/SelfadjointProduct.h +71 -71
  206. package/eigen/Eigen/src/Core/products/SelfadjointRank2Update.h +48 -46
  207. package/eigen/Eigen/src/Core/products/TriangularMatrixMatrix.h +294 -369
  208. package/eigen/Eigen/src/Core/products/TriangularMatrixMatrix_BLAS.h +246 -238
  209. package/eigen/Eigen/src/Core/products/TriangularMatrixVector.h +244 -247
  210. package/eigen/Eigen/src/Core/products/TriangularMatrixVector_BLAS.h +212 -192
  211. package/eigen/Eigen/src/Core/products/TriangularSolverMatrix.h +328 -275
  212. package/eigen/Eigen/src/Core/products/TriangularSolverMatrix_BLAS.h +108 -109
  213. package/eigen/Eigen/src/Core/products/TriangularSolverVector.h +70 -93
  214. package/eigen/Eigen/src/Core/util/Assert.h +158 -0
  215. package/eigen/Eigen/src/Core/util/BlasUtil.h +413 -290
  216. package/eigen/Eigen/src/Core/util/ConfigureVectorization.h +543 -0
  217. package/eigen/Eigen/src/Core/util/Constants.h +314 -263
  218. package/eigen/Eigen/src/Core/util/DisableStupidWarnings.h +130 -78
  219. package/eigen/Eigen/src/Core/util/EmulateArray.h +270 -0
  220. package/eigen/Eigen/src/Core/util/ForwardDeclarations.h +450 -224
  221. package/eigen/Eigen/src/Core/util/GpuHipCudaDefines.inc +101 -0
  222. package/eigen/Eigen/src/Core/util/GpuHipCudaUndefines.inc +45 -0
  223. package/eigen/Eigen/src/Core/util/IndexedViewHelper.h +487 -0
  224. package/eigen/Eigen/src/Core/util/IntegralConstant.h +279 -0
  225. package/eigen/Eigen/src/Core/util/MKL_support.h +39 -30
  226. package/eigen/Eigen/src/Core/util/Macros.h +939 -646
  227. package/eigen/Eigen/src/Core/util/MaxSizeVector.h +139 -0
  228. package/eigen/Eigen/src/Core/util/Memory.h +1042 -650
  229. package/eigen/Eigen/src/Core/util/Meta.h +618 -426
  230. package/eigen/Eigen/src/Core/util/MoreMeta.h +638 -0
  231. package/eigen/Eigen/src/Core/util/ReenableStupidWarnings.h +32 -19
  232. package/eigen/Eigen/src/Core/util/ReshapedHelper.h +51 -0
  233. package/eigen/Eigen/src/Core/util/Serializer.h +209 -0
  234. package/eigen/Eigen/src/Core/util/StaticAssert.h +51 -164
  235. package/eigen/Eigen/src/Core/util/SymbolicIndex.h +445 -0
  236. package/eigen/Eigen/src/Core/util/XprHelper.h +793 -538
  237. package/eigen/Eigen/src/Eigenvalues/ComplexEigenSolver.h +246 -277
  238. package/eigen/Eigen/src/Eigenvalues/ComplexSchur.h +299 -319
  239. package/eigen/Eigen/src/Eigenvalues/ComplexSchur_LAPACKE.h +52 -48
  240. package/eigen/Eigen/src/Eigenvalues/EigenSolver.h +413 -456
  241. package/eigen/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h +309 -325
  242. package/eigen/Eigen/src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h +157 -171
  243. package/eigen/Eigen/src/Eigenvalues/HessenbergDecomposition.h +292 -310
  244. package/eigen/Eigen/src/Eigenvalues/InternalHeaderCheck.h +3 -0
  245. package/eigen/Eigen/src/Eigenvalues/MatrixBaseEigenvalues.h +91 -107
  246. package/eigen/Eigen/src/Eigenvalues/RealQZ.h +539 -606
  247. package/eigen/Eigen/src/Eigenvalues/RealSchur.h +348 -382
  248. package/eigen/Eigen/src/Eigenvalues/RealSchur_LAPACKE.h +41 -35
  249. package/eigen/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h +579 -600
  250. package/eigen/Eigen/src/Eigenvalues/SelfAdjointEigenSolver_LAPACKE.h +47 -44
  251. package/eigen/Eigen/src/Eigenvalues/Tridiagonalization.h +434 -461
  252. package/eigen/Eigen/src/Geometry/AlignedBox.h +307 -214
  253. package/eigen/Eigen/src/Geometry/AngleAxis.h +135 -137
  254. package/eigen/Eigen/src/Geometry/EulerAngles.h +163 -74
  255. package/eigen/Eigen/src/Geometry/Homogeneous.h +289 -333
  256. package/eigen/Eigen/src/Geometry/Hyperplane.h +152 -161
  257. package/eigen/Eigen/src/Geometry/InternalHeaderCheck.h +3 -0
  258. package/eigen/Eigen/src/Geometry/OrthoMethods.h +168 -145
  259. package/eigen/Eigen/src/Geometry/ParametrizedLine.h +141 -104
  260. package/eigen/Eigen/src/Geometry/Quaternion.h +595 -497
  261. package/eigen/Eigen/src/Geometry/Rotation2D.h +110 -108
  262. package/eigen/Eigen/src/Geometry/RotationBase.h +148 -145
  263. package/eigen/Eigen/src/Geometry/Scaling.h +115 -90
  264. package/eigen/Eigen/src/Geometry/Transform.h +896 -953
  265. package/eigen/Eigen/src/Geometry/Translation.h +100 -98
  266. package/eigen/Eigen/src/Geometry/Umeyama.h +79 -84
  267. package/eigen/Eigen/src/Geometry/arch/Geometry_SIMD.h +154 -0
  268. package/eigen/Eigen/src/Householder/BlockHouseholder.h +54 -42
  269. package/eigen/Eigen/src/Householder/Householder.h +104 -122
  270. package/eigen/Eigen/src/Householder/HouseholderSequence.h +416 -382
  271. package/eigen/Eigen/src/Householder/InternalHeaderCheck.h +3 -0
  272. package/eigen/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h +153 -166
  273. package/eigen/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h +127 -138
  274. package/eigen/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h +95 -124
  275. package/eigen/Eigen/src/IterativeLinearSolvers/IncompleteCholesky.h +269 -267
  276. package/eigen/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h +246 -259
  277. package/eigen/Eigen/src/IterativeLinearSolvers/InternalHeaderCheck.h +3 -0
  278. package/eigen/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h +218 -217
  279. package/eigen/Eigen/src/IterativeLinearSolvers/LeastSquareConjugateGradient.h +80 -103
  280. package/eigen/Eigen/src/IterativeLinearSolvers/SolveWithGuess.h +59 -63
  281. package/eigen/Eigen/src/Jacobi/InternalHeaderCheck.h +3 -0
  282. package/eigen/Eigen/src/Jacobi/Jacobi.h +256 -291
  283. package/eigen/Eigen/src/KLUSupport/InternalHeaderCheck.h +3 -0
  284. package/eigen/Eigen/src/KLUSupport/KLUSupport.h +339 -0
  285. package/eigen/Eigen/src/LU/Determinant.h +60 -63
  286. package/eigen/Eigen/src/LU/FullPivLU.h +561 -626
  287. package/eigen/Eigen/src/LU/InternalHeaderCheck.h +3 -0
  288. package/eigen/Eigen/src/LU/InverseImpl.h +213 -275
  289. package/eigen/Eigen/src/LU/PartialPivLU.h +407 -435
  290. package/eigen/Eigen/src/LU/PartialPivLU_LAPACKE.h +54 -40
  291. package/eigen/Eigen/src/LU/arch/InverseSize4.h +353 -0
  292. package/eigen/Eigen/src/MetisSupport/InternalHeaderCheck.h +3 -0
  293. package/eigen/Eigen/src/MetisSupport/MetisSupport.h +81 -93
  294. package/eigen/Eigen/src/OrderingMethods/Amd.h +250 -282
  295. package/eigen/Eigen/src/OrderingMethods/Eigen_Colamd.h +950 -1103
  296. package/eigen/Eigen/src/OrderingMethods/InternalHeaderCheck.h +3 -0
  297. package/eigen/Eigen/src/OrderingMethods/Ordering.h +111 -122
  298. package/eigen/Eigen/src/PaStiXSupport/InternalHeaderCheck.h +3 -0
  299. package/eigen/Eigen/src/PaStiXSupport/PaStiXSupport.h +524 -570
  300. package/eigen/Eigen/src/PardisoSupport/InternalHeaderCheck.h +3 -0
  301. package/eigen/Eigen/src/PardisoSupport/PardisoSupport.h +385 -429
  302. package/eigen/Eigen/src/QR/ColPivHouseholderQR.h +494 -473
  303. package/eigen/Eigen/src/QR/ColPivHouseholderQR_LAPACKE.h +120 -56
  304. package/eigen/Eigen/src/QR/CompleteOrthogonalDecomposition.h +223 -137
  305. package/eigen/Eigen/src/QR/FullPivHouseholderQR.h +517 -460
  306. package/eigen/Eigen/src/QR/HouseholderQR.h +412 -278
  307. package/eigen/Eigen/src/QR/HouseholderQR_LAPACKE.h +32 -23
  308. package/eigen/Eigen/src/QR/InternalHeaderCheck.h +3 -0
  309. package/eigen/Eigen/src/SPQRSupport/InternalHeaderCheck.h +3 -0
  310. package/eigen/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h +263 -261
  311. package/eigen/Eigen/src/SVD/BDCSVD.h +872 -679
  312. package/eigen/Eigen/src/SVD/BDCSVD_LAPACKE.h +174 -0
  313. package/eigen/Eigen/src/SVD/InternalHeaderCheck.h +3 -0
  314. package/eigen/Eigen/src/SVD/JacobiSVD.h +585 -543
  315. package/eigen/Eigen/src/SVD/JacobiSVD_LAPACKE.h +85 -49
  316. package/eigen/Eigen/src/SVD/SVDBase.h +281 -160
  317. package/eigen/Eigen/src/SVD/UpperBidiagonalization.h +202 -237
  318. package/eigen/Eigen/src/SparseCholesky/InternalHeaderCheck.h +3 -0
  319. package/eigen/Eigen/src/SparseCholesky/SimplicialCholesky.h +769 -590
  320. package/eigen/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h +318 -129
  321. package/eigen/Eigen/src/SparseCore/AmbiVector.h +202 -251
  322. package/eigen/Eigen/src/SparseCore/CompressedStorage.h +184 -236
  323. package/eigen/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h +140 -184
  324. package/eigen/Eigen/src/SparseCore/InternalHeaderCheck.h +3 -0
  325. package/eigen/Eigen/src/SparseCore/SparseAssign.h +174 -111
  326. package/eigen/Eigen/src/SparseCore/SparseBlock.h +408 -477
  327. package/eigen/Eigen/src/SparseCore/SparseColEtree.h +100 -112
  328. package/eigen/Eigen/src/SparseCore/SparseCompressedBase.h +531 -280
  329. package/eigen/Eigen/src/SparseCore/SparseCwiseBinaryOp.h +559 -347
  330. package/eigen/Eigen/src/SparseCore/SparseCwiseUnaryOp.h +100 -108
  331. package/eigen/Eigen/src/SparseCore/SparseDenseProduct.h +185 -191
  332. package/eigen/Eigen/src/SparseCore/SparseDiagonalProduct.h +71 -71
  333. package/eigen/Eigen/src/SparseCore/SparseDot.h +49 -47
  334. package/eigen/Eigen/src/SparseCore/SparseFuzzy.h +13 -11
  335. package/eigen/Eigen/src/SparseCore/SparseMap.h +243 -253
  336. package/eigen/Eigen/src/SparseCore/SparseMatrix.h +1614 -1142
  337. package/eigen/Eigen/src/SparseCore/SparseMatrixBase.h +403 -357
  338. package/eigen/Eigen/src/SparseCore/SparsePermutation.h +186 -115
  339. package/eigen/Eigen/src/SparseCore/SparseProduct.h +100 -91
  340. package/eigen/Eigen/src/SparseCore/SparseRedux.h +22 -24
  341. package/eigen/Eigen/src/SparseCore/SparseRef.h +268 -295
  342. package/eigen/Eigen/src/SparseCore/SparseSelfAdjointView.h +371 -414
  343. package/eigen/Eigen/src/SparseCore/SparseSolverBase.h +78 -87
  344. package/eigen/Eigen/src/SparseCore/SparseSparseProductWithPruning.h +81 -95
  345. package/eigen/Eigen/src/SparseCore/SparseTranspose.h +62 -71
  346. package/eigen/Eigen/src/SparseCore/SparseTriangularView.h +132 -144
  347. package/eigen/Eigen/src/SparseCore/SparseUtil.h +146 -115
  348. package/eigen/Eigen/src/SparseCore/SparseVector.h +426 -372
  349. package/eigen/Eigen/src/SparseCore/SparseView.h +164 -193
  350. package/eigen/Eigen/src/SparseCore/TriangularSolver.h +129 -170
  351. package/eigen/Eigen/src/SparseLU/InternalHeaderCheck.h +3 -0
  352. package/eigen/Eigen/src/SparseLU/SparseLU.h +814 -618
  353. package/eigen/Eigen/src/SparseLU/SparseLUImpl.h +61 -48
  354. package/eigen/Eigen/src/SparseLU/SparseLU_Memory.h +102 -118
  355. package/eigen/Eigen/src/SparseLU/SparseLU_Structs.h +38 -35
  356. package/eigen/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h +273 -255
  357. package/eigen/Eigen/src/SparseLU/SparseLU_Utils.h +44 -49
  358. package/eigen/Eigen/src/SparseLU/SparseLU_column_bmod.h +104 -108
  359. package/eigen/Eigen/src/SparseLU/SparseLU_column_dfs.h +90 -101
  360. package/eigen/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h +57 -58
  361. package/eigen/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h +43 -55
  362. package/eigen/Eigen/src/SparseLU/SparseLU_kernel_bmod.h +74 -71
  363. package/eigen/Eigen/src/SparseLU/SparseLU_panel_bmod.h +125 -133
  364. package/eigen/Eigen/src/SparseLU/SparseLU_panel_dfs.h +136 -159
  365. package/eigen/Eigen/src/SparseLU/SparseLU_pivotL.h +51 -52
  366. package/eigen/Eigen/src/SparseLU/SparseLU_pruneL.h +67 -73
  367. package/eigen/Eigen/src/SparseLU/SparseLU_relax_snode.h +24 -26
  368. package/eigen/Eigen/src/SparseQR/InternalHeaderCheck.h +3 -0
  369. package/eigen/Eigen/src/SparseQR/SparseQR.h +451 -490
  370. package/eigen/Eigen/src/StlSupport/StdDeque.h +28 -105
  371. package/eigen/Eigen/src/StlSupport/StdList.h +28 -84
  372. package/eigen/Eigen/src/StlSupport/StdVector.h +28 -108
  373. package/eigen/Eigen/src/StlSupport/details.h +48 -50
  374. package/eigen/Eigen/src/SuperLUSupport/InternalHeaderCheck.h +3 -0
  375. package/eigen/Eigen/src/SuperLUSupport/SuperLUSupport.h +634 -732
  376. package/eigen/Eigen/src/ThreadPool/Barrier.h +70 -0
  377. package/eigen/Eigen/src/ThreadPool/CoreThreadPoolDevice.h +336 -0
  378. package/eigen/Eigen/src/ThreadPool/EventCount.h +241 -0
  379. package/eigen/Eigen/src/ThreadPool/ForkJoin.h +140 -0
  380. package/eigen/Eigen/src/ThreadPool/InternalHeaderCheck.h +4 -0
  381. package/eigen/Eigen/src/ThreadPool/NonBlockingThreadPool.h +587 -0
  382. package/eigen/Eigen/src/ThreadPool/RunQueue.h +230 -0
  383. package/eigen/Eigen/src/ThreadPool/ThreadCancel.h +21 -0
  384. package/eigen/Eigen/src/ThreadPool/ThreadEnvironment.h +43 -0
  385. package/eigen/Eigen/src/ThreadPool/ThreadLocal.h +289 -0
  386. package/eigen/Eigen/src/ThreadPool/ThreadPoolInterface.h +50 -0
  387. package/eigen/Eigen/src/ThreadPool/ThreadYield.h +16 -0
  388. package/eigen/Eigen/src/UmfPackSupport/InternalHeaderCheck.h +3 -0
  389. package/eigen/Eigen/src/UmfPackSupport/UmfPackSupport.h +480 -380
  390. package/eigen/Eigen/src/misc/Image.h +41 -43
  391. package/eigen/Eigen/src/misc/InternalHeaderCheck.h +3 -0
  392. package/eigen/Eigen/src/misc/Kernel.h +39 -41
  393. package/eigen/Eigen/src/misc/RealSvd2x2.h +19 -21
  394. package/eigen/Eigen/src/misc/blas.h +83 -426
  395. package/eigen/Eigen/src/misc/lapacke.h +9976 -16182
  396. package/eigen/Eigen/src/misc/lapacke_helpers.h +163 -0
  397. package/eigen/Eigen/src/misc/lapacke_mangling.h +4 -5
  398. package/eigen/Eigen/src/plugins/ArrayCwiseBinaryOps.inc +344 -0
  399. package/eigen/Eigen/src/plugins/ArrayCwiseUnaryOps.inc +544 -0
  400. package/eigen/Eigen/src/plugins/BlockMethods.inc +1370 -0
  401. package/eigen/Eigen/src/plugins/CommonCwiseBinaryOps.inc +116 -0
  402. package/eigen/Eigen/src/plugins/CommonCwiseUnaryOps.inc +167 -0
  403. package/eigen/Eigen/src/plugins/IndexedViewMethods.inc +192 -0
  404. package/eigen/Eigen/src/plugins/InternalHeaderCheck.inc +3 -0
  405. package/eigen/Eigen/src/plugins/MatrixCwiseBinaryOps.inc +331 -0
  406. package/eigen/Eigen/src/plugins/MatrixCwiseUnaryOps.inc +118 -0
  407. package/eigen/Eigen/src/plugins/ReshapedMethods.inc +133 -0
  408. package/lib/LibEigen.d.ts +4 -0
  409. package/lib/LibEigen.js +14 -0
  410. package/lib/index.d.ts +1 -1
  411. package/lib/index.js +7 -3
  412. package/package.json +2 -10
  413. package/eigen/Eigen/CMakeLists.txt +0 -19
  414. package/eigen/Eigen/src/Core/BooleanRedux.h +0 -164
  415. package/eigen/Eigen/src/Core/arch/CUDA/Complex.h +0 -103
  416. package/eigen/Eigen/src/Core/arch/CUDA/Half.h +0 -675
  417. package/eigen/Eigen/src/Core/arch/CUDA/MathFunctions.h +0 -91
  418. package/eigen/Eigen/src/Core/arch/CUDA/PacketMath.h +0 -333
  419. package/eigen/Eigen/src/Core/arch/CUDA/PacketMathHalf.h +0 -1124
  420. package/eigen/Eigen/src/Core/arch/CUDA/TypeCasting.h +0 -212
  421. package/eigen/Eigen/src/Core/util/NonMPL2.h +0 -3
  422. package/eigen/Eigen/src/Geometry/arch/Geometry_SSE.h +0 -161
  423. package/eigen/Eigen/src/LU/arch/Inverse_SSE.h +0 -338
  424. package/eigen/Eigen/src/SparseCore/MappedSparseMatrix.h +0 -67
  425. package/eigen/Eigen/src/SparseLU/SparseLU_gemm_kernel.h +0 -280
  426. package/eigen/Eigen/src/misc/lapack.h +0 -152
  427. package/eigen/Eigen/src/plugins/ArrayCwiseBinaryOps.h +0 -332
  428. package/eigen/Eigen/src/plugins/ArrayCwiseUnaryOps.h +0 -552
  429. package/eigen/Eigen/src/plugins/BlockMethods.h +0 -1058
  430. package/eigen/Eigen/src/plugins/CommonCwiseBinaryOps.h +0 -115
  431. package/eigen/Eigen/src/plugins/CommonCwiseUnaryOps.h +0 -163
  432. package/eigen/Eigen/src/plugins/MatrixCwiseBinaryOps.h +0 -152
  433. package/eigen/Eigen/src/plugins/MatrixCwiseUnaryOps.h +0 -85
  434. package/lib/eigen.d.ts +0 -2
  435. package/lib/eigen.js +0 -15
@@ -9,29 +9,44 @@
9
9
  // Public License v. 2.0. If a copy of the MPL was not distributed
10
10
  // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
11
11
 
12
-
13
12
  #ifndef EIGEN_COREEVALUATORS_H
14
13
  #define EIGEN_COREEVALUATORS_H
15
14
 
15
+ // IWYU pragma: private
16
+ #include "./InternalHeaderCheck.h"
17
+
16
18
  namespace Eigen {
17
-
19
+
18
20
  namespace internal {
19
21
 
20
22
  // This class returns the evaluator kind from the expression storage kind.
21
23
  // Default assumes index based accessors
22
- template<typename StorageKind>
24
+ template <typename StorageKind>
23
25
  struct storage_kind_to_evaluator_kind {
24
26
  typedef IndexBased Kind;
25
27
  };
26
28
 
27
29
  // This class returns the evaluator shape from the expression storage kind.
28
30
  // It can be Dense, Sparse, Triangular, Diagonal, SelfAdjoint, Band, etc.
29
- template<typename StorageKind> struct storage_kind_to_shape;
31
+ template <typename StorageKind>
32
+ struct storage_kind_to_shape;
30
33
 
31
- template<> struct storage_kind_to_shape<Dense> { typedef DenseShape Shape; };
32
- template<> struct storage_kind_to_shape<SolverStorage> { typedef SolverShape Shape; };
33
- template<> struct storage_kind_to_shape<PermutationStorage> { typedef PermutationShape Shape; };
34
- template<> struct storage_kind_to_shape<TranspositionsStorage> { typedef TranspositionsShape Shape; };
34
+ template <>
35
+ struct storage_kind_to_shape<Dense> {
36
+ typedef DenseShape Shape;
37
+ };
38
+ template <>
39
+ struct storage_kind_to_shape<SolverStorage> {
40
+ typedef SolverShape Shape;
41
+ };
42
+ template <>
43
+ struct storage_kind_to_shape<PermutationStorage> {
44
+ typedef PermutationShape Shape;
45
+ };
46
+ template <>
47
+ struct storage_kind_to_shape<TranspositionsStorage> {
48
+ typedef TranspositionsShape Shape;
49
+ };
35
50
 
36
51
  // Evaluators have to be specialized with respect to various criteria such as:
37
52
  // - storage/structure/shape
@@ -39,81 +54,81 @@ template<> struct storage_kind_to_shape<TranspositionsStorage> { typedef Transp
39
54
  // - etc.
40
55
  // Therefore, we need specialization of evaluator providing additional template arguments for each kind of evaluators.
41
56
  // We currently distinguish the following kind of evaluators:
42
- // - unary_evaluator for expressions taking only one arguments (CwiseUnaryOp, CwiseUnaryView, Transpose, MatrixWrapper, ArrayWrapper, Reverse, Replicate)
57
+ // - unary_evaluator for expressions taking only one arguments (CwiseUnaryOp, CwiseUnaryView, Transpose,
58
+ // MatrixWrapper, ArrayWrapper, Reverse, Replicate)
43
59
  // - binary_evaluator for expression taking two arguments (CwiseBinaryOp)
44
60
  // - ternary_evaluator for expression taking three arguments (CwiseTernaryOp)
45
- // - product_evaluator for linear algebra products (Product); special case of binary_evaluator because it requires additional tags for dispatching.
61
+ // - product_evaluator for linear algebra products (Product); special case of binary_evaluator because it requires
62
+ // additional tags for dispatching.
46
63
  // - mapbase_evaluator for Map, Block, Ref
47
64
  // - block_evaluator for Block (special dispatching to a mapbase_evaluator or unary_evaluator)
48
65
 
49
- template< typename T,
50
- typename Arg1Kind = typename evaluator_traits<typename T::Arg1>::Kind,
51
- typename Arg2Kind = typename evaluator_traits<typename T::Arg2>::Kind,
52
- typename Arg3Kind = typename evaluator_traits<typename T::Arg3>::Kind,
66
+ template <typename T, typename Arg1Kind = typename evaluator_traits<typename T::Arg1>::Kind,
67
+ typename Arg2Kind = typename evaluator_traits<typename T::Arg2>::Kind,
68
+ typename Arg3Kind = typename evaluator_traits<typename T::Arg3>::Kind,
53
69
  typename Arg1Scalar = typename traits<typename T::Arg1>::Scalar,
54
70
  typename Arg2Scalar = typename traits<typename T::Arg2>::Scalar,
55
- typename Arg3Scalar = typename traits<typename T::Arg3>::Scalar> struct ternary_evaluator;
71
+ typename Arg3Scalar = typename traits<typename T::Arg3>::Scalar>
72
+ struct ternary_evaluator;
56
73
 
57
- template< typename T,
58
- typename LhsKind = typename evaluator_traits<typename T::Lhs>::Kind,
59
- typename RhsKind = typename evaluator_traits<typename T::Rhs>::Kind,
74
+ template <typename T, typename LhsKind = typename evaluator_traits<typename T::Lhs>::Kind,
75
+ typename RhsKind = typename evaluator_traits<typename T::Rhs>::Kind,
60
76
  typename LhsScalar = typename traits<typename T::Lhs>::Scalar,
61
- typename RhsScalar = typename traits<typename T::Rhs>::Scalar> struct binary_evaluator;
77
+ typename RhsScalar = typename traits<typename T::Rhs>::Scalar>
78
+ struct binary_evaluator;
62
79
 
63
- template< typename T,
64
- typename Kind = typename evaluator_traits<typename T::NestedExpression>::Kind,
65
- typename Scalar = typename T::Scalar> struct unary_evaluator;
66
-
67
- // evaluator_traits<T> contains traits for evaluator<T>
80
+ template <typename T, typename Kind = typename evaluator_traits<typename T::NestedExpression>::Kind,
81
+ typename Scalar = typename T::Scalar>
82
+ struct unary_evaluator;
68
83
 
69
- template<typename T>
70
- struct evaluator_traits_base
71
- {
84
+ // evaluator_traits<T> contains traits for evaluator<T>
85
+
86
+ template <typename T>
87
+ struct evaluator_traits_base {
72
88
  // by default, get evaluator kind and shape from storage
73
89
  typedef typename storage_kind_to_evaluator_kind<typename traits<T>::StorageKind>::Kind Kind;
74
90
  typedef typename storage_kind_to_shape<typename traits<T>::StorageKind>::Shape Shape;
75
91
  };
76
92
 
77
93
  // Default evaluator traits
78
- template<typename T>
79
- struct evaluator_traits : public evaluator_traits_base<T>
80
- {
81
- };
94
+ template <typename T>
95
+ struct evaluator_traits : public evaluator_traits_base<T> {};
82
96
 
83
- template<typename T, typename Shape = typename evaluator_traits<T>::Shape >
97
+ template <typename T, typename Shape = typename evaluator_traits<T>::Shape>
84
98
  struct evaluator_assume_aliasing {
85
99
  static const bool value = false;
86
100
  };
87
101
 
88
102
  // By default, we assume a unary expression:
89
- template<typename T>
90
- struct evaluator : public unary_evaluator<T>
91
- {
103
+ template <typename T>
104
+ struct evaluator : public unary_evaluator<T> {
92
105
  typedef unary_evaluator<T> Base;
93
- EIGEN_DEVICE_FUNC explicit evaluator(const T& xpr) : Base(xpr) {}
106
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit evaluator(const T& xpr) : Base(xpr) {}
94
107
  };
95
108
 
96
-
97
109
  // TODO: Think about const-correctness
98
- template<typename T>
99
- struct evaluator<const T>
100
- : evaluator<T>
101
- {
102
- EIGEN_DEVICE_FUNC
103
- explicit evaluator(const T& xpr) : evaluator<T>(xpr) {}
110
+ template <typename T>
111
+ struct evaluator<const T> : evaluator<T> {
112
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit evaluator(const T& xpr) : evaluator<T>(xpr) {}
104
113
  };
105
114
 
106
115
  // ---------- base class for all evaluators ----------
107
116
 
108
- template<typename ExpressionType>
109
- struct evaluator_base : public noncopyable
110
- {
111
- // TODO that's not very nice to have to propagate all these traits. They are currently only needed to handle outer,inner indices.
117
+ template <typename ExpressionType>
118
+ struct evaluator_base {
119
+ // TODO that's not very nice to have to propagate all these traits. They are currently only needed to handle
120
+ // outer,inner indices.
112
121
  typedef traits<ExpressionType> ExpressionTraits;
113
-
114
- enum {
115
- Alignment = 0
116
- };
122
+
123
+ enum { Alignment = 0 };
124
+ // noncopyable:
125
+ // Don't make this class inherit noncopyable as this kills EBO (Empty Base Optimization)
126
+ // and make complex evaluator much larger than then should do.
127
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr evaluator_base() = default;
128
+
129
+ private:
130
+ EIGEN_DEVICE_FUNC evaluator_base(const evaluator_base&);
131
+ EIGEN_DEVICE_FUNC const evaluator_base& operator=(const evaluator_base&);
117
132
  };
118
133
 
119
134
  // -------------------- Matrix and Array --------------------
@@ -123,10 +138,35 @@ struct evaluator_base : public noncopyable
123
138
  // Here we directly specialize evaluator. This is not really a unary expression, and it is, by definition, dense,
124
139
  // so no need for more sophisticated dispatching.
125
140
 
126
- template<typename Derived>
127
- struct evaluator<PlainObjectBase<Derived> >
128
- : evaluator_base<Derived>
129
- {
141
+ // this helper permits to completely eliminate m_outerStride if it is known at compiletime.
142
+ template <typename Scalar, int OuterStride>
143
+ class plainobjectbase_evaluator_data {
144
+ public:
145
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr plainobjectbase_evaluator_data(const Scalar* ptr, Index outerStride)
146
+ : data(ptr) {
147
+ #ifndef EIGEN_INTERNAL_DEBUGGING
148
+ EIGEN_UNUSED_VARIABLE(outerStride);
149
+ #endif
150
+ eigen_internal_assert(outerStride == OuterStride);
151
+ }
152
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr Index outerStride() const noexcept { return OuterStride; }
153
+ const Scalar* data;
154
+ };
155
+
156
+ template <typename Scalar>
157
+ class plainobjectbase_evaluator_data<Scalar, Dynamic> {
158
+ public:
159
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr plainobjectbase_evaluator_data(const Scalar* ptr, Index outerStride)
160
+ : data(ptr), m_outerStride(outerStride) {}
161
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr Index outerStride() const { return m_outerStride; }
162
+ const Scalar* data;
163
+
164
+ protected:
165
+ Index m_outerStride;
166
+ };
167
+
168
+ template <typename Derived>
169
+ struct evaluator<PlainObjectBase<Derived>> : evaluator_base<Derived> {
130
170
  typedef PlainObjectBase<Derived> PlainObjectType;
131
171
  typedef typename PlainObjectType::Scalar Scalar;
132
172
  typedef typename PlainObjectType::CoeffReturnType CoeffReturnType;
@@ -136,200 +176,186 @@ struct evaluator<PlainObjectBase<Derived> >
136
176
  IsVectorAtCompileTime = PlainObjectType::IsVectorAtCompileTime,
137
177
  RowsAtCompileTime = PlainObjectType::RowsAtCompileTime,
138
178
  ColsAtCompileTime = PlainObjectType::ColsAtCompileTime,
139
-
179
+
140
180
  CoeffReadCost = NumTraits<Scalar>::ReadCost,
141
181
  Flags = traits<Derived>::EvaluatorFlags,
142
182
  Alignment = traits<Derived>::Alignment
143
183
  };
144
-
145
- EIGEN_DEVICE_FUNC evaluator()
146
- : m_data(0),
147
- m_outerStride(IsVectorAtCompileTime ? 0
148
- : int(IsRowMajor) ? ColsAtCompileTime
149
- : RowsAtCompileTime)
150
- {
184
+ enum {
185
+ // We do not need to know the outer stride for vectors
186
+ OuterStrideAtCompileTime = IsVectorAtCompileTime ? 0
187
+ : int(IsRowMajor) ? ColsAtCompileTime
188
+ : RowsAtCompileTime
189
+ };
190
+
191
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr evaluator() : m_d(0, OuterStrideAtCompileTime) {
151
192
  EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
152
193
  }
153
-
154
- EIGEN_DEVICE_FUNC explicit evaluator(const PlainObjectType& m)
155
- : m_data(m.data()), m_outerStride(IsVectorAtCompileTime ? 0 : m.outerStride())
156
- {
194
+
195
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr explicit evaluator(const PlainObjectType& m)
196
+ : m_d(m.data(), IsVectorAtCompileTime ? 0 : m.outerStride()) {
157
197
  EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
158
198
  }
159
199
 
160
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
161
- CoeffReturnType coeff(Index row, Index col) const
162
- {
163
- if (IsRowMajor)
164
- return m_data[row * m_outerStride.value() + col];
165
- else
166
- return m_data[row + col * m_outerStride.value()];
200
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr CoeffReturnType coeff(Index row, Index col) const {
201
+ return coeff(getIndex(row, col));
167
202
  }
168
203
 
169
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
170
- CoeffReturnType coeff(Index index) const
171
- {
172
- return m_data[index];
204
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr CoeffReturnType coeff(Index index) const { return m_d.data[index]; }
205
+
206
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr Scalar& coeffRef(Index row, Index col) {
207
+ return coeffRef(getIndex(row, col));
173
208
  }
174
209
 
175
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
176
- Scalar& coeffRef(Index row, Index col)
177
- {
178
- if (IsRowMajor)
179
- return const_cast<Scalar*>(m_data)[row * m_outerStride.value() + col];
180
- else
181
- return const_cast<Scalar*>(m_data)[row + col * m_outerStride.value()];
210
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr Scalar& coeffRef(Index index) {
211
+ return const_cast<Scalar*>(m_d.data)[index];
182
212
  }
183
213
 
184
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
185
- Scalar& coeffRef(Index index)
186
- {
187
- return const_cast<Scalar*>(m_data)[index];
214
+ template <int LoadMode, typename PacketType>
215
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(Index row, Index col) const {
216
+ return packet<LoadMode, PacketType>(getIndex(row, col));
188
217
  }
189
218
 
190
- template<int LoadMode, typename PacketType>
191
- EIGEN_STRONG_INLINE
192
- PacketType packet(Index row, Index col) const
193
- {
194
- if (IsRowMajor)
195
- return ploadt<PacketType, LoadMode>(m_data + row * m_outerStride.value() + col);
196
- else
197
- return ploadt<PacketType, LoadMode>(m_data + row + col * m_outerStride.value());
219
+ template <int LoadMode, typename PacketType>
220
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(Index index) const {
221
+ return ploadt<PacketType, LoadMode>(m_d.data + index);
198
222
  }
199
223
 
200
- template<int LoadMode, typename PacketType>
201
- EIGEN_STRONG_INLINE
202
- PacketType packet(Index index) const
203
- {
204
- return ploadt<PacketType, LoadMode>(m_data + index);
224
+ template <int StoreMode, typename PacketType>
225
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void writePacket(Index row, Index col, const PacketType& x) {
226
+ writePacket<StoreMode, PacketType>(getIndex(row, col), x);
205
227
  }
206
228
 
207
- template<int StoreMode,typename PacketType>
208
- EIGEN_STRONG_INLINE
209
- void writePacket(Index row, Index col, const PacketType& x)
210
- {
211
- if (IsRowMajor)
212
- return pstoret<Scalar, PacketType, StoreMode>
213
- (const_cast<Scalar*>(m_data) + row * m_outerStride.value() + col, x);
214
- else
215
- return pstoret<Scalar, PacketType, StoreMode>
216
- (const_cast<Scalar*>(m_data) + row + col * m_outerStride.value(), x);
229
+ template <int StoreMode, typename PacketType>
230
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void writePacket(Index index, const PacketType& x) {
231
+ pstoret<Scalar, PacketType, StoreMode>(const_cast<Scalar*>(m_d.data) + index, x);
217
232
  }
218
233
 
219
- template<int StoreMode, typename PacketType>
220
- EIGEN_STRONG_INLINE
221
- void writePacket(Index index, const PacketType& x)
222
- {
223
- return pstoret<Scalar, PacketType, StoreMode>(const_cast<Scalar*>(m_data) + index, x);
234
+ template <int LoadMode, typename PacketType>
235
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(Index row, Index col, Index begin, Index count) const {
236
+ return packetSegment<LoadMode, PacketType>(getIndex(row, col), begin, count);
224
237
  }
225
238
 
226
- protected:
227
- const Scalar *m_data;
239
+ template <int LoadMode, typename PacketType>
240
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(Index index, Index begin, Index count) const {
241
+ return ploadtSegment<PacketType, LoadMode>(m_d.data + index, begin, count);
242
+ }
228
243
 
229
- // We do not need to know the outer stride for vectors
230
- variable_if_dynamic<Index, IsVectorAtCompileTime ? 0
231
- : int(IsRowMajor) ? ColsAtCompileTime
232
- : RowsAtCompileTime> m_outerStride;
244
+ template <int StoreMode, typename PacketType>
245
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void writePacketSegment(Index row, Index col, const PacketType& x, Index begin,
246
+ Index count) {
247
+ writePacketSegment<StoreMode, PacketType>(getIndex(row, col), x, begin, count);
248
+ }
249
+
250
+ template <int StoreMode, typename PacketType>
251
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void writePacketSegment(Index index, const PacketType& x, Index begin,
252
+ Index count) {
253
+ pstoretSegment<Scalar, PacketType, StoreMode>(const_cast<Scalar*>(m_d.data) + index, x, begin, count);
254
+ }
255
+
256
+ protected:
257
+ plainobjectbase_evaluator_data<Scalar, OuterStrideAtCompileTime> m_d;
258
+
259
+ private:
260
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index constexpr getIndex(Index row, Index col) const {
261
+ return IsRowMajor ? row * m_d.outerStride() + col : row + col * m_d.outerStride();
262
+ }
233
263
  };
234
264
 
235
- template<typename Scalar, int Rows, int Cols, int Options, int MaxRows, int MaxCols>
236
- struct evaluator<Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols> >
237
- : evaluator<PlainObjectBase<Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols> > >
238
- {
265
+ template <typename Scalar, int Rows, int Cols, int Options, int MaxRows, int MaxCols>
266
+ struct evaluator<Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols>>
267
+ : evaluator<PlainObjectBase<Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols>>> {
239
268
  typedef Matrix<Scalar, Rows, Cols, Options, MaxRows, MaxCols> XprType;
240
-
241
- EIGEN_DEVICE_FUNC evaluator() {}
242
269
 
243
- EIGEN_DEVICE_FUNC explicit evaluator(const XprType& m)
244
- : evaluator<PlainObjectBase<XprType> >(m)
245
- { }
270
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr evaluator() = default;
271
+
272
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr explicit evaluator(const XprType& m)
273
+ : evaluator<PlainObjectBase<XprType>>(m) {}
246
274
  };
247
275
 
248
- template<typename Scalar, int Rows, int Cols, int Options, int MaxRows, int MaxCols>
249
- struct evaluator<Array<Scalar, Rows, Cols, Options, MaxRows, MaxCols> >
250
- : evaluator<PlainObjectBase<Array<Scalar, Rows, Cols, Options, MaxRows, MaxCols> > >
251
- {
276
+ template <typename Scalar, int Rows, int Cols, int Options, int MaxRows, int MaxCols>
277
+ struct evaluator<Array<Scalar, Rows, Cols, Options, MaxRows, MaxCols>>
278
+ : evaluator<PlainObjectBase<Array<Scalar, Rows, Cols, Options, MaxRows, MaxCols>>> {
252
279
  typedef Array<Scalar, Rows, Cols, Options, MaxRows, MaxCols> XprType;
253
280
 
254
- EIGEN_DEVICE_FUNC evaluator() {}
255
-
256
- EIGEN_DEVICE_FUNC explicit evaluator(const XprType& m)
257
- : evaluator<PlainObjectBase<XprType> >(m)
258
- { }
281
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr evaluator() = default;
282
+
283
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr explicit evaluator(const XprType& m)
284
+ : evaluator<PlainObjectBase<XprType>>(m) {}
259
285
  };
260
286
 
261
287
  // -------------------- Transpose --------------------
262
288
 
263
- template<typename ArgType>
264
- struct unary_evaluator<Transpose<ArgType>, IndexBased>
265
- : evaluator_base<Transpose<ArgType> >
266
- {
289
+ template <typename ArgType>
290
+ struct unary_evaluator<Transpose<ArgType>, IndexBased> : evaluator_base<Transpose<ArgType>> {
267
291
  typedef Transpose<ArgType> XprType;
268
-
292
+
269
293
  enum {
270
- CoeffReadCost = evaluator<ArgType>::CoeffReadCost,
294
+ CoeffReadCost = evaluator<ArgType>::CoeffReadCost,
271
295
  Flags = evaluator<ArgType>::Flags ^ RowMajorBit,
272
296
  Alignment = evaluator<ArgType>::Alignment
273
297
  };
274
298
 
275
- EIGEN_DEVICE_FUNC explicit unary_evaluator(const XprType& t) : m_argImpl(t.nestedExpression()) {}
299
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit unary_evaluator(const XprType& t) : m_argImpl(t.nestedExpression()) {}
276
300
 
277
301
  typedef typename XprType::Scalar Scalar;
278
302
  typedef typename XprType::CoeffReturnType CoeffReturnType;
279
303
 
280
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
281
- CoeffReturnType coeff(Index row, Index col) const
282
- {
304
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const {
283
305
  return m_argImpl.coeff(col, row);
284
306
  }
285
307
 
286
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
287
- CoeffReturnType coeff(Index index) const
288
- {
289
- return m_argImpl.coeff(index);
308
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const { return m_argImpl.coeff(index); }
309
+
310
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(Index row, Index col) { return m_argImpl.coeffRef(col, row); }
311
+
312
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename XprType::Scalar& coeffRef(Index index) {
313
+ return m_argImpl.coeffRef(index);
290
314
  }
291
315
 
292
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
293
- Scalar& coeffRef(Index row, Index col)
294
- {
295
- return m_argImpl.coeffRef(col, row);
316
+ template <int LoadMode, typename PacketType>
317
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(Index row, Index col) const {
318
+ return m_argImpl.template packet<LoadMode, PacketType>(col, row);
296
319
  }
297
320
 
298
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
299
- typename XprType::Scalar& coeffRef(Index index)
300
- {
301
- return m_argImpl.coeffRef(index);
321
+ template <int LoadMode, typename PacketType>
322
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(Index index) const {
323
+ return m_argImpl.template packet<LoadMode, PacketType>(index);
324
+ }
325
+
326
+ template <int StoreMode, typename PacketType>
327
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void writePacket(Index row, Index col, const PacketType& x) {
328
+ m_argImpl.template writePacket<StoreMode, PacketType>(col, row, x);
329
+ }
330
+
331
+ template <int StoreMode, typename PacketType>
332
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void writePacket(Index index, const PacketType& x) {
333
+ m_argImpl.template writePacket<StoreMode, PacketType>(index, x);
302
334
  }
303
335
 
304
- template<int LoadMode, typename PacketType>
305
- EIGEN_STRONG_INLINE
306
- PacketType packet(Index row, Index col) const
307
- {
308
- return m_argImpl.template packet<LoadMode,PacketType>(col, row);
336
+ template <int LoadMode, typename PacketType>
337
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(Index row, Index col, Index begin, Index count) const {
338
+ return m_argImpl.template packetSegment<LoadMode, PacketType>(col, row, begin, count);
309
339
  }
310
340
 
311
- template<int LoadMode, typename PacketType>
312
- EIGEN_STRONG_INLINE
313
- PacketType packet(Index index) const
314
- {
315
- return m_argImpl.template packet<LoadMode,PacketType>(index);
341
+ template <int LoadMode, typename PacketType>
342
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(Index index, Index begin, Index count) const {
343
+ return m_argImpl.template packetSegment<LoadMode, PacketType>(index, begin, count);
316
344
  }
317
345
 
318
- template<int StoreMode, typename PacketType>
319
- EIGEN_STRONG_INLINE
320
- void writePacket(Index row, Index col, const PacketType& x)
321
- {
322
- m_argImpl.template writePacket<StoreMode,PacketType>(col, row, x);
346
+ template <int StoreMode, typename PacketType>
347
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void writePacketSegment(Index row, Index col, const PacketType& x, Index begin,
348
+ Index count) {
349
+ m_argImpl.template writePacketSegment<StoreMode, PacketType>(col, row, x, begin, count);
323
350
  }
324
351
 
325
- template<int StoreMode, typename PacketType>
326
- EIGEN_STRONG_INLINE
327
- void writePacket(Index index, const PacketType& x)
328
- {
329
- m_argImpl.template writePacket<StoreMode,PacketType>(index, x);
352
+ template <int StoreMode, typename PacketType>
353
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void writePacketSegment(Index index, const PacketType& x, Index begin,
354
+ Index count) {
355
+ m_argImpl.template writePacketSegment<StoreMode, PacketType>(index, x, begin, count);
330
356
  }
331
357
 
332
- protected:
358
+ protected:
333
359
  evaluator<ArgType> m_argImpl;
334
360
  };
335
361
 
@@ -337,66 +363,86 @@ protected:
337
363
  // Like Matrix and Array, this is not really a unary expression, so we directly specialize evaluator.
338
364
  // Likewise, there is not need to more sophisticated dispatching here.
339
365
 
340
- template<typename Scalar,typename NullaryOp,
341
- bool has_nullary = has_nullary_operator<NullaryOp>::value,
342
- bool has_unary = has_unary_operator<NullaryOp>::value,
343
- bool has_binary = has_binary_operator<NullaryOp>::value>
344
- struct nullary_wrapper
345
- {
366
+ template <typename Scalar, typename NullaryOp, bool has_nullary = has_nullary_operator<NullaryOp>::value,
367
+ bool has_unary = has_unary_operator<NullaryOp>::value,
368
+ bool has_binary = has_binary_operator<NullaryOp>::value>
369
+ struct nullary_wrapper {
346
370
  template <typename IndexType>
347
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const NullaryOp& op, IndexType i, IndexType j) const { return op(i,j); }
371
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const NullaryOp& op, IndexType i, IndexType j) const {
372
+ return op(i, j);
373
+ }
348
374
  template <typename IndexType>
349
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const NullaryOp& op, IndexType i) const { return op(i); }
375
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const NullaryOp& op, IndexType i) const {
376
+ return op(i);
377
+ }
350
378
 
351
- template <typename T, typename IndexType> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(const NullaryOp& op, IndexType i, IndexType j) const { return op.template packetOp<T>(i,j); }
352
- template <typename T, typename IndexType> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(const NullaryOp& op, IndexType i) const { return op.template packetOp<T>(i); }
379
+ template <typename T, typename IndexType>
380
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(const NullaryOp& op, IndexType i, IndexType j) const {
381
+ return op.template packetOp<T>(i, j);
382
+ }
383
+ template <typename T, typename IndexType>
384
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(const NullaryOp& op, IndexType i) const {
385
+ return op.template packetOp<T>(i);
386
+ }
353
387
  };
354
388
 
355
- template<typename Scalar,typename NullaryOp>
356
- struct nullary_wrapper<Scalar,NullaryOp,true,false,false>
357
- {
389
+ template <typename Scalar, typename NullaryOp>
390
+ struct nullary_wrapper<Scalar, NullaryOp, true, false, false> {
358
391
  template <typename IndexType>
359
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const NullaryOp& op, IndexType=0, IndexType=0) const { return op(); }
360
- template <typename T, typename IndexType> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(const NullaryOp& op, IndexType=0, IndexType=0) const { return op.template packetOp<T>(); }
392
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const NullaryOp& op, IndexType = 0, IndexType = 0) const {
393
+ return op();
394
+ }
395
+ template <typename T, typename IndexType>
396
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(const NullaryOp& op, IndexType = 0, IndexType = 0) const {
397
+ return op.template packetOp<T>();
398
+ }
361
399
  };
362
400
 
363
- template<typename Scalar,typename NullaryOp>
364
- struct nullary_wrapper<Scalar,NullaryOp,false,false,true>
365
- {
401
+ template <typename Scalar, typename NullaryOp>
402
+ struct nullary_wrapper<Scalar, NullaryOp, false, false, true> {
366
403
  template <typename IndexType>
367
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const NullaryOp& op, IndexType i, IndexType j=0) const { return op(i,j); }
368
- template <typename T, typename IndexType> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(const NullaryOp& op, IndexType i, IndexType j=0) const { return op.template packetOp<T>(i,j); }
404
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const NullaryOp& op, IndexType i, IndexType j = 0) const {
405
+ return op(i, j);
406
+ }
407
+ template <typename T, typename IndexType>
408
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(const NullaryOp& op, IndexType i, IndexType j = 0) const {
409
+ return op.template packetOp<T>(i, j);
410
+ }
369
411
  };
370
412
 
371
413
  // We need the following specialization for vector-only functors assigned to a runtime vector,
372
414
  // for instance, using linspace and assigning a RowVectorXd to a MatrixXd or even a row of a MatrixXd.
373
415
  // In this case, i==0 and j is used for the actual iteration.
374
- template<typename Scalar,typename NullaryOp>
375
- struct nullary_wrapper<Scalar,NullaryOp,false,true,false>
376
- {
416
+ template <typename Scalar, typename NullaryOp>
417
+ struct nullary_wrapper<Scalar, NullaryOp, false, true, false> {
377
418
  template <typename IndexType>
378
419
  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const NullaryOp& op, IndexType i, IndexType j) const {
379
- eigen_assert(i==0 || j==0);
380
- return op(i+j);
420
+ eigen_assert(i == 0 || j == 0);
421
+ return op(i + j);
381
422
  }
382
- template <typename T, typename IndexType> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(const NullaryOp& op, IndexType i, IndexType j) const {
383
- eigen_assert(i==0 || j==0);
384
- return op.template packetOp<T>(i+j);
423
+ template <typename T, typename IndexType>
424
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(const NullaryOp& op, IndexType i, IndexType j) const {
425
+ eigen_assert(i == 0 || j == 0);
426
+ return op.template packetOp<T>(i + j);
385
427
  }
386
428
 
387
429
  template <typename IndexType>
388
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const NullaryOp& op, IndexType i) const { return op(i); }
430
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const NullaryOp& op, IndexType i) const {
431
+ return op(i);
432
+ }
389
433
  template <typename T, typename IndexType>
390
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(const NullaryOp& op, IndexType i) const { return op.template packetOp<T>(i); }
434
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T packetOp(const NullaryOp& op, IndexType i) const {
435
+ return op.template packetOp<T>(i);
436
+ }
391
437
  };
392
438
 
393
- template<typename Scalar,typename NullaryOp>
394
- struct nullary_wrapper<Scalar,NullaryOp,false,false,false> {};
439
+ template <typename Scalar, typename NullaryOp>
440
+ struct nullary_wrapper<Scalar, NullaryOp, false, false, false> {};
395
441
 
396
- #if 0 && EIGEN_COMP_MSVC>0
442
+ #if 0 && EIGEN_COMP_MSVC > 0
397
443
  // Disable this ugly workaround. This is now handled in traits<Ref>::match,
398
444
  // but this piece of code might still become handly if some other weird compilation
399
- // erros pop up again.
445
+ // errors pop up again.
400
446
 
401
447
  // MSVC exhibits a weird compilation error when
402
448
  // compiling:
@@ -449,318 +495,693 @@ struct nullary_wrapper<Scalar,NullaryOp,true,true,true>
449
495
  has_binary_operator<NullaryOp,nullary_wrapper_workaround_msvc<IndexType> >::value>().template packetOp<T>(op,i);
450
496
  }
451
497
  };
452
- #endif // MSVC workaround
498
+ #endif // MSVC workaround
499
+
500
+ template <typename NullaryOp, typename PlainObjectType>
501
+ struct evaluator<CwiseNullaryOp<NullaryOp, PlainObjectType>>
502
+ : evaluator_base<CwiseNullaryOp<NullaryOp, PlainObjectType>> {
503
+ typedef CwiseNullaryOp<NullaryOp, PlainObjectType> XprType;
504
+ typedef remove_all_t<PlainObjectType> PlainObjectTypeCleaned;
453
505
 
454
- template<typename NullaryOp, typename PlainObjectType>
455
- struct evaluator<CwiseNullaryOp<NullaryOp,PlainObjectType> >
456
- : evaluator_base<CwiseNullaryOp<NullaryOp,PlainObjectType> >
457
- {
458
- typedef CwiseNullaryOp<NullaryOp,PlainObjectType> XprType;
459
- typedef typename internal::remove_all<PlainObjectType>::type PlainObjectTypeCleaned;
460
-
461
506
  enum {
462
- CoeffReadCost = internal::functor_traits<NullaryOp>::Cost,
463
-
464
- Flags = (evaluator<PlainObjectTypeCleaned>::Flags
465
- & ( HereditaryBits
466
- | (functor_has_linear_access<NullaryOp>::ret ? LinearAccessBit : 0)
467
- | (functor_traits<NullaryOp>::PacketAccess ? PacketAccessBit : 0)))
468
- | (functor_traits<NullaryOp>::IsRepeatable ? 0 : EvalBeforeNestingBit),
507
+ CoeffReadCost = functor_traits<NullaryOp>::Cost,
508
+
509
+ Flags = (evaluator<PlainObjectTypeCleaned>::Flags &
510
+ (HereditaryBits | (functor_has_linear_access<NullaryOp>::ret ? LinearAccessBit : 0) |
511
+ (functor_traits<NullaryOp>::PacketAccess ? PacketAccessBit : 0))) |
512
+ (functor_traits<NullaryOp>::IsRepeatable ? 0 : EvalBeforeNestingBit),
469
513
  Alignment = AlignedMax
470
514
  };
471
515
 
472
- EIGEN_DEVICE_FUNC explicit evaluator(const XprType& n)
473
- : m_functor(n.functor()), m_wrapper()
474
- {
516
+ EIGEN_DEVICE_FUNC explicit evaluator(const XprType& n) : m_functor(n.functor()), m_wrapper() {
475
517
  EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
476
518
  }
477
519
 
478
520
  typedef typename XprType::CoeffReturnType CoeffReturnType;
479
521
 
480
522
  template <typename IndexType>
481
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
482
- CoeffReturnType coeff(IndexType row, IndexType col) const
483
- {
523
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(IndexType row, IndexType col) const {
484
524
  return m_wrapper(m_functor, row, col);
485
525
  }
486
526
 
487
527
  template <typename IndexType>
488
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
489
- CoeffReturnType coeff(IndexType index) const
490
- {
491
- return m_wrapper(m_functor,index);
528
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(IndexType index) const {
529
+ return m_wrapper(m_functor, index);
492
530
  }
493
531
 
494
- template<int LoadMode, typename PacketType, typename IndexType>
495
- EIGEN_STRONG_INLINE
496
- PacketType packet(IndexType row, IndexType col) const
497
- {
532
+ template <int LoadMode, typename PacketType, typename IndexType>
533
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(IndexType row, IndexType col) const {
498
534
  return m_wrapper.template packetOp<PacketType>(m_functor, row, col);
499
535
  }
500
536
 
501
- template<int LoadMode, typename PacketType, typename IndexType>
502
- EIGEN_STRONG_INLINE
503
- PacketType packet(IndexType index) const
504
- {
537
+ template <int LoadMode, typename PacketType, typename IndexType>
538
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(IndexType index) const {
505
539
  return m_wrapper.template packetOp<PacketType>(m_functor, index);
506
540
  }
507
541
 
508
- protected:
542
+ template <int LoadMode, typename PacketType, typename IndexType>
543
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(IndexType row, IndexType col, Index /*begin*/,
544
+ Index /*count*/) const {
545
+ return packet<LoadMode, PacketType, IndexType>(row, col);
546
+ }
547
+
548
+ template <int LoadMode, typename PacketType, typename IndexType>
549
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(IndexType index, Index /*begin*/,
550
+ Index /*count*/) const {
551
+ return packet<LoadMode, PacketType, IndexType>(index);
552
+ }
553
+
554
+ protected:
509
555
  const NullaryOp m_functor;
510
- const internal::nullary_wrapper<CoeffReturnType,NullaryOp> m_wrapper;
556
+ const nullary_wrapper<CoeffReturnType, NullaryOp> m_wrapper;
511
557
  };
512
558
 
513
559
  // -------------------- CwiseUnaryOp --------------------
514
560
 
515
- template<typename UnaryOp, typename ArgType>
516
- struct unary_evaluator<CwiseUnaryOp<UnaryOp, ArgType>, IndexBased >
517
- : evaluator_base<CwiseUnaryOp<UnaryOp, ArgType> >
518
- {
561
+ template <typename UnaryOp, typename ArgType>
562
+ struct unary_evaluator<CwiseUnaryOp<UnaryOp, ArgType>, IndexBased> : evaluator_base<CwiseUnaryOp<UnaryOp, ArgType>> {
519
563
  typedef CwiseUnaryOp<UnaryOp, ArgType> XprType;
520
-
564
+
521
565
  enum {
522
- CoeffReadCost = evaluator<ArgType>::CoeffReadCost + functor_traits<UnaryOp>::Cost,
523
-
524
- Flags = evaluator<ArgType>::Flags
525
- & (HereditaryBits | LinearAccessBit | (functor_traits<UnaryOp>::PacketAccess ? PacketAccessBit : 0)),
566
+ CoeffReadCost = int(evaluator<ArgType>::CoeffReadCost) + int(functor_traits<UnaryOp>::Cost),
567
+
568
+ Flags = evaluator<ArgType>::Flags &
569
+ (HereditaryBits | LinearAccessBit | (functor_traits<UnaryOp>::PacketAccess ? PacketAccessBit : 0)),
526
570
  Alignment = evaluator<ArgType>::Alignment
527
571
  };
528
572
 
529
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
530
- explicit unary_evaluator(const XprType& op)
531
- : m_functor(op.functor()),
532
- m_argImpl(op.nestedExpression())
533
- {
573
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit unary_evaluator(const XprType& op) : m_d(op) {
534
574
  EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<UnaryOp>::Cost);
535
575
  EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
536
576
  }
537
577
 
538
578
  typedef typename XprType::CoeffReturnType CoeffReturnType;
539
579
 
540
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
541
- CoeffReturnType coeff(Index row, Index col) const
542
- {
543
- return m_functor(m_argImpl.coeff(row, col));
580
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const {
581
+ return m_d.func()(m_d.argImpl.coeff(row, col));
544
582
  }
545
583
 
546
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
547
- CoeffReturnType coeff(Index index) const
548
- {
549
- return m_functor(m_argImpl.coeff(index));
584
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const {
585
+ return m_d.func()(m_d.argImpl.coeff(index));
550
586
  }
551
587
 
552
- template<int LoadMode, typename PacketType>
553
- EIGEN_STRONG_INLINE
554
- PacketType packet(Index row, Index col) const
555
- {
556
- return m_functor.packetOp(m_argImpl.template packet<LoadMode, PacketType>(row, col));
588
+ template <int LoadMode, typename PacketType>
589
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(Index row, Index col) const {
590
+ return m_d.func().packetOp(m_d.argImpl.template packet<LoadMode, PacketType>(row, col));
557
591
  }
558
592
 
559
- template<int LoadMode, typename PacketType>
560
- EIGEN_STRONG_INLINE
561
- PacketType packet(Index index) const
562
- {
563
- return m_functor.packetOp(m_argImpl.template packet<LoadMode, PacketType>(index));
593
+ template <int LoadMode, typename PacketType>
594
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(Index index) const {
595
+ return m_d.func().packetOp(m_d.argImpl.template packet<LoadMode, PacketType>(index));
564
596
  }
565
597
 
566
- protected:
567
- const UnaryOp m_functor;
568
- evaluator<ArgType> m_argImpl;
598
+ template <int LoadMode, typename PacketType>
599
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(Index row, Index col, Index begin, Index count) const {
600
+ return m_d.func().packetOp(m_d.argImpl.template packetSegment<LoadMode, PacketType>(row, col, begin, count));
601
+ }
602
+
603
+ template <int LoadMode, typename PacketType>
604
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(Index index, Index begin, Index count) const {
605
+ return m_d.func().packetOp(m_d.argImpl.template packetSegment<LoadMode, PacketType>(index, begin, count));
606
+ }
607
+
608
+ protected:
609
+ // this helper permits to completely eliminate the functor if it is empty
610
+ struct Data {
611
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Data(const XprType& xpr)
612
+ : op(xpr.functor()), argImpl(xpr.nestedExpression()) {}
613
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const UnaryOp& func() const { return op; }
614
+ UnaryOp op;
615
+ evaluator<ArgType> argImpl;
616
+ };
617
+
618
+ Data m_d;
619
+ };
620
+
621
+ // ----------------------- Casting ---------------------
622
+
623
+ template <typename SrcType, typename DstType, typename ArgType>
624
+ struct unary_evaluator<CwiseUnaryOp<core_cast_op<SrcType, DstType>, ArgType>, IndexBased> {
625
+ using CastOp = core_cast_op<SrcType, DstType>;
626
+ using XprType = CwiseUnaryOp<CastOp, ArgType>;
627
+
628
+ // Use the largest packet type by default
629
+ using SrcPacketType = typename packet_traits<SrcType>::type;
630
+ static constexpr int SrcPacketSize = unpacket_traits<SrcPacketType>::size;
631
+ static constexpr int SrcPacketBytes = SrcPacketSize * sizeof(SrcType);
632
+
633
+ enum {
634
+ CoeffReadCost = int(evaluator<ArgType>::CoeffReadCost) + int(functor_traits<CastOp>::Cost),
635
+ PacketAccess = functor_traits<CastOp>::PacketAccess,
636
+ ActualPacketAccessBit = PacketAccess ? PacketAccessBit : 0,
637
+ Flags = evaluator<ArgType>::Flags & (HereditaryBits | LinearAccessBit | ActualPacketAccessBit),
638
+ IsRowMajor = (evaluator<ArgType>::Flags & RowMajorBit),
639
+ Alignment = evaluator<ArgType>::Alignment
640
+ };
641
+
642
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit unary_evaluator(const XprType& xpr)
643
+ : m_argImpl(xpr.nestedExpression()), m_rows(xpr.rows()), m_cols(xpr.cols()) {
644
+ EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<CastOp>::Cost);
645
+ EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
646
+ }
647
+
648
+ template <typename DstPacketType>
649
+ using AltSrcScalarOp = std::enable_if_t<(unpacket_traits<DstPacketType>::size < SrcPacketSize &&
650
+ !find_packet_by_size<SrcType, unpacket_traits<DstPacketType>::size>::value),
651
+ bool>;
652
+ template <typename DstPacketType>
653
+ using SrcPacketArgs1 =
654
+ std::enable_if_t<(find_packet_by_size<SrcType, unpacket_traits<DstPacketType>::size>::value), bool>;
655
+ template <typename DstPacketType>
656
+ using SrcPacketArgs2 = std::enable_if_t<(unpacket_traits<DstPacketType>::size) == (2 * SrcPacketSize), bool>;
657
+ template <typename DstPacketType>
658
+ using SrcPacketArgs4 = std::enable_if_t<(unpacket_traits<DstPacketType>::size) == (4 * SrcPacketSize), bool>;
659
+ template <typename DstPacketType>
660
+ using SrcPacketArgs8 = std::enable_if_t<(unpacket_traits<DstPacketType>::size) == (8 * SrcPacketSize), bool>;
661
+
662
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool check_array_bounds(Index row, Index col, Index begin, Index count) const {
663
+ return IsRowMajor ? (col + count + begin <= cols()) : (row + count + begin <= rows());
664
+ }
665
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool check_array_bounds(Index index, Index begin, Index count) const {
666
+ return index + count + begin <= size();
667
+ }
668
+
669
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE SrcType srcCoeff(Index row, Index col, Index offset) const {
670
+ Index actualRow = IsRowMajor ? row : row + offset;
671
+ Index actualCol = IsRowMajor ? col + offset : col;
672
+ return m_argImpl.coeff(actualRow, actualCol);
673
+ }
674
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE SrcType srcCoeff(Index index, Index offset) const {
675
+ Index actualIndex = index + offset;
676
+ return m_argImpl.coeff(actualIndex);
677
+ }
678
+
679
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstType coeff(Index row, Index col) const {
680
+ return cast<SrcType, DstType>(srcCoeff(row, col, 0));
681
+ }
682
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstType coeff(Index index) const {
683
+ return cast<SrcType, DstType>(srcCoeff(index, 0));
684
+ }
685
+
686
+ template <int LoadMode, typename PacketType = SrcPacketType>
687
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType srcPacket(Index row, Index col, Index offset) const {
688
+ constexpr int PacketSize = unpacket_traits<PacketType>::size;
689
+ Index packetOffset = offset * PacketSize;
690
+ Index actualRow = IsRowMajor ? row : row + packetOffset;
691
+ Index actualCol = IsRowMajor ? col + packetOffset : col;
692
+ eigen_assert(check_array_bounds(actualRow, actualCol, 0, PacketSize) && "Array index out of bounds");
693
+ return m_argImpl.template packet<LoadMode, PacketType>(actualRow, actualCol);
694
+ }
695
+ template <int LoadMode, typename PacketType = SrcPacketType>
696
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType srcPacket(Index index, Index offset) const {
697
+ constexpr int PacketSize = unpacket_traits<PacketType>::size;
698
+ Index packetOffset = offset * PacketSize;
699
+ Index actualIndex = index + packetOffset;
700
+ eigen_assert(check_array_bounds(actualIndex, 0, PacketSize) && "Array index out of bounds");
701
+ return m_argImpl.template packet<LoadMode, PacketType>(actualIndex);
702
+ }
703
+ template <int LoadMode, typename PacketType = SrcPacketType>
704
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType srcPacketSegment(Index row, Index col, Index begin, Index count,
705
+ Index offset) const {
706
+ constexpr int PacketSize = unpacket_traits<PacketType>::size;
707
+ Index packetOffset = offset * PacketSize;
708
+ Index actualRow = IsRowMajor ? row : row + packetOffset;
709
+ Index actualCol = IsRowMajor ? col + packetOffset : col;
710
+ eigen_assert(check_array_bounds(actualRow, actualCol, begin, count) && "Array index out of bounds");
711
+ return m_argImpl.template packetSegment<LoadMode, PacketType>(actualRow, actualCol, begin, count);
712
+ }
713
+ template <int LoadMode, typename PacketType = SrcPacketType>
714
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType srcPacketSegment(Index index, Index begin, Index count,
715
+ Index offset) const {
716
+ constexpr int PacketSize = unpacket_traits<PacketType>::size;
717
+ Index packetOffset = offset * PacketSize;
718
+ Index actualIndex = index + packetOffset;
719
+ eigen_assert(check_array_bounds(actualIndex, begin, count) && "Array index out of bounds");
720
+ return m_argImpl.template packetSegment<LoadMode, PacketType>(actualIndex, begin, count);
721
+ }
722
+
723
+ template <int NumPackets, int LoadMode, typename PacketType = SrcPacketType>
724
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketBlock<PacketType, NumPackets> srcPacketSegmentHelper(Index row, Index col,
725
+ Index begin,
726
+ Index count) const {
727
+ constexpr int SrcLoadMode = plain_enum_min(SrcPacketBytes, LoadMode);
728
+ PacketBlock<PacketType, NumPackets> packets;
729
+ for (Index i = 0; i < NumPackets; i++) packets.packet[i] = pzero(PacketType());
730
+ Index offset = begin / SrcPacketSize;
731
+ Index actualBegin = begin % SrcPacketSize;
732
+ for (; offset < NumPackets; offset++) {
733
+ Index actualCount = numext::mini(SrcPacketSize - actualBegin, count);
734
+ packets.packet[offset] = srcPacketSegment<SrcLoadMode>(row, col, actualBegin, actualCount, offset);
735
+ if (count == actualCount) break;
736
+ actualBegin = 0;
737
+ count -= actualCount;
738
+ }
739
+ return packets;
740
+ }
741
+ template <int NumPackets, int LoadMode, typename PacketType = SrcPacketType>
742
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketBlock<PacketType, NumPackets> srcPacketSegmentHelper(Index index,
743
+ Index begin,
744
+ Index count) const {
745
+ constexpr int SrcLoadMode = plain_enum_min(SrcPacketBytes, LoadMode);
746
+ PacketBlock<PacketType, NumPackets> packets;
747
+ for (Index i = 0; i < NumPackets; i++) packets.packet[i] = pzero(PacketType());
748
+ Index offset = begin / SrcPacketSize;
749
+ Index actualBegin = begin % SrcPacketSize;
750
+ for (; offset < NumPackets; offset++) {
751
+ Index actualCount = numext::mini(SrcPacketSize - actualBegin, count);
752
+ packets.packet[offset] = srcPacketSegment<SrcLoadMode>(index, actualBegin, actualCount, offset);
753
+ if (count == actualCount) break;
754
+ actualBegin = 0;
755
+ count -= actualCount;
756
+ }
757
+ return packets;
758
+ }
759
+
760
+ // There is no source packet type with equal or fewer elements than DstPacketType.
761
+ // This is problematic as the evaluation loop may attempt to access data outside the bounds of the array.
762
+ // For example, consider the cast utilizing pcast<Packet4f,Packet2d> with an array of size 4: {0.0f,1.0f,2.0f,3.0f}.
763
+ // The first iteration of the evaluation loop will load 16 bytes: {0.0f,1.0f,2.0f,3.0f} and cast to {0.0,1.0}, which
764
+ // is acceptable. The second iteration will load 16 bytes: {2.0f,3.0f,?,?}, which is outside the bounds of the array.
765
+ template <int LoadMode, typename DstPacketType, AltSrcScalarOp<DstPacketType> = true>
766
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packet(Index row, Index col) const {
767
+ constexpr int DstPacketSize = unpacket_traits<DstPacketType>::size;
768
+ constexpr int SrcBytesIncrement = DstPacketSize * sizeof(SrcType);
769
+ constexpr int SrcLoadMode = plain_enum_min(SrcBytesIncrement, LoadMode);
770
+ return pcast<SrcPacketType, DstPacketType>(srcPacketSegment<SrcLoadMode>(row, col, 0, DstPacketSize, 0));
771
+ }
772
+ // Use the source packet type with the same size as DstPacketType, if it exists
773
+ template <int LoadMode, typename DstPacketType, SrcPacketArgs1<DstPacketType> = true>
774
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packet(Index row, Index col) const {
775
+ constexpr int DstPacketSize = unpacket_traits<DstPacketType>::size;
776
+ using SizedSrcPacketType = typename find_packet_by_size<SrcType, DstPacketSize>::type;
777
+ constexpr int SrcBytesIncrement = DstPacketSize * sizeof(SrcType);
778
+ constexpr int SrcLoadMode = plain_enum_min(SrcBytesIncrement, LoadMode);
779
+ return pcast<SizedSrcPacketType, DstPacketType>(srcPacket<SrcLoadMode, SizedSrcPacketType>(row, col, 0));
780
+ }
781
+ // unpacket_traits<DstPacketType>::size == 2 * SrcPacketSize
782
+ template <int LoadMode, typename DstPacketType, SrcPacketArgs2<DstPacketType> = true>
783
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packet(Index row, Index col) const {
784
+ constexpr int SrcLoadMode = plain_enum_min(SrcPacketBytes, LoadMode);
785
+ return pcast<SrcPacketType, DstPacketType>(srcPacket<SrcLoadMode>(row, col, 0),
786
+ srcPacket<SrcLoadMode>(row, col, 1));
787
+ }
788
+ // unpacket_traits<DstPacketType>::size == 4 * SrcPacketSize
789
+ template <int LoadMode, typename DstPacketType, SrcPacketArgs4<DstPacketType> = true>
790
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packet(Index row, Index col) const {
791
+ constexpr int SrcLoadMode = plain_enum_min(SrcPacketBytes, LoadMode);
792
+ return pcast<SrcPacketType, DstPacketType>(srcPacket<SrcLoadMode>(row, col, 0), srcPacket<SrcLoadMode>(row, col, 1),
793
+ srcPacket<SrcLoadMode>(row, col, 2),
794
+ srcPacket<SrcLoadMode>(row, col, 3));
795
+ }
796
+ // unpacket_traits<DstPacketType>::size == 8 * SrcPacketSize
797
+ template <int LoadMode, typename DstPacketType, SrcPacketArgs8<DstPacketType> = true>
798
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packet(Index row, Index col) const {
799
+ constexpr int SrcLoadMode = plain_enum_min(SrcPacketBytes, LoadMode);
800
+ return pcast<SrcPacketType, DstPacketType>(
801
+ srcPacket<SrcLoadMode>(row, col, 0), srcPacket<SrcLoadMode>(row, col, 1), srcPacket<SrcLoadMode>(row, col, 2),
802
+ srcPacket<SrcLoadMode>(row, col, 3), srcPacket<SrcLoadMode>(row, col, 4), srcPacket<SrcLoadMode>(row, col, 5),
803
+ srcPacket<SrcLoadMode>(row, col, 6), srcPacket<SrcLoadMode>(row, col, 7));
804
+ }
805
+
806
+ // packetSegment variants
807
+ template <int LoadMode, typename DstPacketType, AltSrcScalarOp<DstPacketType> = true>
808
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packetSegment(Index row, Index col, Index begin,
809
+ Index count) const {
810
+ constexpr int DstPacketSize = unpacket_traits<DstPacketType>::size;
811
+ constexpr int SrcBytesIncrement = DstPacketSize * sizeof(SrcType);
812
+ constexpr int SrcLoadMode = plain_enum_min(SrcBytesIncrement, LoadMode);
813
+ return pcast<SrcPacketType, DstPacketType>(srcPacketSegment<SrcLoadMode>(row, col, begin, count, 0));
814
+ }
815
+ // Use the source packet type with the same size as DstPacketType, if it exists
816
+ template <int LoadMode, typename DstPacketType, SrcPacketArgs1<DstPacketType> = true>
817
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packetSegment(Index row, Index col, Index begin,
818
+ Index count) const {
819
+ constexpr int DstPacketSize = unpacket_traits<DstPacketType>::size;
820
+ using SizedSrcPacketType = typename find_packet_by_size<SrcType, DstPacketSize>::type;
821
+ constexpr int SrcBytesIncrement = DstPacketSize * sizeof(SrcType);
822
+ constexpr int SrcLoadMode = plain_enum_min(SrcBytesIncrement, LoadMode);
823
+ return pcast<SizedSrcPacketType, DstPacketType>(
824
+ srcPacketSegment<SrcLoadMode, SizedSrcPacketType>(row, col, begin, count, 0));
825
+ }
826
+ // unpacket_traits<DstPacketType>::size == 2 * SrcPacketSize
827
+ template <int LoadMode, typename DstPacketType, SrcPacketArgs2<DstPacketType> = true>
828
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packetSegment(Index row, Index col, Index begin,
829
+ Index count) const {
830
+ constexpr int NumPackets = 2;
831
+ constexpr int SrcLoadMode = plain_enum_min(SrcPacketBytes, LoadMode);
832
+ PacketBlock<SrcPacketType, NumPackets> packets =
833
+ srcPacketSegmentHelper<NumPackets, SrcLoadMode>(row, col, begin, count);
834
+ return pcast<SrcPacketType, DstPacketType>(packets.packet[0], packets.packet[1]);
835
+ }
836
+ // unpacket_traits<DstPacketType>::size == 4 * SrcPacketSize
837
+ template <int LoadMode, typename DstPacketType, SrcPacketArgs4<DstPacketType> = true>
838
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packetSegment(Index row, Index col, Index begin,
839
+ Index count) const {
840
+ constexpr int NumPackets = 4;
841
+ constexpr int SrcLoadMode = plain_enum_min(SrcPacketBytes, LoadMode);
842
+ PacketBlock<SrcPacketType, NumPackets> packets =
843
+ srcPacketSegmentHelper<NumPackets, SrcLoadMode>(row, col, begin, count);
844
+ return pcast<SrcPacketType, DstPacketType>(packets.packet[0], packets.packet[1], packets.packet[2],
845
+ packets.packet[3]);
846
+ }
847
+ // unpacket_traits<DstPacketType>::size == 8 * SrcPacketSize
848
+ template <int LoadMode, typename DstPacketType, SrcPacketArgs8<DstPacketType> = true>
849
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packetSegment(Index row, Index col, Index begin,
850
+ Index count) const {
851
+ constexpr int NumPackets = 8;
852
+ constexpr int SrcLoadMode = plain_enum_min(SrcPacketBytes, LoadMode);
853
+ PacketBlock<SrcPacketType, NumPackets> packets =
854
+ srcPacketSegmentHelper<NumPackets, SrcLoadMode>(row, col, begin, count);
855
+ return pcast<SrcPacketType, DstPacketType>(packets.packet[0], packets.packet[1], packets.packet[2],
856
+ packets.packet[3], packets.packet[4], packets.packet[5],
857
+ packets.packet[6], packets.packet[7]);
858
+ }
859
+
860
+ // Analogous routines for linear access.
861
+ template <int LoadMode, typename DstPacketType, AltSrcScalarOp<DstPacketType> = true>
862
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packet(Index index) const {
863
+ constexpr int DstPacketSize = unpacket_traits<DstPacketType>::size;
864
+ constexpr int SrcBytesIncrement = DstPacketSize * sizeof(SrcType);
865
+ constexpr int SrcLoadMode = plain_enum_min(SrcBytesIncrement, LoadMode);
866
+ return pcast<SrcPacketType, DstPacketType>(srcPacketSegment<SrcLoadMode>(index, 0, DstPacketSize, 0));
867
+ }
868
+ template <int LoadMode, typename DstPacketType, SrcPacketArgs1<DstPacketType> = true>
869
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packet(Index index) const {
870
+ constexpr int DstPacketSize = unpacket_traits<DstPacketType>::size;
871
+ using SizedSrcPacketType = typename find_packet_by_size<SrcType, DstPacketSize>::type;
872
+ constexpr int SrcBytesIncrement = DstPacketSize * sizeof(SrcType);
873
+ constexpr int SrcLoadMode = plain_enum_min(SrcBytesIncrement, LoadMode);
874
+ return pcast<SizedSrcPacketType, DstPacketType>(srcPacket<SrcLoadMode, SizedSrcPacketType>(index, 0));
875
+ }
876
+ template <int LoadMode, typename DstPacketType, SrcPacketArgs2<DstPacketType> = true>
877
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packet(Index index) const {
878
+ constexpr int SrcLoadMode = plain_enum_min(SrcPacketBytes, LoadMode);
879
+ return pcast<SrcPacketType, DstPacketType>(srcPacket<SrcLoadMode>(index, 0), srcPacket<SrcLoadMode>(index, 1));
880
+ }
881
+ template <int LoadMode, typename DstPacketType, SrcPacketArgs4<DstPacketType> = true>
882
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packet(Index index) const {
883
+ constexpr int SrcLoadMode = plain_enum_min(SrcPacketBytes, LoadMode);
884
+ return pcast<SrcPacketType, DstPacketType>(srcPacket<SrcLoadMode>(index, 0), srcPacket<SrcLoadMode>(index, 1),
885
+ srcPacket<SrcLoadMode>(index, 2), srcPacket<SrcLoadMode>(index, 3));
886
+ }
887
+ template <int LoadMode, typename DstPacketType, SrcPacketArgs8<DstPacketType> = true>
888
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packet(Index index) const {
889
+ constexpr int SrcLoadMode = plain_enum_min(SrcPacketBytes, LoadMode);
890
+ return pcast<SrcPacketType, DstPacketType>(srcPacket<SrcLoadMode>(index, 0), srcPacket<SrcLoadMode>(index, 1),
891
+ srcPacket<SrcLoadMode>(index, 2), srcPacket<SrcLoadMode>(index, 3),
892
+ srcPacket<SrcLoadMode>(index, 4), srcPacket<SrcLoadMode>(index, 5),
893
+ srcPacket<SrcLoadMode>(index, 6), srcPacket<SrcLoadMode>(index, 7));
894
+ }
895
+
896
+ // packetSegment variants
897
+ template <int LoadMode, typename DstPacketType, AltSrcScalarOp<DstPacketType> = true>
898
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packetSegment(Index index, Index begin, Index count) const {
899
+ constexpr int DstPacketSize = unpacket_traits<DstPacketType>::size;
900
+ constexpr int SrcBytesIncrement = DstPacketSize * sizeof(SrcType);
901
+ constexpr int SrcLoadMode = plain_enum_min(SrcBytesIncrement, LoadMode);
902
+ return pcast<SrcPacketType, DstPacketType>(srcPacketSegment<SrcLoadMode>(index, begin, count, 0));
903
+ }
904
+ // Use the source packet type with the same size as DstPacketType, if it exists
905
+ template <int LoadMode, typename DstPacketType, SrcPacketArgs1<DstPacketType> = true>
906
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packetSegment(Index index, Index begin, Index count) const {
907
+ constexpr int DstPacketSize = unpacket_traits<DstPacketType>::size;
908
+ using SizedSrcPacketType = typename find_packet_by_size<SrcType, DstPacketSize>::type;
909
+ constexpr int SrcBytesIncrement = DstPacketSize * sizeof(SrcType);
910
+ constexpr int SrcLoadMode = plain_enum_min(SrcBytesIncrement, LoadMode);
911
+ return pcast<SizedSrcPacketType, DstPacketType>(
912
+ srcPacketSegment<SrcLoadMode, SizedSrcPacketType>(index, begin, count, 0));
913
+ }
914
+ // unpacket_traits<DstPacketType>::size == 2 * SrcPacketSize
915
+ template <int LoadMode, typename DstPacketType, SrcPacketArgs2<DstPacketType> = true>
916
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packetSegment(Index index, Index begin, Index count) const {
917
+ constexpr int NumPackets = 2;
918
+ constexpr int SrcLoadMode = plain_enum_min(SrcPacketBytes, LoadMode);
919
+ PacketBlock<SrcPacketType, NumPackets> packets =
920
+ srcPacketSegmentHelper<NumPackets, SrcLoadMode>(index, begin, count);
921
+ return pcast<SrcPacketType, DstPacketType>(packets.packet[0], packets.packet[1]);
922
+ }
923
+ // unpacket_traits<DstPacketType>::size == 4 * SrcPacketSize
924
+ template <int LoadMode, typename DstPacketType, SrcPacketArgs4<DstPacketType> = true>
925
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packetSegment(Index index, Index begin, Index count) const {
926
+ constexpr int NumPackets = 4;
927
+ constexpr int SrcLoadMode = plain_enum_min(SrcPacketBytes, LoadMode);
928
+ PacketBlock<SrcPacketType, NumPackets> packets =
929
+ srcPacketSegmentHelper<NumPackets, SrcLoadMode>(index, begin, count);
930
+ return pcast<SrcPacketType, DstPacketType>(packets.packet[0], packets.packet[1], packets.packet[2],
931
+ packets.packet[3]);
932
+ }
933
+ // unpacket_traits<DstPacketType>::size == 8 * SrcPacketSize
934
+ template <int LoadMode, typename DstPacketType, SrcPacketArgs8<DstPacketType> = true>
935
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DstPacketType packetSegment(Index index, Index begin, Index count) const {
936
+ constexpr int NumPackets = 8;
937
+ constexpr int SrcLoadMode = plain_enum_min(SrcPacketBytes, LoadMode);
938
+ PacketBlock<SrcPacketType, NumPackets> packets =
939
+ srcPacketSegmentHelper<NumPackets, SrcLoadMode>(index, begin, count);
940
+ return pcast<SrcPacketType, DstPacketType>(packets.packet[0], packets.packet[1], packets.packet[2],
941
+ packets.packet[3], packets.packet[4], packets.packet[5],
942
+ packets.packet[6], packets.packet[7]);
943
+ }
944
+
945
+ constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index rows() const { return m_rows; }
946
+ constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index cols() const { return m_cols; }
947
+ constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index size() const { return m_rows * m_cols; }
948
+
949
+ protected:
950
+ const evaluator<ArgType> m_argImpl;
951
+ const variable_if_dynamic<Index, XprType::RowsAtCompileTime> m_rows;
952
+ const variable_if_dynamic<Index, XprType::ColsAtCompileTime> m_cols;
569
953
  };
570
954
 
571
955
  // -------------------- CwiseTernaryOp --------------------
572
956
 
573
957
  // this is a ternary expression
574
- template<typename TernaryOp, typename Arg1, typename Arg2, typename Arg3>
575
- struct evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> >
576
- : public ternary_evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> >
577
- {
958
+ template <typename TernaryOp, typename Arg1, typename Arg2, typename Arg3>
959
+ struct evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>>
960
+ : public ternary_evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>> {
578
961
  typedef CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> XprType;
579
- typedef ternary_evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> > Base;
580
-
962
+ typedef ternary_evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>> Base;
963
+
581
964
  EIGEN_DEVICE_FUNC explicit evaluator(const XprType& xpr) : Base(xpr) {}
582
965
  };
583
966
 
584
- template<typename TernaryOp, typename Arg1, typename Arg2, typename Arg3>
967
+ template <typename TernaryOp, typename Arg1, typename Arg2, typename Arg3>
585
968
  struct ternary_evaluator<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>, IndexBased, IndexBased>
586
- : evaluator_base<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> >
587
- {
969
+ : evaluator_base<CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>> {
588
970
  typedef CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3> XprType;
589
-
971
+
590
972
  enum {
591
- CoeffReadCost = evaluator<Arg1>::CoeffReadCost + evaluator<Arg2>::CoeffReadCost + evaluator<Arg3>::CoeffReadCost + functor_traits<TernaryOp>::Cost,
592
-
973
+ CoeffReadCost = int(evaluator<Arg1>::CoeffReadCost) + int(evaluator<Arg2>::CoeffReadCost) +
974
+ int(evaluator<Arg3>::CoeffReadCost) + int(functor_traits<TernaryOp>::Cost),
975
+
593
976
  Arg1Flags = evaluator<Arg1>::Flags,
594
977
  Arg2Flags = evaluator<Arg2>::Flags,
595
978
  Arg3Flags = evaluator<Arg3>::Flags,
596
- SameType = is_same<typename Arg1::Scalar,typename Arg2::Scalar>::value && is_same<typename Arg1::Scalar,typename Arg3::Scalar>::value,
597
- StorageOrdersAgree = (int(Arg1Flags)&RowMajorBit)==(int(Arg2Flags)&RowMajorBit) && (int(Arg1Flags)&RowMajorBit)==(int(Arg3Flags)&RowMajorBit),
598
- Flags0 = (int(Arg1Flags) | int(Arg2Flags) | int(Arg3Flags)) & (
599
- HereditaryBits
600
- | (int(Arg1Flags) & int(Arg2Flags) & int(Arg3Flags) &
601
- ( (StorageOrdersAgree ? LinearAccessBit : 0)
602
- | (functor_traits<TernaryOp>::PacketAccess && StorageOrdersAgree && SameType ? PacketAccessBit : 0)
603
- )
604
- )
605
- ),
979
+ SameType = is_same<typename Arg1::Scalar, typename Arg2::Scalar>::value &&
980
+ is_same<typename Arg1::Scalar, typename Arg3::Scalar>::value,
981
+ StorageOrdersAgree = (int(Arg1Flags) & RowMajorBit) == (int(Arg2Flags) & RowMajorBit) &&
982
+ (int(Arg1Flags) & RowMajorBit) == (int(Arg3Flags) & RowMajorBit),
983
+ Flags0 = (int(Arg1Flags) | int(Arg2Flags) | int(Arg3Flags)) &
984
+ (HereditaryBits |
985
+ (int(Arg1Flags) & int(Arg2Flags) & int(Arg3Flags) &
986
+ ((StorageOrdersAgree ? LinearAccessBit : 0) |
987
+ (functor_traits<TernaryOp>::PacketAccess && StorageOrdersAgree && SameType ? PacketAccessBit : 0)))),
606
988
  Flags = (Flags0 & ~RowMajorBit) | (Arg1Flags & RowMajorBit),
607
- Alignment = EIGEN_PLAIN_ENUM_MIN(
608
- EIGEN_PLAIN_ENUM_MIN(evaluator<Arg1>::Alignment, evaluator<Arg2>::Alignment),
609
- evaluator<Arg3>::Alignment)
989
+ Alignment = plain_enum_min(plain_enum_min(evaluator<Arg1>::Alignment, evaluator<Arg2>::Alignment),
990
+ evaluator<Arg3>::Alignment)
610
991
  };
611
992
 
612
- EIGEN_DEVICE_FUNC explicit ternary_evaluator(const XprType& xpr)
613
- : m_functor(xpr.functor()),
614
- m_arg1Impl(xpr.arg1()),
615
- m_arg2Impl(xpr.arg2()),
616
- m_arg3Impl(xpr.arg3())
617
- {
993
+ EIGEN_DEVICE_FUNC explicit ternary_evaluator(const XprType& xpr) : m_d(xpr) {
618
994
  EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<TernaryOp>::Cost);
619
995
  EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
620
996
  }
621
997
 
622
998
  typedef typename XprType::CoeffReturnType CoeffReturnType;
623
999
 
624
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
625
- CoeffReturnType coeff(Index row, Index col) const
626
- {
627
- return m_functor(m_arg1Impl.coeff(row, col), m_arg2Impl.coeff(row, col), m_arg3Impl.coeff(row, col));
1000
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const {
1001
+ return m_d.func()(m_d.arg1Impl.coeff(row, col), m_d.arg2Impl.coeff(row, col), m_d.arg3Impl.coeff(row, col));
1002
+ }
1003
+
1004
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const {
1005
+ return m_d.func()(m_d.arg1Impl.coeff(index), m_d.arg2Impl.coeff(index), m_d.arg3Impl.coeff(index));
1006
+ }
1007
+
1008
+ template <int LoadMode, typename PacketType>
1009
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(Index row, Index col) const {
1010
+ return m_d.func().packetOp(m_d.arg1Impl.template packet<LoadMode, PacketType>(row, col),
1011
+ m_d.arg2Impl.template packet<LoadMode, PacketType>(row, col),
1012
+ m_d.arg3Impl.template packet<LoadMode, PacketType>(row, col));
628
1013
  }
629
1014
 
630
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
631
- CoeffReturnType coeff(Index index) const
632
- {
633
- return m_functor(m_arg1Impl.coeff(index), m_arg2Impl.coeff(index), m_arg3Impl.coeff(index));
1015
+ template <int LoadMode, typename PacketType>
1016
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(Index index) const {
1017
+ return m_d.func().packetOp(m_d.arg1Impl.template packet<LoadMode, PacketType>(index),
1018
+ m_d.arg2Impl.template packet<LoadMode, PacketType>(index),
1019
+ m_d.arg3Impl.template packet<LoadMode, PacketType>(index));
634
1020
  }
635
1021
 
636
- template<int LoadMode, typename PacketType>
637
- EIGEN_STRONG_INLINE
638
- PacketType packet(Index row, Index col) const
639
- {
640
- return m_functor.packetOp(m_arg1Impl.template packet<LoadMode,PacketType>(row, col),
641
- m_arg2Impl.template packet<LoadMode,PacketType>(row, col),
642
- m_arg3Impl.template packet<LoadMode,PacketType>(row, col));
1022
+ template <int LoadMode, typename PacketType>
1023
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(Index row, Index col, Index begin, Index count) const {
1024
+ return m_d.func().packetOp(m_d.arg1Impl.template packetSegment<LoadMode, PacketType>(row, col, begin, count),
1025
+ m_d.arg2Impl.template packetSegment<LoadMode, PacketType>(row, col, begin, count),
1026
+ m_d.arg3Impl.template packetSegment<LoadMode, PacketType>(row, col, begin, count));
643
1027
  }
644
1028
 
645
- template<int LoadMode, typename PacketType>
646
- EIGEN_STRONG_INLINE
647
- PacketType packet(Index index) const
648
- {
649
- return m_functor.packetOp(m_arg1Impl.template packet<LoadMode,PacketType>(index),
650
- m_arg2Impl.template packet<LoadMode,PacketType>(index),
651
- m_arg3Impl.template packet<LoadMode,PacketType>(index));
1029
+ template <int LoadMode, typename PacketType>
1030
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(Index index, Index begin, Index count) const {
1031
+ return m_d.func().packetOp(m_d.arg1Impl.template packetSegment<LoadMode, PacketType>(index, begin, count),
1032
+ m_d.arg2Impl.template packetSegment<LoadMode, PacketType>(index, begin, count),
1033
+ m_d.arg3Impl.template packetSegment<LoadMode, PacketType>(index, begin, count));
652
1034
  }
653
1035
 
654
- protected:
655
- const TernaryOp m_functor;
656
- evaluator<Arg1> m_arg1Impl;
657
- evaluator<Arg2> m_arg2Impl;
658
- evaluator<Arg3> m_arg3Impl;
1036
+ protected:
1037
+ // this helper permits to completely eliminate the functor if it is empty
1038
+ struct Data {
1039
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Data(const XprType& xpr)
1040
+ : op(xpr.functor()), arg1Impl(xpr.arg1()), arg2Impl(xpr.arg2()), arg3Impl(xpr.arg3()) {}
1041
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const TernaryOp& func() const { return op; }
1042
+ TernaryOp op;
1043
+ evaluator<Arg1> arg1Impl;
1044
+ evaluator<Arg2> arg2Impl;
1045
+ evaluator<Arg3> arg3Impl;
1046
+ };
1047
+
1048
+ Data m_d;
1049
+ };
1050
+
1051
+ template <typename Arg1, typename Arg2, typename Scalar, typename CmpLhsType, typename CmpRhsType, ComparisonName cmp>
1052
+ struct scalar_boolean_select_spec {
1053
+ using DummyTernaryOp = scalar_boolean_select_op<Scalar, Scalar, bool>;
1054
+ using DummyArg3 = CwiseBinaryOp<scalar_cmp_op<Scalar, Scalar, cmp, false>, CmpLhsType, CmpRhsType>;
1055
+ using DummyXprType = CwiseTernaryOp<DummyTernaryOp, Arg1, Arg2, DummyArg3>;
1056
+
1057
+ // only use the typed comparison if it is vectorized
1058
+ static constexpr bool UseTyped = functor_traits<scalar_cmp_op<Scalar, Scalar, cmp, true>>::PacketAccess;
1059
+ using CondScalar = std::conditional_t<UseTyped, Scalar, bool>;
1060
+
1061
+ using TernaryOp = scalar_boolean_select_op<Scalar, Scalar, CondScalar>;
1062
+ using Arg3 = CwiseBinaryOp<scalar_cmp_op<Scalar, Scalar, cmp, UseTyped>, CmpLhsType, CmpRhsType>;
1063
+ using XprType = CwiseTernaryOp<TernaryOp, Arg1, Arg2, Arg3>;
1064
+
1065
+ using Base = ternary_evaluator<XprType>;
1066
+ };
1067
+
1068
+ // specialization for expressions like (a < b).select(c, d) to enable full vectorization
1069
+ template <typename Arg1, typename Arg2, typename Scalar, typename CmpLhsType, typename CmpRhsType, ComparisonName cmp>
1070
+ struct evaluator<CwiseTernaryOp<scalar_boolean_select_op<Scalar, Scalar, bool>, Arg1, Arg2,
1071
+ CwiseBinaryOp<scalar_cmp_op<Scalar, Scalar, cmp, false>, CmpLhsType, CmpRhsType>>>
1072
+ : public scalar_boolean_select_spec<Arg1, Arg2, Scalar, CmpLhsType, CmpRhsType, cmp>::Base {
1073
+ using Helper = scalar_boolean_select_spec<Arg1, Arg2, Scalar, CmpLhsType, CmpRhsType, cmp>;
1074
+ using Base = typename Helper::Base;
1075
+ using DummyXprType = typename Helper::DummyXprType;
1076
+ using Arg3 = typename Helper::Arg3;
1077
+ using XprType = typename Helper::XprType;
1078
+
1079
+ EIGEN_DEVICE_FUNC explicit evaluator(const DummyXprType& xpr)
1080
+ : Base(XprType(xpr.arg1(), xpr.arg2(), Arg3(xpr.arg3().lhs(), xpr.arg3().rhs()))) {}
659
1081
  };
660
1082
 
661
1083
  // -------------------- CwiseBinaryOp --------------------
662
1084
 
663
1085
  // this is a binary expression
664
- template<typename BinaryOp, typename Lhs, typename Rhs>
665
- struct evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >
666
- : public binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >
667
- {
1086
+ template <typename BinaryOp, typename Lhs, typename Rhs>
1087
+ struct evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>> : public binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>> {
668
1088
  typedef CwiseBinaryOp<BinaryOp, Lhs, Rhs> XprType;
669
- typedef binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs> > Base;
670
-
671
- EIGEN_DEVICE_FUNC explicit evaluator(const XprType& xpr) : Base(xpr) {}
1089
+ typedef binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>> Base;
1090
+
1091
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit evaluator(const XprType& xpr) : Base(xpr) {}
672
1092
  };
673
1093
 
674
- template<typename BinaryOp, typename Lhs, typename Rhs>
1094
+ template <typename BinaryOp, typename Lhs, typename Rhs>
675
1095
  struct binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>, IndexBased, IndexBased>
676
- : evaluator_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >
677
- {
1096
+ : evaluator_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs>> {
678
1097
  typedef CwiseBinaryOp<BinaryOp, Lhs, Rhs> XprType;
679
-
1098
+
680
1099
  enum {
681
- CoeffReadCost = evaluator<Lhs>::CoeffReadCost + evaluator<Rhs>::CoeffReadCost + functor_traits<BinaryOp>::Cost,
682
-
1100
+ CoeffReadCost =
1101
+ int(evaluator<Lhs>::CoeffReadCost) + int(evaluator<Rhs>::CoeffReadCost) + int(functor_traits<BinaryOp>::Cost),
1102
+
683
1103
  LhsFlags = evaluator<Lhs>::Flags,
684
1104
  RhsFlags = evaluator<Rhs>::Flags,
685
- SameType = is_same<typename Lhs::Scalar,typename Rhs::Scalar>::value,
686
- StorageOrdersAgree = (int(LhsFlags)&RowMajorBit)==(int(RhsFlags)&RowMajorBit),
687
- Flags0 = (int(LhsFlags) | int(RhsFlags)) & (
688
- HereditaryBits
689
- | (int(LhsFlags) & int(RhsFlags) &
690
- ( (StorageOrdersAgree ? LinearAccessBit : 0)
691
- | (functor_traits<BinaryOp>::PacketAccess && StorageOrdersAgree && SameType ? PacketAccessBit : 0)
692
- )
693
- )
694
- ),
1105
+ SameType = is_same<typename Lhs::Scalar, typename Rhs::Scalar>::value,
1106
+ StorageOrdersAgree = (int(LhsFlags) & RowMajorBit) == (int(RhsFlags) & RowMajorBit),
1107
+ Flags0 = (int(LhsFlags) | int(RhsFlags)) &
1108
+ (HereditaryBits |
1109
+ (int(LhsFlags) & int(RhsFlags) &
1110
+ ((StorageOrdersAgree ? LinearAccessBit : 0) |
1111
+ (functor_traits<BinaryOp>::PacketAccess && StorageOrdersAgree && SameType ? PacketAccessBit : 0)))),
695
1112
  Flags = (Flags0 & ~RowMajorBit) | (LhsFlags & RowMajorBit),
696
- Alignment = EIGEN_PLAIN_ENUM_MIN(evaluator<Lhs>::Alignment,evaluator<Rhs>::Alignment)
1113
+ Alignment = plain_enum_min(evaluator<Lhs>::Alignment, evaluator<Rhs>::Alignment)
697
1114
  };
698
1115
 
699
- EIGEN_DEVICE_FUNC explicit binary_evaluator(const XprType& xpr)
700
- : m_functor(xpr.functor()),
701
- m_lhsImpl(xpr.lhs()),
702
- m_rhsImpl(xpr.rhs())
703
- {
1116
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit binary_evaluator(const XprType& xpr) : m_d(xpr) {
704
1117
  EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<BinaryOp>::Cost);
705
1118
  EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
706
1119
  }
707
1120
 
708
1121
  typedef typename XprType::CoeffReturnType CoeffReturnType;
709
1122
 
710
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
711
- CoeffReturnType coeff(Index row, Index col) const
712
- {
713
- return m_functor(m_lhsImpl.coeff(row, col), m_rhsImpl.coeff(row, col));
1123
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const {
1124
+ return m_d.func()(m_d.lhsImpl.coeff(row, col), m_d.rhsImpl.coeff(row, col));
1125
+ }
1126
+
1127
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const {
1128
+ return m_d.func()(m_d.lhsImpl.coeff(index), m_d.rhsImpl.coeff(index));
1129
+ }
1130
+
1131
+ template <int LoadMode, typename PacketType>
1132
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(Index row, Index col) const {
1133
+ return m_d.func().packetOp(m_d.lhsImpl.template packet<LoadMode, PacketType>(row, col),
1134
+ m_d.rhsImpl.template packet<LoadMode, PacketType>(row, col));
714
1135
  }
715
1136
 
716
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
717
- CoeffReturnType coeff(Index index) const
718
- {
719
- return m_functor(m_lhsImpl.coeff(index), m_rhsImpl.coeff(index));
1137
+ template <int LoadMode, typename PacketType>
1138
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(Index index) const {
1139
+ return m_d.func().packetOp(m_d.lhsImpl.template packet<LoadMode, PacketType>(index),
1140
+ m_d.rhsImpl.template packet<LoadMode, PacketType>(index));
720
1141
  }
721
1142
 
722
- template<int LoadMode, typename PacketType>
723
- EIGEN_STRONG_INLINE
724
- PacketType packet(Index row, Index col) const
725
- {
726
- return m_functor.packetOp(m_lhsImpl.template packet<LoadMode,PacketType>(row, col),
727
- m_rhsImpl.template packet<LoadMode,PacketType>(row, col));
1143
+ template <int LoadMode, typename PacketType>
1144
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(Index row, Index col, Index begin, Index count) const {
1145
+ return m_d.func().packetOp(m_d.lhsImpl.template packetSegment<LoadMode, PacketType>(row, col, begin, count),
1146
+ m_d.rhsImpl.template packetSegment<LoadMode, PacketType>(row, col, begin, count));
728
1147
  }
729
1148
 
730
- template<int LoadMode, typename PacketType>
731
- EIGEN_STRONG_INLINE
732
- PacketType packet(Index index) const
733
- {
734
- return m_functor.packetOp(m_lhsImpl.template packet<LoadMode,PacketType>(index),
735
- m_rhsImpl.template packet<LoadMode,PacketType>(index));
1149
+ template <int LoadMode, typename PacketType>
1150
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(Index index, Index begin, Index count) const {
1151
+ return m_d.func().packetOp(m_d.lhsImpl.template packetSegment<LoadMode, PacketType>(index, begin, count),
1152
+ m_d.rhsImpl.template packetSegment<LoadMode, PacketType>(index, begin, count));
736
1153
  }
737
1154
 
738
- protected:
739
- const BinaryOp m_functor;
740
- evaluator<Lhs> m_lhsImpl;
741
- evaluator<Rhs> m_rhsImpl;
1155
+ protected:
1156
+ // this helper permits to completely eliminate the functor if it is empty
1157
+ struct Data {
1158
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Data(const XprType& xpr)
1159
+ : op(xpr.functor()), lhsImpl(xpr.lhs()), rhsImpl(xpr.rhs()) {}
1160
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const BinaryOp& func() const { return op; }
1161
+ BinaryOp op;
1162
+ evaluator<Lhs> lhsImpl;
1163
+ evaluator<Rhs> rhsImpl;
1164
+ };
1165
+
1166
+ Data m_d;
742
1167
  };
743
1168
 
744
1169
  // -------------------- CwiseUnaryView --------------------
745
1170
 
746
- template<typename UnaryOp, typename ArgType>
747
- struct unary_evaluator<CwiseUnaryView<UnaryOp, ArgType>, IndexBased>
748
- : evaluator_base<CwiseUnaryView<UnaryOp, ArgType> >
749
- {
750
- typedef CwiseUnaryView<UnaryOp, ArgType> XprType;
751
-
1171
+ template <typename UnaryOp, typename ArgType, typename StrideType>
1172
+ struct unary_evaluator<CwiseUnaryView<UnaryOp, ArgType, StrideType>, IndexBased>
1173
+ : evaluator_base<CwiseUnaryView<UnaryOp, ArgType, StrideType>> {
1174
+ typedef CwiseUnaryView<UnaryOp, ArgType, StrideType> XprType;
1175
+
752
1176
  enum {
753
- CoeffReadCost = evaluator<ArgType>::CoeffReadCost + functor_traits<UnaryOp>::Cost,
754
-
1177
+ CoeffReadCost = int(evaluator<ArgType>::CoeffReadCost) + int(functor_traits<UnaryOp>::Cost),
1178
+
755
1179
  Flags = (evaluator<ArgType>::Flags & (HereditaryBits | LinearAccessBit | DirectAccessBit)),
756
-
757
- Alignment = 0 // FIXME it is not very clear why alignment is necessarily lost...
1180
+
1181
+ Alignment = 0 // FIXME it is not very clear why alignment is necessarily lost...
758
1182
  };
759
1183
 
760
- EIGEN_DEVICE_FUNC explicit unary_evaluator(const XprType& op)
761
- : m_unaryOp(op.functor()),
762
- m_argImpl(op.nestedExpression())
763
- {
1184
+ EIGEN_DEVICE_FUNC explicit unary_evaluator(const XprType& op) : m_d(op) {
764
1185
  EIGEN_INTERNAL_CHECK_COST_VALUE(functor_traits<UnaryOp>::Cost);
765
1186
  EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
766
1187
  }
@@ -768,671 +1189,576 @@ struct unary_evaluator<CwiseUnaryView<UnaryOp, ArgType>, IndexBased>
768
1189
  typedef typename XprType::Scalar Scalar;
769
1190
  typedef typename XprType::CoeffReturnType CoeffReturnType;
770
1191
 
771
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
772
- CoeffReturnType coeff(Index row, Index col) const
773
- {
774
- return m_unaryOp(m_argImpl.coeff(row, col));
1192
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const {
1193
+ return m_d.func()(m_d.argImpl.coeff(row, col));
775
1194
  }
776
1195
 
777
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
778
- CoeffReturnType coeff(Index index) const
779
- {
780
- return m_unaryOp(m_argImpl.coeff(index));
1196
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const {
1197
+ return m_d.func()(m_d.argImpl.coeff(index));
781
1198
  }
782
1199
 
783
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
784
- Scalar& coeffRef(Index row, Index col)
785
- {
786
- return m_unaryOp(m_argImpl.coeffRef(row, col));
1200
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(Index row, Index col) {
1201
+ return m_d.func()(m_d.argImpl.coeffRef(row, col));
787
1202
  }
788
1203
 
789
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
790
- Scalar& coeffRef(Index index)
791
- {
792
- return m_unaryOp(m_argImpl.coeffRef(index));
1204
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(Index index) {
1205
+ return m_d.func()(m_d.argImpl.coeffRef(index));
793
1206
  }
794
1207
 
795
- protected:
796
- const UnaryOp m_unaryOp;
797
- evaluator<ArgType> m_argImpl;
1208
+ protected:
1209
+ // this helper permits to completely eliminate the functor if it is empty
1210
+ struct Data {
1211
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Data(const XprType& xpr)
1212
+ : op(xpr.functor()), argImpl(xpr.nestedExpression()) {}
1213
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const UnaryOp& func() const { return op; }
1214
+ UnaryOp op;
1215
+ evaluator<ArgType> argImpl;
1216
+ };
1217
+
1218
+ Data m_d;
798
1219
  };
799
1220
 
800
1221
  // -------------------- Map --------------------
801
1222
 
802
1223
  // FIXME perhaps the PlainObjectType could be provided by Derived::PlainObject ?
803
1224
  // but that might complicate template specialization
804
- template<typename Derived, typename PlainObjectType>
1225
+ template <typename Derived, typename PlainObjectType>
805
1226
  struct mapbase_evaluator;
806
1227
 
807
- template<typename Derived, typename PlainObjectType>
808
- struct mapbase_evaluator : evaluator_base<Derived>
809
- {
810
- typedef Derived XprType;
1228
+ template <typename Derived, typename PlainObjectType>
1229
+ struct mapbase_evaluator : evaluator_base<Derived> {
1230
+ typedef Derived XprType;
811
1231
  typedef typename XprType::PointerType PointerType;
812
1232
  typedef typename XprType::Scalar Scalar;
813
1233
  typedef typename XprType::CoeffReturnType CoeffReturnType;
814
-
1234
+
815
1235
  enum {
816
1236
  IsRowMajor = XprType::RowsAtCompileTime,
817
1237
  ColsAtCompileTime = XprType::ColsAtCompileTime,
818
1238
  CoeffReadCost = NumTraits<Scalar>::ReadCost
819
1239
  };
820
1240
 
821
- EIGEN_DEVICE_FUNC explicit mapbase_evaluator(const XprType& map)
822
- : m_data(const_cast<PointerType>(map.data())),
823
- m_innerStride(map.innerStride()),
824
- m_outerStride(map.outerStride())
825
- {
826
- EIGEN_STATIC_ASSERT(EIGEN_IMPLIES(evaluator<Derived>::Flags&PacketAccessBit, internal::inner_stride_at_compile_time<Derived>::ret==1),
1241
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit mapbase_evaluator(const XprType& map)
1242
+ : m_data(const_cast<PointerType>(map.data())),
1243
+ m_innerStride(map.innerStride()),
1244
+ m_outerStride(map.outerStride()) {
1245
+ EIGEN_STATIC_ASSERT(check_implication((evaluator<Derived>::Flags & PacketAccessBit) != 0,
1246
+ inner_stride_at_compile_time<Derived>::ret == 1),
827
1247
  PACKET_ACCESS_REQUIRES_TO_HAVE_INNER_STRIDE_FIXED_TO_1);
828
1248
  EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
829
1249
  }
830
1250
 
831
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
832
- CoeffReturnType coeff(Index row, Index col) const
833
- {
1251
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const {
834
1252
  return m_data[col * colStride() + row * rowStride()];
835
1253
  }
836
1254
 
837
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
838
- CoeffReturnType coeff(Index index) const
839
- {
1255
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const {
840
1256
  return m_data[index * m_innerStride.value()];
841
1257
  }
842
1258
 
843
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
844
- Scalar& coeffRef(Index row, Index col)
845
- {
1259
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(Index row, Index col) {
846
1260
  return m_data[col * colStride() + row * rowStride()];
847
1261
  }
848
1262
 
849
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
850
- Scalar& coeffRef(Index index)
851
- {
852
- return m_data[index * m_innerStride.value()];
1263
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(Index index) { return m_data[index * m_innerStride.value()]; }
1264
+
1265
+ template <int LoadMode, typename PacketType>
1266
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(Index row, Index col) const {
1267
+ PointerType ptr = m_data + row * rowStride() + col * colStride();
1268
+ return ploadt<PacketType, LoadMode>(ptr);
1269
+ }
1270
+
1271
+ template <int LoadMode, typename PacketType>
1272
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(Index index) const {
1273
+ return ploadt<PacketType, LoadMode>(m_data + index * m_innerStride.value());
1274
+ }
1275
+
1276
+ template <int StoreMode, typename PacketType>
1277
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void writePacket(Index row, Index col, const PacketType& x) {
1278
+ PointerType ptr = m_data + row * rowStride() + col * colStride();
1279
+ pstoret<Scalar, PacketType, StoreMode>(ptr, x);
1280
+ }
1281
+
1282
+ template <int StoreMode, typename PacketType>
1283
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void writePacket(Index index, const PacketType& x) {
1284
+ pstoret<Scalar, PacketType, StoreMode>(m_data + index * m_innerStride.value(), x);
853
1285
  }
854
1286
 
855
- template<int LoadMode, typename PacketType>
856
- EIGEN_STRONG_INLINE
857
- PacketType packet(Index row, Index col) const
858
- {
1287
+ template <int LoadMode, typename PacketType>
1288
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(Index row, Index col, Index begin, Index count) const {
859
1289
  PointerType ptr = m_data + row * rowStride() + col * colStride();
860
- return internal::ploadt<PacketType, LoadMode>(ptr);
1290
+ return ploadtSegment<PacketType, LoadMode>(ptr, begin, count);
861
1291
  }
862
1292
 
863
- template<int LoadMode, typename PacketType>
864
- EIGEN_STRONG_INLINE
865
- PacketType packet(Index index) const
866
- {
867
- return internal::ploadt<PacketType, LoadMode>(m_data + index * m_innerStride.value());
1293
+ template <int LoadMode, typename PacketType>
1294
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(Index index, Index begin, Index count) const {
1295
+ return ploadtSegment<PacketType, LoadMode>(m_data + index * m_innerStride.value(), begin, count);
868
1296
  }
869
1297
 
870
- template<int StoreMode, typename PacketType>
871
- EIGEN_STRONG_INLINE
872
- void writePacket(Index row, Index col, const PacketType& x)
873
- {
1298
+ template <int StoreMode, typename PacketType>
1299
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void writePacketSegment(Index row, Index col, const PacketType& x, Index begin,
1300
+ Index count) {
874
1301
  PointerType ptr = m_data + row * rowStride() + col * colStride();
875
- return internal::pstoret<Scalar, PacketType, StoreMode>(ptr, x);
1302
+ pstoretSegment<Scalar, PacketType, StoreMode>(ptr, x, begin, count);
1303
+ }
1304
+
1305
+ template <int StoreMode, typename PacketType>
1306
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void writePacketSegment(Index index, const PacketType& x, Index begin,
1307
+ Index count) {
1308
+ pstoretSegment<Scalar, PacketType, StoreMode>(m_data + index * m_innerStride.value(), x, begin, count);
876
1309
  }
877
1310
 
878
- template<int StoreMode, typename PacketType>
879
- EIGEN_STRONG_INLINE
880
- void writePacket(Index index, const PacketType& x)
881
- {
882
- internal::pstoret<Scalar, PacketType, StoreMode>(m_data + index * m_innerStride.value(), x);
1311
+ protected:
1312
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr Index rowStride() const noexcept {
1313
+ return XprType::IsRowMajor ? m_outerStride.value() : m_innerStride.value();
1314
+ }
1315
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr Index colStride() const noexcept {
1316
+ return XprType::IsRowMajor ? m_innerStride.value() : m_outerStride.value();
883
1317
  }
884
- protected:
885
- EIGEN_DEVICE_FUNC
886
- inline Index rowStride() const { return XprType::IsRowMajor ? m_outerStride.value() : m_innerStride.value(); }
887
- EIGEN_DEVICE_FUNC
888
- inline Index colStride() const { return XprType::IsRowMajor ? m_innerStride.value() : m_outerStride.value(); }
889
1318
 
890
1319
  PointerType m_data;
891
- const internal::variable_if_dynamic<Index, XprType::InnerStrideAtCompileTime> m_innerStride;
892
- const internal::variable_if_dynamic<Index, XprType::OuterStrideAtCompileTime> m_outerStride;
1320
+ const variable_if_dynamic<Index, XprType::InnerStrideAtCompileTime> m_innerStride;
1321
+ const variable_if_dynamic<Index, XprType::OuterStrideAtCompileTime> m_outerStride;
893
1322
  };
894
1323
 
895
- template<typename PlainObjectType, int MapOptions, typename StrideType>
896
- struct evaluator<Map<PlainObjectType, MapOptions, StrideType> >
897
- : public mapbase_evaluator<Map<PlainObjectType, MapOptions, StrideType>, PlainObjectType>
898
- {
1324
+ template <typename PlainObjectType, int MapOptions, typename StrideType>
1325
+ struct evaluator<Map<PlainObjectType, MapOptions, StrideType>>
1326
+ : public mapbase_evaluator<Map<PlainObjectType, MapOptions, StrideType>, PlainObjectType> {
899
1327
  typedef Map<PlainObjectType, MapOptions, StrideType> XprType;
900
1328
  typedef typename XprType::Scalar Scalar;
901
1329
  // TODO: should check for smaller packet types once we can handle multi-sized packet types
902
1330
  typedef typename packet_traits<Scalar>::type PacketScalar;
903
-
1331
+
904
1332
  enum {
905
1333
  InnerStrideAtCompileTime = StrideType::InnerStrideAtCompileTime == 0
906
- ? int(PlainObjectType::InnerStrideAtCompileTime)
907
- : int(StrideType::InnerStrideAtCompileTime),
1334
+ ? int(PlainObjectType::InnerStrideAtCompileTime)
1335
+ : int(StrideType::InnerStrideAtCompileTime),
908
1336
  OuterStrideAtCompileTime = StrideType::OuterStrideAtCompileTime == 0
909
- ? int(PlainObjectType::OuterStrideAtCompileTime)
910
- : int(StrideType::OuterStrideAtCompileTime),
1337
+ ? int(PlainObjectType::OuterStrideAtCompileTime)
1338
+ : int(StrideType::OuterStrideAtCompileTime),
911
1339
  HasNoInnerStride = InnerStrideAtCompileTime == 1,
912
1340
  HasNoOuterStride = StrideType::OuterStrideAtCompileTime == 0,
913
1341
  HasNoStride = HasNoInnerStride && HasNoOuterStride,
914
- IsDynamicSize = PlainObjectType::SizeAtCompileTime==Dynamic,
915
-
1342
+ IsDynamicSize = PlainObjectType::SizeAtCompileTime == Dynamic,
1343
+
916
1344
  PacketAccessMask = bool(HasNoInnerStride) ? ~int(0) : ~int(PacketAccessBit),
917
- LinearAccessMask = bool(HasNoStride) || bool(PlainObjectType::IsVectorAtCompileTime) ? ~int(0) : ~int(LinearAccessBit),
918
- Flags = int( evaluator<PlainObjectType>::Flags) & (LinearAccessMask&PacketAccessMask),
919
-
920
- Alignment = int(MapOptions)&int(AlignedMask)
1345
+ LinearAccessMask =
1346
+ bool(HasNoStride) || bool(PlainObjectType::IsVectorAtCompileTime) ? ~int(0) : ~int(LinearAccessBit),
1347
+ Flags = int(evaluator<PlainObjectType>::Flags) & (LinearAccessMask & PacketAccessMask),
1348
+
1349
+ Alignment = int(MapOptions) & int(AlignedMask)
921
1350
  };
922
1351
 
923
- EIGEN_DEVICE_FUNC explicit evaluator(const XprType& map)
924
- : mapbase_evaluator<XprType, PlainObjectType>(map)
925
- { }
1352
+ EIGEN_DEVICE_FUNC explicit evaluator(const XprType& map) : mapbase_evaluator<XprType, PlainObjectType>(map) {}
926
1353
  };
927
1354
 
928
1355
  // -------------------- Ref --------------------
929
1356
 
930
- template<typename PlainObjectType, int RefOptions, typename StrideType>
931
- struct evaluator<Ref<PlainObjectType, RefOptions, StrideType> >
932
- : public mapbase_evaluator<Ref<PlainObjectType, RefOptions, StrideType>, PlainObjectType>
933
- {
1357
+ template <typename PlainObjectType, int RefOptions, typename StrideType>
1358
+ struct evaluator<Ref<PlainObjectType, RefOptions, StrideType>>
1359
+ : public mapbase_evaluator<Ref<PlainObjectType, RefOptions, StrideType>, PlainObjectType> {
934
1360
  typedef Ref<PlainObjectType, RefOptions, StrideType> XprType;
935
-
1361
+
936
1362
  enum {
937
- Flags = evaluator<Map<PlainObjectType, RefOptions, StrideType> >::Flags,
938
- Alignment = evaluator<Map<PlainObjectType, RefOptions, StrideType> >::Alignment
1363
+ Flags = evaluator<Map<PlainObjectType, RefOptions, StrideType>>::Flags,
1364
+ Alignment = evaluator<Map<PlainObjectType, RefOptions, StrideType>>::Alignment
939
1365
  };
940
1366
 
941
- EIGEN_DEVICE_FUNC explicit evaluator(const XprType& ref)
942
- : mapbase_evaluator<XprType, PlainObjectType>(ref)
943
- { }
1367
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit evaluator(const XprType& ref)
1368
+ : mapbase_evaluator<XprType, PlainObjectType>(ref) {}
944
1369
  };
945
1370
 
946
1371
  // -------------------- Block --------------------
947
1372
 
948
- template<typename ArgType, int BlockRows, int BlockCols, bool InnerPanel,
949
- bool HasDirectAccess = internal::has_direct_access<ArgType>::ret> struct block_evaluator;
950
-
951
- template<typename ArgType, int BlockRows, int BlockCols, bool InnerPanel>
952
- struct evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel> >
953
- : block_evaluator<ArgType, BlockRows, BlockCols, InnerPanel>
954
- {
1373
+ template <typename ArgType, int BlockRows, int BlockCols, bool InnerPanel,
1374
+ bool HasDirectAccess = has_direct_access<ArgType>::ret>
1375
+ struct block_evaluator;
1376
+
1377
+ template <typename ArgType, int BlockRows, int BlockCols, bool InnerPanel>
1378
+ struct evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>>
1379
+ : block_evaluator<ArgType, BlockRows, BlockCols, InnerPanel> {
955
1380
  typedef Block<ArgType, BlockRows, BlockCols, InnerPanel> XprType;
956
1381
  typedef typename XprType::Scalar Scalar;
957
1382
  // TODO: should check for smaller packet types once we can handle multi-sized packet types
958
1383
  typedef typename packet_traits<Scalar>::type PacketScalar;
959
-
1384
+
960
1385
  enum {
961
1386
  CoeffReadCost = evaluator<ArgType>::CoeffReadCost,
962
-
1387
+
963
1388
  RowsAtCompileTime = traits<XprType>::RowsAtCompileTime,
964
1389
  ColsAtCompileTime = traits<XprType>::ColsAtCompileTime,
965
1390
  MaxRowsAtCompileTime = traits<XprType>::MaxRowsAtCompileTime,
966
1391
  MaxColsAtCompileTime = traits<XprType>::MaxColsAtCompileTime,
967
-
968
- ArgTypeIsRowMajor = (int(evaluator<ArgType>::Flags)&RowMajorBit) != 0,
969
- IsRowMajor = (MaxRowsAtCompileTime==1 && MaxColsAtCompileTime!=1) ? 1
970
- : (MaxColsAtCompileTime==1 && MaxRowsAtCompileTime!=1) ? 0
971
- : ArgTypeIsRowMajor,
1392
+
1393
+ ArgTypeIsRowMajor = (int(evaluator<ArgType>::Flags) & RowMajorBit) != 0,
1394
+ IsRowMajor = (MaxRowsAtCompileTime == 1 && MaxColsAtCompileTime != 1) ? 1
1395
+ : (MaxColsAtCompileTime == 1 && MaxRowsAtCompileTime != 1) ? 0
1396
+ : ArgTypeIsRowMajor,
972
1397
  HasSameStorageOrderAsArgType = (IsRowMajor == ArgTypeIsRowMajor),
973
1398
  InnerSize = IsRowMajor ? int(ColsAtCompileTime) : int(RowsAtCompileTime),
974
- InnerStrideAtCompileTime = HasSameStorageOrderAsArgType
975
- ? int(inner_stride_at_compile_time<ArgType>::ret)
976
- : int(outer_stride_at_compile_time<ArgType>::ret),
977
- OuterStrideAtCompileTime = HasSameStorageOrderAsArgType
978
- ? int(outer_stride_at_compile_time<ArgType>::ret)
979
- : int(inner_stride_at_compile_time<ArgType>::ret),
1399
+ InnerStrideAtCompileTime = HasSameStorageOrderAsArgType ? int(inner_stride_at_compile_time<ArgType>::ret)
1400
+ : int(outer_stride_at_compile_time<ArgType>::ret),
1401
+ OuterStrideAtCompileTime = HasSameStorageOrderAsArgType ? int(outer_stride_at_compile_time<ArgType>::ret)
1402
+ : int(inner_stride_at_compile_time<ArgType>::ret),
980
1403
  MaskPacketAccessBit = (InnerStrideAtCompileTime == 1 || HasSameStorageOrderAsArgType) ? PacketAccessBit : 0,
981
-
982
- FlagsLinearAccessBit = (RowsAtCompileTime == 1 || ColsAtCompileTime == 1 || (InnerPanel && (evaluator<ArgType>::Flags&LinearAccessBit))) ? LinearAccessBit : 0,
983
- FlagsRowMajorBit = XprType::Flags&RowMajorBit,
984
- Flags0 = evaluator<ArgType>::Flags & ( (HereditaryBits & ~RowMajorBit) |
985
- DirectAccessBit |
986
- MaskPacketAccessBit),
1404
+
1405
+ FlagsLinearAccessBit = (RowsAtCompileTime == 1 || ColsAtCompileTime == 1 ||
1406
+ (InnerPanel && (evaluator<ArgType>::Flags & LinearAccessBit)))
1407
+ ? LinearAccessBit
1408
+ : 0,
1409
+ FlagsRowMajorBit = XprType::Flags & RowMajorBit,
1410
+ Flags0 = evaluator<ArgType>::Flags & ((HereditaryBits & ~RowMajorBit) | DirectAccessBit | MaskPacketAccessBit),
987
1411
  Flags = Flags0 | FlagsLinearAccessBit | FlagsRowMajorBit,
988
-
1412
+
989
1413
  PacketAlignment = unpacket_traits<PacketScalar>::alignment,
990
- Alignment0 = (InnerPanel && (OuterStrideAtCompileTime!=Dynamic)
991
- && (OuterStrideAtCompileTime!=0)
992
- && (((OuterStrideAtCompileTime * int(sizeof(Scalar))) % int(PacketAlignment)) == 0)) ? int(PacketAlignment) : 0,
993
- Alignment = EIGEN_PLAIN_ENUM_MIN(evaluator<ArgType>::Alignment, Alignment0)
1414
+ Alignment0 = (InnerPanel && (OuterStrideAtCompileTime != Dynamic) && (OuterStrideAtCompileTime != 0) &&
1415
+ (((OuterStrideAtCompileTime * int(sizeof(Scalar))) % int(PacketAlignment)) == 0))
1416
+ ? int(PacketAlignment)
1417
+ : 0,
1418
+ Alignment = plain_enum_min(evaluator<ArgType>::Alignment, Alignment0)
994
1419
  };
995
1420
  typedef block_evaluator<ArgType, BlockRows, BlockCols, InnerPanel> block_evaluator_type;
996
- EIGEN_DEVICE_FUNC explicit evaluator(const XprType& block) : block_evaluator_type(block)
997
- {
1421
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit evaluator(const XprType& block) : block_evaluator_type(block) {
998
1422
  EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
999
1423
  }
1000
1424
  };
1001
1425
 
1002
1426
  // no direct-access => dispatch to a unary evaluator
1003
- template<typename ArgType, int BlockRows, int BlockCols, bool InnerPanel>
1427
+ template <typename ArgType, int BlockRows, int BlockCols, bool InnerPanel>
1004
1428
  struct block_evaluator<ArgType, BlockRows, BlockCols, InnerPanel, /*HasDirectAccess*/ false>
1005
- : unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel> >
1006
- {
1429
+ : unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>> {
1007
1430
  typedef Block<ArgType, BlockRows, BlockCols, InnerPanel> XprType;
1008
1431
 
1009
- EIGEN_DEVICE_FUNC explicit block_evaluator(const XprType& block)
1010
- : unary_evaluator<XprType>(block)
1011
- {}
1432
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit block_evaluator(const XprType& block)
1433
+ : unary_evaluator<XprType>(block) {}
1012
1434
  };
1013
1435
 
1014
- template<typename ArgType, int BlockRows, int BlockCols, bool InnerPanel>
1436
+ template <typename ArgType, int BlockRows, int BlockCols, bool InnerPanel>
1015
1437
  struct unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>, IndexBased>
1016
- : evaluator_base<Block<ArgType, BlockRows, BlockCols, InnerPanel> >
1017
- {
1438
+ : evaluator_base<Block<ArgType, BlockRows, BlockCols, InnerPanel>> {
1018
1439
  typedef Block<ArgType, BlockRows, BlockCols, InnerPanel> XprType;
1019
1440
 
1020
- EIGEN_DEVICE_FUNC explicit unary_evaluator(const XprType& block)
1021
- : m_argImpl(block.nestedExpression()),
1022
- m_startRow(block.startRow()),
1023
- m_startCol(block.startCol()),
1024
- m_linear_offset(InnerPanel?(XprType::IsRowMajor ? block.startRow()*block.cols() : block.startCol()*block.rows()):0)
1025
- { }
1026
-
1441
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit unary_evaluator(const XprType& block)
1442
+ : m_argImpl(block.nestedExpression()),
1443
+ m_startRow(block.startRow()),
1444
+ m_startCol(block.startCol()),
1445
+ m_linear_offset(ForwardLinearAccess
1446
+ ? (ArgType::IsRowMajor
1447
+ ? block.startRow() * block.nestedExpression().cols() + block.startCol()
1448
+ : block.startCol() * block.nestedExpression().rows() + block.startRow())
1449
+ : 0) {}
1450
+
1027
1451
  typedef typename XprType::Scalar Scalar;
1028
1452
  typedef typename XprType::CoeffReturnType CoeffReturnType;
1029
1453
 
1030
1454
  enum {
1031
1455
  RowsAtCompileTime = XprType::RowsAtCompileTime,
1032
- ForwardLinearAccess = InnerPanel && bool(evaluator<ArgType>::Flags&LinearAccessBit)
1456
+ ForwardLinearAccess = (InnerPanel || int(XprType::IsRowMajor) == int(ArgType::IsRowMajor)) &&
1457
+ bool(evaluator<ArgType>::Flags & LinearAccessBit)
1033
1458
  };
1034
-
1035
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1036
- CoeffReturnType coeff(Index row, Index col) const
1037
- {
1038
- return m_argImpl.coeff(m_startRow.value() + row, m_startCol.value() + col);
1039
- }
1040
-
1041
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1042
- CoeffReturnType coeff(Index index) const
1043
- {
1459
+
1460
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const {
1461
+ return m_argImpl.coeff(m_startRow.value() + row, m_startCol.value() + col);
1462
+ }
1463
+
1464
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const {
1465
+ return linear_coeff_impl(index, bool_constant<ForwardLinearAccess>());
1466
+ }
1467
+
1468
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(Index row, Index col) {
1469
+ return m_argImpl.coeffRef(m_startRow.value() + row, m_startCol.value() + col);
1470
+ }
1471
+
1472
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(Index index) {
1473
+ return linear_coeffRef_impl(index, bool_constant<ForwardLinearAccess>());
1474
+ }
1475
+
1476
+ template <int LoadMode, typename PacketType>
1477
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(Index row, Index col) const {
1478
+ return m_argImpl.template packet<LoadMode, PacketType>(m_startRow.value() + row, m_startCol.value() + col);
1479
+ }
1480
+
1481
+ template <int LoadMode, typename PacketType>
1482
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(Index index) const {
1044
1483
  if (ForwardLinearAccess)
1045
- return m_argImpl.coeff(m_linear_offset.value() + index);
1484
+ return m_argImpl.template packet<LoadMode, PacketType>(m_linear_offset.value() + index);
1046
1485
  else
1047
- return coeff(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0);
1486
+ return packet<LoadMode, PacketType>(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0);
1048
1487
  }
1049
1488
 
1050
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1051
- Scalar& coeffRef(Index row, Index col)
1052
- {
1053
- return m_argImpl.coeffRef(m_startRow.value() + row, m_startCol.value() + col);
1489
+ template <int StoreMode, typename PacketType>
1490
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void writePacket(Index row, Index col, const PacketType& x) {
1491
+ return m_argImpl.template writePacket<StoreMode, PacketType>(m_startRow.value() + row, m_startCol.value() + col, x);
1054
1492
  }
1055
-
1056
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1057
- Scalar& coeffRef(Index index)
1058
- {
1493
+
1494
+ template <int StoreMode, typename PacketType>
1495
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void writePacket(Index index, const PacketType& x) {
1059
1496
  if (ForwardLinearAccess)
1060
- return m_argImpl.coeffRef(m_linear_offset.value() + index);
1497
+ return m_argImpl.template writePacket<StoreMode, PacketType>(m_linear_offset.value() + index, x);
1061
1498
  else
1062
- return coeffRef(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0);
1499
+ return writePacket<StoreMode, PacketType>(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0,
1500
+ x);
1063
1501
  }
1064
-
1065
- template<int LoadMode, typename PacketType>
1066
- EIGEN_STRONG_INLINE
1067
- PacketType packet(Index row, Index col) const
1068
- {
1069
- return m_argImpl.template packet<LoadMode,PacketType>(m_startRow.value() + row, m_startCol.value() + col);
1502
+
1503
+ template <int LoadMode, typename PacketType>
1504
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(Index row, Index col, Index begin, Index count) const {
1505
+ return m_argImpl.template packetSegment<LoadMode, PacketType>(m_startRow.value() + row, m_startCol.value() + col,
1506
+ begin, count);
1070
1507
  }
1071
1508
 
1072
- template<int LoadMode, typename PacketType>
1073
- EIGEN_STRONG_INLINE
1074
- PacketType packet(Index index) const
1075
- {
1509
+ template <int LoadMode, typename PacketType>
1510
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(Index index, Index begin, Index count) const {
1076
1511
  if (ForwardLinearAccess)
1077
- return m_argImpl.template packet<LoadMode,PacketType>(m_linear_offset.value() + index);
1512
+ return m_argImpl.template packetSegment<LoadMode, PacketType>(m_linear_offset.value() + index, begin, count);
1078
1513
  else
1079
- return packet<LoadMode,PacketType>(RowsAtCompileTime == 1 ? 0 : index,
1080
- RowsAtCompileTime == 1 ? index : 0);
1081
- }
1082
-
1083
- template<int StoreMode, typename PacketType>
1084
- EIGEN_STRONG_INLINE
1085
- void writePacket(Index row, Index col, const PacketType& x)
1086
- {
1087
- return m_argImpl.template writePacket<StoreMode,PacketType>(m_startRow.value() + row, m_startCol.value() + col, x);
1088
- }
1089
-
1090
- template<int StoreMode, typename PacketType>
1091
- EIGEN_STRONG_INLINE
1092
- void writePacket(Index index, const PacketType& x)
1093
- {
1514
+ return packetSegment<LoadMode, PacketType>(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0,
1515
+ begin, count);
1516
+ }
1517
+
1518
+ template <int StoreMode, typename PacketType>
1519
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void writePacketSegment(Index row, Index col, const PacketType& x, Index begin,
1520
+ Index count) {
1521
+ return m_argImpl.template writePacketSegment<StoreMode, PacketType>(m_startRow.value() + row,
1522
+ m_startCol.value() + col, x, begin, count);
1523
+ }
1524
+
1525
+ template <int StoreMode, typename PacketType>
1526
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void writePacketSegment(Index index, const PacketType& x, Index begin,
1527
+ Index count) {
1094
1528
  if (ForwardLinearAccess)
1095
- return m_argImpl.template writePacket<StoreMode,PacketType>(m_linear_offset.value() + index, x);
1529
+ return m_argImpl.template writePacketSegment<StoreMode, PacketType>(m_linear_offset.value() + index, x, begin,
1530
+ count);
1096
1531
  else
1097
- return writePacket<StoreMode,PacketType>(RowsAtCompileTime == 1 ? 0 : index,
1098
- RowsAtCompileTime == 1 ? index : 0,
1099
- x);
1532
+ return writePacketSegment<StoreMode, PacketType>(RowsAtCompileTime == 1 ? 0 : index,
1533
+ RowsAtCompileTime == 1 ? index : 0, x, begin, count);
1534
+ }
1535
+
1536
+ protected:
1537
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType
1538
+ linear_coeff_impl(Index index, internal::true_type /* ForwardLinearAccess */) const {
1539
+ return m_argImpl.coeff(m_linear_offset.value() + index);
1540
+ }
1541
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType
1542
+ linear_coeff_impl(Index index, internal::false_type /* not ForwardLinearAccess */) const {
1543
+ return coeff(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0);
1544
+ }
1545
+
1546
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& linear_coeffRef_impl(Index index,
1547
+ internal::true_type /* ForwardLinearAccess */) {
1548
+ return m_argImpl.coeffRef(m_linear_offset.value() + index);
1549
+ }
1550
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& linear_coeffRef_impl(
1551
+ Index index, internal::false_type /* not ForwardLinearAccess */) {
1552
+ return coeffRef(RowsAtCompileTime == 1 ? 0 : index, RowsAtCompileTime == 1 ? index : 0);
1100
1553
  }
1101
-
1102
- protected:
1554
+
1103
1555
  evaluator<ArgType> m_argImpl;
1104
- const variable_if_dynamic<Index, (ArgType::RowsAtCompileTime == 1 && BlockRows==1) ? 0 : Dynamic> m_startRow;
1105
- const variable_if_dynamic<Index, (ArgType::ColsAtCompileTime == 1 && BlockCols==1) ? 0 : Dynamic> m_startCol;
1106
- const variable_if_dynamic<Index, InnerPanel ? Dynamic : 0> m_linear_offset;
1556
+ const variable_if_dynamic<Index, (ArgType::RowsAtCompileTime == 1 && BlockRows == 1) ? 0 : Dynamic> m_startRow;
1557
+ const variable_if_dynamic<Index, (ArgType::ColsAtCompileTime == 1 && BlockCols == 1) ? 0 : Dynamic> m_startCol;
1558
+ const variable_if_dynamic<Index, ForwardLinearAccess ? Dynamic : 0> m_linear_offset;
1107
1559
  };
1108
1560
 
1109
- // TODO: This evaluator does not actually use the child evaluator;
1561
+ // TODO: This evaluator does not actually use the child evaluator;
1110
1562
  // all action is via the data() as returned by the Block expression.
1111
1563
 
1112
- template<typename ArgType, int BlockRows, int BlockCols, bool InnerPanel>
1564
+ template <typename ArgType, int BlockRows, int BlockCols, bool InnerPanel>
1113
1565
  struct block_evaluator<ArgType, BlockRows, BlockCols, InnerPanel, /* HasDirectAccess */ true>
1114
- : mapbase_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>,
1115
- typename Block<ArgType, BlockRows, BlockCols, InnerPanel>::PlainObject>
1116
- {
1566
+ : mapbase_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>,
1567
+ typename Block<ArgType, BlockRows, BlockCols, InnerPanel>::PlainObject> {
1117
1568
  typedef Block<ArgType, BlockRows, BlockCols, InnerPanel> XprType;
1118
1569
  typedef typename XprType::Scalar Scalar;
1119
1570
 
1120
- EIGEN_DEVICE_FUNC explicit block_evaluator(const XprType& block)
1121
- : mapbase_evaluator<XprType, typename XprType::PlainObject>(block)
1122
- {
1123
- // TODO: for the 3.3 release, this should be turned to an internal assertion, but let's keep it as is for the beta lifetime
1124
- eigen_assert(((internal::UIntPtr(block.data()) % EIGEN_PLAIN_ENUM_MAX(1,evaluator<XprType>::Alignment)) == 0) && "data is not aligned");
1571
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit block_evaluator(const XprType& block)
1572
+ : mapbase_evaluator<XprType, typename XprType::PlainObject>(block) {
1573
+ eigen_internal_assert((internal::is_constant_evaluated() ||
1574
+ (std::uintptr_t(block.data()) % plain_enum_max(1, evaluator<XprType>::Alignment)) == 0) &&
1575
+ "data is not aligned");
1125
1576
  }
1126
1577
  };
1127
1578
 
1128
-
1129
- // -------------------- Select --------------------
1130
- // NOTE shall we introduce a ternary_evaluator?
1131
-
1132
- // TODO enable vectorization for Select
1133
- template<typename ConditionMatrixType, typename ThenMatrixType, typename ElseMatrixType>
1134
- struct evaluator<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >
1135
- : evaluator_base<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >
1136
- {
1137
- typedef Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> XprType;
1138
- enum {
1139
- CoeffReadCost = evaluator<ConditionMatrixType>::CoeffReadCost
1140
- + EIGEN_PLAIN_ENUM_MAX(evaluator<ThenMatrixType>::CoeffReadCost,
1141
- evaluator<ElseMatrixType>::CoeffReadCost),
1142
-
1143
- Flags = (unsigned int)evaluator<ThenMatrixType>::Flags & evaluator<ElseMatrixType>::Flags & HereditaryBits,
1144
-
1145
- Alignment = EIGEN_PLAIN_ENUM_MIN(evaluator<ThenMatrixType>::Alignment, evaluator<ElseMatrixType>::Alignment)
1146
- };
1147
-
1148
- EIGEN_DEVICE_FUNC explicit evaluator(const XprType& select)
1149
- : m_conditionImpl(select.conditionMatrix()),
1150
- m_thenImpl(select.thenMatrix()),
1151
- m_elseImpl(select.elseMatrix())
1152
- {
1153
- EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
1154
- }
1155
-
1156
- typedef typename XprType::CoeffReturnType CoeffReturnType;
1157
-
1158
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1159
- CoeffReturnType coeff(Index row, Index col) const
1160
- {
1161
- if (m_conditionImpl.coeff(row, col))
1162
- return m_thenImpl.coeff(row, col);
1163
- else
1164
- return m_elseImpl.coeff(row, col);
1165
- }
1166
-
1167
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1168
- CoeffReturnType coeff(Index index) const
1169
- {
1170
- if (m_conditionImpl.coeff(index))
1171
- return m_thenImpl.coeff(index);
1172
- else
1173
- return m_elseImpl.coeff(index);
1174
- }
1175
-
1176
- protected:
1177
- evaluator<ConditionMatrixType> m_conditionImpl;
1178
- evaluator<ThenMatrixType> m_thenImpl;
1179
- evaluator<ElseMatrixType> m_elseImpl;
1180
- };
1181
-
1182
-
1183
1579
  // -------------------- Replicate --------------------
1184
1580
 
1185
- template<typename ArgType, int RowFactor, int ColFactor>
1186
- struct unary_evaluator<Replicate<ArgType, RowFactor, ColFactor> >
1187
- : evaluator_base<Replicate<ArgType, RowFactor, ColFactor> >
1188
- {
1581
+ template <typename ArgType, int RowFactor, int ColFactor>
1582
+ struct unary_evaluator<Replicate<ArgType, RowFactor, ColFactor>>
1583
+ : evaluator_base<Replicate<ArgType, RowFactor, ColFactor>> {
1189
1584
  typedef Replicate<ArgType, RowFactor, ColFactor> XprType;
1190
1585
  typedef typename XprType::CoeffReturnType CoeffReturnType;
1191
- enum {
1192
- Factor = (RowFactor==Dynamic || ColFactor==Dynamic) ? Dynamic : RowFactor*ColFactor
1193
- };
1194
- typedef typename internal::nested_eval<ArgType,Factor>::type ArgTypeNested;
1195
- typedef typename internal::remove_all<ArgTypeNested>::type ArgTypeNestedCleaned;
1196
-
1586
+ enum { Factor = (RowFactor == Dynamic || ColFactor == Dynamic) ? Dynamic : RowFactor * ColFactor };
1587
+ typedef typename nested_eval<ArgType, Factor>::type ArgTypeNested;
1588
+ typedef remove_all_t<ArgTypeNested> ArgTypeNestedCleaned;
1589
+
1197
1590
  enum {
1198
1591
  CoeffReadCost = evaluator<ArgTypeNestedCleaned>::CoeffReadCost,
1199
1592
  LinearAccessMask = XprType::IsVectorAtCompileTime ? LinearAccessBit : 0,
1200
- Flags = (evaluator<ArgTypeNestedCleaned>::Flags & (HereditaryBits|LinearAccessMask) & ~RowMajorBit) | (traits<XprType>::Flags & RowMajorBit),
1201
-
1593
+ Flags = (evaluator<ArgTypeNestedCleaned>::Flags & (HereditaryBits | LinearAccessMask) & ~RowMajorBit) |
1594
+ (traits<XprType>::Flags & RowMajorBit),
1595
+
1202
1596
  Alignment = evaluator<ArgTypeNestedCleaned>::Alignment
1203
1597
  };
1204
1598
 
1205
- EIGEN_DEVICE_FUNC explicit unary_evaluator(const XprType& replicate)
1206
- : m_arg(replicate.nestedExpression()),
1207
- m_argImpl(m_arg),
1208
- m_rows(replicate.nestedExpression().rows()),
1209
- m_cols(replicate.nestedExpression().cols())
1210
- {}
1211
-
1212
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1213
- CoeffReturnType coeff(Index row, Index col) const
1214
- {
1599
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit unary_evaluator(const XprType& replicate)
1600
+ : m_arg(replicate.nestedExpression()),
1601
+ m_argImpl(m_arg),
1602
+ m_rows(replicate.nestedExpression().rows()),
1603
+ m_cols(replicate.nestedExpression().cols()) {}
1604
+
1605
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const {
1215
1606
  // try to avoid using modulo; this is a pure optimization strategy
1216
- const Index actual_row = internal::traits<XprType>::RowsAtCompileTime==1 ? 0
1217
- : RowFactor==1 ? row
1218
- : row % m_rows.value();
1219
- const Index actual_col = internal::traits<XprType>::ColsAtCompileTime==1 ? 0
1220
- : ColFactor==1 ? col
1221
- : col % m_cols.value();
1222
-
1607
+ const Index actual_row = traits<XprType>::RowsAtCompileTime == 1 ? 0 : RowFactor == 1 ? row : row % m_rows.value();
1608
+ const Index actual_col = traits<XprType>::ColsAtCompileTime == 1 ? 0 : ColFactor == 1 ? col : col % m_cols.value();
1609
+
1223
1610
  return m_argImpl.coeff(actual_row, actual_col);
1224
1611
  }
1225
-
1226
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1227
- CoeffReturnType coeff(Index index) const
1228
- {
1612
+
1613
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const {
1229
1614
  // try to avoid using modulo; this is a pure optimization strategy
1230
- const Index actual_index = internal::traits<XprType>::RowsAtCompileTime==1
1231
- ? (ColFactor==1 ? index : index%m_cols.value())
1232
- : (RowFactor==1 ? index : index%m_rows.value());
1233
-
1615
+ const Index actual_index = traits<XprType>::RowsAtCompileTime == 1
1616
+ ? (ColFactor == 1 ? index : index % m_cols.value())
1617
+ : (RowFactor == 1 ? index : index % m_rows.value());
1618
+
1234
1619
  return m_argImpl.coeff(actual_index);
1235
1620
  }
1236
1621
 
1237
- template<int LoadMode, typename PacketType>
1238
- EIGEN_STRONG_INLINE
1239
- PacketType packet(Index row, Index col) const
1240
- {
1241
- const Index actual_row = internal::traits<XprType>::RowsAtCompileTime==1 ? 0
1242
- : RowFactor==1 ? row
1243
- : row % m_rows.value();
1244
- const Index actual_col = internal::traits<XprType>::ColsAtCompileTime==1 ? 0
1245
- : ColFactor==1 ? col
1246
- : col % m_cols.value();
1247
-
1248
- return m_argImpl.template packet<LoadMode,PacketType>(actual_row, actual_col);
1249
- }
1250
-
1251
- template<int LoadMode, typename PacketType>
1252
- EIGEN_STRONG_INLINE
1253
- PacketType packet(Index index) const
1254
- {
1255
- const Index actual_index = internal::traits<XprType>::RowsAtCompileTime==1
1256
- ? (ColFactor==1 ? index : index%m_cols.value())
1257
- : (RowFactor==1 ? index : index%m_rows.value());
1258
-
1259
- return m_argImpl.template packet<LoadMode,PacketType>(actual_index);
1260
- }
1261
-
1262
- protected:
1263
- const ArgTypeNested m_arg;
1264
- evaluator<ArgTypeNestedCleaned> m_argImpl;
1265
- const variable_if_dynamic<Index, ArgType::RowsAtCompileTime> m_rows;
1266
- const variable_if_dynamic<Index, ArgType::ColsAtCompileTime> m_cols;
1267
- };
1622
+ template <int LoadMode, typename PacketType>
1623
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(Index row, Index col) const {
1624
+ const Index actual_row = traits<XprType>::RowsAtCompileTime == 1 ? 0 : RowFactor == 1 ? row : row % m_rows.value();
1625
+ const Index actual_col = traits<XprType>::ColsAtCompileTime == 1 ? 0 : ColFactor == 1 ? col : col % m_cols.value();
1268
1626
 
1627
+ return m_argImpl.template packet<LoadMode, PacketType>(actual_row, actual_col);
1628
+ }
1269
1629
 
1270
- // -------------------- PartialReduxExpr --------------------
1630
+ template <int LoadMode, typename PacketType>
1631
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(Index index) const {
1632
+ const Index actual_index = traits<XprType>::RowsAtCompileTime == 1
1633
+ ? (ColFactor == 1 ? index : index % m_cols.value())
1634
+ : (RowFactor == 1 ? index : index % m_rows.value());
1271
1635
 
1272
- template< typename ArgType, typename MemberOp, int Direction>
1273
- struct evaluator<PartialReduxExpr<ArgType, MemberOp, Direction> >
1274
- : evaluator_base<PartialReduxExpr<ArgType, MemberOp, Direction> >
1275
- {
1276
- typedef PartialReduxExpr<ArgType, MemberOp, Direction> XprType;
1277
- typedef typename internal::nested_eval<ArgType,1>::type ArgTypeNested;
1278
- typedef typename internal::remove_all<ArgTypeNested>::type ArgTypeNestedCleaned;
1279
- typedef typename ArgType::Scalar InputScalar;
1280
- typedef typename XprType::Scalar Scalar;
1281
- enum {
1282
- TraversalSize = Direction==int(Vertical) ? int(ArgType::RowsAtCompileTime) : int(ArgType::ColsAtCompileTime)
1283
- };
1284
- typedef typename MemberOp::template Cost<InputScalar,int(TraversalSize)> CostOpType;
1285
- enum {
1286
- CoeffReadCost = TraversalSize==Dynamic ? HugeCost
1287
- : TraversalSize * evaluator<ArgType>::CoeffReadCost + int(CostOpType::value),
1288
-
1289
- Flags = (traits<XprType>::Flags&RowMajorBit) | (evaluator<ArgType>::Flags&(HereditaryBits&(~RowMajorBit))) | LinearAccessBit,
1290
-
1291
- Alignment = 0 // FIXME this will need to be improved once PartialReduxExpr is vectorized
1292
- };
1293
-
1294
- EIGEN_DEVICE_FUNC explicit evaluator(const XprType xpr)
1295
- : m_arg(xpr.nestedExpression()), m_functor(xpr.functor())
1296
- {
1297
- EIGEN_INTERNAL_CHECK_COST_VALUE(TraversalSize==Dynamic ? HugeCost : int(CostOpType::value));
1298
- EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost);
1636
+ return m_argImpl.template packet<LoadMode, PacketType>(actual_index);
1299
1637
  }
1300
1638
 
1301
- typedef typename XprType::CoeffReturnType CoeffReturnType;
1639
+ template <int LoadMode, typename PacketType>
1640
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(Index row, Index col, Index begin, Index count) const {
1641
+ const Index actual_row = traits<XprType>::RowsAtCompileTime == 1 ? 0 : RowFactor == 1 ? row : row % m_rows.value();
1642
+ const Index actual_col = traits<XprType>::ColsAtCompileTime == 1 ? 0 : ColFactor == 1 ? col : col % m_cols.value();
1302
1643
 
1303
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1304
- const Scalar coeff(Index i, Index j) const
1305
- {
1306
- if (Direction==Vertical)
1307
- return m_functor(m_arg.col(j));
1308
- else
1309
- return m_functor(m_arg.row(i));
1644
+ return m_argImpl.template packetSegment<LoadMode, PacketType>(actual_row, actual_col, begin, count);
1310
1645
  }
1311
1646
 
1312
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1313
- const Scalar coeff(Index index) const
1314
- {
1315
- if (Direction==Vertical)
1316
- return m_functor(m_arg.col(index));
1317
- else
1318
- return m_functor(m_arg.row(index));
1647
+ template <int LoadMode, typename PacketType>
1648
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(Index index, Index begin, Index count) const {
1649
+ const Index actual_index = traits<XprType>::RowsAtCompileTime == 1
1650
+ ? (ColFactor == 1 ? index : index % m_cols.value())
1651
+ : (RowFactor == 1 ? index : index % m_rows.value());
1652
+
1653
+ return m_argImpl.template packetSegment<LoadMode, PacketType>(actual_index, begin, count);
1319
1654
  }
1320
1655
 
1321
- protected:
1322
- typename internal::add_const_on_value_type<ArgTypeNested>::type m_arg;
1323
- const MemberOp m_functor;
1656
+ protected:
1657
+ const ArgTypeNested m_arg;
1658
+ evaluator<ArgTypeNestedCleaned> m_argImpl;
1659
+ const variable_if_dynamic<Index, ArgType::RowsAtCompileTime> m_rows;
1660
+ const variable_if_dynamic<Index, ArgType::ColsAtCompileTime> m_cols;
1324
1661
  };
1325
1662
 
1326
-
1327
1663
  // -------------------- MatrixWrapper and ArrayWrapper --------------------
1328
1664
  //
1329
1665
  // evaluator_wrapper_base<T> is a common base class for the
1330
1666
  // MatrixWrapper and ArrayWrapper evaluators.
1331
1667
 
1332
- template<typename XprType>
1333
- struct evaluator_wrapper_base
1334
- : evaluator_base<XprType>
1335
- {
1336
- typedef typename remove_all<typename XprType::NestedExpressionType>::type ArgType;
1668
+ template <typename XprType>
1669
+ struct evaluator_wrapper_base : evaluator_base<XprType> {
1670
+ typedef remove_all_t<typename XprType::NestedExpressionType> ArgType;
1337
1671
  enum {
1338
1672
  CoeffReadCost = evaluator<ArgType>::CoeffReadCost,
1339
1673
  Flags = evaluator<ArgType>::Flags,
1340
1674
  Alignment = evaluator<ArgType>::Alignment
1341
1675
  };
1342
1676
 
1343
- EIGEN_DEVICE_FUNC explicit evaluator_wrapper_base(const ArgType& arg) : m_argImpl(arg) {}
1677
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit evaluator_wrapper_base(const ArgType& arg) : m_argImpl(arg) {}
1344
1678
 
1345
1679
  typedef typename ArgType::Scalar Scalar;
1346
1680
  typedef typename ArgType::CoeffReturnType CoeffReturnType;
1347
1681
 
1348
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1349
- CoeffReturnType coeff(Index row, Index col) const
1350
- {
1682
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const {
1351
1683
  return m_argImpl.coeff(row, col);
1352
1684
  }
1353
1685
 
1354
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1355
- CoeffReturnType coeff(Index index) const
1356
- {
1357
- return m_argImpl.coeff(index);
1686
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const { return m_argImpl.coeff(index); }
1687
+
1688
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(Index row, Index col) { return m_argImpl.coeffRef(row, col); }
1689
+
1690
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(Index index) { return m_argImpl.coeffRef(index); }
1691
+
1692
+ template <int LoadMode, typename PacketType>
1693
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(Index row, Index col) const {
1694
+ return m_argImpl.template packet<LoadMode, PacketType>(row, col);
1358
1695
  }
1359
1696
 
1360
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1361
- Scalar& coeffRef(Index row, Index col)
1362
- {
1363
- return m_argImpl.coeffRef(row, col);
1697
+ template <int LoadMode, typename PacketType>
1698
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(Index index) const {
1699
+ return m_argImpl.template packet<LoadMode, PacketType>(index);
1364
1700
  }
1365
1701
 
1366
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1367
- Scalar& coeffRef(Index index)
1368
- {
1369
- return m_argImpl.coeffRef(index);
1702
+ template <int StoreMode, typename PacketType>
1703
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void writePacket(Index row, Index col, const PacketType& x) {
1704
+ m_argImpl.template writePacket<StoreMode>(row, col, x);
1370
1705
  }
1371
1706
 
1372
- template<int LoadMode, typename PacketType>
1373
- EIGEN_STRONG_INLINE
1374
- PacketType packet(Index row, Index col) const
1375
- {
1376
- return m_argImpl.template packet<LoadMode,PacketType>(row, col);
1707
+ template <int StoreMode, typename PacketType>
1708
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void writePacket(Index index, const PacketType& x) {
1709
+ m_argImpl.template writePacket<StoreMode>(index, x);
1377
1710
  }
1378
1711
 
1379
- template<int LoadMode, typename PacketType>
1380
- EIGEN_STRONG_INLINE
1381
- PacketType packet(Index index) const
1382
- {
1383
- return m_argImpl.template packet<LoadMode,PacketType>(index);
1712
+ template <int LoadMode, typename PacketType>
1713
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(Index row, Index col, Index begin, Index count) const {
1714
+ return m_argImpl.template packetSegment<LoadMode, PacketType>(row, col, begin, count);
1384
1715
  }
1385
1716
 
1386
- template<int StoreMode, typename PacketType>
1387
- EIGEN_STRONG_INLINE
1388
- void writePacket(Index row, Index col, const PacketType& x)
1389
- {
1390
- m_argImpl.template writePacket<StoreMode>(row, col, x);
1717
+ template <int LoadMode, typename PacketType>
1718
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(Index index, Index begin, Index count) const {
1719
+ return m_argImpl.template packetSegment<LoadMode, PacketType>(index, begin, count);
1391
1720
  }
1392
1721
 
1393
- template<int StoreMode, typename PacketType>
1394
- EIGEN_STRONG_INLINE
1395
- void writePacket(Index index, const PacketType& x)
1396
- {
1397
- m_argImpl.template writePacket<StoreMode>(index, x);
1722
+ template <int StoreMode, typename PacketType>
1723
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void writePacketSegment(Index row, Index col, const PacketType& x, Index begin,
1724
+ Index count) {
1725
+ m_argImpl.template writePacketSegment<StoreMode>(row, col, x, begin, count);
1726
+ }
1727
+
1728
+ template <int StoreMode, typename PacketType>
1729
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void writePacketSegment(Index index, const PacketType& x, Index begin,
1730
+ Index count) {
1731
+ m_argImpl.template writePacketSegment<StoreMode>(index, x, begin, count);
1398
1732
  }
1399
1733
 
1400
- protected:
1734
+ protected:
1401
1735
  evaluator<ArgType> m_argImpl;
1402
1736
  };
1403
1737
 
1404
- template<typename TArgType>
1405
- struct unary_evaluator<MatrixWrapper<TArgType> >
1406
- : evaluator_wrapper_base<MatrixWrapper<TArgType> >
1407
- {
1738
+ template <typename TArgType>
1739
+ struct unary_evaluator<MatrixWrapper<TArgType>> : evaluator_wrapper_base<MatrixWrapper<TArgType>> {
1408
1740
  typedef MatrixWrapper<TArgType> XprType;
1409
1741
 
1410
- EIGEN_DEVICE_FUNC explicit unary_evaluator(const XprType& wrapper)
1411
- : evaluator_wrapper_base<MatrixWrapper<TArgType> >(wrapper.nestedExpression())
1412
- { }
1742
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit unary_evaluator(const XprType& wrapper)
1743
+ : evaluator_wrapper_base<MatrixWrapper<TArgType>>(wrapper.nestedExpression()) {}
1413
1744
  };
1414
1745
 
1415
- template<typename TArgType>
1416
- struct unary_evaluator<ArrayWrapper<TArgType> >
1417
- : evaluator_wrapper_base<ArrayWrapper<TArgType> >
1418
- {
1746
+ template <typename TArgType>
1747
+ struct unary_evaluator<ArrayWrapper<TArgType>> : evaluator_wrapper_base<ArrayWrapper<TArgType>> {
1419
1748
  typedef ArrayWrapper<TArgType> XprType;
1420
1749
 
1421
- EIGEN_DEVICE_FUNC explicit unary_evaluator(const XprType& wrapper)
1422
- : evaluator_wrapper_base<ArrayWrapper<TArgType> >(wrapper.nestedExpression())
1423
- { }
1750
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit unary_evaluator(const XprType& wrapper)
1751
+ : evaluator_wrapper_base<ArrayWrapper<TArgType>>(wrapper.nestedExpression()) {}
1424
1752
  };
1425
1753
 
1426
-
1427
1754
  // -------------------- Reverse --------------------
1428
1755
 
1429
1756
  // defined in Reverse.h:
1430
- template<typename PacketType, bool ReversePacket> struct reverse_packet_cond;
1757
+ template <typename PacketType, bool ReversePacket>
1758
+ struct reverse_packet_cond;
1431
1759
 
1432
- template<typename ArgType, int Direction>
1433
- struct unary_evaluator<Reverse<ArgType, Direction> >
1434
- : evaluator_base<Reverse<ArgType, Direction> >
1435
- {
1760
+ template <typename ArgType, int Direction>
1761
+ struct unary_evaluator<Reverse<ArgType, Direction>> : evaluator_base<Reverse<ArgType, Direction>> {
1436
1762
  typedef Reverse<ArgType, Direction> XprType;
1437
1763
  typedef typename XprType::Scalar Scalar;
1438
1764
  typedef typename XprType::CoeffReturnType CoeffReturnType;
@@ -1440,108 +1766,144 @@ struct unary_evaluator<Reverse<ArgType, Direction> >
1440
1766
  enum {
1441
1767
  IsRowMajor = XprType::IsRowMajor,
1442
1768
  IsColMajor = !IsRowMajor,
1443
- ReverseRow = (Direction == Vertical) || (Direction == BothDirections),
1769
+ ReverseRow = (Direction == Vertical) || (Direction == BothDirections),
1444
1770
  ReverseCol = (Direction == Horizontal) || (Direction == BothDirections),
1445
- ReversePacket = (Direction == BothDirections)
1446
- || ((Direction == Vertical) && IsColMajor)
1447
- || ((Direction == Horizontal) && IsRowMajor),
1448
-
1771
+ ReversePacket = (Direction == BothDirections) || ((Direction == Vertical) && IsColMajor) ||
1772
+ ((Direction == Horizontal) && IsRowMajor),
1773
+
1449
1774
  CoeffReadCost = evaluator<ArgType>::CoeffReadCost,
1450
-
1775
+
1451
1776
  // let's enable LinearAccess only with vectorization because of the product overhead
1452
1777
  // FIXME enable DirectAccess with negative strides?
1453
1778
  Flags0 = evaluator<ArgType>::Flags,
1454
- LinearAccess = ( (Direction==BothDirections) && (int(Flags0)&PacketAccessBit) )
1455
- || ((ReverseRow && XprType::ColsAtCompileTime==1) || (ReverseCol && XprType::RowsAtCompileTime==1))
1456
- ? LinearAccessBit : 0,
1779
+ LinearAccess =
1780
+ ((Direction == BothDirections) && (int(Flags0) & PacketAccessBit)) ||
1781
+ ((ReverseRow && XprType::ColsAtCompileTime == 1) || (ReverseCol && XprType::RowsAtCompileTime == 1))
1782
+ ? LinearAccessBit
1783
+ : 0,
1457
1784
 
1458
1785
  Flags = int(Flags0) & (HereditaryBits | PacketAccessBit | LinearAccess),
1459
-
1460
- Alignment = 0 // FIXME in some rare cases, Alignment could be preserved, like a Vector4f.
1786
+
1787
+ Alignment = 0 // FIXME in some rare cases, Alignment could be preserved, like a Vector4f.
1461
1788
  };
1462
1789
 
1463
- EIGEN_DEVICE_FUNC explicit unary_evaluator(const XprType& reverse)
1464
- : m_argImpl(reverse.nestedExpression()),
1465
- m_rows(ReverseRow ? reverse.nestedExpression().rows() : 1),
1466
- m_cols(ReverseCol ? reverse.nestedExpression().cols() : 1)
1467
- { }
1468
-
1469
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1470
- CoeffReturnType coeff(Index row, Index col) const
1471
- {
1472
- return m_argImpl.coeff(ReverseRow ? m_rows.value() - row - 1 : row,
1473
- ReverseCol ? m_cols.value() - col - 1 : col);
1474
- }
1475
-
1476
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1477
- CoeffReturnType coeff(Index index) const
1478
- {
1790
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit unary_evaluator(const XprType& reverse)
1791
+ : m_argImpl(reverse.nestedExpression()),
1792
+ m_rows(ReverseRow ? reverse.nestedExpression().rows() : 1),
1793
+ m_cols(ReverseCol ? reverse.nestedExpression().cols() : 1) {}
1794
+
1795
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index col) const {
1796
+ return m_argImpl.coeff(ReverseRow ? m_rows.value() - row - 1 : row, ReverseCol ? m_cols.value() - col - 1 : col);
1797
+ }
1798
+
1799
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const {
1479
1800
  return m_argImpl.coeff(m_rows.value() * m_cols.value() - index - 1);
1480
1801
  }
1481
1802
 
1482
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1483
- Scalar& coeffRef(Index row, Index col)
1484
- {
1485
- return m_argImpl.coeffRef(ReverseRow ? m_rows.value() - row - 1 : row,
1486
- ReverseCol ? m_cols.value() - col - 1 : col);
1803
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(Index row, Index col) {
1804
+ return m_argImpl.coeffRef(ReverseRow ? m_rows.value() - row - 1 : row, ReverseCol ? m_cols.value() - col - 1 : col);
1487
1805
  }
1488
1806
 
1489
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1490
- Scalar& coeffRef(Index index)
1491
- {
1807
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(Index index) {
1492
1808
  return m_argImpl.coeffRef(m_rows.value() * m_cols.value() - index - 1);
1493
1809
  }
1494
1810
 
1495
- template<int LoadMode, typename PacketType>
1496
- EIGEN_STRONG_INLINE
1497
- PacketType packet(Index row, Index col) const
1498
- {
1499
- enum {
1500
- PacketSize = unpacket_traits<PacketType>::size,
1501
- OffsetRow = ReverseRow && IsColMajor ? PacketSize : 1,
1502
- OffsetCol = ReverseCol && IsRowMajor ? PacketSize : 1
1503
- };
1504
- typedef internal::reverse_packet_cond<PacketType,ReversePacket> reverse_packet;
1505
- return reverse_packet::run(m_argImpl.template packet<LoadMode,PacketType>(
1506
- ReverseRow ? m_rows.value() - row - OffsetRow : row,
1507
- ReverseCol ? m_cols.value() - col - OffsetCol : col));
1508
- }
1509
-
1510
- template<int LoadMode, typename PacketType>
1511
- EIGEN_STRONG_INLINE
1512
- PacketType packet(Index index) const
1513
- {
1514
- enum { PacketSize = unpacket_traits<PacketType>::size };
1515
- return preverse(m_argImpl.template packet<LoadMode,PacketType>(m_rows.value() * m_cols.value() - index - PacketSize));
1516
- }
1517
-
1518
- template<int LoadMode, typename PacketType>
1519
- EIGEN_STRONG_INLINE
1520
- void writePacket(Index row, Index col, const PacketType& x)
1521
- {
1522
- // FIXME we could factorize some code with packet(i,j)
1523
- enum {
1524
- PacketSize = unpacket_traits<PacketType>::size,
1525
- OffsetRow = ReverseRow && IsColMajor ? PacketSize : 1,
1526
- OffsetCol = ReverseCol && IsRowMajor ? PacketSize : 1
1527
- };
1528
- typedef internal::reverse_packet_cond<PacketType,ReversePacket> reverse_packet;
1529
- m_argImpl.template writePacket<LoadMode>(
1530
- ReverseRow ? m_rows.value() - row - OffsetRow : row,
1531
- ReverseCol ? m_cols.value() - col - OffsetCol : col,
1532
- reverse_packet::run(x));
1533
- }
1534
-
1535
- template<int LoadMode, typename PacketType>
1536
- EIGEN_STRONG_INLINE
1537
- void writePacket(Index index, const PacketType& x)
1538
- {
1539
- enum { PacketSize = unpacket_traits<PacketType>::size };
1540
- m_argImpl.template writePacket<LoadMode>
1541
- (m_rows.value() * m_cols.value() - index - PacketSize, preverse(x));
1542
- }
1543
-
1544
- protected:
1811
+ template <int LoadMode, typename PacketType>
1812
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(Index row, Index col) const {
1813
+ static constexpr int PacketSize = unpacket_traits<PacketType>::size;
1814
+ static constexpr int OffsetRow = ReverseRow && IsColMajor ? PacketSize : 1;
1815
+ static constexpr int OffsetCol = ReverseCol && IsRowMajor ? PacketSize : 1;
1816
+ using reverse_packet = reverse_packet_cond<PacketType, ReversePacket>;
1817
+
1818
+ Index actualRow = ReverseRow ? m_rows.value() - row - OffsetRow : row;
1819
+ Index actualCol = ReverseCol ? m_cols.value() - col - OffsetCol : col;
1820
+
1821
+ return reverse_packet::run(m_argImpl.template packet<LoadMode, PacketType>(actualRow, actualCol));
1822
+ }
1823
+
1824
+ template <int LoadMode, typename PacketType>
1825
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packet(Index index) const {
1826
+ static constexpr int PacketSize = unpacket_traits<PacketType>::size;
1827
+
1828
+ Index actualIndex = m_rows.value() * m_cols.value() - index - PacketSize;
1829
+
1830
+ return preverse(m_argImpl.template packet<LoadMode, PacketType>(actualIndex));
1831
+ }
1832
+
1833
+ template <int LoadMode, typename PacketType>
1834
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void writePacket(Index row, Index col, const PacketType& x) {
1835
+ static constexpr int PacketSize = unpacket_traits<PacketType>::size;
1836
+ static constexpr int OffsetRow = ReverseRow && IsColMajor ? PacketSize : 1;
1837
+ static constexpr int OffsetCol = ReverseCol && IsRowMajor ? PacketSize : 1;
1838
+ using reverse_packet = reverse_packet_cond<PacketType, ReversePacket>;
1839
+
1840
+ Index actualRow = ReverseRow ? m_rows.value() - row - OffsetRow : row;
1841
+ Index actualCol = ReverseCol ? m_cols.value() - col - OffsetCol : col;
1842
+
1843
+ m_argImpl.template writePacket<LoadMode>(actualRow, actualCol, reverse_packet::run(x));
1844
+ }
1845
+
1846
+ template <int LoadMode, typename PacketType>
1847
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void writePacket(Index index, const PacketType& x) {
1848
+ static constexpr int PacketSize = unpacket_traits<PacketType>::size;
1849
+
1850
+ Index actualIndex = m_rows.value() * m_cols.value() - index - PacketSize;
1851
+
1852
+ m_argImpl.template writePacket<LoadMode>(actualIndex, preverse(x));
1853
+ }
1854
+
1855
+ template <int LoadMode, typename PacketType>
1856
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(Index row, Index col, Index begin, Index count) const {
1857
+ static constexpr int PacketSize = unpacket_traits<PacketType>::size;
1858
+ static constexpr int OffsetRow = ReverseRow && IsColMajor ? PacketSize : 1;
1859
+ static constexpr int OffsetCol = ReverseCol && IsRowMajor ? PacketSize : 1;
1860
+ using reverse_packet = reverse_packet_cond<PacketType, ReversePacket>;
1861
+
1862
+ Index actualRow = ReverseRow ? m_rows.value() - row - OffsetRow : row;
1863
+ Index actualCol = ReverseCol ? m_cols.value() - col - OffsetCol : col;
1864
+ Index actualBegin = ReversePacket ? (PacketSize - count - begin) : begin;
1865
+
1866
+ return reverse_packet::run(
1867
+ m_argImpl.template packetSegment<LoadMode, PacketType>(actualRow, actualCol, actualBegin, count));
1868
+ }
1869
+
1870
+ template <int LoadMode, typename PacketType>
1871
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketType packetSegment(Index index, Index begin, Index count) const {
1872
+ static constexpr int PacketSize = unpacket_traits<PacketType>::size;
1873
+
1874
+ Index actualIndex = m_rows.value() * m_cols.value() - index - PacketSize;
1875
+ Index actualBegin = PacketSize - count - begin;
1876
+
1877
+ return preverse(m_argImpl.template packetSegment<LoadMode, PacketType>(actualIndex, actualBegin, count));
1878
+ }
1879
+
1880
+ template <int LoadMode, typename PacketType>
1881
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void writePacketSegment(Index row, Index col, const PacketType& x, Index begin,
1882
+ Index count) {
1883
+ static constexpr int PacketSize = unpacket_traits<PacketType>::size;
1884
+ static constexpr int OffsetRow = ReverseRow && IsColMajor ? PacketSize : 1;
1885
+ static constexpr int OffsetCol = ReverseCol && IsRowMajor ? PacketSize : 1;
1886
+ using reverse_packet = reverse_packet_cond<PacketType, ReversePacket>;
1887
+
1888
+ Index actualRow = ReverseRow ? m_rows.value() - row - OffsetRow : row;
1889
+ Index actualCol = ReverseCol ? m_cols.value() - col - OffsetCol : col;
1890
+ Index actualBegin = ReversePacket ? (PacketSize - count - begin) : begin;
1891
+
1892
+ m_argImpl.template writePacketSegment<LoadMode>(actualRow, actualCol, reverse_packet::run(x), actualBegin, count);
1893
+ }
1894
+
1895
+ template <int LoadMode, typename PacketType>
1896
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void writePacketSegment(Index index, const PacketType& x, Index begin,
1897
+ Index count) {
1898
+ static constexpr int PacketSize = unpacket_traits<PacketType>::size;
1899
+
1900
+ Index actualIndex = m_rows.value() * m_cols.value() - index - PacketSize;
1901
+ Index actualBegin = PacketSize - count - begin;
1902
+
1903
+ m_argImpl.template writePacketSegment<LoadMode>(actualIndex, preverse(x), actualBegin, count);
1904
+ }
1905
+
1906
+ protected:
1545
1907
  evaluator<ArgType> m_argImpl;
1546
1908
 
1547
1909
  // If we do not reverse rows, then we do not need to know the number of rows; same for columns
@@ -1550,65 +1912,56 @@ protected:
1550
1912
  const variable_if_dynamic<Index, ReverseCol ? ArgType::ColsAtCompileTime : 1> m_cols;
1551
1913
  };
1552
1914
 
1553
-
1554
1915
  // -------------------- Diagonal --------------------
1555
1916
 
1556
- template<typename ArgType, int DiagIndex>
1557
- struct evaluator<Diagonal<ArgType, DiagIndex> >
1558
- : evaluator_base<Diagonal<ArgType, DiagIndex> >
1559
- {
1917
+ template <typename ArgType, int DiagIndex>
1918
+ struct evaluator<Diagonal<ArgType, DiagIndex>> : evaluator_base<Diagonal<ArgType, DiagIndex>> {
1560
1919
  typedef Diagonal<ArgType, DiagIndex> XprType;
1561
-
1920
+
1562
1921
  enum {
1563
1922
  CoeffReadCost = evaluator<ArgType>::CoeffReadCost,
1564
-
1565
- Flags = (unsigned int)(evaluator<ArgType>::Flags & (HereditaryBits | DirectAccessBit) & ~RowMajorBit) | LinearAccessBit,
1566
-
1923
+
1924
+ Flags =
1925
+ (unsigned int)(evaluator<ArgType>::Flags & (HereditaryBits | DirectAccessBit) & ~RowMajorBit) | LinearAccessBit,
1926
+
1567
1927
  Alignment = 0
1568
1928
  };
1569
1929
 
1570
- EIGEN_DEVICE_FUNC explicit evaluator(const XprType& diagonal)
1571
- : m_argImpl(diagonal.nestedExpression()),
1572
- m_index(diagonal.index())
1573
- { }
1574
-
1930
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit evaluator(const XprType& diagonal)
1931
+ : m_argImpl(diagonal.nestedExpression()), m_index(diagonal.index()) {}
1932
+
1575
1933
  typedef typename XprType::Scalar Scalar;
1576
1934
  typedef typename XprType::CoeffReturnType CoeffReturnType;
1577
1935
 
1578
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1579
- CoeffReturnType coeff(Index row, Index) const
1580
- {
1936
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index row, Index) const {
1581
1937
  return m_argImpl.coeff(row + rowOffset(), row + colOffset());
1582
1938
  }
1583
1939
 
1584
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1585
- CoeffReturnType coeff(Index index) const
1586
- {
1940
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const {
1587
1941
  return m_argImpl.coeff(index + rowOffset(), index + colOffset());
1588
1942
  }
1589
1943
 
1590
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1591
- Scalar& coeffRef(Index row, Index)
1592
- {
1944
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(Index row, Index) {
1593
1945
  return m_argImpl.coeffRef(row + rowOffset(), row + colOffset());
1594
1946
  }
1595
1947
 
1596
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
1597
- Scalar& coeffRef(Index index)
1598
- {
1948
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(Index index) {
1599
1949
  return m_argImpl.coeffRef(index + rowOffset(), index + colOffset());
1600
1950
  }
1601
1951
 
1602
- protected:
1952
+ protected:
1603
1953
  evaluator<ArgType> m_argImpl;
1604
- const internal::variable_if_dynamicindex<Index, XprType::DiagIndex> m_index;
1954
+ const variable_if_dynamicindex<Index, XprType::DiagIndex> m_index;
1605
1955
 
1606
- private:
1607
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index rowOffset() const { return m_index.value() > 0 ? 0 : -m_index.value(); }
1608
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index colOffset() const { return m_index.value() > 0 ? m_index.value() : 0; }
1956
+ private:
1957
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr Index rowOffset() const {
1958
+ return m_index.value() > 0 ? 0 : -m_index.value();
1959
+ }
1960
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr Index colOffset() const {
1961
+ return m_index.value() > 0 ? m_index.value() : 0;
1962
+ }
1609
1963
  };
1610
1964
 
1611
-
1612
1965
  //----------------------------------------------------------------------
1613
1966
  // deprecated code
1614
1967
  //----------------------------------------------------------------------
@@ -1617,72 +1970,49 @@ private:
1617
1970
 
1618
1971
  // expression class for evaluating nested expression to a temporary
1619
1972
 
1620
- template<typename ArgType> class EvalToTemp;
1973
+ template <typename ArgType>
1974
+ class EvalToTemp;
1621
1975
 
1622
- template<typename ArgType>
1623
- struct traits<EvalToTemp<ArgType> >
1624
- : public traits<ArgType>
1625
- { };
1976
+ template <typename ArgType>
1977
+ struct traits<EvalToTemp<ArgType>> : public traits<ArgType> {};
1626
1978
 
1627
- template<typename ArgType>
1628
- class EvalToTemp
1629
- : public dense_xpr_base<EvalToTemp<ArgType> >::type
1630
- {
1979
+ template <typename ArgType>
1980
+ class EvalToTemp : public dense_xpr_base<EvalToTemp<ArgType>>::type {
1631
1981
  public:
1632
-
1633
1982
  typedef typename dense_xpr_base<EvalToTemp>::type Base;
1634
1983
  EIGEN_GENERIC_PUBLIC_INTERFACE(EvalToTemp)
1635
-
1636
- explicit EvalToTemp(const ArgType& arg)
1637
- : m_arg(arg)
1638
- { }
1639
-
1640
- const ArgType& arg() const
1641
- {
1642
- return m_arg;
1643
- }
1644
1984
 
1645
- Index rows() const
1646
- {
1647
- return m_arg.rows();
1648
- }
1985
+ explicit EvalToTemp(const ArgType& arg) : m_arg(arg) {}
1649
1986
 
1650
- Index cols() const
1651
- {
1652
- return m_arg.cols();
1653
- }
1987
+ const ArgType& arg() const { return m_arg; }
1988
+
1989
+ constexpr Index rows() const noexcept { return m_arg.rows(); }
1990
+
1991
+ constexpr Index cols() const noexcept { return m_arg.cols(); }
1654
1992
 
1655
1993
  private:
1656
1994
  const ArgType& m_arg;
1657
1995
  };
1658
-
1659
- template<typename ArgType>
1660
- struct evaluator<EvalToTemp<ArgType> >
1661
- : public evaluator<typename ArgType::PlainObject>
1662
- {
1663
- typedef EvalToTemp<ArgType> XprType;
1664
- typedef typename ArgType::PlainObject PlainObject;
1996
+
1997
+ template <typename ArgType>
1998
+ struct evaluator<EvalToTemp<ArgType>> : public evaluator<typename ArgType::PlainObject> {
1999
+ typedef EvalToTemp<ArgType> XprType;
2000
+ typedef typename ArgType::PlainObject PlainObject;
1665
2001
  typedef evaluator<PlainObject> Base;
1666
-
1667
- EIGEN_DEVICE_FUNC explicit evaluator(const XprType& xpr)
1668
- : m_result(xpr.arg())
1669
- {
1670
- ::new (static_cast<Base*>(this)) Base(m_result);
2002
+
2003
+ EIGEN_DEVICE_FUNC explicit evaluator(const XprType& xpr) : m_result(xpr.arg()) {
2004
+ internal::construct_at<Base>(this, m_result);
1671
2005
  }
1672
2006
 
1673
2007
  // This constructor is used when nesting an EvalTo evaluator in another evaluator
1674
- EIGEN_DEVICE_FUNC evaluator(const ArgType& arg)
1675
- : m_result(arg)
1676
- {
1677
- ::new (static_cast<Base*>(this)) Base(m_result);
1678
- }
2008
+ EIGEN_DEVICE_FUNC evaluator(const ArgType& arg) : m_result(arg) { internal::construct_at<Base>(this, m_result); }
1679
2009
 
1680
- protected:
2010
+ protected:
1681
2011
  PlainObject m_result;
1682
2012
  };
1683
2013
 
1684
- } // namespace internal
2014
+ } // namespace internal
1685
2015
 
1686
- } // end namespace Eigen
2016
+ } // end namespace Eigen
1687
2017
 
1688
- #endif // EIGEN_COREEVALUATORS_H
2018
+ #endif // EIGEN_COREEVALUATORS_H