tomoto 0.1.0

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 (420) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +3 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +123 -0
  5. data/ext/tomoto/ext.cpp +245 -0
  6. data/ext/tomoto/extconf.rb +28 -0
  7. data/lib/tomoto.rb +12 -0
  8. data/lib/tomoto/ct.rb +11 -0
  9. data/lib/tomoto/hdp.rb +11 -0
  10. data/lib/tomoto/lda.rb +67 -0
  11. data/lib/tomoto/version.rb +3 -0
  12. data/vendor/EigenRand/EigenRand/Core.h +1139 -0
  13. data/vendor/EigenRand/EigenRand/Dists/Basic.h +111 -0
  14. data/vendor/EigenRand/EigenRand/Dists/Discrete.h +877 -0
  15. data/vendor/EigenRand/EigenRand/Dists/GammaPoisson.h +108 -0
  16. data/vendor/EigenRand/EigenRand/Dists/NormalExp.h +626 -0
  17. data/vendor/EigenRand/EigenRand/EigenRand +19 -0
  18. data/vendor/EigenRand/EigenRand/Macro.h +24 -0
  19. data/vendor/EigenRand/EigenRand/MorePacketMath.h +978 -0
  20. data/vendor/EigenRand/EigenRand/PacketFilter.h +286 -0
  21. data/vendor/EigenRand/EigenRand/PacketRandomEngine.h +624 -0
  22. data/vendor/EigenRand/EigenRand/RandUtils.h +413 -0
  23. data/vendor/EigenRand/EigenRand/doc.h +220 -0
  24. data/vendor/EigenRand/LICENSE +21 -0
  25. data/vendor/EigenRand/README.md +288 -0
  26. data/vendor/eigen/COPYING.BSD +26 -0
  27. data/vendor/eigen/COPYING.GPL +674 -0
  28. data/vendor/eigen/COPYING.LGPL +502 -0
  29. data/vendor/eigen/COPYING.MINPACK +52 -0
  30. data/vendor/eigen/COPYING.MPL2 +373 -0
  31. data/vendor/eigen/COPYING.README +18 -0
  32. data/vendor/eigen/Eigen/CMakeLists.txt +19 -0
  33. data/vendor/eigen/Eigen/Cholesky +46 -0
  34. data/vendor/eigen/Eigen/CholmodSupport +48 -0
  35. data/vendor/eigen/Eigen/Core +537 -0
  36. data/vendor/eigen/Eigen/Dense +7 -0
  37. data/vendor/eigen/Eigen/Eigen +2 -0
  38. data/vendor/eigen/Eigen/Eigenvalues +61 -0
  39. data/vendor/eigen/Eigen/Geometry +62 -0
  40. data/vendor/eigen/Eigen/Householder +30 -0
  41. data/vendor/eigen/Eigen/IterativeLinearSolvers +48 -0
  42. data/vendor/eigen/Eigen/Jacobi +33 -0
  43. data/vendor/eigen/Eigen/LU +50 -0
  44. data/vendor/eigen/Eigen/MetisSupport +35 -0
  45. data/vendor/eigen/Eigen/OrderingMethods +73 -0
  46. data/vendor/eigen/Eigen/PaStiXSupport +48 -0
  47. data/vendor/eigen/Eigen/PardisoSupport +35 -0
  48. data/vendor/eigen/Eigen/QR +51 -0
  49. data/vendor/eigen/Eigen/QtAlignedMalloc +40 -0
  50. data/vendor/eigen/Eigen/SPQRSupport +34 -0
  51. data/vendor/eigen/Eigen/SVD +51 -0
  52. data/vendor/eigen/Eigen/Sparse +36 -0
  53. data/vendor/eigen/Eigen/SparseCholesky +45 -0
  54. data/vendor/eigen/Eigen/SparseCore +69 -0
  55. data/vendor/eigen/Eigen/SparseLU +46 -0
  56. data/vendor/eigen/Eigen/SparseQR +37 -0
  57. data/vendor/eigen/Eigen/StdDeque +27 -0
  58. data/vendor/eigen/Eigen/StdList +26 -0
  59. data/vendor/eigen/Eigen/StdVector +27 -0
  60. data/vendor/eigen/Eigen/SuperLUSupport +64 -0
  61. data/vendor/eigen/Eigen/UmfPackSupport +40 -0
  62. data/vendor/eigen/Eigen/src/Cholesky/LDLT.h +673 -0
  63. data/vendor/eigen/Eigen/src/Cholesky/LLT.h +542 -0
  64. data/vendor/eigen/Eigen/src/Cholesky/LLT_LAPACKE.h +99 -0
  65. data/vendor/eigen/Eigen/src/CholmodSupport/CholmodSupport.h +639 -0
  66. data/vendor/eigen/Eigen/src/Core/Array.h +329 -0
  67. data/vendor/eigen/Eigen/src/Core/ArrayBase.h +226 -0
  68. data/vendor/eigen/Eigen/src/Core/ArrayWrapper.h +209 -0
  69. data/vendor/eigen/Eigen/src/Core/Assign.h +90 -0
  70. data/vendor/eigen/Eigen/src/Core/AssignEvaluator.h +935 -0
  71. data/vendor/eigen/Eigen/src/Core/Assign_MKL.h +178 -0
  72. data/vendor/eigen/Eigen/src/Core/BandMatrix.h +353 -0
  73. data/vendor/eigen/Eigen/src/Core/Block.h +452 -0
  74. data/vendor/eigen/Eigen/src/Core/BooleanRedux.h +164 -0
  75. data/vendor/eigen/Eigen/src/Core/CommaInitializer.h +160 -0
  76. data/vendor/eigen/Eigen/src/Core/ConditionEstimator.h +175 -0
  77. data/vendor/eigen/Eigen/src/Core/CoreEvaluators.h +1688 -0
  78. data/vendor/eigen/Eigen/src/Core/CoreIterators.h +127 -0
  79. data/vendor/eigen/Eigen/src/Core/CwiseBinaryOp.h +184 -0
  80. data/vendor/eigen/Eigen/src/Core/CwiseNullaryOp.h +866 -0
  81. data/vendor/eigen/Eigen/src/Core/CwiseTernaryOp.h +197 -0
  82. data/vendor/eigen/Eigen/src/Core/CwiseUnaryOp.h +103 -0
  83. data/vendor/eigen/Eigen/src/Core/CwiseUnaryView.h +128 -0
  84. data/vendor/eigen/Eigen/src/Core/DenseBase.h +611 -0
  85. data/vendor/eigen/Eigen/src/Core/DenseCoeffsBase.h +681 -0
  86. data/vendor/eigen/Eigen/src/Core/DenseStorage.h +570 -0
  87. data/vendor/eigen/Eigen/src/Core/Diagonal.h +260 -0
  88. data/vendor/eigen/Eigen/src/Core/DiagonalMatrix.h +343 -0
  89. data/vendor/eigen/Eigen/src/Core/DiagonalProduct.h +28 -0
  90. data/vendor/eigen/Eigen/src/Core/Dot.h +318 -0
  91. data/vendor/eigen/Eigen/src/Core/EigenBase.h +159 -0
  92. data/vendor/eigen/Eigen/src/Core/ForceAlignedAccess.h +146 -0
  93. data/vendor/eigen/Eigen/src/Core/Fuzzy.h +155 -0
  94. data/vendor/eigen/Eigen/src/Core/GeneralProduct.h +455 -0
  95. data/vendor/eigen/Eigen/src/Core/GenericPacketMath.h +593 -0
  96. data/vendor/eigen/Eigen/src/Core/GlobalFunctions.h +187 -0
  97. data/vendor/eigen/Eigen/src/Core/IO.h +225 -0
  98. data/vendor/eigen/Eigen/src/Core/Inverse.h +118 -0
  99. data/vendor/eigen/Eigen/src/Core/Map.h +171 -0
  100. data/vendor/eigen/Eigen/src/Core/MapBase.h +303 -0
  101. data/vendor/eigen/Eigen/src/Core/MathFunctions.h +1415 -0
  102. data/vendor/eigen/Eigen/src/Core/MathFunctionsImpl.h +101 -0
  103. data/vendor/eigen/Eigen/src/Core/Matrix.h +459 -0
  104. data/vendor/eigen/Eigen/src/Core/MatrixBase.h +529 -0
  105. data/vendor/eigen/Eigen/src/Core/NestByValue.h +110 -0
  106. data/vendor/eigen/Eigen/src/Core/NoAlias.h +108 -0
  107. data/vendor/eigen/Eigen/src/Core/NumTraits.h +248 -0
  108. data/vendor/eigen/Eigen/src/Core/PermutationMatrix.h +633 -0
  109. data/vendor/eigen/Eigen/src/Core/PlainObjectBase.h +1035 -0
  110. data/vendor/eigen/Eigen/src/Core/Product.h +186 -0
  111. data/vendor/eigen/Eigen/src/Core/ProductEvaluators.h +1112 -0
  112. data/vendor/eigen/Eigen/src/Core/Random.h +182 -0
  113. data/vendor/eigen/Eigen/src/Core/Redux.h +505 -0
  114. data/vendor/eigen/Eigen/src/Core/Ref.h +283 -0
  115. data/vendor/eigen/Eigen/src/Core/Replicate.h +142 -0
  116. data/vendor/eigen/Eigen/src/Core/ReturnByValue.h +117 -0
  117. data/vendor/eigen/Eigen/src/Core/Reverse.h +211 -0
  118. data/vendor/eigen/Eigen/src/Core/Select.h +162 -0
  119. data/vendor/eigen/Eigen/src/Core/SelfAdjointView.h +352 -0
  120. data/vendor/eigen/Eigen/src/Core/SelfCwiseBinaryOp.h +47 -0
  121. data/vendor/eigen/Eigen/src/Core/Solve.h +188 -0
  122. data/vendor/eigen/Eigen/src/Core/SolveTriangular.h +235 -0
  123. data/vendor/eigen/Eigen/src/Core/SolverBase.h +130 -0
  124. data/vendor/eigen/Eigen/src/Core/StableNorm.h +221 -0
  125. data/vendor/eigen/Eigen/src/Core/Stride.h +111 -0
  126. data/vendor/eigen/Eigen/src/Core/Swap.h +67 -0
  127. data/vendor/eigen/Eigen/src/Core/Transpose.h +403 -0
  128. data/vendor/eigen/Eigen/src/Core/Transpositions.h +407 -0
  129. data/vendor/eigen/Eigen/src/Core/TriangularMatrix.h +983 -0
  130. data/vendor/eigen/Eigen/src/Core/VectorBlock.h +96 -0
  131. data/vendor/eigen/Eigen/src/Core/VectorwiseOp.h +695 -0
  132. data/vendor/eigen/Eigen/src/Core/Visitor.h +273 -0
  133. data/vendor/eigen/Eigen/src/Core/arch/AVX/Complex.h +451 -0
  134. data/vendor/eigen/Eigen/src/Core/arch/AVX/MathFunctions.h +439 -0
  135. data/vendor/eigen/Eigen/src/Core/arch/AVX/PacketMath.h +637 -0
  136. data/vendor/eigen/Eigen/src/Core/arch/AVX/TypeCasting.h +51 -0
  137. data/vendor/eigen/Eigen/src/Core/arch/AVX512/MathFunctions.h +391 -0
  138. data/vendor/eigen/Eigen/src/Core/arch/AVX512/PacketMath.h +1316 -0
  139. data/vendor/eigen/Eigen/src/Core/arch/AltiVec/Complex.h +430 -0
  140. data/vendor/eigen/Eigen/src/Core/arch/AltiVec/MathFunctions.h +322 -0
  141. data/vendor/eigen/Eigen/src/Core/arch/AltiVec/PacketMath.h +1061 -0
  142. data/vendor/eigen/Eigen/src/Core/arch/CUDA/Complex.h +103 -0
  143. data/vendor/eigen/Eigen/src/Core/arch/CUDA/Half.h +674 -0
  144. data/vendor/eigen/Eigen/src/Core/arch/CUDA/MathFunctions.h +91 -0
  145. data/vendor/eigen/Eigen/src/Core/arch/CUDA/PacketMath.h +333 -0
  146. data/vendor/eigen/Eigen/src/Core/arch/CUDA/PacketMathHalf.h +1124 -0
  147. data/vendor/eigen/Eigen/src/Core/arch/CUDA/TypeCasting.h +212 -0
  148. data/vendor/eigen/Eigen/src/Core/arch/Default/ConjHelper.h +29 -0
  149. data/vendor/eigen/Eigen/src/Core/arch/Default/Settings.h +49 -0
  150. data/vendor/eigen/Eigen/src/Core/arch/NEON/Complex.h +490 -0
  151. data/vendor/eigen/Eigen/src/Core/arch/NEON/MathFunctions.h +91 -0
  152. data/vendor/eigen/Eigen/src/Core/arch/NEON/PacketMath.h +760 -0
  153. data/vendor/eigen/Eigen/src/Core/arch/SSE/Complex.h +471 -0
  154. data/vendor/eigen/Eigen/src/Core/arch/SSE/MathFunctions.h +562 -0
  155. data/vendor/eigen/Eigen/src/Core/arch/SSE/PacketMath.h +895 -0
  156. data/vendor/eigen/Eigen/src/Core/arch/SSE/TypeCasting.h +77 -0
  157. data/vendor/eigen/Eigen/src/Core/arch/ZVector/Complex.h +397 -0
  158. data/vendor/eigen/Eigen/src/Core/arch/ZVector/MathFunctions.h +137 -0
  159. data/vendor/eigen/Eigen/src/Core/arch/ZVector/PacketMath.h +945 -0
  160. data/vendor/eigen/Eigen/src/Core/functors/AssignmentFunctors.h +168 -0
  161. data/vendor/eigen/Eigen/src/Core/functors/BinaryFunctors.h +475 -0
  162. data/vendor/eigen/Eigen/src/Core/functors/NullaryFunctors.h +188 -0
  163. data/vendor/eigen/Eigen/src/Core/functors/StlFunctors.h +136 -0
  164. data/vendor/eigen/Eigen/src/Core/functors/TernaryFunctors.h +25 -0
  165. data/vendor/eigen/Eigen/src/Core/functors/UnaryFunctors.h +792 -0
  166. data/vendor/eigen/Eigen/src/Core/products/GeneralBlockPanelKernel.h +2156 -0
  167. data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixMatrix.h +492 -0
  168. data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h +311 -0
  169. data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_BLAS.h +145 -0
  170. data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixMatrix_BLAS.h +122 -0
  171. data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixVector.h +619 -0
  172. data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixVector_BLAS.h +136 -0
  173. data/vendor/eigen/Eigen/src/Core/products/Parallelizer.h +163 -0
  174. data/vendor/eigen/Eigen/src/Core/products/SelfadjointMatrixMatrix.h +521 -0
  175. data/vendor/eigen/Eigen/src/Core/products/SelfadjointMatrixMatrix_BLAS.h +287 -0
  176. data/vendor/eigen/Eigen/src/Core/products/SelfadjointMatrixVector.h +260 -0
  177. data/vendor/eigen/Eigen/src/Core/products/SelfadjointMatrixVector_BLAS.h +118 -0
  178. data/vendor/eigen/Eigen/src/Core/products/SelfadjointProduct.h +133 -0
  179. data/vendor/eigen/Eigen/src/Core/products/SelfadjointRank2Update.h +93 -0
  180. data/vendor/eigen/Eigen/src/Core/products/TriangularMatrixMatrix.h +466 -0
  181. data/vendor/eigen/Eigen/src/Core/products/TriangularMatrixMatrix_BLAS.h +315 -0
  182. data/vendor/eigen/Eigen/src/Core/products/TriangularMatrixVector.h +350 -0
  183. data/vendor/eigen/Eigen/src/Core/products/TriangularMatrixVector_BLAS.h +255 -0
  184. data/vendor/eigen/Eigen/src/Core/products/TriangularSolverMatrix.h +335 -0
  185. data/vendor/eigen/Eigen/src/Core/products/TriangularSolverMatrix_BLAS.h +163 -0
  186. data/vendor/eigen/Eigen/src/Core/products/TriangularSolverVector.h +145 -0
  187. data/vendor/eigen/Eigen/src/Core/util/BlasUtil.h +398 -0
  188. data/vendor/eigen/Eigen/src/Core/util/Constants.h +547 -0
  189. data/vendor/eigen/Eigen/src/Core/util/DisableStupidWarnings.h +83 -0
  190. data/vendor/eigen/Eigen/src/Core/util/ForwardDeclarations.h +302 -0
  191. data/vendor/eigen/Eigen/src/Core/util/MKL_support.h +130 -0
  192. data/vendor/eigen/Eigen/src/Core/util/Macros.h +1001 -0
  193. data/vendor/eigen/Eigen/src/Core/util/Memory.h +993 -0
  194. data/vendor/eigen/Eigen/src/Core/util/Meta.h +534 -0
  195. data/vendor/eigen/Eigen/src/Core/util/NonMPL2.h +3 -0
  196. data/vendor/eigen/Eigen/src/Core/util/ReenableStupidWarnings.h +27 -0
  197. data/vendor/eigen/Eigen/src/Core/util/StaticAssert.h +218 -0
  198. data/vendor/eigen/Eigen/src/Core/util/XprHelper.h +821 -0
  199. data/vendor/eigen/Eigen/src/Eigenvalues/ComplexEigenSolver.h +346 -0
  200. data/vendor/eigen/Eigen/src/Eigenvalues/ComplexSchur.h +459 -0
  201. data/vendor/eigen/Eigen/src/Eigenvalues/ComplexSchur_LAPACKE.h +91 -0
  202. data/vendor/eigen/Eigen/src/Eigenvalues/EigenSolver.h +622 -0
  203. data/vendor/eigen/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h +418 -0
  204. data/vendor/eigen/Eigen/src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h +226 -0
  205. data/vendor/eigen/Eigen/src/Eigenvalues/HessenbergDecomposition.h +374 -0
  206. data/vendor/eigen/Eigen/src/Eigenvalues/MatrixBaseEigenvalues.h +158 -0
  207. data/vendor/eigen/Eigen/src/Eigenvalues/RealQZ.h +654 -0
  208. data/vendor/eigen/Eigen/src/Eigenvalues/RealSchur.h +546 -0
  209. data/vendor/eigen/Eigen/src/Eigenvalues/RealSchur_LAPACKE.h +77 -0
  210. data/vendor/eigen/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h +870 -0
  211. data/vendor/eigen/Eigen/src/Eigenvalues/SelfAdjointEigenSolver_LAPACKE.h +87 -0
  212. data/vendor/eigen/Eigen/src/Eigenvalues/Tridiagonalization.h +556 -0
  213. data/vendor/eigen/Eigen/src/Geometry/AlignedBox.h +392 -0
  214. data/vendor/eigen/Eigen/src/Geometry/AngleAxis.h +247 -0
  215. data/vendor/eigen/Eigen/src/Geometry/EulerAngles.h +114 -0
  216. data/vendor/eigen/Eigen/src/Geometry/Homogeneous.h +497 -0
  217. data/vendor/eigen/Eigen/src/Geometry/Hyperplane.h +282 -0
  218. data/vendor/eigen/Eigen/src/Geometry/OrthoMethods.h +234 -0
  219. data/vendor/eigen/Eigen/src/Geometry/ParametrizedLine.h +195 -0
  220. data/vendor/eigen/Eigen/src/Geometry/Quaternion.h +814 -0
  221. data/vendor/eigen/Eigen/src/Geometry/Rotation2D.h +199 -0
  222. data/vendor/eigen/Eigen/src/Geometry/RotationBase.h +206 -0
  223. data/vendor/eigen/Eigen/src/Geometry/Scaling.h +170 -0
  224. data/vendor/eigen/Eigen/src/Geometry/Transform.h +1542 -0
  225. data/vendor/eigen/Eigen/src/Geometry/Translation.h +208 -0
  226. data/vendor/eigen/Eigen/src/Geometry/Umeyama.h +166 -0
  227. data/vendor/eigen/Eigen/src/Geometry/arch/Geometry_SSE.h +161 -0
  228. data/vendor/eigen/Eigen/src/Householder/BlockHouseholder.h +103 -0
  229. data/vendor/eigen/Eigen/src/Householder/Householder.h +172 -0
  230. data/vendor/eigen/Eigen/src/Householder/HouseholderSequence.h +470 -0
  231. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h +226 -0
  232. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h +228 -0
  233. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h +246 -0
  234. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/IncompleteCholesky.h +400 -0
  235. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h +462 -0
  236. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h +394 -0
  237. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/LeastSquareConjugateGradient.h +216 -0
  238. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/SolveWithGuess.h +115 -0
  239. data/vendor/eigen/Eigen/src/Jacobi/Jacobi.h +462 -0
  240. data/vendor/eigen/Eigen/src/LU/Determinant.h +101 -0
  241. data/vendor/eigen/Eigen/src/LU/FullPivLU.h +891 -0
  242. data/vendor/eigen/Eigen/src/LU/InverseImpl.h +415 -0
  243. data/vendor/eigen/Eigen/src/LU/PartialPivLU.h +611 -0
  244. data/vendor/eigen/Eigen/src/LU/PartialPivLU_LAPACKE.h +83 -0
  245. data/vendor/eigen/Eigen/src/LU/arch/Inverse_SSE.h +338 -0
  246. data/vendor/eigen/Eigen/src/MetisSupport/MetisSupport.h +137 -0
  247. data/vendor/eigen/Eigen/src/OrderingMethods/Amd.h +445 -0
  248. data/vendor/eigen/Eigen/src/OrderingMethods/Eigen_Colamd.h +1843 -0
  249. data/vendor/eigen/Eigen/src/OrderingMethods/Ordering.h +157 -0
  250. data/vendor/eigen/Eigen/src/PaStiXSupport/PaStiXSupport.h +678 -0
  251. data/vendor/eigen/Eigen/src/PardisoSupport/PardisoSupport.h +543 -0
  252. data/vendor/eigen/Eigen/src/QR/ColPivHouseholderQR.h +653 -0
  253. data/vendor/eigen/Eigen/src/QR/ColPivHouseholderQR_LAPACKE.h +97 -0
  254. data/vendor/eigen/Eigen/src/QR/CompleteOrthogonalDecomposition.h +562 -0
  255. data/vendor/eigen/Eigen/src/QR/FullPivHouseholderQR.h +676 -0
  256. data/vendor/eigen/Eigen/src/QR/HouseholderQR.h +409 -0
  257. data/vendor/eigen/Eigen/src/QR/HouseholderQR_LAPACKE.h +68 -0
  258. data/vendor/eigen/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h +313 -0
  259. data/vendor/eigen/Eigen/src/SVD/BDCSVD.h +1246 -0
  260. data/vendor/eigen/Eigen/src/SVD/JacobiSVD.h +804 -0
  261. data/vendor/eigen/Eigen/src/SVD/JacobiSVD_LAPACKE.h +91 -0
  262. data/vendor/eigen/Eigen/src/SVD/SVDBase.h +315 -0
  263. data/vendor/eigen/Eigen/src/SVD/UpperBidiagonalization.h +414 -0
  264. data/vendor/eigen/Eigen/src/SparseCholesky/SimplicialCholesky.h +689 -0
  265. data/vendor/eigen/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h +199 -0
  266. data/vendor/eigen/Eigen/src/SparseCore/AmbiVector.h +377 -0
  267. data/vendor/eigen/Eigen/src/SparseCore/CompressedStorage.h +258 -0
  268. data/vendor/eigen/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h +352 -0
  269. data/vendor/eigen/Eigen/src/SparseCore/MappedSparseMatrix.h +67 -0
  270. data/vendor/eigen/Eigen/src/SparseCore/SparseAssign.h +216 -0
  271. data/vendor/eigen/Eigen/src/SparseCore/SparseBlock.h +603 -0
  272. data/vendor/eigen/Eigen/src/SparseCore/SparseColEtree.h +206 -0
  273. data/vendor/eigen/Eigen/src/SparseCore/SparseCompressedBase.h +341 -0
  274. data/vendor/eigen/Eigen/src/SparseCore/SparseCwiseBinaryOp.h +726 -0
  275. data/vendor/eigen/Eigen/src/SparseCore/SparseCwiseUnaryOp.h +148 -0
  276. data/vendor/eigen/Eigen/src/SparseCore/SparseDenseProduct.h +320 -0
  277. data/vendor/eigen/Eigen/src/SparseCore/SparseDiagonalProduct.h +138 -0
  278. data/vendor/eigen/Eigen/src/SparseCore/SparseDot.h +98 -0
  279. data/vendor/eigen/Eigen/src/SparseCore/SparseFuzzy.h +29 -0
  280. data/vendor/eigen/Eigen/src/SparseCore/SparseMap.h +305 -0
  281. data/vendor/eigen/Eigen/src/SparseCore/SparseMatrix.h +1403 -0
  282. data/vendor/eigen/Eigen/src/SparseCore/SparseMatrixBase.h +405 -0
  283. data/vendor/eigen/Eigen/src/SparseCore/SparsePermutation.h +178 -0
  284. data/vendor/eigen/Eigen/src/SparseCore/SparseProduct.h +169 -0
  285. data/vendor/eigen/Eigen/src/SparseCore/SparseRedux.h +49 -0
  286. data/vendor/eigen/Eigen/src/SparseCore/SparseRef.h +397 -0
  287. data/vendor/eigen/Eigen/src/SparseCore/SparseSelfAdjointView.h +656 -0
  288. data/vendor/eigen/Eigen/src/SparseCore/SparseSolverBase.h +124 -0
  289. data/vendor/eigen/Eigen/src/SparseCore/SparseSparseProductWithPruning.h +198 -0
  290. data/vendor/eigen/Eigen/src/SparseCore/SparseTranspose.h +92 -0
  291. data/vendor/eigen/Eigen/src/SparseCore/SparseTriangularView.h +189 -0
  292. data/vendor/eigen/Eigen/src/SparseCore/SparseUtil.h +178 -0
  293. data/vendor/eigen/Eigen/src/SparseCore/SparseVector.h +478 -0
  294. data/vendor/eigen/Eigen/src/SparseCore/SparseView.h +253 -0
  295. data/vendor/eigen/Eigen/src/SparseCore/TriangularSolver.h +315 -0
  296. data/vendor/eigen/Eigen/src/SparseLU/SparseLU.h +773 -0
  297. data/vendor/eigen/Eigen/src/SparseLU/SparseLUImpl.h +66 -0
  298. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_Memory.h +226 -0
  299. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_Structs.h +110 -0
  300. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h +301 -0
  301. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_Utils.h +80 -0
  302. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_column_bmod.h +181 -0
  303. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_column_dfs.h +179 -0
  304. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h +107 -0
  305. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_gemm_kernel.h +280 -0
  306. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h +126 -0
  307. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_kernel_bmod.h +130 -0
  308. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_panel_bmod.h +223 -0
  309. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_panel_dfs.h +258 -0
  310. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_pivotL.h +137 -0
  311. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_pruneL.h +136 -0
  312. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_relax_snode.h +83 -0
  313. data/vendor/eigen/Eigen/src/SparseQR/SparseQR.h +745 -0
  314. data/vendor/eigen/Eigen/src/StlSupport/StdDeque.h +126 -0
  315. data/vendor/eigen/Eigen/src/StlSupport/StdList.h +106 -0
  316. data/vendor/eigen/Eigen/src/StlSupport/StdVector.h +131 -0
  317. data/vendor/eigen/Eigen/src/StlSupport/details.h +84 -0
  318. data/vendor/eigen/Eigen/src/SuperLUSupport/SuperLUSupport.h +1027 -0
  319. data/vendor/eigen/Eigen/src/UmfPackSupport/UmfPackSupport.h +506 -0
  320. data/vendor/eigen/Eigen/src/misc/Image.h +82 -0
  321. data/vendor/eigen/Eigen/src/misc/Kernel.h +79 -0
  322. data/vendor/eigen/Eigen/src/misc/RealSvd2x2.h +55 -0
  323. data/vendor/eigen/Eigen/src/misc/blas.h +440 -0
  324. data/vendor/eigen/Eigen/src/misc/lapack.h +152 -0
  325. data/vendor/eigen/Eigen/src/misc/lapacke.h +16291 -0
  326. data/vendor/eigen/Eigen/src/misc/lapacke_mangling.h +17 -0
  327. data/vendor/eigen/Eigen/src/plugins/ArrayCwiseBinaryOps.h +332 -0
  328. data/vendor/eigen/Eigen/src/plugins/ArrayCwiseUnaryOps.h +552 -0
  329. data/vendor/eigen/Eigen/src/plugins/BlockMethods.h +1058 -0
  330. data/vendor/eigen/Eigen/src/plugins/CommonCwiseBinaryOps.h +115 -0
  331. data/vendor/eigen/Eigen/src/plugins/CommonCwiseUnaryOps.h +163 -0
  332. data/vendor/eigen/Eigen/src/plugins/MatrixCwiseBinaryOps.h +152 -0
  333. data/vendor/eigen/Eigen/src/plugins/MatrixCwiseUnaryOps.h +85 -0
  334. data/vendor/eigen/README.md +3 -0
  335. data/vendor/eigen/bench/README.txt +55 -0
  336. data/vendor/eigen/bench/btl/COPYING +340 -0
  337. data/vendor/eigen/bench/btl/README +154 -0
  338. data/vendor/eigen/bench/tensors/README +21 -0
  339. data/vendor/eigen/blas/README.txt +6 -0
  340. data/vendor/eigen/demos/mandelbrot/README +10 -0
  341. data/vendor/eigen/demos/mix_eigen_and_c/README +9 -0
  342. data/vendor/eigen/demos/opengl/README +13 -0
  343. data/vendor/eigen/unsupported/Eigen/CXX11/src/Tensor/README.md +1760 -0
  344. data/vendor/eigen/unsupported/README.txt +50 -0
  345. data/vendor/tomotopy/LICENSE +21 -0
  346. data/vendor/tomotopy/README.kr.rst +375 -0
  347. data/vendor/tomotopy/README.rst +382 -0
  348. data/vendor/tomotopy/src/Labeling/FoRelevance.cpp +362 -0
  349. data/vendor/tomotopy/src/Labeling/FoRelevance.h +88 -0
  350. data/vendor/tomotopy/src/Labeling/Labeler.h +50 -0
  351. data/vendor/tomotopy/src/TopicModel/CT.h +37 -0
  352. data/vendor/tomotopy/src/TopicModel/CTModel.cpp +13 -0
  353. data/vendor/tomotopy/src/TopicModel/CTModel.hpp +293 -0
  354. data/vendor/tomotopy/src/TopicModel/DMR.h +51 -0
  355. data/vendor/tomotopy/src/TopicModel/DMRModel.cpp +13 -0
  356. data/vendor/tomotopy/src/TopicModel/DMRModel.hpp +374 -0
  357. data/vendor/tomotopy/src/TopicModel/DT.h +65 -0
  358. data/vendor/tomotopy/src/TopicModel/DTM.h +22 -0
  359. data/vendor/tomotopy/src/TopicModel/DTModel.cpp +15 -0
  360. data/vendor/tomotopy/src/TopicModel/DTModel.hpp +572 -0
  361. data/vendor/tomotopy/src/TopicModel/GDMR.h +37 -0
  362. data/vendor/tomotopy/src/TopicModel/GDMRModel.cpp +14 -0
  363. data/vendor/tomotopy/src/TopicModel/GDMRModel.hpp +485 -0
  364. data/vendor/tomotopy/src/TopicModel/HDP.h +74 -0
  365. data/vendor/tomotopy/src/TopicModel/HDPModel.cpp +13 -0
  366. data/vendor/tomotopy/src/TopicModel/HDPModel.hpp +592 -0
  367. data/vendor/tomotopy/src/TopicModel/HLDA.h +40 -0
  368. data/vendor/tomotopy/src/TopicModel/HLDAModel.cpp +13 -0
  369. data/vendor/tomotopy/src/TopicModel/HLDAModel.hpp +681 -0
  370. data/vendor/tomotopy/src/TopicModel/HPA.h +27 -0
  371. data/vendor/tomotopy/src/TopicModel/HPAModel.cpp +21 -0
  372. data/vendor/tomotopy/src/TopicModel/HPAModel.hpp +588 -0
  373. data/vendor/tomotopy/src/TopicModel/LDA.h +144 -0
  374. data/vendor/tomotopy/src/TopicModel/LDACVB0Model.hpp +442 -0
  375. data/vendor/tomotopy/src/TopicModel/LDAModel.cpp +13 -0
  376. data/vendor/tomotopy/src/TopicModel/LDAModel.hpp +1058 -0
  377. data/vendor/tomotopy/src/TopicModel/LLDA.h +45 -0
  378. data/vendor/tomotopy/src/TopicModel/LLDAModel.cpp +13 -0
  379. data/vendor/tomotopy/src/TopicModel/LLDAModel.hpp +203 -0
  380. data/vendor/tomotopy/src/TopicModel/MGLDA.h +63 -0
  381. data/vendor/tomotopy/src/TopicModel/MGLDAModel.cpp +17 -0
  382. data/vendor/tomotopy/src/TopicModel/MGLDAModel.hpp +558 -0
  383. data/vendor/tomotopy/src/TopicModel/PA.h +43 -0
  384. data/vendor/tomotopy/src/TopicModel/PAModel.cpp +13 -0
  385. data/vendor/tomotopy/src/TopicModel/PAModel.hpp +467 -0
  386. data/vendor/tomotopy/src/TopicModel/PLDA.h +17 -0
  387. data/vendor/tomotopy/src/TopicModel/PLDAModel.cpp +13 -0
  388. data/vendor/tomotopy/src/TopicModel/PLDAModel.hpp +214 -0
  389. data/vendor/tomotopy/src/TopicModel/SLDA.h +54 -0
  390. data/vendor/tomotopy/src/TopicModel/SLDAModel.cpp +17 -0
  391. data/vendor/tomotopy/src/TopicModel/SLDAModel.hpp +456 -0
  392. data/vendor/tomotopy/src/TopicModel/TopicModel.hpp +692 -0
  393. data/vendor/tomotopy/src/Utils/AliasMethod.hpp +169 -0
  394. data/vendor/tomotopy/src/Utils/Dictionary.h +80 -0
  395. data/vendor/tomotopy/src/Utils/EigenAddonOps.hpp +181 -0
  396. data/vendor/tomotopy/src/Utils/LBFGS.h +202 -0
  397. data/vendor/tomotopy/src/Utils/LBFGS/LineSearchBacktracking.h +120 -0
  398. data/vendor/tomotopy/src/Utils/LBFGS/LineSearchBracketing.h +122 -0
  399. data/vendor/tomotopy/src/Utils/LBFGS/Param.h +213 -0
  400. data/vendor/tomotopy/src/Utils/LUT.hpp +82 -0
  401. data/vendor/tomotopy/src/Utils/MultiNormalDistribution.hpp +69 -0
  402. data/vendor/tomotopy/src/Utils/PolyaGamma.hpp +200 -0
  403. data/vendor/tomotopy/src/Utils/PolyaGammaHybrid.hpp +672 -0
  404. data/vendor/tomotopy/src/Utils/ThreadPool.hpp +150 -0
  405. data/vendor/tomotopy/src/Utils/Trie.hpp +220 -0
  406. data/vendor/tomotopy/src/Utils/TruncMultiNormal.hpp +94 -0
  407. data/vendor/tomotopy/src/Utils/Utils.hpp +337 -0
  408. data/vendor/tomotopy/src/Utils/avx_gamma.h +46 -0
  409. data/vendor/tomotopy/src/Utils/avx_mathfun.h +736 -0
  410. data/vendor/tomotopy/src/Utils/exception.h +28 -0
  411. data/vendor/tomotopy/src/Utils/math.h +281 -0
  412. data/vendor/tomotopy/src/Utils/rtnorm.hpp +2690 -0
  413. data/vendor/tomotopy/src/Utils/sample.hpp +192 -0
  414. data/vendor/tomotopy/src/Utils/serializer.hpp +695 -0
  415. data/vendor/tomotopy/src/Utils/slp.hpp +131 -0
  416. data/vendor/tomotopy/src/Utils/sse_gamma.h +48 -0
  417. data/vendor/tomotopy/src/Utils/sse_mathfun.h +710 -0
  418. data/vendor/tomotopy/src/Utils/text.hpp +49 -0
  419. data/vendor/tomotopy/src/Utils/tvector.hpp +543 -0
  420. metadata +531 -0
