@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
@@ -10,30 +10,29 @@
10
10
 
11
11
  #ifndef EIGEN_QUATERNION_H
12
12
  #define EIGEN_QUATERNION_H
13
- namespace Eigen {
13
+ // IWYU pragma: private
14
+ #include "./InternalHeaderCheck.h"
14
15
 
16
+ namespace Eigen {
15
17
 
16
18
  /***************************************************************************
17
- * Definition of QuaternionBase<Derived>
18
- * The implementation is at the end of the file
19
- ***************************************************************************/
19
+ * Definition of QuaternionBase<Derived>
20
+ * The implementation is at the end of the file
21
+ ***************************************************************************/
20
22
 
21
23
  namespace internal {
22
- template<typename Other,
23
- int OtherRows=Other::RowsAtCompileTime,
24
- int OtherCols=Other::ColsAtCompileTime>
24
+ template <typename Other, int OtherRows = Other::RowsAtCompileTime, int OtherCols = Other::ColsAtCompileTime>
25
25
  struct quaternionbase_assign_impl;
26
26
  }
27
27
 
28
28
  /** \geometry_module \ingroup Geometry_Module
29
- * \class QuaternionBase
30
- * \brief Base class for quaternion expressions
31
- * \tparam Derived derived type (CRTP)
32
- * \sa class Quaternion
33
- */
34
- template<class Derived>
35
- class QuaternionBase : public RotationBase<Derived, 3>
36
- {
29
+ * \class QuaternionBase
30
+ * \brief Base class for quaternion expressions
31
+ * \tparam Derived derived type (CRTP)
32
+ * \sa class Quaternion
33
+ */
34
+ template <class Derived>
35
+ class QuaternionBase : public RotationBase<Derived, 3> {
37
36
  public:
38
37
  typedef RotationBase<Derived, 3> Base;
39
38
 
@@ -44,111 +43,144 @@ class QuaternionBase : public RotationBase<Derived, 3>
44
43
  typedef typename NumTraits<Scalar>::Real RealScalar;
45
44
  typedef typename internal::traits<Derived>::Coefficients Coefficients;
46
45
  typedef typename Coefficients::CoeffReturnType CoeffReturnType;
47
- typedef typename internal::conditional<bool(internal::traits<Derived>::Flags&LvalueBit),
48
- Scalar&, CoeffReturnType>::type NonConstCoeffReturnType;
49
-
46
+ typedef std::conditional_t<bool(internal::traits<Derived>::Flags& LvalueBit), Scalar&, CoeffReturnType>
47
+ NonConstCoeffReturnType;
50
48
 
51
- enum {
52
- Flags = Eigen::internal::traits<Derived>::Flags
53
- };
49
+ enum { Flags = Eigen::internal::traits<Derived>::Flags };
54
50
 
55
- // typedef typename Matrix<Scalar,4,1> Coefficients;
51
+ // typedef typename Matrix<Scalar,4,1> Coefficients;
56
52
  /** the type of a 3D vector */
57
- typedef Matrix<Scalar,3,1> Vector3;
53
+ typedef Matrix<Scalar, 3, 1> Vector3;
58
54
  /** the equivalent rotation matrix type */
59
- typedef Matrix<Scalar,3,3> Matrix3;
55
+ typedef Matrix<Scalar, 3, 3> Matrix3;
60
56
  /** the equivalent angle-axis type */
61
57
  typedef AngleAxis<Scalar> AngleAxisType;
62
58
 
63
-
64
-
65
59
  /** \returns the \c x coefficient */
66
- EIGEN_DEVICE_FUNC inline CoeffReturnType x() const { return this->derived().coeffs().coeff(0); }
60
+ EIGEN_DEVICE_FUNC constexpr CoeffReturnType x() const { return this->derived().coeffs().coeff(0); }
67
61
  /** \returns the \c y coefficient */
68
- EIGEN_DEVICE_FUNC inline CoeffReturnType y() const { return this->derived().coeffs().coeff(1); }
62
+ EIGEN_DEVICE_FUNC constexpr CoeffReturnType y() const { return this->derived().coeffs().coeff(1); }
69
63
  /** \returns the \c z coefficient */
70
- EIGEN_DEVICE_FUNC inline CoeffReturnType z() const { return this->derived().coeffs().coeff(2); }
64
+ EIGEN_DEVICE_FUNC constexpr CoeffReturnType z() const { return this->derived().coeffs().coeff(2); }
71
65
  /** \returns the \c w coefficient */
72
- EIGEN_DEVICE_FUNC inline CoeffReturnType w() const { return this->derived().coeffs().coeff(3); }
66
+ EIGEN_DEVICE_FUNC constexpr CoeffReturnType w() const { return this->derived().coeffs().coeff(3); }
73
67
 
74
68
  /** \returns a reference to the \c x coefficient (if Derived is a non-const lvalue) */
75
- EIGEN_DEVICE_FUNC inline NonConstCoeffReturnType x() { return this->derived().coeffs().x(); }
69
+ EIGEN_DEVICE_FUNC constexpr NonConstCoeffReturnType x() { return this->derived().coeffs().x(); }
76
70
  /** \returns a reference to the \c y coefficient (if Derived is a non-const lvalue) */
77
- EIGEN_DEVICE_FUNC inline NonConstCoeffReturnType y() { return this->derived().coeffs().y(); }
71
+ EIGEN_DEVICE_FUNC constexpr NonConstCoeffReturnType y() { return this->derived().coeffs().y(); }
78
72
  /** \returns a reference to the \c z coefficient (if Derived is a non-const lvalue) */
79
- EIGEN_DEVICE_FUNC inline NonConstCoeffReturnType z() { return this->derived().coeffs().z(); }
73
+ EIGEN_DEVICE_FUNC constexpr NonConstCoeffReturnType z() { return this->derived().coeffs().z(); }
80
74
  /** \returns a reference to the \c w coefficient (if Derived is a non-const lvalue) */
81
- EIGEN_DEVICE_FUNC inline NonConstCoeffReturnType w() { return this->derived().coeffs().w(); }
75
+ EIGEN_DEVICE_FUNC constexpr NonConstCoeffReturnType w() { return this->derived().coeffs().w(); }
82
76
 
83
77
  /** \returns a read-only vector expression of the imaginary part (x,y,z) */
84
- EIGEN_DEVICE_FUNC inline const VectorBlock<const Coefficients,3> vec() const { return coeffs().template head<3>(); }
78
+ EIGEN_DEVICE_FUNC inline const VectorBlock<const Coefficients, 3> vec() const { return coeffs().template head<3>(); }
85
79
 
86
80
  /** \returns a vector expression of the imaginary part (x,y,z) */
87
- EIGEN_DEVICE_FUNC inline VectorBlock<Coefficients,3> vec() { return coeffs().template head<3>(); }
81
+ EIGEN_DEVICE_FUNC inline VectorBlock<Coefficients, 3> vec() { return coeffs().template head<3>(); }
88
82
 
89
83
  /** \returns a read-only vector expression of the coefficients (x,y,z,w) */
90
- EIGEN_DEVICE_FUNC inline const typename internal::traits<Derived>::Coefficients& coeffs() const { return derived().coeffs(); }
84
+ EIGEN_DEVICE_FUNC inline const typename internal::traits<Derived>::Coefficients& coeffs() const {
85
+ return derived().coeffs();
86
+ }
87
+
88
+ /** \returns a vector containing the coefficients, rearranged into the order [\c w, \c x, \c y, \c z].
89
+ *
90
+ * This is the order expected by the \code Quaternion(const Scalar& w, const Scalar& x, const Scalar& y, const Scalar&
91
+ * z) \endcode constructor, but not the order of the internal vector representation. Therefore, it returns a newly
92
+ * constructed vector.
93
+ *
94
+ * \sa QuaternionBase::coeffsScalarLast()
95
+ * */
96
+ EIGEN_DEVICE_FUNC inline typename internal::traits<Derived>::Coefficients coeffsScalarFirst() const {
97
+ return derived().coeffsScalarFirst();
98
+ }
99
+
100
+ /** \returns a vector containing the coefficients in their original order [\c x, \c y, \c z, \c w].
101
+ *
102
+ * This is equivalent to \code coeffs() \endcode, but returns a newly constructed vector for uniformity with \code
103
+ * coeffsScalarFirst() \endcode.
104
+ *
105
+ * \sa QuaternionBase::coeffsScalarFirst()
106
+ * */
107
+ EIGEN_DEVICE_FUNC inline typename internal::traits<Derived>::Coefficients coeffsScalarLast() const {
108
+ return derived().coeffsScalarLast();
109
+ }
91
110
 
92
111
  /** \returns a vector expression of the coefficients (x,y,z,w) */
93
112
  EIGEN_DEVICE_FUNC inline typename internal::traits<Derived>::Coefficients& coeffs() { return derived().coeffs(); }
94
113
 
95
114
  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE QuaternionBase<Derived>& operator=(const QuaternionBase<Derived>& other);
96
- template<class OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const QuaternionBase<OtherDerived>& other);
115
+ template <class OtherDerived>
116
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const QuaternionBase<OtherDerived>& other);
97
117
 
98
- // disabled this copy operator as it is giving very strange compilation errors when compiling
99
- // test_stdvector with GCC 4.4.2. This looks like a GCC bug though, so feel free to re-enable it if it's
100
- // useful; however notice that we already have the templated operator= above and e.g. in MatrixBase
101
- // we didn't have to add, in addition to templated operator=, such a non-templated copy operator.
102
- // Derived& operator=(const QuaternionBase& other)
103
- // { return operator=<Derived>(other); }
118
+ // disabled this copy operator as it is giving very strange compilation errors when compiling
119
+ // test_stdvector with GCC 4.4.2. This looks like a GCC bug though, so feel free to re-enable it if it's
120
+ // useful; however notice that we already have the templated operator= above and e.g. in MatrixBase
121
+ // we didn't have to add, in addition to templated operator=, such a non-templated copy operator.
122
+ // Derived& operator=(const QuaternionBase& other)
123
+ // { return operator=<Derived>(other); }
104
124
 
105
125
  EIGEN_DEVICE_FUNC Derived& operator=(const AngleAxisType& aa);
106
- template<class OtherDerived> EIGEN_DEVICE_FUNC Derived& operator=(const MatrixBase<OtherDerived>& m);
126
+ template <class OtherDerived>
127
+ EIGEN_DEVICE_FUNC Derived& operator=(const MatrixBase<OtherDerived>& m);
107
128
 
108
129
  /** \returns a quaternion representing an identity rotation
109
- * \sa MatrixBase::Identity()
110
- */
111
- EIGEN_DEVICE_FUNC static inline Quaternion<Scalar> Identity() { return Quaternion<Scalar>(Scalar(1), Scalar(0), Scalar(0), Scalar(0)); }
130
+ * \sa MatrixBase::Identity()
131
+ */
132
+ EIGEN_DEVICE_FUNC static inline Quaternion<Scalar> Identity() {
133
+ return Quaternion<Scalar>(Scalar(1), Scalar(0), Scalar(0), Scalar(0));
134
+ }
112
135
 
113
136
  /** \sa QuaternionBase::Identity(), MatrixBase::setIdentity()
114
- */
115
- EIGEN_DEVICE_FUNC inline QuaternionBase& setIdentity() { coeffs() << Scalar(0), Scalar(0), Scalar(0), Scalar(1); return *this; }
137
+ */
138
+ EIGEN_DEVICE_FUNC inline QuaternionBase& setIdentity() {
139
+ coeffs() << Scalar(0), Scalar(0), Scalar(0), Scalar(1);
140
+ return *this;
141
+ }
116
142
 
117
143
  /** \returns the squared norm of the quaternion's coefficients
118
- * \sa QuaternionBase::norm(), MatrixBase::squaredNorm()
119
- */
144
+ * \sa QuaternionBase::norm(), MatrixBase::squaredNorm()
145
+ */
120
146
  EIGEN_DEVICE_FUNC inline Scalar squaredNorm() const { return coeffs().squaredNorm(); }
121
147
 
122
148
  /** \returns the norm of the quaternion's coefficients
123
- * \sa QuaternionBase::squaredNorm(), MatrixBase::norm()
124
- */
149
+ * \sa QuaternionBase::squaredNorm(), MatrixBase::norm()
150
+ */
125
151
  EIGEN_DEVICE_FUNC inline Scalar norm() const { return coeffs().norm(); }
126
152
 
127
153
  /** Normalizes the quaternion \c *this
128
- * \sa normalized(), MatrixBase::normalize() */
154
+ * \sa normalized(), MatrixBase::normalize() */
129
155
  EIGEN_DEVICE_FUNC inline void normalize() { coeffs().normalize(); }
130
156
  /** \returns a normalized copy of \c *this
131
- * \sa normalize(), MatrixBase::normalized() */
157
+ * \sa normalize(), MatrixBase::normalized() */
132
158
  EIGEN_DEVICE_FUNC inline Quaternion<Scalar> normalized() const { return Quaternion<Scalar>(coeffs().normalized()); }
133
159
 
134
- /** \returns the dot product of \c *this and \a other
135
- * Geometrically speaking, the dot product of two unit quaternions
136
- * corresponds to the cosine of half the angle between the two rotations.
137
- * \sa angularDistance()
138
- */
139
- template<class OtherDerived> EIGEN_DEVICE_FUNC inline Scalar dot(const QuaternionBase<OtherDerived>& other) const { return coeffs().dot(other.coeffs()); }
160
+ /** \returns the dot product of \c *this and \a other
161
+ * Geometrically speaking, the dot product of two unit quaternions
162
+ * corresponds to the cosine of half the angle between the two rotations.
163
+ * \sa angularDistance()
164
+ */
165
+ template <class OtherDerived>
166
+ EIGEN_DEVICE_FUNC inline Scalar dot(const QuaternionBase<OtherDerived>& other) const {
167
+ return coeffs().dot(other.coeffs());
168
+ }
140
169
 
141
- template<class OtherDerived> EIGEN_DEVICE_FUNC Scalar angularDistance(const QuaternionBase<OtherDerived>& other) const;
170
+ template <class OtherDerived>
171
+ EIGEN_DEVICE_FUNC Scalar angularDistance(const QuaternionBase<OtherDerived>& other) const;
142
172
 
143
173
  /** \returns an equivalent 3x3 rotation matrix */
144
- EIGEN_DEVICE_FUNC Matrix3 toRotationMatrix() const;
174
+ EIGEN_DEVICE_FUNC inline Matrix3 toRotationMatrix() const;
145
175
 
146
176
  /** \returns the quaternion which transform \a a into \a b through a rotation */
147
- template<typename Derived1, typename Derived2>
177
+ template <typename Derived1, typename Derived2>
148
178
  EIGEN_DEVICE_FUNC Derived& setFromTwoVectors(const MatrixBase<Derived1>& a, const MatrixBase<Derived2>& b);
149
179
 
150
- template<class OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Quaternion<Scalar> operator* (const QuaternionBase<OtherDerived>& q) const;
151
- template<class OtherDerived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator*= (const QuaternionBase<OtherDerived>& q);
180
+ template <class OtherDerived>
181
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Quaternion<Scalar> operator*(const QuaternionBase<OtherDerived>& q) const;
182
+ template <class OtherDerived>
183
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator*=(const QuaternionBase<OtherDerived>& q);
152
184
 
153
185
  /** \returns the quaternion describing the inverse rotation */
154
186
  EIGEN_DEVICE_FUNC Quaternion<Scalar> inverse() const;
@@ -156,104 +188,129 @@ class QuaternionBase : public RotationBase<Derived, 3>
156
188
  /** \returns the conjugated quaternion */
157
189
  EIGEN_DEVICE_FUNC Quaternion<Scalar> conjugate() const;
158
190
 
159
- template<class OtherDerived> EIGEN_DEVICE_FUNC Quaternion<Scalar> slerp(const Scalar& t, const QuaternionBase<OtherDerived>& other) const;
191
+ template <class OtherDerived>
192
+ EIGEN_DEVICE_FUNC Quaternion<Scalar> slerp(const Scalar& t, const QuaternionBase<OtherDerived>& other) const;
193
+
194
+ /** \returns true if each coefficients of \c *this and \a other are all exactly equal.
195
+ * \warning When using floating point scalar values you probably should rather use a
196
+ * fuzzy comparison such as isApprox()
197
+ * \sa isApprox(), operator!= */
198
+ template <class OtherDerived>
199
+ EIGEN_DEVICE_FUNC inline bool operator==(const QuaternionBase<OtherDerived>& other) const {
200
+ return coeffs() == other.coeffs();
201
+ }
202
+
203
+ /** \returns true if at least one pair of coefficients of \c *this and \a other are not exactly equal to each other.
204
+ * \warning When using floating point scalar values you probably should rather use a
205
+ * fuzzy comparison such as isApprox()
206
+ * \sa isApprox(), operator== */
207
+ template <class OtherDerived>
208
+ EIGEN_DEVICE_FUNC inline bool operator!=(const QuaternionBase<OtherDerived>& other) const {
209
+ return coeffs() != other.coeffs();
210
+ }
160
211
 
161
212
  /** \returns \c true if \c *this is approximately equal to \a other, within the precision
162
- * determined by \a prec.
163
- *
164
- * \sa MatrixBase::isApprox() */
165
- template<class OtherDerived>
166
- EIGEN_DEVICE_FUNC bool isApprox(const QuaternionBase<OtherDerived>& other, const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const
167
- { return coeffs().isApprox(other.coeffs(), prec); }
213
+ * determined by \a prec.
214
+ *
215
+ * \sa MatrixBase::isApprox() */
216
+ template <class OtherDerived>
217
+ EIGEN_DEVICE_FUNC bool isApprox(const QuaternionBase<OtherDerived>& other,
218
+ const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const {
219
+ return coeffs().isApprox(other.coeffs(), prec);
220
+ }
168
221
 
169
222
  /** return the result vector of \a v through the rotation*/
170
223
  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Vector3 _transformVector(const Vector3& v) const;
171
224
 
172
- #ifdef EIGEN_PARSED_BY_DOXYGEN
225
+ #ifdef EIGEN_PARSED_BY_DOXYGEN
173
226
  /** \returns \c *this with scalar type casted to \a NewScalarType
174
- *
175
- * Note that if \a NewScalarType is equal to the current scalar type of \c *this
176
- * then this function smartly returns a const reference to \c *this.
177
- */
178
- template<typename NewScalarType>
179
- EIGEN_DEVICE_FUNC inline typename internal::cast_return_type<Derived,Quaternion<NewScalarType> >::type cast() const;
180
-
181
- #else
182
-
183
- template<typename NewScalarType>
184
- EIGEN_DEVICE_FUNC inline
185
- typename internal::enable_if<internal::is_same<Scalar,NewScalarType>::value,const Derived&>::type cast() const
186
- {
227
+ *
228
+ * Note that if \a NewScalarType is equal to the current scalar type of \c *this
229
+ * then this function smartly returns a const reference to \c *this.
230
+ */
231
+ template <typename NewScalarType>
232
+ EIGEN_DEVICE_FUNC inline typename internal::cast_return_type<Derived, Quaternion<NewScalarType> >::type cast() const;
233
+
234
+ #else
235
+
236
+ template <typename NewScalarType>
237
+ EIGEN_DEVICE_FUNC inline std::enable_if_t<internal::is_same<Scalar, NewScalarType>::value, const Derived&> cast()
238
+ const {
187
239
  return derived();
188
240
  }
189
241
 
190
- template<typename NewScalarType>
191
- EIGEN_DEVICE_FUNC inline
192
- typename internal::enable_if<!internal::is_same<Scalar,NewScalarType>::value,Quaternion<NewScalarType> >::type cast() const
193
- {
242
+ template <typename NewScalarType>
243
+ EIGEN_DEVICE_FUNC inline std::enable_if_t<!internal::is_same<Scalar, NewScalarType>::value,
244
+ Quaternion<NewScalarType> >
245
+ cast() const {
194
246
  return Quaternion<NewScalarType>(coeffs().template cast<NewScalarType>());
195
247
  }
196
- #endif
248
+ #endif
249
+
250
+ #ifndef EIGEN_NO_IO
251
+ friend std::ostream& operator<<(std::ostream& s, const QuaternionBase<Derived>& q) {
252
+ s << q.x() << "i + " << q.y() << "j + " << q.z() << "k"
253
+ << " + " << q.w();
254
+ return s;
255
+ }
256
+ #endif
197
257
 
198
258
  #ifdef EIGEN_QUATERNIONBASE_PLUGIN
199
- # include EIGEN_QUATERNIONBASE_PLUGIN
259
+ #include EIGEN_QUATERNIONBASE_PLUGIN
200
260
  #endif
201
- protected:
261
+ protected:
202
262
  EIGEN_DEFAULT_COPY_CONSTRUCTOR(QuaternionBase)
203
263
  EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR(QuaternionBase)
204
264
  };
205
265
 
206
266
  /***************************************************************************
207
- * Definition/implementation of Quaternion<Scalar>
208
- ***************************************************************************/
267
+ * Definition/implementation of Quaternion<Scalar>
268
+ ***************************************************************************/
209
269
 
210
270
  /** \geometry_module \ingroup Geometry_Module
211
- *
212
- * \class Quaternion
213
- *
214
- * \brief The quaternion class used to represent 3D orientations and rotations
215
- *
216
- * \tparam _Scalar the scalar type, i.e., the type of the coefficients
217
- * \tparam _Options controls the memory alignment of the coefficients. Can be \# AutoAlign or \# DontAlign. Default is AutoAlign.
218
- *
219
- * This class represents a quaternion \f$ w+xi+yj+zk \f$ that is a convenient representation of
220
- * orientations and rotations of objects in three dimensions. Compared to other representations
221
- * like Euler angles or 3x3 matrices, quaternions offer the following advantages:
222
- * \li \b compact storage (4 scalars)
223
- * \li \b efficient to compose (28 flops),
224
- * \li \b stable spherical interpolation
225
- *
226
- * The following two typedefs are provided for convenience:
227
- * \li \c Quaternionf for \c float
228
- * \li \c Quaterniond for \c double
229
- *
230
- * \warning Operations interpreting the quaternion as rotation have undefined behavior if the quaternion is not normalized.
231
- *
232
- * \sa class AngleAxis, class Transform
233
- */
271
+ *
272
+ * \class Quaternion
273
+ *
274
+ * \brief The quaternion class used to represent 3D orientations and rotations
275
+ *
276
+ * \tparam Scalar_ the scalar type, i.e., the type of the coefficients
277
+ * \tparam Options_ controls the memory alignment of the coefficients. Can be \# AutoAlign or \# DontAlign. Default is
278
+ * AutoAlign.
279
+ *
280
+ * This class represents a quaternion \f$ w+xi+yj+zk \f$ that is a convenient representation of
281
+ * orientations and rotations of objects in three dimensions. Compared to other representations
282
+ * like Euler angles or 3x3 matrices, quaternions offer the following advantages:
283
+ * \li \b compact storage (4 scalars)
284
+ * \li \b efficient to compose (28 flops),
285
+ * \li \b stable spherical interpolation
286
+ *
287
+ * The following two typedefs are provided for convenience:
288
+ * \li \c Quaternionf for \c float
289
+ * \li \c Quaterniond for \c double
290
+ *
291
+ * \warning Operations interpreting the quaternion as rotation have undefined behavior if the quaternion is not
292
+ * normalized.
293
+ *
294
+ * \sa class AngleAxis, class Transform
295
+ */
234
296
 
235
297
  namespace internal {
236
- template<typename _Scalar,int _Options>
237
- struct traits<Quaternion<_Scalar,_Options> >
238
- {
239
- typedef Quaternion<_Scalar,_Options> PlainObject;
240
- typedef _Scalar Scalar;
241
- typedef Matrix<_Scalar,4,1,_Options> Coefficients;
242
- enum{
243
- Alignment = internal::traits<Coefficients>::Alignment,
244
- Flags = LvalueBit
245
- };
298
+ template <typename Scalar_, int Options_>
299
+ struct traits<Quaternion<Scalar_, Options_> > {
300
+ typedef Quaternion<Scalar_, Options_> PlainObject;
301
+ typedef Scalar_ Scalar;
302
+ typedef Matrix<Scalar_, 4, 1, Options_> Coefficients;
303
+ enum { Alignment = internal::traits<Coefficients>::Alignment, Flags = LvalueBit };
246
304
  };
247
- }
305
+ } // namespace internal
248
306
 
249
- template<typename _Scalar, int _Options>
250
- class Quaternion : public QuaternionBase<Quaternion<_Scalar,_Options> >
251
- {
252
- public:
253
- typedef QuaternionBase<Quaternion<_Scalar,_Options> > Base;
254
- enum { NeedsAlignment = internal::traits<Quaternion>::Alignment>0 };
307
+ template <typename Scalar_, int Options_>
308
+ class Quaternion : public QuaternionBase<Quaternion<Scalar_, Options_> > {
309
+ public:
310
+ typedef QuaternionBase<Quaternion<Scalar_, Options_> > Base;
311
+ enum { NeedsAlignment = internal::traits<Quaternion>::Alignment > 0 };
255
312
 
256
- typedef _Scalar Scalar;
313
+ typedef Scalar_ Scalar;
257
314
 
258
315
  EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Quaternion)
259
316
  using Base::operator*=;
@@ -265,341 +322,376 @@ public:
265
322
  EIGEN_DEVICE_FUNC inline Quaternion() {}
266
323
 
267
324
  /** Constructs and initializes the quaternion \f$ w+xi+yj+zk \f$ from
268
- * its four coefficients \a w, \a x, \a y and \a z.
269
- *
270
- * \warning Note the order of the arguments: the real \a w coefficient first,
271
- * while internally the coefficients are stored in the following order:
272
- * [\c x, \c y, \c z, \c w]
273
- */
274
- EIGEN_DEVICE_FUNC inline Quaternion(const Scalar& w, const Scalar& x, const Scalar& y, const Scalar& z) : m_coeffs(x, y, z, w){}
325
+ * its four coefficients \a w, \a x, \a y and \a z.
326
+ *
327
+ * \warning Note the order of the arguments: the real \a w coefficient first,
328
+ * while internally the coefficients are stored in the following order:
329
+ * [\c x, \c y, \c z, \c w]
330
+ */
331
+ EIGEN_DEVICE_FUNC inline Quaternion(const Scalar& w, const Scalar& x, const Scalar& y, const Scalar& z)
332
+ : m_coeffs(x, y, z, w) {}
333
+
334
+ /** Constructs and initializes a quaternion from its real part as a scalar,
335
+ * and its imaginary part as a 3-vector [\c x, \c y, \c z]
336
+ */
337
+ template <typename Derived>
338
+ EIGEN_DEVICE_FUNC inline Quaternion(const Scalar& w, const Eigen::MatrixBase<Derived>& vec)
339
+ : m_coeffs(vec.x(), vec.y(), vec.z(), w) {
340
+ EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Derived, 3);
341
+ }
275
342
 
276
343
  /** Constructs and initialize a quaternion from the array data */
277
344
  EIGEN_DEVICE_FUNC explicit inline Quaternion(const Scalar* data) : m_coeffs(data) {}
278
345
 
279
346
  /** Copy constructor */
280
- template<class Derived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Quaternion(const QuaternionBase<Derived>& other) { this->Base::operator=(other); }
347
+ template <class Derived>
348
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Quaternion(const QuaternionBase<Derived>& other) {
349
+ this->Base::operator=(other);
350
+ }
281
351
 
282
352
  /** Constructs and initializes a quaternion from the angle-axis \a aa */
283
353
  EIGEN_DEVICE_FUNC explicit inline Quaternion(const AngleAxisType& aa) { *this = aa; }
284
354
 
285
355
  /** Constructs and initializes a quaternion from either:
286
- * - a rotation matrix expression,
287
- * - a 4D vector expression representing quaternion coefficients.
288
- */
289
- template<typename Derived>
290
- EIGEN_DEVICE_FUNC explicit inline Quaternion(const MatrixBase<Derived>& other) { *this = other; }
356
+ * - a rotation matrix expression,
357
+ * - a 4D vector expression representing quaternion coefficients in the order [\c x, \c y, \c z, \c w].
358
+ */
359
+ template <typename Derived>
360
+ EIGEN_DEVICE_FUNC explicit inline Quaternion(const MatrixBase<Derived>& other) {
361
+ *this = other;
362
+ }
291
363
 
292
364
  /** Explicit copy constructor with scalar conversion */
293
- template<typename OtherScalar, int OtherOptions>
294
- EIGEN_DEVICE_FUNC explicit inline Quaternion(const Quaternion<OtherScalar, OtherOptions>& other)
295
- { m_coeffs = other.coeffs().template cast<Scalar>(); }
365
+ template <typename OtherScalar, int OtherOptions>
366
+ EIGEN_DEVICE_FUNC explicit inline Quaternion(const Quaternion<OtherScalar, OtherOptions>& other) {
367
+ m_coeffs = other.coeffs().template cast<Scalar>();
368
+ }
369
+
370
+ // We define a copy constructor, which means we don't get an implicit move constructor or assignment operator.
371
+ /** Default move constructor */
372
+ EIGEN_DEVICE_FUNC inline Quaternion(Quaternion&& other) noexcept(std::is_nothrow_move_constructible<Scalar>::value)
373
+ : m_coeffs(std::move(other.coeffs())) {}
374
+
375
+ /** Default move assignment operator */
376
+ EIGEN_DEVICE_FUNC Quaternion& operator=(Quaternion&& other) noexcept(std::is_nothrow_move_assignable<Scalar>::value) {
377
+ m_coeffs = std::move(other.coeffs());
378
+ return *this;
379
+ }
296
380
 
297
381
  EIGEN_DEVICE_FUNC static Quaternion UnitRandom();
298
382
 
299
- template<typename Derived1, typename Derived2>
383
+ EIGEN_DEVICE_FUNC static Quaternion FromCoeffsScalarLast(const Scalar& x, const Scalar& y, const Scalar& z,
384
+ const Scalar& w);
385
+
386
+ EIGEN_DEVICE_FUNC static Quaternion FromCoeffsScalarFirst(const Scalar& w, const Scalar& x, const Scalar& y,
387
+ const Scalar& z);
388
+
389
+ template <typename Derived1, typename Derived2>
300
390
  EIGEN_DEVICE_FUNC static Quaternion FromTwoVectors(const MatrixBase<Derived1>& a, const MatrixBase<Derived2>& b);
301
391
 
302
- EIGEN_DEVICE_FUNC inline Coefficients& coeffs() { return m_coeffs;}
303
- EIGEN_DEVICE_FUNC inline const Coefficients& coeffs() const { return m_coeffs;}
392
+ EIGEN_DEVICE_FUNC inline Coefficients& coeffs() { return m_coeffs; }
393
+ EIGEN_DEVICE_FUNC inline const Coefficients& coeffs() const { return m_coeffs; }
394
+
395
+ EIGEN_DEVICE_FUNC inline Coefficients coeffsScalarLast() const { return m_coeffs; }
304
396
 
397
+ EIGEN_DEVICE_FUNC inline Coefficients coeffsScalarFirst() const {
398
+ return {m_coeffs.w(), m_coeffs.x(), m_coeffs.y(), m_coeffs.z()};
399
+ }
305
400
  EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(bool(NeedsAlignment))
306
-
401
+
307
402
  #ifdef EIGEN_QUATERNION_PLUGIN
308
- # include EIGEN_QUATERNION_PLUGIN
403
+ #include EIGEN_QUATERNION_PLUGIN
309
404
  #endif
310
405
 
311
- protected:
406
+ protected:
312
407
  Coefficients m_coeffs;
313
-
408
+
314
409
  #ifndef EIGEN_PARSED_BY_DOXYGEN
315
- static EIGEN_STRONG_INLINE void _check_template_params()
316
- {
317
- EIGEN_STATIC_ASSERT( (_Options & DontAlign) == _Options,
318
- INVALID_MATRIX_TEMPLATE_PARAMETERS)
319
- }
410
+ EIGEN_STATIC_ASSERT((Options_ & DontAlign) == Options_, INVALID_MATRIX_TEMPLATE_PARAMETERS)
320
411
  #endif
321
412
  };
322
413
 
323
414
  /** \ingroup Geometry_Module
324
- * single precision quaternion type */
415
+ * single precision quaternion type */
325
416
  typedef Quaternion<float> Quaternionf;
326
417
  /** \ingroup Geometry_Module
327
- * double precision quaternion type */
418
+ * double precision quaternion type */
328
419
  typedef Quaternion<double> Quaterniond;
329
420
 
330
421
  /***************************************************************************
331
- * Specialization of Map<Quaternion<Scalar>>
332
- ***************************************************************************/
422
+ * Specialization of Map<Quaternion<Scalar>>
423
+ ***************************************************************************/
333
424
 
334
425
  namespace internal {
335
- template<typename _Scalar, int _Options>
336
- struct traits<Map<Quaternion<_Scalar>, _Options> > : traits<Quaternion<_Scalar, (int(_Options)&Aligned)==Aligned ? AutoAlign : DontAlign> >
337
- {
338
- typedef Map<Matrix<_Scalar,4,1>, _Options> Coefficients;
339
- };
340
- }
426
+ template <typename Scalar_, int Options_>
427
+ struct traits<Map<Quaternion<Scalar_>, Options_> >
428
+ : traits<Quaternion<Scalar_, (int(Options_) & Aligned) == Aligned ? AutoAlign : DontAlign> > {
429
+ typedef Map<Matrix<Scalar_, 4, 1>, Options_> Coefficients;
430
+ };
431
+ } // namespace internal
341
432
 
342
433
  namespace internal {
343
- template<typename _Scalar, int _Options>
344
- struct traits<Map<const Quaternion<_Scalar>, _Options> > : traits<Quaternion<_Scalar, (int(_Options)&Aligned)==Aligned ? AutoAlign : DontAlign> >
345
- {
346
- typedef Map<const Matrix<_Scalar,4,1>, _Options> Coefficients;
347
- typedef traits<Quaternion<_Scalar, (int(_Options)&Aligned)==Aligned ? AutoAlign : DontAlign> > TraitsBase;
348
- enum {
349
- Flags = TraitsBase::Flags & ~LvalueBit
350
- };
351
- };
352
- }
434
+ template <typename Scalar_, int Options_>
435
+ struct traits<Map<const Quaternion<Scalar_>, Options_> >
436
+ : traits<Quaternion<Scalar_, (int(Options_) & Aligned) == Aligned ? AutoAlign : DontAlign> > {
437
+ typedef Map<const Matrix<Scalar_, 4, 1>, Options_> Coefficients;
438
+ typedef traits<Quaternion<Scalar_, (int(Options_) & Aligned) == Aligned ? AutoAlign : DontAlign> > TraitsBase;
439
+ enum { Flags = TraitsBase::Flags & ~LvalueBit };
440
+ };
441
+ } // namespace internal
353
442
 
354
443
  /** \ingroup Geometry_Module
355
- * \brief Quaternion expression mapping a constant memory buffer
356
- *
357
- * \tparam _Scalar the type of the Quaternion coefficients
358
- * \tparam _Options see class Map
359
- *
360
- * This is a specialization of class Map for Quaternion. This class allows to view
361
- * a 4 scalar memory buffer as an Eigen's Quaternion object.
362
- *
363
- * \sa class Map, class Quaternion, class QuaternionBase
364
- */
365
- template<typename _Scalar, int _Options>
366
- class Map<const Quaternion<_Scalar>, _Options >
367
- : public QuaternionBase<Map<const Quaternion<_Scalar>, _Options> >
368
- {
369
- public:
370
- typedef QuaternionBase<Map<const Quaternion<_Scalar>, _Options> > Base;
371
-
372
- typedef _Scalar Scalar;
373
- typedef typename internal::traits<Map>::Coefficients Coefficients;
374
- EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map)
375
- using Base::operator*=;
376
-
377
- /** Constructs a Mapped Quaternion object from the pointer \a coeffs
378
- *
379
- * The pointer \a coeffs must reference the four coefficients of Quaternion in the following order:
380
- * \code *coeffs == {x, y, z, w} \endcode
381
- *
382
- * If the template parameter _Options is set to #Aligned, then the pointer coeffs must be aligned. */
383
- EIGEN_DEVICE_FUNC explicit EIGEN_STRONG_INLINE Map(const Scalar* coeffs) : m_coeffs(coeffs) {}
384
-
385
- EIGEN_DEVICE_FUNC inline const Coefficients& coeffs() const { return m_coeffs;}
386
-
387
- protected:
388
- const Coefficients m_coeffs;
444
+ * \brief Quaternion expression mapping a constant memory buffer
445
+ *
446
+ * \tparam Scalar_ the type of the Quaternion coefficients
447
+ * \tparam Options_ see class Map
448
+ *
449
+ * This is a specialization of class Map for Quaternion. This class allows to view
450
+ * a 4 scalar memory buffer as an Eigen's Quaternion object.
451
+ *
452
+ * \sa class Map, class Quaternion, class QuaternionBase
453
+ */
454
+ template <typename Scalar_, int Options_>
455
+ class Map<const Quaternion<Scalar_>, Options_> : public QuaternionBase<Map<const Quaternion<Scalar_>, Options_> > {
456
+ public:
457
+ typedef QuaternionBase<Map<const Quaternion<Scalar_>, Options_> > Base;
458
+
459
+ typedef Scalar_ Scalar;
460
+ typedef typename internal::traits<Map>::Coefficients Coefficients;
461
+ EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map)
462
+ using Base::operator*=;
463
+
464
+ /** Constructs a Mapped Quaternion object from the pointer \a coeffs
465
+ *
466
+ * The pointer \a coeffs must reference the four coefficients of Quaternion in the following order:
467
+ * \code *coeffs == {x, y, z, w} \endcode
468
+ *
469
+ * If the template parameter Options_ is set to #Aligned, then the pointer coeffs must be aligned. */
470
+ EIGEN_DEVICE_FUNC explicit EIGEN_STRONG_INLINE Map(const Scalar* coeffs) : m_coeffs(coeffs) {}
471
+
472
+ EIGEN_DEVICE_FUNC inline const Coefficients& coeffs() const { return m_coeffs; }
473
+
474
+ EIGEN_DEVICE_FUNC inline Coefficients coeffsScalarLast() const { return m_coeffs; }
475
+
476
+ EIGEN_DEVICE_FUNC inline Coefficients coeffsScalarFirst() const {
477
+ return {m_coeffs.w(), m_coeffs.x(), m_coeffs.y(), m_coeffs.z()};
478
+ }
479
+
480
+ protected:
481
+ const Coefficients m_coeffs;
389
482
  };
390
483
 
391
484
  /** \ingroup Geometry_Module
392
- * \brief Expression of a quaternion from a memory buffer
393
- *
394
- * \tparam _Scalar the type of the Quaternion coefficients
395
- * \tparam _Options see class Map
396
- *
397
- * This is a specialization of class Map for Quaternion. This class allows to view
398
- * a 4 scalar memory buffer as an Eigen's Quaternion object.
399
- *
400
- * \sa class Map, class Quaternion, class QuaternionBase
401
- */
402
- template<typename _Scalar, int _Options>
403
- class Map<Quaternion<_Scalar>, _Options >
404
- : public QuaternionBase<Map<Quaternion<_Scalar>, _Options> >
405
- {
406
- public:
407
- typedef QuaternionBase<Map<Quaternion<_Scalar>, _Options> > Base;
408
-
409
- typedef _Scalar Scalar;
410
- typedef typename internal::traits<Map>::Coefficients Coefficients;
411
- EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map)
412
- using Base::operator*=;
413
-
414
- /** Constructs a Mapped Quaternion object from the pointer \a coeffs
415
- *
416
- * The pointer \a coeffs must reference the four coefficients of Quaternion in the following order:
417
- * \code *coeffs == {x, y, z, w} \endcode
418
- *
419
- * If the template parameter _Options is set to #Aligned, then the pointer coeffs must be aligned. */
420
- EIGEN_DEVICE_FUNC explicit EIGEN_STRONG_INLINE Map(Scalar* coeffs) : m_coeffs(coeffs) {}
421
-
422
- EIGEN_DEVICE_FUNC inline Coefficients& coeffs() { return m_coeffs; }
423
- EIGEN_DEVICE_FUNC inline const Coefficients& coeffs() const { return m_coeffs; }
424
-
425
- protected:
426
- Coefficients m_coeffs;
485
+ * \brief Expression of a quaternion from a memory buffer
486
+ *
487
+ * \tparam Scalar_ the type of the Quaternion coefficients
488
+ * \tparam Options_ see class Map
489
+ *
490
+ * This is a specialization of class Map for Quaternion. This class allows to view
491
+ * a 4 scalar memory buffer as an Eigen's Quaternion object.
492
+ *
493
+ * \sa class Map, class Quaternion, class QuaternionBase
494
+ */
495
+ template <typename Scalar_, int Options_>
496
+ class Map<Quaternion<Scalar_>, Options_> : public QuaternionBase<Map<Quaternion<Scalar_>, Options_> > {
497
+ public:
498
+ typedef QuaternionBase<Map<Quaternion<Scalar_>, Options_> > Base;
499
+
500
+ typedef Scalar_ Scalar;
501
+ typedef typename internal::traits<Map>::Coefficients Coefficients;
502
+ EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map)
503
+ using Base::operator*=;
504
+
505
+ /** Constructs a Mapped Quaternion object from the pointer \a coeffs
506
+ *
507
+ * The pointer \a coeffs must reference the four coefficients of Quaternion in the following order:
508
+ * \code *coeffs == {x, y, z, w} \endcode
509
+ *
510
+ * If the template parameter Options_ is set to #Aligned, then the pointer coeffs must be aligned. */
511
+ EIGEN_DEVICE_FUNC explicit EIGEN_STRONG_INLINE Map(Scalar* coeffs) : m_coeffs(coeffs) {}
512
+
513
+ EIGEN_DEVICE_FUNC inline Coefficients& coeffs() { return m_coeffs; }
514
+ EIGEN_DEVICE_FUNC inline const Coefficients& coeffs() const { return m_coeffs; }
515
+
516
+ EIGEN_DEVICE_FUNC inline Coefficients coeffsScalarLast() const { return m_coeffs; }
517
+
518
+ EIGEN_DEVICE_FUNC inline Coefficients coeffsScalarFirst() const {
519
+ return {m_coeffs.w(), m_coeffs.x(), m_coeffs.y(), m_coeffs.z()};
520
+ }
521
+
522
+ protected:
523
+ Coefficients m_coeffs;
427
524
  };