@@ -0,0 +1,195 @@
1
+ // This file is part of Eigen, a lightweight C++ template library
2
+ // for linear algebra.
3
+ //
4
+ // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
5
+ // Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>
6
+ //
7
+ // This Source Code Form is subject to the terms of the Mozilla
8
+ // Public License v. 2.0. If a copy of the MPL was not distributed
9
+ // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10
+
11
+ #ifndef EIGEN_PARAMETRIZEDLINE_H
12
+ #define EIGEN_PARAMETRIZEDLINE_H
13
+
14
+ namespace Eigen {
15
+
16
+ /** \geometry_module \ingroup Geometry_Module
17
+ *
18
+ * \class ParametrizedLine
19
+ *
20
+ * \brief A parametrized line
21
+ *
22
+ * A parametrized line is defined by an origin point \f$ \mathbf{o} \f$ and a unit
23
+ * direction vector \f$ \mathbf{d} \f$ such that the line corresponds to
24
+ * the set \f$ l(t) = \mathbf{o} + t \mathbf{d} \f$, \f$ t \in \mathbf{R} \f$.
25
+ *
26
+ * \tparam _Scalar the scalar type, i.e., the type of the coefficients
27
+ * \tparam _AmbientDim the dimension of the ambient space, can be a compile time value or Dynamic.
28
+ */
29
+ template <typename _Scalar, int _AmbientDim, int _Options>
30
+ class ParametrizedLine
31
+ {
32
+ public:
33
+ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim)
34
+ enum {
35
+ AmbientDimAtCompileTime = _AmbientDim,
36
+ Options = _Options
37
+ };
38
+ typedef _Scalar Scalar;
39
+ typedef typename NumTraits<Scalar>::Real RealScalar;
40
+ typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3
41
+ typedef Matrix<Scalar,AmbientDimAtCompileTime,1,Options> VectorType;
42
+
43
+ /** Default constructor without initialization */
44
+ EIGEN_DEVICE_FUNC inline ParametrizedLine() {}
45
+
46
+ template<int OtherOptions>
47
+ EIGEN_DEVICE_FUNC ParametrizedLine(const ParametrizedLine<Scalar,AmbientDimAtCompileTime,OtherOptions>& other)
48
+ : m_origin(other.origin()), m_direction(other.direction())
49
+ {}
50
+
51
+ /** Constructs a dynamic-size line with \a _dim the dimension
52
+ * of the ambient space */
53
+ EIGEN_DEVICE_FUNC inline explicit ParametrizedLine(Index _dim) : m_origin(_dim), m_direction(_dim) {}
54
+
55
+ /** Initializes a parametrized line of direction \a direction and origin \a origin.
56
+ * \warning the vector direction is assumed to be normalized.
57
+ */
58
+ EIGEN_DEVICE_FUNC ParametrizedLine(const VectorType& origin, const VectorType& direction)
59
+ : m_origin(origin), m_direction(direction) {}
60
+
61
+ template <int OtherOptions>
62
+ EIGEN_DEVICE_FUNC explicit ParametrizedLine(const Hyperplane<_Scalar, _AmbientDim, OtherOptions>& hyperplane);
63
+
64
+ /** Constructs a parametrized line going from \a p0 to \a p1. */
65
+ EIGEN_DEVICE_FUNC static inline ParametrizedLine Through(const VectorType& p0, const VectorType& p1)
66
+ { return ParametrizedLine(p0, (p1-p0).normalized()); }
67
+
68
+ EIGEN_DEVICE_FUNC ~ParametrizedLine() {}
69
+
70
+ /** \returns the dimension in which the line holds */
71
+ EIGEN_DEVICE_FUNC inline Index dim() const { return m_direction.size(); }
72
+
73
+ EIGEN_DEVICE_FUNC const VectorType& origin() const { return m_origin; }
74
+ EIGEN_DEVICE_FUNC VectorType& origin() { return m_origin; }
75
+
76
+ EIGEN_DEVICE_FUNC const VectorType& direction() const { return m_direction; }
77
+ EIGEN_DEVICE_FUNC VectorType& direction() { return m_direction; }
78
+
79
+ /** \returns the squared distance of a point \a p to its projection onto the line \c *this.
80
+ * \sa distance()
81
+ */
82
+ EIGEN_DEVICE_FUNC RealScalar squaredDistance(const VectorType& p) const
83
+ {
84
+ VectorType diff = p - origin();
85
+ return (diff - direction().dot(diff) * direction()).squaredNorm();
86
+ }
87
+ /** \returns the distance of a point \a p to its projection onto the line \c *this.
88
+ * \sa squaredDistance()
89
+ */
90
+ EIGEN_DEVICE_FUNC RealScalar distance(const VectorType& p) const { EIGEN_USING_STD_MATH(sqrt) return sqrt(squaredDistance(p)); }
91
+
92
+ /** \returns the projection of a point \a p onto the line \c *this. */
93
+ EIGEN_DEVICE_FUNC VectorType projection(const VectorType& p) const
94
+ { return origin() + direction().dot(p-origin()) * direction(); }
95
+
96
+ EIGEN_DEVICE_FUNC VectorType pointAt(const Scalar& t) const;
97
+
98
+ template <int OtherOptions>
99
+ EIGEN_DEVICE_FUNC Scalar intersectionParameter(const Hyperplane<_Scalar, _AmbientDim, OtherOptions>& hyperplane) const;
100
+
101
+ template <int OtherOptions>
102
+ EIGEN_DEVICE_FUNC Scalar intersection(const Hyperplane<_Scalar, _AmbientDim, OtherOptions>& hyperplane) const;
103
+
104
+ template <int OtherOptions>
105
+ EIGEN_DEVICE_FUNC VectorType intersectionPoint(const Hyperplane<_Scalar, _AmbientDim, OtherOptions>& hyperplane) const;
106
+
107
+ /** \returns \c *this with scalar type casted to \a NewScalarType
108
+ *
109
+ * Note that if \a NewScalarType is equal to the current scalar type of \c *this
110
+ * then this function smartly returns a const reference to \c *this.
111
+ */
112
+ template<typename NewScalarType>
113
+ EIGEN_DEVICE_FUNC inline typename internal::cast_return_type<ParametrizedLine,
114
+ ParametrizedLine<NewScalarType,AmbientDimAtCompileTime,Options> >::type cast() const
115
+ {
116
+ return typename internal::cast_return_type<ParametrizedLine,
117
+ ParametrizedLine<NewScalarType,AmbientDimAtCompileTime,Options> >::type(*this);
118
+ }
119
+
120
+ /** Copy constructor with scalar type conversion */
121
+ template<typename OtherScalarType,int OtherOptions>
122
+ EIGEN_DEVICE_FUNC inline explicit ParametrizedLine(const ParametrizedLine<OtherScalarType,AmbientDimAtCompileTime,OtherOptions>& other)
123
+ {
124
+ m_origin = other.origin().template cast<Scalar>();
125
+ m_direction = other.direction().template cast<Scalar>();
126
+ }
127
+
128
+ /** \returns \c true if \c *this is approximately equal to \a other, within the precision
129
+ * determined by \a prec.
130
+ *
131
+ * \sa MatrixBase::isApprox() */
132
+ EIGEN_DEVICE_FUNC bool isApprox(const ParametrizedLine& other, const typename NumTraits<Scalar>::Real& prec = NumTraits<Scalar>::dummy_precision()) const
133
+ { return m_origin.isApprox(other.m_origin, prec) && m_direction.isApprox(other.m_direction, prec); }
134
+
135
+ protected:
136
+
137
+ VectorType m_origin, m_direction;
138
+ };
139
+
140
+ /** Constructs a parametrized line from a 2D hyperplane
141
+ *
142
+ * \warning the ambient space must have dimension 2 such that the hyperplane actually describes a line
143
+ */
144
+ template <typename _Scalar, int _AmbientDim, int _Options>
145
+ template <int OtherOptions>
146
+ EIGEN_DEVICE_FUNC inline ParametrizedLine<_Scalar, _AmbientDim,_Options>::ParametrizedLine(const Hyperplane<_Scalar, _AmbientDim,OtherOptions>& hyperplane)
147
+ {
148
+ EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(VectorType, 2)
149
+ direction() = hyperplane.normal().unitOrthogonal();
150
+ origin() = -hyperplane.normal()*hyperplane.offset();
151
+ }
152
+
153
+ /** \returns the point at \a t along this line
154
+ */
155
+ template <typename _Scalar, int _AmbientDim, int _Options>
156
+ EIGEN_DEVICE_FUNC inline typename ParametrizedLine<_Scalar, _AmbientDim,_Options>::VectorType
157
+ ParametrizedLine<_Scalar, _AmbientDim,_Options>::pointAt(const _Scalar& t) const
158
+ {
159
+ return origin() + (direction()*t);
160
+ }
161
+
162
+ /** \returns the parameter value of the intersection between \c *this and the given \a hyperplane
163
+ */
164
+ template <typename _Scalar, int _AmbientDim, int _Options>
165
+ template <int OtherOptions>
166
+ EIGEN_DEVICE_FUNC inline _Scalar ParametrizedLine<_Scalar, _AmbientDim,_Options>::intersectionParameter(const Hyperplane<_Scalar, _AmbientDim, OtherOptions>& hyperplane) const
167
+ {
168
+ return -(hyperplane.offset()+hyperplane.normal().dot(origin()))
169
+ / hyperplane.normal().dot(direction());
170
+ }
171
+
172
+
173
+ /** \deprecated use intersectionParameter()
174
+ * \returns the parameter value of the intersection between \c *this and the given \a hyperplane
175
+ */
176
+ template <typename _Scalar, int _AmbientDim, int _Options>
177
+ template <int OtherOptions>
178
+ EIGEN_DEVICE_FUNC inline _Scalar ParametrizedLine<_Scalar, _AmbientDim,_Options>::intersection(const Hyperplane<_Scalar, _AmbientDim, OtherOptions>& hyperplane) const
179
+ {
180
+ return intersectionParameter(hyperplane);
181
+ }
182
+
183
+ /** \returns the point of the intersection between \c *this and the given hyperplane
184
+ */
185
+ template <typename _Scalar, int _AmbientDim, int _Options>
186
+ template <int OtherOptions>
187
+ EIGEN_DEVICE_FUNC inline typename ParametrizedLine<_Scalar, _AmbientDim,_Options>::VectorType
188
+ ParametrizedLine<_Scalar, _AmbientDim,_Options>::intersectionPoint(const Hyperplane<_Scalar, _AmbientDim, OtherOptions>& hyperplane) const
189
+ {
190
+ return pointAt(intersectionParameter(hyperplane));
191
+ }
192
+
193
+ } // end namespace Eigen
194
+
195
+ #endif // EIGEN_PARAMETRIZEDLINE_H
@@ -0,0 +1,814 @@
1
+ // This file is part of Eigen, a lightweight C++ template library
2
+ // for linear algebra.
3
+ //
4
+ // Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>
5
+ // Copyright (C) 2009 Mathieu Gautier <mathieu.gautier@cea.fr>
6
+ //
7
+ // This Source Code Form is subject to the terms of the Mozilla
8
+ // Public License v. 2.0. If a copy of the MPL was not distributed
9
+ // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10
+
11
+ #ifndef EIGEN_QUATERNION_H
12
+ #define EIGEN_QUATERNION_H
13
+ namespace Eigen {
14
+
15
+
16
+ /***************************************************************************
17
+ * Definition of QuaternionBase<Derived>
18
+ * The implementation is at the end of the file
19
+ ***************************************************************************/
20
+
21
+ namespace internal {
22
+ template<typename Other,
23
+ int OtherRows=Other::RowsAtCompileTime,
24
+ int OtherCols=Other::ColsAtCompileTime>
25
+ struct quaternionbase_assign_impl;
26
+ }
27
+
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
+ {
37
+ public:
38
+ typedef RotationBase<Derived, 3> Base;
39
+
40
+ using Base::operator*;
41
+ using Base::derived;
42
+
43
+ typedef typename internal::traits<Derived>::Scalar Scalar;
44
+ typedef typename NumTraits<Scalar>::Real RealScalar;
45
+ typedef typename internal::traits<Derived>::Coefficients Coefficients;
46
+ typedef typename Coefficients::CoeffReturnType CoeffReturnType;
47
+ typedef typename internal::conditional<bool(internal::traits<Derived>::Flags&LvalueBit),
48
+ Scalar&, CoeffReturnType>::type NonConstCoeffReturnType;
49
+
50
+
51
+ enum {
52
+ Flags = Eigen::internal::traits<Derived>::Flags
53
+ };
54
+
55
+ // typedef typename Matrix<Scalar,4,1> Coefficients;
56
+ /** the type of a 3D vector */
57
+ typedef Matrix<Scalar,3,1> Vector3;
58
+ /** the equivalent rotation matrix type */
59
+ typedef Matrix<Scalar,3,3> Matrix3;
60
+ /** the equivalent angle-axis type */
61
+ typedef AngleAxis<Scalar> AngleAxisType;
62
+
63
+
64
+
65
+ /** \returns the \c x coefficient */
66
+ EIGEN_DEVICE_FUNC inline CoeffReturnType x() const { return this->derived().coeffs().coeff(0); }
67
+ /** \returns the \c y coefficient */
68
+ EIGEN_DEVICE_FUNC inline CoeffReturnType y() const { return this->derived().coeffs().coeff(1); }
69
+ /** \returns the \c z coefficient */
70
+ EIGEN_DEVICE_FUNC inline CoeffReturnType z() const { return this->derived().coeffs().coeff(2); }
71
+ /** \returns the \c w coefficient */
72
+ EIGEN_DEVICE_FUNC inline CoeffReturnType w() const { return this->derived().coeffs().coeff(3); }
73
+
74
+ /** \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(); }
76
+ /** \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(); }
78
+ /** \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(); }
80
+ /** \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(); }
82
+
83
+ /** \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>(); }
85
+
86
+ /** \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>(); }
88
+
89
+ /** \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(); }
91
+
92
+ /** \returns a vector expression of the coefficients (x,y,z,w) */
93
+ EIGEN_DEVICE_FUNC inline typename internal::traits<Derived>::Coefficients& coeffs() { return derived().coeffs(); }
94
+
95
+ 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);
97
+
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); }
104
+
105
+ EIGEN_DEVICE_FUNC Derived& operator=(const AngleAxisType& aa);
106
+ template<class OtherDerived> EIGEN_DEVICE_FUNC Derived& operator=(const MatrixBase<OtherDerived>& m);
107
+
108
+ /** \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)); }
112
+
113
+ /** \sa QuaternionBase::Identity(), MatrixBase::setIdentity()
114
+ */
115
+ EIGEN_DEVICE_FUNC inline QuaternionBase& setIdentity() { coeffs() << Scalar(0), Scalar(0), Scalar(0), Scalar(1); return *this; }
116
+
117
+ /** \returns the squared norm of the quaternion's coefficients
118
+ * \sa QuaternionBase::norm(), MatrixBase::squaredNorm()
119
+ */
120
+ EIGEN_DEVICE_FUNC inline Scalar squaredNorm() const { return coeffs().squaredNorm(); }
121
+
122
+ /** \returns the norm of the quaternion's coefficients
123
+ * \sa QuaternionBase::squaredNorm(), MatrixBase::norm()
124
+ */
125
+ EIGEN_DEVICE_FUNC inline Scalar norm() const { return coeffs().norm(); }
126
+
127
+ /** Normalizes the quaternion \c *this
128
+ * \sa normalized(), MatrixBase::normalize() */
129
+ EIGEN_DEVICE_FUNC inline void normalize() { coeffs().normalize(); }
130
+ /** \returns a normalized copy of \c *this
131
+ * \sa normalize(), MatrixBase::normalized() */
132
+ EIGEN_DEVICE_FUNC inline Quaternion<Scalar> normalized() const { return Quaternion<Scalar>(coeffs().normalized()); }
133
+
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()); }
140
+
141
+ template<class OtherDerived> EIGEN_DEVICE_FUNC Scalar angularDistance(const QuaternionBase<OtherDerived>& other) const;
142
+
143
+ /** \returns an equivalent 3x3 rotation matrix */
144
+ EIGEN_DEVICE_FUNC Matrix3 toRotationMatrix() const;
145
+
146
+ /** \returns the quaternion which transform \a a into \a b through a rotation */
147
+ template<typename Derived1, typename Derived2>
148
+ EIGEN_DEVICE_FUNC Derived& setFromTwoVectors(const MatrixBase<Derived1>& a, const MatrixBase<Derived2>& b);
149
+
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);
152
+
153
+ /** \returns the quaternion describing the inverse rotation */
154
+ EIGEN_DEVICE_FUNC Quaternion<Scalar> inverse() const;
155
+
156
+ /** \returns the conjugated quaternion */
157
+ EIGEN_DEVICE_FUNC Quaternion<Scalar> conjugate() const;
158
+
159
+ template<class OtherDerived> EIGEN_DEVICE_FUNC Quaternion<Scalar> slerp(const Scalar& t, const QuaternionBase<OtherDerived>& other) const;
160
+
161
+ /** \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); }
168
+
169
+ /** return the result vector of \a v through the rotation*/
170
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Vector3 _transformVector(const Vector3& v) const;
171
+
172
+ /** \returns \c *this with scalar type casted to \a NewScalarType
173
+ *
174
+ * Note that if \a NewScalarType is equal to the current scalar type of \c *this
175
+ * then this function smartly returns a const reference to \c *this.
176
+ */
177
+ template<typename NewScalarType>
178
+ EIGEN_DEVICE_FUNC inline typename internal::cast_return_type<Derived,Quaternion<NewScalarType> >::type cast() const
179
+ {
180
+ return typename internal::cast_return_type<Derived,Quaternion<NewScalarType> >::type(derived());
181
+ }
182
+
183
+ #ifdef EIGEN_QUATERNIONBASE_PLUGIN
184
+ # include EIGEN_QUATERNIONBASE_PLUGIN
185
+ #endif
186
+ };
187
+
188
+ /***************************************************************************
189
+ * Definition/implementation of Quaternion<Scalar>
190
+ ***************************************************************************/
191
+
192
+ /** \geometry_module \ingroup Geometry_Module
193
+ *
194
+ * \class Quaternion
195
+ *
196
+ * \brief The quaternion class used to represent 3D orientations and rotations
197
+ *
198
+ * \tparam _Scalar the scalar type, i.e., the type of the coefficients
199
+ * \tparam _Options controls the memory alignment of the coefficients. Can be \# AutoAlign or \# DontAlign. Default is AutoAlign.
200
+ *
201
+ * This class represents a quaternion \f$ w+xi+yj+zk \f$ that is a convenient representation of
202
+ * orientations and rotations of objects in three dimensions. Compared to other representations
203
+ * like Euler angles or 3x3 matrices, quaternions offer the following advantages:
204
+ * \li \b compact storage (4 scalars)
205
+ * \li \b efficient to compose (28 flops),
206
+ * \li \b stable spherical interpolation
207
+ *
208
+ * The following two typedefs are provided for convenience:
209
+ * \li \c Quaternionf for \c float
210
+ * \li \c Quaterniond for \c double
211
+ *
212
+ * \warning Operations interpreting the quaternion as rotation have undefined behavior if the quaternion is not normalized.
213
+ *
214
+ * \sa class AngleAxis, class Transform
215
+ */
216
+
217
+ namespace internal {
218
+ template<typename _Scalar,int _Options>
219
+ struct traits<Quaternion<_Scalar,_Options> >
220
+ {
221
+ typedef Quaternion<_Scalar,_Options> PlainObject;
222
+ typedef _Scalar Scalar;
223
+ typedef Matrix<_Scalar,4,1,_Options> Coefficients;
224
+ enum{
225
+ Alignment = internal::traits<Coefficients>::Alignment,
226
+ Flags = LvalueBit
227
+ };
228
+ };
229
+ }
230
+
231
+ template<typename _Scalar, int _Options>
232
+ class Quaternion : public QuaternionBase<Quaternion<_Scalar,_Options> >
233
+ {
234
+ public:
235
+ typedef QuaternionBase<Quaternion<_Scalar,_Options> > Base;
236
+ enum { NeedsAlignment = internal::traits<Quaternion>::Alignment>0 };
237
+
238
+ typedef _Scalar Scalar;
239
+
240
+ EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Quaternion)
241
+ using Base::operator*=;
242
+
243
+ typedef typename internal::traits<Quaternion>::Coefficients Coefficients;
244
+ typedef typename Base::AngleAxisType AngleAxisType;
245
+
246
+ /** Default constructor leaving the quaternion uninitialized. */
247
+ EIGEN_DEVICE_FUNC inline Quaternion() {}
248
+
249
+ /** Constructs and initializes the quaternion \f$ w+xi+yj+zk \f$ from
250
+ * its four coefficients \a w, \a x, \a y and \a z.
251
+ *
252
+ * \warning Note the order of the arguments: the real \a w coefficient first,
253
+ * while internally the coefficients are stored in the following order:
254
+ * [\c x, \c y, \c z, \c w]
255
+ */
256
+ EIGEN_DEVICE_FUNC inline Quaternion(const Scalar& w, const Scalar& x, const Scalar& y, const Scalar& z) : m_coeffs(x, y, z, w){}
257
+
258
+ /** Constructs and initialize a quaternion from the array data */
259
+ EIGEN_DEVICE_FUNC explicit inline Quaternion(const Scalar* data) : m_coeffs(data) {}
260
+
261
+ /** Copy constructor */
262
+ template<class Derived> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Quaternion(const QuaternionBase<Derived>& other) { this->Base::operator=(other); }
263
+
264
+ /** Constructs and initializes a quaternion from the angle-axis \a aa */
265
+ EIGEN_DEVICE_FUNC explicit inline Quaternion(const AngleAxisType& aa) { *this = aa; }
266
+
267
+ /** Constructs and initializes a quaternion from either:
268
+ * - a rotation matrix expression,
269
+ * - a 4D vector expression representing quaternion coefficients.
270
+ */
271
+ template<typename Derived>
272
+ EIGEN_DEVICE_FUNC explicit inline Quaternion(const MatrixBase<Derived>& other) { *this = other; }
273
+
274
+ /** Explicit copy constructor with scalar conversion */
275
+ template<typename OtherScalar, int OtherOptions>
276
+ EIGEN_DEVICE_FUNC explicit inline Quaternion(const Quaternion<OtherScalar, OtherOptions>& other)
277
+ { m_coeffs = other.coeffs().template cast<Scalar>(); }
278
+
279
+ EIGEN_DEVICE_FUNC static Quaternion UnitRandom();
280
+
281
+ template<typename Derived1, typename Derived2>
282
+ EIGEN_DEVICE_FUNC static Quaternion FromTwoVectors(const MatrixBase<Derived1>& a, const MatrixBase<Derived2>& b);
283
+
284
+ EIGEN_DEVICE_FUNC inline Coefficients& coeffs() { return m_coeffs;}
285
+ EIGEN_DEVICE_FUNC inline const Coefficients& coeffs() const { return m_coeffs;}
286
+
287
+ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(bool(NeedsAlignment))
288
+
289
+ #ifdef EIGEN_QUATERNION_PLUGIN
290
+ # include EIGEN_QUATERNION_PLUGIN
291
+ #endif
292
+
293
+ protected:
294
+ Coefficients m_coeffs;
295
+
296
+ #ifndef EIGEN_PARSED_BY_DOXYGEN
297
+ static EIGEN_STRONG_INLINE void _check_template_params()
298
+ {
299
+ EIGEN_STATIC_ASSERT( (_Options & DontAlign) == _Options,
300
+ INVALID_MATRIX_TEMPLATE_PARAMETERS)
301
+ }
302
+ #endif
303
+ };
304
+
305
+ /** \ingroup Geometry_Module
306
+ * single precision quaternion type */
307
+ typedef Quaternion<float> Quaternionf;
308
+ /** \ingroup Geometry_Module
309
+ * double precision quaternion type */
310
+ typedef Quaternion<double> Quaterniond;
311
+
312
+ /***************************************************************************
313
+ * Specialization of Map<Quaternion<Scalar>>
314
+ ***************************************************************************/
315
+
316
+ namespace internal {
317
+ template<typename _Scalar, int _Options>
318
+ struct traits<Map<Quaternion<_Scalar>, _Options> > : traits<Quaternion<_Scalar, (int(_Options)&Aligned)==Aligned ? AutoAlign : DontAlign> >
319
+ {
320
+ typedef Map<Matrix<_Scalar,4,1>, _Options> Coefficients;
321
+ };
322
+ }
323
+
324
+ namespace internal {
325
+ template<typename _Scalar, int _Options>
326
+ struct traits<Map<const Quaternion<_Scalar>, _Options> > : traits<Quaternion<_Scalar, (int(_Options)&Aligned)==Aligned ? AutoAlign : DontAlign> >
327
+ {
328
+ typedef Map<const Matrix<_Scalar,4,1>, _Options> Coefficients;
329
+ typedef traits<Quaternion<_Scalar, (int(_Options)&Aligned)==Aligned ? AutoAlign : DontAlign> > TraitsBase;
330
+ enum {
331
+ Flags = TraitsBase::Flags & ~LvalueBit
332
+ };
333
+ };
334
+ }
335
+
336
+ /** \ingroup Geometry_Module
337
+ * \brief Quaternion expression mapping a constant memory buffer
338
+ *
339
+ * \tparam _Scalar the type of the Quaternion coefficients
340
+ * \tparam _Options see class Map
341
+ *
342
+ * This is a specialization of class Map for Quaternion. This class allows to view
343
+ * a 4 scalar memory buffer as an Eigen's Quaternion object.
344
+ *
345
+ * \sa class Map, class Quaternion, class QuaternionBase
346
+ */
347
+ template<typename _Scalar, int _Options>
348
+ class Map<const Quaternion<_Scalar>, _Options >
349
+ : public QuaternionBase<Map<const Quaternion<_Scalar>, _Options> >
350
+ {
351
+ public:
352
+ typedef QuaternionBase<Map<const Quaternion<_Scalar>, _Options> > Base;
353
+
354
+ typedef _Scalar Scalar;
355
+ typedef typename internal::traits<Map>::Coefficients Coefficients;
356
+ EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map)
357
+ using Base::operator*=;
358
+
359
+ /** Constructs a Mapped Quaternion object from the pointer \a coeffs
360
+ *
361
+ * The pointer \a coeffs must reference the four coefficients of Quaternion in the following order:
362
+ * \code *coeffs == {x, y, z, w} \endcode
363
+ *
364
+ * If the template parameter _Options is set to #Aligned, then the pointer coeffs must be aligned. */
365
+ EIGEN_DEVICE_FUNC explicit EIGEN_STRONG_INLINE Map(const Scalar* coeffs) : m_coeffs(coeffs) {}
366
+
367
+ EIGEN_DEVICE_FUNC inline const Coefficients& coeffs() const { return m_coeffs;}
368
+
369
+ protected:
370
+ const Coefficients m_coeffs;
371
+ };
372
+
373
+ /** \ingroup Geometry_Module
374
+ * \brief Expression of a quaternion from a memory buffer
375
+ *
376
+ * \tparam _Scalar the type of the Quaternion coefficients
377
+ * \tparam _Options see class Map
378
+ *
379
+ * This is a specialization of class Map for Quaternion. This class allows to view
380
+ * a 4 scalar memory buffer as an Eigen's Quaternion object.
381
+ *
382
+ * \sa class Map, class Quaternion, class QuaternionBase
383
+ */
384
+ template<typename _Scalar, int _Options>
385
+ class Map<Quaternion<_Scalar>, _Options >
386
+ : public QuaternionBase<Map<Quaternion<_Scalar>, _Options> >
387
+ {
388
+ public:
389
+ typedef QuaternionBase<Map<Quaternion<_Scalar>, _Options> > Base;
390
+
391
+ typedef _Scalar Scalar;
392
+ typedef typename internal::traits<Map>::Coefficients Coefficients;
393
+ EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map)
394
+ using Base::operator*=;
395
+
396
+ /** Constructs a Mapped Quaternion object from the pointer \a coeffs
397
+ *
398
+ * The pointer \a coeffs must reference the four coefficients of Quaternion in the following order:
399
+ * \code *coeffs == {x, y, z, w} \endcode
400
+ *
401
+ * If the template parameter _Options is set to #Aligned, then the pointer coeffs must be aligned. */
402
+ EIGEN_DEVICE_FUNC explicit EIGEN_STRONG_INLINE Map(Scalar* coeffs) : m_coeffs(coeffs) {}
403
+
404
+ EIGEN_DEVICE_FUNC inline Coefficients& coeffs() { return m_coeffs; }
405
+ EIGEN_DEVICE_FUNC inline const Coefficients& coeffs() const { return m_coeffs; }
406
+
407
+ protected:
408
+ Coefficients m_coeffs;
409
+ };
410
+
411
+ /** \ingroup Geometry_Module
412
+ * Map an unaligned array of single precision scalars as a quaternion */
413
+ typedef Map<Quaternion<float>, 0> QuaternionMapf;
414
+ /** \ingroup Geometry_Module
415
+ * Map an unaligned array of double precision scalars as a quaternion */
416
+ typedef Map<Quaternion<double>, 0> QuaternionMapd;
417
+ /** \ingroup Geometry_Module
418
+ * Map a 16-byte aligned array of single precision scalars as a quaternion */
419
+ typedef Map<Quaternion<float>, Aligned> QuaternionMapAlignedf;
420
+ /** \ingroup Geometry_Module
421
+ * Map a 16-byte aligned array of double precision scalars as a quaternion */
422
+ typedef Map<Quaternion<double>, Aligned> QuaternionMapAlignedd;
423
+
424
+ /***************************************************************************
425
+ * Implementation of QuaternionBase methods
426
+ ***************************************************************************/
427
+
428
+ // Generic Quaternion * Quaternion product
429
+ // This product can be specialized for a given architecture via the Arch template argument.
430
+ namespace internal {
431
+ template<int Arch, class Derived1, class Derived2, typename Scalar> struct quat_product
432
+ {
433
+ EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Quaternion<Scalar> run(const QuaternionBase<Derived1>& a, const QuaternionBase<Derived2>& b){
434
+ return Quaternion<Scalar>
435
+ (
436
+ a.w() * b.w() - a.x() * b.x() - a.y() * b.y() - a.z() * b.z(),
437
+ a.w() * b.x() + a.x() * b.w() + a.y() * b.z() - a.z() * b.y(),
438
+ a.w() * b.y() + a.y() * b.w() + a.z() * b.x() - a.x() * b.z(),
439
+ a.w() * b.z() + a.z() * b.w() + a.x() * b.y() - a.y() * b.x()
440
+ );
441
+ }
442
+ };
443
+ }
444
+
445
+ /** \returns the concatenation of two rotations as a quaternion-quaternion product */
446
+ template <class Derived>
447
+ template <class OtherDerived>
448
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Quaternion<typename internal::traits<Derived>::Scalar>
449
+ QuaternionBase<Derived>::operator* (const QuaternionBase<OtherDerived>& other) const
450
+ {
451
+ EIGEN_STATIC_ASSERT((internal::is_same<typename Derived::Scalar, typename OtherDerived::Scalar>::value),
452
+ YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
453
+ return internal::quat_product<Architecture::Target, Derived, OtherDerived,
454
+ typename internal::traits<Derived>::Scalar>::run(*this, other);
455
+ }
456
+
457
+ /** \sa operator*(Quaternion) */
458
+ template <class Derived>
459
+ template <class OtherDerived>
460
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& QuaternionBase<Derived>::operator*= (const QuaternionBase<OtherDerived>& other)
461
+ {
462
+ derived() = derived() * other.derived();
463
+ return derived();
464
+ }
465
+
466
+ /** Rotation of a vector by a quaternion.
467
+ * \remarks If the quaternion is used to rotate several points (>1)
468
+ * then it is much more efficient to first convert it to a 3x3 Matrix.
469
+ * Comparison of the operation cost for n transformations:
470
+ * - Quaternion2: 30n
471
+ * - Via a Matrix3: 24 + 15n
472
+ */
473
+ template <class Derived>
474
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename QuaternionBase<Derived>::Vector3
475
+ QuaternionBase<Derived>::_transformVector(const Vector3& v) const
476
+ {
477
+ // Note that this algorithm comes from the optimization by hand
478
+ // of the conversion to a Matrix followed by a Matrix/Vector product.
479
+ // It appears to be much faster than the common algorithm found
480
+ // in the literature (30 versus 39 flops). It also requires two
481
+ // Vector3 as temporaries.
482
+ Vector3 uv = this->vec().cross(v);
483
+ uv += uv;
484
+ return v + this->w() * uv + this->vec().cross(uv);
485
+ }
486
+
487
+ template<class Derived>
488
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE QuaternionBase<Derived>& QuaternionBase<Derived>::operator=(const QuaternionBase<Derived>& other)
489
+ {
490
+ coeffs() = other.coeffs();
491
+ return derived();
492
+ }
493
+
494
+ template<class Derived>
495
+ template<class OtherDerived>
496
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& QuaternionBase<Derived>::operator=(const QuaternionBase<OtherDerived>& other)
497
+ {
498
+ coeffs() = other.coeffs();
499
+ return derived();
500
+ }
501
+
502
+ /** Set \c *this from an angle-axis \a aa and returns a reference to \c *this
503
+ */
504
+ template<class Derived>
505
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& QuaternionBase<Derived>::operator=(const AngleAxisType& aa)
506
+ {
507
+ EIGEN_USING_STD_MATH(cos)
508
+ EIGEN_USING_STD_MATH(sin)
509
+ Scalar ha = Scalar(0.5)*aa.angle(); // Scalar(0.5) to suppress precision loss warnings
510
+ this->w() = cos(ha);
511
+ this->vec() = sin(ha) * aa.axis();
512
+ return derived();
513
+ }
514
+
515
+ /** Set \c *this from the expression \a xpr:
516
+ * - if \a xpr is a 4x1 vector, then \a xpr is assumed to be a quaternion
517
+ * - if \a xpr is a 3x3 matrix, then \a xpr is assumed to be rotation matrix
518
+ * and \a xpr is converted to a quaternion
519
+ */
520
+
521
+ template<class Derived>
522
+ template<class MatrixDerived>
523
+ EIGEN_DEVICE_FUNC inline Derived& QuaternionBase<Derived>::operator=(const MatrixBase<MatrixDerived>& xpr)
524
+ {
525
+ EIGEN_STATIC_ASSERT((internal::is_same<typename Derived::Scalar, typename MatrixDerived::Scalar>::value),
526
+ YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
527
+ internal::quaternionbase_assign_impl<MatrixDerived>::run(*this, xpr.derived());
528
+ return derived();
529
+ }
530
+
531
+ /** Convert the quaternion to a 3x3 rotation matrix. The quaternion is required to
532
+ * be normalized, otherwise the result is undefined.
533
+ */
534
+ template<class Derived>
535
+ EIGEN_DEVICE_FUNC inline typename QuaternionBase<Derived>::Matrix3
536
+ QuaternionBase<Derived>::toRotationMatrix(void) const
537
+ {
538
+ // NOTE if inlined, then gcc 4.2 and 4.4 get rid of the temporary (not gcc 4.3 !!)
539
+ // if not inlined then the cost of the return by value is huge ~ +35%,
540
+ // however, not inlining this function is an order of magnitude slower, so
541
+ // it has to be inlined, and so the return by value is not an issue
542
+ Matrix3 res;
543
+
544
+ const Scalar tx = Scalar(2)*this->x();
545
+ const Scalar ty = Scalar(2)*this->y();
546
+ const Scalar tz = Scalar(2)*this->z();
547
+ const Scalar twx = tx*this->w();
548
+ const Scalar twy = ty*this->w();
549
+ const Scalar twz = tz*this->w();
550
+ const Scalar txx = tx*this->x();
551
+ const Scalar txy = ty*this->x();
552
+ const Scalar txz = tz*this->x();
553
+ const Scalar tyy = ty*this->y();
554
+ const Scalar tyz = tz*this->y();
555
+ const Scalar tzz = tz*this->z();
556
+
557
+ res.coeffRef(0,0) = Scalar(1)-(tyy+tzz);
558
+ res.coeffRef(0,1) = txy-twz;
559
+ res.coeffRef(0,2) = txz+twy;
560
+ res.coeffRef(1,0) = txy+twz;
561
+ res.coeffRef(1,1) = Scalar(1)-(txx+tzz);
562
+ res.coeffRef(1,2) = tyz-twx;
563
+ res.coeffRef(2,0) = txz-twy;
564
+ res.coeffRef(2,1) = tyz+twx;
565
+ res.coeffRef(2,2) = Scalar(1)-(txx+tyy);
566
+
567
+ return res;
568
+ }
569
+
570
+ /** Sets \c *this to be a quaternion representing a rotation between
571
+ * the two arbitrary vectors \a a and \a b. In other words, the built
572
+ * rotation represent a rotation sending the line of direction \a a
573
+ * to the line of direction \a b, both lines passing through the origin.
574
+ *
575
+ * \returns a reference to \c *this.
576
+ *
577
+ * Note that the two input vectors do \b not have to be normalized, and
578
+ * do not need to have the same norm.
579
+ */
580
+ template<class Derived>
581
+ template<typename Derived1, typename Derived2>
582
+ EIGEN_DEVICE_FUNC inline Derived& QuaternionBase<Derived>::setFromTwoVectors(const MatrixBase<Derived1>& a, const MatrixBase<Derived2>& b)
583
+ {
584
+ EIGEN_USING_STD_MATH(sqrt)
585
+ Vector3 v0 = a.normalized();
586
+ Vector3 v1 = b.normalized();
587
+ Scalar c = v1.dot(v0);
588
+
589
+ // if dot == -1, vectors are nearly opposites
590
+ // => accurately compute the rotation axis by computing the
591
+ // intersection of the two planes. This is done by solving:
592
+ // x^T v0 = 0
593
+ // x^T v1 = 0
594
+ // under the constraint:
595
+ // ||x|| = 1
596
+ // which yields a singular value problem
597
+ if (c < Scalar(-1)+NumTraits<Scalar>::dummy_precision())
598
+ {
599
+ c = numext::maxi(c,Scalar(-1));
600
+ Matrix<Scalar,2,3> m; m << v0.transpose(), v1.transpose();
601
+ JacobiSVD<Matrix<Scalar,2,3> > svd(m, ComputeFullV);
602
+ Vector3 axis = svd.matrixV().col(2);
603
+
604
+ Scalar w2 = (Scalar(1)+c)*Scalar(0.5);
605
+ this->w() = sqrt(w2);
606
+ this->vec() = axis * sqrt(Scalar(1) - w2);
607
+ return derived();
608
+ }
609
+ Vector3 axis = v0.cross(v1);
610
+ Scalar s = sqrt((Scalar(1)+c)*Scalar(2));
611
+ Scalar invs = Scalar(1)/s;
612
+ this->vec() = axis * invs;
613
+ this->w() = s * Scalar(0.5);
614
+
615
+ return derived();
616
+ }
617
+
618
+ /** \returns a random unit quaternion following a uniform distribution law on SO(3)
619
+ *
620
+ * \note The implementation is based on http://planning.cs.uiuc.edu/node198.html
621
+ */
622
+ template<typename Scalar, int Options>
623
+ EIGEN_DEVICE_FUNC Quaternion<Scalar,Options> Quaternion<Scalar,Options>::UnitRandom()
624
+ {
625
+ EIGEN_USING_STD_MATH(sqrt)
626
+ EIGEN_USING_STD_MATH(sin)
627
+ EIGEN_USING_STD_MATH(cos)
628
+ const Scalar u1 = internal::random<Scalar>(0, 1),
629
+ u2 = internal::random<Scalar>(0, 2*EIGEN_PI),
630
+ u3 = internal::random<Scalar>(0, 2*EIGEN_PI);
631
+ const Scalar a = sqrt(1 - u1),
632
+ b = sqrt(u1);
633
+ return Quaternion (a * sin(u2), a * cos(u2), b * sin(u3), b * cos(u3));
634
+ }
635
+
636
+
637
+ /** Returns a quaternion representing a rotation between
638
+ * the two arbitrary vectors \a a and \a b. In other words, the built
639
+ * rotation represent a rotation sending the line of direction \a a
640
+ * to the line of direction \a b, both lines passing through the origin.
641
+ *
642
+ * \returns resulting quaternion
643
+ *
644
+ * Note that the two input vectors do \b not have to be normalized, and
645
+ * do not need to have the same norm.
646
+ */
647
+ template<typename Scalar, int Options>
648
+ template<typename Derived1, typename Derived2>
649
+ EIGEN_DEVICE_FUNC Quaternion<Scalar,Options> Quaternion<Scalar,Options>::FromTwoVectors(const MatrixBase<Derived1>& a, const MatrixBase<Derived2>& b)
650
+ {
651
+ Quaternion quat;
652
+ quat.setFromTwoVectors(a, b);
653
+ return quat;
654
+ }
655
+
656
+
657
+ /** \returns the multiplicative inverse of \c *this
658
+ * Note that in most cases, i.e., if you simply want the opposite rotation,
659
+ * and/or the quaternion is normalized, then it is enough to use the conjugate.
660
+ *
661
+ * \sa QuaternionBase::conjugate()
662
+ */
663
+ template <class Derived>
664
+ EIGEN_DEVICE_FUNC inline Quaternion<typename internal::traits<Derived>::Scalar> QuaternionBase<Derived>::inverse() const
665
+ {
666
+ // FIXME should this function be called multiplicativeInverse and conjugate() be called inverse() or opposite() ??
667
+ Scalar n2 = this->squaredNorm();
668
+ if (n2 > Scalar(0))
669
+ return Quaternion<Scalar>(conjugate().coeffs() / n2);
670
+ else
671
+ {
672
+ // return an invalid result to flag the error
673
+ return Quaternion<Scalar>(Coefficients::Zero());
674
+ }
675
+ }
676
+
677
+ // Generic conjugate of a Quaternion
678
+ namespace internal {
679
+ template<int Arch, class Derived, typename Scalar> struct quat_conj
680
+ {
681
+ EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Quaternion<Scalar> run(const QuaternionBase<Derived>& q){
682
+ return Quaternion<Scalar>(q.w(),-q.x(),-q.y(),-q.z());
683
+ }
684
+ };
685
+ }
686
+
687
+ /** \returns the conjugate of the \c *this which is equal to the multiplicative inverse
688
+ * if the quaternion is normalized.
689
+ * The conjugate of a quaternion represents the opposite rotation.
690
+ *
691
+ * \sa Quaternion2::inverse()
692
+ */
693
+ template <class Derived>
694
+ EIGEN_DEVICE_FUNC inline Quaternion<typename internal::traits<Derived>::Scalar>
695
+ QuaternionBase<Derived>::conjugate() const
696
+ {
697
+ return internal::quat_conj<Architecture::Target, Derived,
698
+ typename internal::traits<Derived>::Scalar>::run(*this);
699
+
700
+ }
701
+
702
+ /** \returns the angle (in radian) between two rotations
703
+ * \sa dot()
704
+ */
705
+ template <class Derived>
706
+ template <class OtherDerived>
707
+ EIGEN_DEVICE_FUNC inline typename internal::traits<Derived>::Scalar
708
+ QuaternionBase<Derived>::angularDistance(const QuaternionBase<OtherDerived>& other) const
709
+ {
710
+ EIGEN_USING_STD_MATH(atan2)
711
+ Quaternion<Scalar> d = (*this) * other.conjugate();
712
+ return Scalar(2) * atan2( d.vec().norm(), numext::abs(d.w()) );
713
+ }
714
+
715
+
716
+
717
+ /** \returns the spherical linear interpolation between the two quaternions
718
+ * \c *this and \a other at the parameter \a t in [0;1].
719
+ *
720
+ * This represents an interpolation for a constant motion between \c *this and \a other,
721
+ * see also http://en.wikipedia.org/wiki/Slerp.
722
+ */
723
+ template <class Derived>
724
+ template <class OtherDerived>
725
+ EIGEN_DEVICE_FUNC Quaternion<typename internal::traits<Derived>::Scalar>
726
+ QuaternionBase<Derived>::slerp(const Scalar& t, const QuaternionBase<OtherDerived>& other) const
727
+ {
728
+ EIGEN_USING_STD_MATH(acos)
729
+ EIGEN_USING_STD_MATH(sin)
730
+ const Scalar one = Scalar(1) - NumTraits<Scalar>::epsilon();
731
+ Scalar d = this->dot(other);
732
+ Scalar absD = numext::abs(d);
733
+
734
+ Scalar scale0;
735
+ Scalar scale1;
736
+
737
+ if(absD>=one)
738
+ {
739
+ scale0 = Scalar(1) - t;
740
+ scale1 = t;
741
+ }
742
+ else
743
+ {
744
+ // theta is the angle between the 2 quaternions
745
+ Scalar theta = acos(absD);
746
+ Scalar sinTheta = sin(theta);
747
+
748
+ scale0 = sin( ( Scalar(1) - t ) * theta) / sinTheta;
749
+ scale1 = sin( ( t * theta) ) / sinTheta;
750
+ }
751
+ if(d<Scalar(0)) scale1 = -scale1;
752
+
753
+ return Quaternion<Scalar>(scale0 * coeffs() + scale1 * other.coeffs());
754
+ }
755
+
756
+ namespace internal {
757
+
758
+ // set from a rotation matrix
759
+ template<typename Other>
760
+ struct quaternionbase_assign_impl<Other,3,3>
761
+ {
762
+ typedef typename Other::Scalar Scalar;
763
+ template<class Derived> EIGEN_DEVICE_FUNC static inline void run(QuaternionBase<Derived>& q, const Other& a_mat)
764
+ {
765
+ const typename internal::nested_eval<Other,2>::type mat(a_mat);
766
+ EIGEN_USING_STD_MATH(sqrt)
767
+ // This algorithm comes from "Quaternion Calculus and Fast Animation",
768
+ // Ken Shoemake, 1987 SIGGRAPH course notes
769
+ Scalar t = mat.trace();
770
+ if (t > Scalar(0))
771
+ {
772
+ t = sqrt(t + Scalar(1.0));
773
+ q.w() = Scalar(0.5)*t;
774
+ t = Scalar(0.5)/t;
775
+ q.x() = (mat.coeff(2,1) - mat.coeff(1,2)) * t;
776
+ q.y() = (mat.coeff(0,2) - mat.coeff(2,0)) * t;
777
+ q.z() = (mat.coeff(1,0) - mat.coeff(0,1)) * t;
778
+ }
779
+ else
780
+ {
781
+ Index i = 0;
782
+ if (mat.coeff(1,1) > mat.coeff(0,0))
783
+ i = 1;
784
+ if (mat.coeff(2,2) > mat.coeff(i,i))
785
+ i = 2;
786
+ Index j = (i+1)%3;
787
+ Index k = (j+1)%3;
788
+
789
+ t = sqrt(mat.coeff(i,i)-mat.coeff(j,j)-mat.coeff(k,k) + Scalar(1.0));
790
+ q.coeffs().coeffRef(i) = Scalar(0.5) * t;
791
+ t = Scalar(0.5)/t;
792
+ q.w() = (mat.coeff(k,j)-mat.coeff(j,k))*t;
793
+ q.coeffs().coeffRef(j) = (mat.coeff(j,i)+mat.coeff(i,j))*t;
794
+ q.coeffs().coeffRef(k) = (mat.coeff(k,i)+mat.coeff(i,k))*t;
795
+ }
796
+ }
797
+ };
798
+
799
+ // set from a vector of coefficients assumed to be a quaternion
800
+ template<typename Other>
801
+ struct quaternionbase_assign_impl<Other,4,1>
802
+ {
803
+ typedef typename Other::Scalar Scalar;
804
+ template<class Derived> EIGEN_DEVICE_FUNC static inline void run(QuaternionBase<Derived>& q, const Other& vec)
805
+ {
806
+ q.coeffs() = vec;
807
+ }
808
+ };
809
+
810
+ } // end namespace internal
811
+
812
+ } // end namespace Eigen
813
+
814
+ #endif // EIGEN_QUATERNION_H