428
525
 
429
526
  /** \ingroup Geometry_Module
430
- * Map an unaligned array of single precision scalars as a quaternion */
431
- typedef Map<Quaternion<float>, 0> QuaternionMapf;
527
+ * Map an unaligned array of single precision scalars as a quaternion */
528
+ typedef Map<Quaternion<float>, 0> QuaternionMapf;
432
529
  /** \ingroup Geometry_Module
433
- * Map an unaligned array of double precision scalars as a quaternion */
434
- typedef Map<Quaternion<double>, 0> QuaternionMapd;
530
+ * Map an unaligned array of double precision scalars as a quaternion */
531
+ typedef Map<Quaternion<double>, 0> QuaternionMapd;
435
532
  /** \ingroup Geometry_Module
436
- * Map a 16-byte aligned array of single precision scalars as a quaternion */
437
- typedef Map<Quaternion<float>, Aligned> QuaternionMapAlignedf;
533
+ * Map a 16-byte aligned array of single precision scalars as a quaternion */
534
+ typedef Map<Quaternion<float>, Aligned> QuaternionMapAlignedf;
438
535
  /** \ingroup Geometry_Module
439
- * Map a 16-byte aligned array of double precision scalars as a quaternion */
440
- typedef Map<Quaternion<double>, Aligned> QuaternionMapAlignedd;
536
+ * Map a 16-byte aligned array of double precision scalars as a quaternion */
537
+ typedef Map<Quaternion<double>, Aligned> QuaternionMapAlignedd;
441
538
 
442
539
  /***************************************************************************
443
- * Implementation of QuaternionBase methods
444
- ***************************************************************************/
540
+ * Implementation of QuaternionBase methods
541
+ ***************************************************************************/
445
542
 
446
543
  // Generic Quaternion * Quaternion product
447
544
  // This product can be specialized for a given architecture via the Arch template argument.
448
545
  namespace internal {
449
- template<int Arch, class Derived1, class Derived2, typename Scalar> struct quat_product
450
- {
451
- EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Quaternion<Scalar> run(const QuaternionBase<Derived1>& a, const QuaternionBase<Derived2>& b){
452
- return Quaternion<Scalar>
453
- (
454
- a.w() * b.w() - a.x() * b.x() - a.y() * b.y() - a.z() * b.z(),
455
- a.w() * b.x() + a.x() * b.w() + a.y() * b.z() - a.z() * b.y(),
456
- a.w() * b.y() + a.y() * b.w() + a.z() * b.x() - a.x() * b.z(),
457
- a.w() * b.z() + a.z() * b.w() + a.x() * b.y() - a.y() * b.x()
458
- );
546
+ template <int Arch, class Derived1, class Derived2, typename Scalar>
547
+ struct quat_product {
548
+ EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Quaternion<Scalar> run(const QuaternionBase<Derived1>& a,
549
+ const QuaternionBase<Derived2>& b) {
550
+ return Quaternion<Scalar>(a.w() * b.w() - a.x() * b.x() - a.y() * b.y() - a.z() * b.z(),
551
+ a.w() * b.x() + a.x() * b.w() + a.y() * b.z() - a.z() * b.y(),
552
+ a.w() * b.y() + a.y() * b.w() + a.z() * b.x() - a.x() * b.z(),
553
+ a.w() * b.z() + a.z() * b.w() + a.x() * b.y() - a.y() * b.x());
459
554
  }
460
555
  };
461
- }
556
+ } // namespace internal
462
557
 
463
558
  /** \returns the concatenation of two rotations as a quaternion-quaternion product */
464
559
  template <class Derived>
465
560
  template <class OtherDerived>
466
561
  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Quaternion<typename internal::traits<Derived>::Scalar>
467
- QuaternionBase<Derived>::operator* (const QuaternionBase<OtherDerived>& other) const
468
- {
469
- EIGEN_STATIC_ASSERT((internal::is_same<typename Derived::Scalar, typename OtherDerived::Scalar>::value),
470
- YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
562
+ QuaternionBase<Derived>::operator*(const QuaternionBase<OtherDerived>& other) const {
563
+ EIGEN_STATIC_ASSERT(
564
+ (internal::is_same<typename Derived::Scalar, typename OtherDerived::Scalar>::value),
565
+ YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
471
566
  return internal::quat_product<Architecture::Target, Derived, OtherDerived,
472
- typename internal::traits<Derived>::Scalar>::run(*this, other);
567
+ typename internal::traits<Derived>::Scalar>::run(*this, other);
473
568
  }
474
569
 
475
570
  /** \sa operator*(Quaternion) */
476
571
  template <class Derived>
477
572
  template <class OtherDerived>
478
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& QuaternionBase<Derived>::operator*= (const QuaternionBase<OtherDerived>& other)
479
- {
573
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& QuaternionBase<Derived>::operator*=(
574
+ const QuaternionBase<OtherDerived>& other) {
480
575
  derived() = derived() * other.derived();
481
576
  return derived();
482
577
  }
483
578
 
484
579
  /** Rotation of a vector by a quaternion.
485
- * \remarks If the quaternion is used to rotate several points (>1)
486
- * then it is much more efficient to first convert it to a 3x3 Matrix.
487
- * Comparison of the operation cost for n transformations:
488
- * - Quaternion2: 30n
489
- * - Via a Matrix3: 24 + 15n
490
- */
580
+ * \remarks If the quaternion is used to rotate several points (>1)
581
+ * then it is much more efficient to first convert it to a 3x3 Matrix.
582
+ * Comparison of the operation cost for n transformations:
583
+ * - Quaternion2: 30n
584
+ * - Via a Matrix3: 24 + 15n
585
+ */
491
586
  template <class Derived>
492
587
  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename QuaternionBase<Derived>::Vector3
493
- QuaternionBase<Derived>::_transformVector(const Vector3& v) const
494
- {
495
- // Note that this algorithm comes from the optimization by hand
496
- // of the conversion to a Matrix followed by a Matrix/Vector product.
497
- // It appears to be much faster than the common algorithm found
498
- // in the literature (30 versus 39 flops). It also requires two
499
- // Vector3 as temporaries.
500
- Vector3 uv = this->vec().cross(v);
501
- uv += uv;
502
- return v + this->w() * uv + this->vec().cross(uv);
588
+ QuaternionBase<Derived>::_transformVector(const Vector3& v) const {
589
+ // Note that this algorithm comes from the optimization by hand
590
+ // of the conversion to a Matrix followed by a Matrix/Vector product.
591
+ // It appears to be much faster than the common algorithm found
592
+ // in the literature (30 versus 39 flops). It also requires two
593
+ // Vector3 as temporaries.
594
+ Vector3 uv = this->vec().cross(v);
595
+ uv += uv;
596
+ return v + this->w() * uv + this->vec().cross(uv);
503
597
  }
504
598
 
505
- template<class Derived>
506
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE QuaternionBase<Derived>& QuaternionBase<Derived>::operator=(const QuaternionBase<Derived>& other)
507
- {
599
+ template <class Derived>
600
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE QuaternionBase<Derived>& QuaternionBase<Derived>::operator=(
601
+ const QuaternionBase<Derived>& other) {
508
602
  coeffs() = other.coeffs();
509
603
  return derived();
510
604
  }
511
605
 
512
- template<class Derived>
513
- template<class OtherDerived>
514
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& QuaternionBase<Derived>::operator=(const QuaternionBase<OtherDerived>& other)
515
- {
606
+ template <class Derived>
607
+ template <class OtherDerived>
608
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& QuaternionBase<Derived>::operator=(
609
+ const QuaternionBase<OtherDerived>& other) {
516
610
  coeffs() = other.coeffs();
517
611
  return derived();
518
612
  }
519
613
 
520
614
  /** Set \c *this from an angle-axis \a aa and returns a reference to \c *this
521
- */
522
- template<class Derived>
523
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& QuaternionBase<Derived>::operator=(const AngleAxisType& aa)
524
- {
525
- EIGEN_USING_STD_MATH(cos)
526
- EIGEN_USING_STD_MATH(sin)
527
- Scalar ha = Scalar(0.5)*aa.angle(); // Scalar(0.5) to suppress precision loss warnings
615
+ */
616
+ template <class Derived>
617
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& QuaternionBase<Derived>::operator=(const AngleAxisType& aa) {
618
+ EIGEN_USING_STD(cos)
619
+ EIGEN_USING_STD(sin)
620
+ Scalar ha = Scalar(0.5) * aa.angle(); // Scalar(0.5) to suppress precision loss warnings
528
621
  this->w() = cos(ha);
529
622
  this->vec() = sin(ha) * aa.axis();
530
623
  return derived();
531
624
  }
532
625
 
533
626
  /** Set \c *this from the expression \a xpr:
534
- * - if \a xpr is a 4x1 vector, then \a xpr is assumed to be a quaternion
535
- * - if \a xpr is a 3x3 matrix, then \a xpr is assumed to be rotation matrix
536
- * and \a xpr is converted to a quaternion
537
- */
538
-
539
- template<class Derived>
540
- template<class MatrixDerived>
541
- EIGEN_DEVICE_FUNC inline Derived& QuaternionBase<Derived>::operator=(const MatrixBase<MatrixDerived>& xpr)
542
- {
543
- EIGEN_STATIC_ASSERT((internal::is_same<typename Derived::Scalar, typename MatrixDerived::Scalar>::value),
544
- YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
627
+ * - if \a xpr is a 4x1 vector, then \a xpr is assumed to be a quaternion
628
+ * - if \a xpr is a 3x3 matrix, then \a xpr is assumed to be rotation matrix
629
+ * and \a xpr is converted to a quaternion
630
+ */
631
+
632
+ template <class Derived>
633
+ template <class MatrixDerived>
634
+ EIGEN_DEVICE_FUNC inline Derived& QuaternionBase<Derived>::operator=(const MatrixBase<MatrixDerived>& xpr) {
635
+ EIGEN_STATIC_ASSERT(
636
+ (internal::is_same<typename Derived::Scalar, typename MatrixDerived::Scalar>::value),
637
+ YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
545
638
  internal::quaternionbase_assign_impl<MatrixDerived>::run(*this, xpr.derived());
546
639
  return derived();
547
640
  }
548
641
 
549
642
  /** Convert the quaternion to a 3x3 rotation matrix. The quaternion is required to
550
- * be normalized, otherwise the result is undefined.
551
- */
552
- template<class Derived>
553
- EIGEN_DEVICE_FUNC inline typename QuaternionBase<Derived>::Matrix3
554
- QuaternionBase<Derived>::toRotationMatrix(void) const
555
- {
643
+ * be normalized, otherwise the result is undefined.
644
+ */
645
+ template <class Derived>
646
+ EIGEN_DEVICE_FUNC inline typename QuaternionBase<Derived>::Matrix3 QuaternionBase<Derived>::toRotationMatrix(
647
+ void) const {
556
648
  // NOTE if inlined, then gcc 4.2 and 4.4 get rid of the temporary (not gcc 4.3 !!)
557
649
  // if not inlined then the cost of the return by value is huge ~ +35%,
558
650
  // however, not inlining this function is an order of magnitude slower, so
559
651
  // it has to be inlined, and so the return by value is not an issue
560
652
  Matrix3 res;
561
653
 
562
- const Scalar tx = Scalar(2)*this->x();
563
- const Scalar ty = Scalar(2)*this->y();
564
- const Scalar tz = Scalar(2)*this->z();
565
- const Scalar twx = tx*this->w();
566
- const Scalar twy = ty*this->w();
567
- const Scalar twz = tz*this->w();
568
- const Scalar txx = tx*this->x();
569
- const Scalar txy = ty*this->x();
570
- const Scalar txz = tz*this->x();
571
- const Scalar tyy = ty*this->y();
572
- const Scalar tyz = tz*this->y();
573
- const Scalar tzz = tz*this->z();
574
-
575
- res.coeffRef(0,0) = Scalar(1)-(tyy+tzz);
576
- res.coeffRef(0,1) = txy-twz;
577
- res.coeffRef(0,2) = txz+twy;
578
- res.coeffRef(1,0) = txy+twz;
579
- res.coeffRef(1,1) = Scalar(1)-(txx+tzz);
580
- res.coeffRef(1,2) = tyz-twx;
581
- res.coeffRef(2,0) = txz-twy;
582
- res.coeffRef(2,1) = tyz+twx;
583
- res.coeffRef(2,2) = Scalar(1)-(txx+tyy);
654
+ const Scalar tx = Scalar(2) * this->x();
655
+ const Scalar ty = Scalar(2) * this->y();
656
+ const Scalar tz = Scalar(2) * this->z();
657
+ const Scalar twx = tx * this->w();
658
+ const Scalar twy = ty * this->w();
659
+ const Scalar twz = tz * this->w();
660
+ const Scalar txx = tx * this->x();
661
+ const Scalar txy = ty * this->x();
662
+ const Scalar txz = tz * this->x();
663
+ const Scalar tyy = ty * this->y();
664
+ const Scalar tyz = tz * this->y();
665
+ const Scalar tzz = tz * this->z();
666
+
667
+ res.coeffRef(0, 0) = Scalar(1) - (tyy + tzz);
668
+ res.coeffRef(0, 1) = txy - twz;
669
+ res.coeffRef(0, 2) = txz + twy;
670
+ res.coeffRef(1, 0) = txy + twz;
671
+ res.coeffRef(1, 1) = Scalar(1) - (txx + tzz);
672
+ res.coeffRef(1, 2) = tyz - twx;
673
+ res.coeffRef(2, 0) = txz - twy;
674
+ res.coeffRef(2, 1) = tyz + twx;
675
+ res.coeffRef(2, 2) = Scalar(1) - (txx + tyy);
584
676
 
585
677
  return res;
586
678
  }
587
679
 
588
680
  /** Sets \c *this to be a quaternion representing a rotation between
589
- * the two arbitrary vectors \a a and \a b. In other words, the built
590
- * rotation represent a rotation sending the line of direction \a a
591
- * to the line of direction \a b, both lines passing through the origin.
592
- *
593
- * \returns a reference to \c *this.
594
- *
595
- * Note that the two input vectors do \b not have to be normalized, and
596
- * do not need to have the same norm.
597
- */
598
- template<class Derived>
599
- template<typename Derived1, typename Derived2>
600
- EIGEN_DEVICE_FUNC inline Derived& QuaternionBase<Derived>::setFromTwoVectors(const MatrixBase<Derived1>& a, const MatrixBase<Derived2>& b)
601
- {
602
- EIGEN_USING_STD_MATH(sqrt)
681
+ * the two arbitrary vectors \a a and \a b. In other words, the built
682
+ * rotation represent a rotation sending the line of direction \a a
683
+ * to the line of direction \a b, both lines passing through the origin.
684
+ *
685
+ * \returns a reference to \c *this.
686
+ *
687
+ * Note that the two input vectors do \b not have to be normalized, and
688
+ * do not need to have the same norm.
689
+ */
690
+ template <class Derived>
691
+ template <typename Derived1, typename Derived2>
692
+ EIGEN_DEVICE_FUNC inline Derived& QuaternionBase<Derived>::setFromTwoVectors(const MatrixBase<Derived1>& a,
693
+ const MatrixBase<Derived2>& b) {
694
+ EIGEN_USING_STD(sqrt)
603
695
  Vector3 v0 = a.normalized();
604
696
  Vector3 v1 = b.normalized();
605
697
  Scalar c = v1.dot(v0);
@@ -612,21 +704,21 @@ EIGEN_DEVICE_FUNC inline Derived& QuaternionBase<Derived>::setFromTwoVectors(con
612
704
  // under the constraint:
613
705
  // ||x|| = 1
614
706
  // which yields a singular value problem
615
- if (c < Scalar(-1)+NumTraits<Scalar>::dummy_precision())
616
- {
617
- c = numext::maxi(c,Scalar(-1));
618
- Matrix<Scalar,2,3> m; m << v0.transpose(), v1.transpose();
619
- JacobiSVD<Matrix<Scalar,2,3> > svd(m, ComputeFullV);
707
+ if (c < Scalar(-1) + NumTraits<Scalar>::dummy_precision()) {
708
+ c = numext::maxi(c, Scalar(-1));
709
+ Matrix<Scalar, 2, 3> m;
710
+ m << v0.transpose(), v1.transpose();
711
+ JacobiSVD<Matrix<Scalar, 2, 3>, ComputeFullV> svd(m);
620
712
  Vector3 axis = svd.matrixV().col(2);
621
713
 
622
- Scalar w2 = (Scalar(1)+c)*Scalar(0.5);
714
+ Scalar w2 = (Scalar(1) + c) * Scalar(0.5);
623
715
  this->w() = sqrt(w2);
624
716
  this->vec() = axis * sqrt(Scalar(1) - w2);
625
717
  return derived();
626
718
  }
627
719
  Vector3 axis = v0.cross(v1);
628
- Scalar s = sqrt((Scalar(1)+c)*Scalar(2));
629
- Scalar invs = Scalar(1)/s;
720
+ Scalar s = sqrt((Scalar(1) + c) * Scalar(2));
721
+ Scalar invs = Scalar(1) / s;
630
722
  this->vec() = axis * invs;
631
723
  this->w() = s * Scalar(0.5);
632
724
 
@@ -634,59 +726,82 @@ EIGEN_DEVICE_FUNC inline Derived& QuaternionBase<Derived>::setFromTwoVectors(con
634
726
  }
635
727
 
636
728
  /** \returns a random unit quaternion following a uniform distribution law on SO(3)
637
- *
638
- * \note The implementation is based on http://planning.cs.uiuc.edu/node198.html
639
- */
640
- template<typename Scalar, int Options>
641
- EIGEN_DEVICE_FUNC Quaternion<Scalar,Options> Quaternion<Scalar,Options>::UnitRandom()
642
- {
643
- EIGEN_USING_STD_MATH(sqrt)
644
- EIGEN_USING_STD_MATH(sin)
645
- EIGEN_USING_STD_MATH(cos)
646
- const Scalar u1 = internal::random<Scalar>(0, 1),
647
- u2 = internal::random<Scalar>(0, 2*EIGEN_PI),
648
- u3 = internal::random<Scalar>(0, 2*EIGEN_PI);
649
- const Scalar a = sqrt(1 - u1),
650
- b = sqrt(u1);
651
- return Quaternion (a * sin(u2), a * cos(u2), b * sin(u3), b * cos(u3));
729
+ *
730
+ * \note The implementation is based on http://planning.cs.uiuc.edu/node198.html
731
+ */
732
+ template <typename Scalar, int Options>
733
+ EIGEN_DEVICE_FUNC Quaternion<Scalar, Options> Quaternion<Scalar, Options>::UnitRandom() {
734
+ EIGEN_USING_STD(sqrt)
735
+ EIGEN_USING_STD(sin)
736
+ EIGEN_USING_STD(cos)
737
+ const Scalar u1 = internal::random<Scalar>(0, 1), u2 = internal::random<Scalar>(0, 2 * EIGEN_PI),
738
+ u3 = internal::random<Scalar>(0, 2 * EIGEN_PI);
739
+ const Scalar a = sqrt(Scalar(1) - u1), b = sqrt(u1);
740
+ return Quaternion(a * sin(u2), a * cos(u2), b * sin(u3), b * cos(u3));
652
741
  }
653
742
 
743
+ /** Constructs a quaternion from its coefficients in the order [\c x, \c y, \c z, \c w], i.e. vector part [\c x, \c y,
744
+ * \c z] first, scalar part \a w LAST.
745
+ *
746
+ * This factory accepts the parameters in the same order as the underlying coefficient vector. Consider using this
747
+ * factory function to make the parameter ordering explicit.
748
+ */
749
+ template <typename Scalar, int Options>
750
+ EIGEN_DEVICE_FUNC Quaternion<Scalar, Options> Quaternion<Scalar, Options>::FromCoeffsScalarLast(const Scalar& x,
751
+ const Scalar& y,
752
+ const Scalar& z,
753
+ const Scalar& w) {
754
+ return Quaternion(w, x, y, z);
755
+ }
654
756
 
655
- /** Returns a quaternion representing a rotation between
656
- * the two arbitrary vectors \a a and \a b. In other words, the built
657
- * rotation represent a rotation sending the line of direction \a a
658
- * to the line of direction \a b, both lines passing through the origin.
659
- *
660
- * \returns resulting quaternion
661
- *
662
- * Note that the two input vectors do \b not have to be normalized, and
663
- * do not need to have the same norm.
664
- */
665
- template<typename Scalar, int Options>
666
- template<typename Derived1, typename Derived2>
667
- EIGEN_DEVICE_FUNC Quaternion<Scalar,Options> Quaternion<Scalar,Options>::FromTwoVectors(const MatrixBase<Derived1>& a, const MatrixBase<Derived2>& b)
668
- {
669
- Quaternion quat;
670
- quat.setFromTwoVectors(a, b);
671
- return quat;
757
+ /** Constructs a quaternion from its coefficients in the order [\c w, \c x, \c y, \c z], i.e. scalar part \a w FIRST,
758
+ * vector part [\c x, \c y, \c z] last.
759
+ *
760
+ * This factory accepts the parameters in the same order as the constructor \code Quaternion(const Scalar& w, const
761
+ * Scalar& x, const Scalar& y, const Scalar& z) \endcode. Consider using this factory function to make the parameter
762
+ * ordering explicit.
763
+ */
764
+ template <typename Scalar, int Options>
765
+ EIGEN_DEVICE_FUNC Quaternion<Scalar, Options> Quaternion<Scalar, Options>::FromCoeffsScalarFirst(const Scalar& w,
766
+ const Scalar& x,
767
+ const Scalar& y,
768
+ const Scalar& z) {
769
+ return Quaternion(w, x, y, z);
672
770
  }
673
771
 
772
+ /** Returns a quaternion representing a rotation between
773
+ * the two arbitrary vectors \a a and \a b. In other words, the built
774
+ * rotation represent a rotation sending the line of direction \a a
775
+ * to the line of direction \a b, both lines passing through the origin.
776
+ *
777
+ * \returns resulting quaternion
778
+ *
779
+ * Note that the two input vectors do \b not have to be normalized, and
780
+ * do not need to have the same norm.
781
+ */
782
+ template <typename Scalar, int Options>
783
+ template <typename Derived1, typename Derived2>
784
+ EIGEN_DEVICE_FUNC Quaternion<Scalar, Options> Quaternion<Scalar, Options>::FromTwoVectors(
785
+ const MatrixBase<Derived1>& a, const MatrixBase<Derived2>& b) {
786
+ Quaternion quat;
787
+ quat.setFromTwoVectors(a, b);
788
+ return quat;
789
+ }
674
790
 
675
791
  /** \returns the multiplicative inverse of \c *this
676
- * Note that in most cases, i.e., if you simply want the opposite rotation,
677
- * and/or the quaternion is normalized, then it is enough to use the conjugate.
678
- *
679
- * \sa QuaternionBase::conjugate()
680
- */
792
+ * Note that in most cases, i.e., if you simply want the opposite rotation,
793
+ * and/or the quaternion is normalized, then it is enough to use the conjugate.
794
+ *
795
+ * \sa QuaternionBase::conjugate()
796
+ */
681
797
  template <class Derived>
682
- EIGEN_DEVICE_FUNC inline Quaternion<typename internal::traits<Derived>::Scalar> QuaternionBase<Derived>::inverse() const
683
- {
798
+ EIGEN_DEVICE_FUNC inline Quaternion<typename internal::traits<Derived>::Scalar> QuaternionBase<Derived>::inverse()
799
+ const {
684
800
  // FIXME should this function be called multiplicativeInverse and conjugate() be called inverse() or opposite() ??
685
801
  Scalar n2 = this->squaredNorm();
686
802
  if (n2 > Scalar(0))
687
803
  return Quaternion<Scalar>(conjugate().coeffs() / n2);
688
- else
689
- {
804
+ else {
690
805
  // return an invalid result to flag the error
691
806
  return Quaternion<Scalar>(Coefficients::Zero());
692
807
  }
@@ -694,57 +809,50 @@ EIGEN_DEVICE_FUNC inline Quaternion<typename internal::traits<Derived>::Scalar>
694
809
 
695
810
  // Generic conjugate of a Quaternion
696
811
  namespace internal {
697
- template<int Arch, class Derived, typename Scalar> struct quat_conj
698
- {
699
- EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Quaternion<Scalar> run(const QuaternionBase<Derived>& q){
700
- return Quaternion<Scalar>(q.w(),-q.x(),-q.y(),-q.z());
812
+ template <int Arch, class Derived, typename Scalar>
813
+ struct quat_conj {
814
+ EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Quaternion<Scalar> run(const QuaternionBase<Derived>& q) {
815
+ return Quaternion<Scalar>(q.w(), -q.x(), -q.y(), -q.z());
701
816
  }
702
817
  };
703
- }
704
-
818
+ } // namespace internal
819
+
705
820
  /** \returns the conjugate of the \c *this which is equal to the multiplicative inverse
706
- * if the quaternion is normalized.
707
- * The conjugate of a quaternion represents the opposite rotation.
708
- *
709
- * \sa Quaternion2::inverse()
710
- */
821
+ * if the quaternion is normalized.
822
+ * The conjugate of a quaternion represents the opposite rotation.
823
+ *
824
+ * \sa Quaternion2::inverse()
825
+ */
711
826
  template <class Derived>
712
- EIGEN_DEVICE_FUNC inline Quaternion<typename internal::traits<Derived>::Scalar>
713
- QuaternionBase<Derived>::conjugate() const
714
- {
715
- return internal::quat_conj<Architecture::Target, Derived,
716
- typename internal::traits<Derived>::Scalar>::run(*this);
717
-
827
+ EIGEN_DEVICE_FUNC inline Quaternion<typename internal::traits<Derived>::Scalar> QuaternionBase<Derived>::conjugate()
828
+ const {
829
+ return internal::quat_conj<Architecture::Target, Derived, typename internal::traits<Derived>::Scalar>::run(*this);
718
830
  }
719
831
 
720
832
  /** \returns the angle (in radian) between two rotations
721
- * \sa dot()
722
- */
833
+ * \sa dot()
834
+ */
723
835
  template <class Derived>
724
836
  template <class OtherDerived>
725
- EIGEN_DEVICE_FUNC inline typename internal::traits<Derived>::Scalar
726
- QuaternionBase<Derived>::angularDistance(const QuaternionBase<OtherDerived>& other) const
727
- {
728
- EIGEN_USING_STD_MATH(atan2)
837
+ EIGEN_DEVICE_FUNC inline typename internal::traits<Derived>::Scalar QuaternionBase<Derived>::angularDistance(
838
+ const QuaternionBase<OtherDerived>& other) const {
839
+ EIGEN_USING_STD(atan2)
729
840
  Quaternion<Scalar> d = (*this) * other.conjugate();
730
- return Scalar(2) * atan2( d.vec().norm(), numext::abs(d.w()) );
841
+ return Scalar(2) * atan2(d.vec().norm(), numext::abs(d.w()));
731
842
  }
732
843
 
733
-
734
-
735
844
  /** \returns the spherical linear interpolation between the two quaternions
736
- * \c *this and \a other at the parameter \a t in [0;1].
737
- *
738
- * This represents an interpolation for a constant motion between \c *this and \a other,
739
- * see also http://en.wikipedia.org/wiki/Slerp.
740
- */
845
+ * \c *this and \a other at the parameter \a t in [0;1].
846
+ *
847
+ * This represents an interpolation for a constant motion between \c *this and \a other,
848
+ * see also http://en.wikipedia.org/wiki/Slerp.
849
+ */
741
850
  template <class Derived>
742
851
  template <class OtherDerived>
743
- EIGEN_DEVICE_FUNC Quaternion<typename internal::traits<Derived>::Scalar>
744
- QuaternionBase<Derived>::slerp(const Scalar& t, const QuaternionBase<OtherDerived>& other) const
745
- {
746
- EIGEN_USING_STD_MATH(acos)
747
- EIGEN_USING_STD_MATH(sin)
852
+ EIGEN_DEVICE_FUNC Quaternion<typename internal::traits<Derived>::Scalar> QuaternionBase<Derived>::slerp(
853
+ const Scalar& t, const QuaternionBase<OtherDerived>& other) const {
854
+ EIGEN_USING_STD(acos)
855
+ EIGEN_USING_STD(sin)
748
856
  const Scalar one = Scalar(1) - NumTraits<Scalar>::epsilon();
749
857
  Scalar d = this->dot(other);
750
858
  Scalar absD = numext::abs(d);
@@ -752,21 +860,18 @@ QuaternionBase<Derived>::slerp(const Scalar& t, const QuaternionBase<OtherDerive
752
860
  Scalar scale0;
753
861
  Scalar scale1;
754
862
 
755
- if(absD>=one)
756
- {
863
+ if (absD >= one) {
757
864
  scale0 = Scalar(1) - t;
758
865
  scale1 = t;
759
- }
760
- else
761
- {
866
+ } else {
762
867
  // theta is the angle between the 2 quaternions
763
868
  Scalar theta = acos(absD);
764
- Scalar sinTheta = sin(theta);
869
+ Scalar sinTheta = numext::sqrt(Scalar(1) - absD * absD);
765
870
 
766
- scale0 = sin( ( Scalar(1) - t ) * theta) / sinTheta;
767
- scale1 = sin( ( t * theta) ) / sinTheta;
871
+ scale0 = sin((Scalar(1) - t) * theta) / sinTheta;
872
+ scale1 = sin((t * theta)) / sinTheta;
768
873
  }
769
- if(d<Scalar(0)) scale1 = -scale1;
874
+ if (d < Scalar(0)) scale1 = -scale1;
770
875
 
771
876
  return Quaternion<Scalar>(scale0 * coeffs() + scale1 * other.coeffs());
772
877
  }
@@ -774,59 +879,52 @@ QuaternionBase<Derived>::slerp(const Scalar& t, const QuaternionBase<OtherDerive
774
879
  namespace internal {
775
880
 
776
881
  // set from a rotation matrix
777
- template<typename Other>
778
- struct quaternionbase_assign_impl<Other,3,3>
779
- {
882
+ template <typename Other>
883
+ struct quaternionbase_assign_impl<Other, 3, 3> {
780
884
  typedef typename Other::Scalar Scalar;
781
- template<class Derived> EIGEN_DEVICE_FUNC static inline void run(QuaternionBase<Derived>& q, const Other& a_mat)
782
- {
783
- const typename internal::nested_eval<Other,2>::type mat(a_mat);
784
- EIGEN_USING_STD_MATH(sqrt)
885
+ template <class Derived>
886
+ EIGEN_DEVICE_FUNC static inline void run(QuaternionBase<Derived>& q, const Other& a_mat) {
887
+ const typename internal::nested_eval<Other, 2>::type mat(a_mat);
888
+ EIGEN_USING_STD(sqrt)
785
889
  // This algorithm comes from "Quaternion Calculus and Fast Animation",
786
890
  // Ken Shoemake, 1987 SIGGRAPH course notes
787
891
  Scalar t = mat.trace();
788
- if (t > Scalar(0))
789
- {
892
+ if (t > Scalar(0)) {
790
893
  t = sqrt(t + Scalar(1.0));
791
- q.w() = Scalar(0.5)*t;
792
- t = Scalar(0.5)/t;
793
- q.x() = (mat.coeff(2,1) - mat.coeff(1,2)) * t;
794
- q.y() = (mat.coeff(0,2) - mat.coeff(2,0)) * t;
795
- q.z() = (mat.coeff(1,0) - mat.coeff(0,1)) * t;
796
- }
797
- else
798
- {
894
+ q.w() = Scalar(0.5) * t;
895
+ t = Scalar(0.5) / t;
896
+ q.x() = (mat.coeff(2, 1) - mat.coeff(1, 2)) * t;
897
+ q.y() = (mat.coeff(0, 2) - mat.coeff(2, 0)) * t;
898
+ q.z() = (mat.coeff(1, 0) - mat.coeff(0, 1)) * t;
899
+ } else {
799
900
  Index i = 0;
800
- if (mat.coeff(1,1) > mat.coeff(0,0))
801
- i = 1;
802
- if (mat.coeff(2,2) > mat.coeff(i,i))
803
- i = 2;
804
- Index j = (i+1)%3;
805
- Index k = (j+1)%3;
806
-
807
- t = sqrt(mat.coeff(i,i)-mat.coeff(j,j)-mat.coeff(k,k) + Scalar(1.0));
901
+ if (mat.coeff(1, 1) > mat.coeff(0, 0)) i = 1;
902
+ if (mat.coeff(2, 2) > mat.coeff(i, i)) i = 2;
903
+ Index j = (i + 1) % 3;
904
+ Index k = (j + 1) % 3;
905
+
906
+ t = sqrt(mat.coeff(i, i) - mat.coeff(j, j) - mat.coeff(k, k) + Scalar(1.0));
808
907
  q.coeffs().coeffRef(i) = Scalar(0.5) * t;
809
- t = Scalar(0.5)/t;
810
- q.w() = (mat.coeff(k,j)-mat.coeff(j,k))*t;
811
- q.coeffs().coeffRef(j) = (mat.coeff(j,i)+mat.coeff(i,j))*t;
812
- q.coeffs().coeffRef(k) = (mat.coeff(k,i)+mat.coeff(i,k))*t;
908
+ t = Scalar(0.5) / t;
909
+ q.w() = (mat.coeff(k, j) - mat.coeff(j, k)) * t;
910
+ q.coeffs().coeffRef(j) = (mat.coeff(j, i) + mat.coeff(i, j)) * t;
911
+ q.coeffs().coeffRef(k) = (mat.coeff(k, i) + mat.coeff(i, k)) * t;
813
912
  }
814
913
  }
815
914
  };
816
915
 
817
916
  // set from a vector of coefficients assumed to be a quaternion
818
- template<typename Other>
819
- struct quaternionbase_assign_impl<Other,4,1>
820
- {
917
+ template <typename Other>
918
+ struct quaternionbase_assign_impl<Other, 4, 1> {
821
919
  typedef typename Other::Scalar Scalar;
822
- template<class Derived> EIGEN_DEVICE_FUNC static inline void run(QuaternionBase<Derived>& q, const Other& vec)
823
- {
920
+ template <class Derived>
921
+ EIGEN_DEVICE_FUNC static inline void run(QuaternionBase<Derived>& q, const Other& vec) {
824
922
  q.coeffs() = vec;
825
923
  }
826
924
  };
827
925
 
828
- } // end namespace internal
926
+ } // end namespace internal
829
927
 
830
- } // end namespace Eigen
928
+ } // end namespace Eigen
831
929
 
832
- #endif // EIGEN_QUATERNION_H
930
+ #endif // EIGEN_QUATERNION_H