ruby-eigen 0.0.9 → 0.0.10.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (293) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +22 -0
  3. data/README.md +21 -0
  4. data/ext/eigen/eigen3/COPYING.BSD +26 -0
  5. data/ext/eigen/eigen3/COPYING.MPL2 +373 -0
  6. data/ext/eigen/eigen3/COPYING.README +18 -0
  7. data/ext/eigen/eigen3/Eigen/Array +11 -0
  8. data/ext/eigen/eigen3/Eigen/Cholesky +32 -0
  9. data/ext/eigen/eigen3/Eigen/CholmodSupport +45 -0
  10. data/ext/eigen/eigen3/Eigen/Core +376 -0
  11. data/ext/eigen/eigen3/Eigen/Dense +7 -0
  12. data/ext/eigen/eigen3/Eigen/Eigen +2 -0
  13. data/ext/eigen/eigen3/Eigen/Eigen2Support +95 -0
  14. data/ext/eigen/eigen3/Eigen/Eigenvalues +48 -0
  15. data/ext/eigen/eigen3/Eigen/Geometry +63 -0
  16. data/ext/eigen/eigen3/Eigen/Householder +23 -0
  17. data/ext/eigen/eigen3/Eigen/IterativeLinearSolvers +40 -0
  18. data/ext/eigen/eigen3/Eigen/Jacobi +26 -0
  19. data/ext/eigen/eigen3/Eigen/LU +41 -0
  20. data/ext/eigen/eigen3/Eigen/LeastSquares +32 -0
  21. data/ext/eigen/eigen3/Eigen/MetisSupport +28 -0
  22. data/ext/eigen/eigen3/Eigen/PaStiXSupport +46 -0
  23. data/ext/eigen/eigen3/Eigen/PardisoSupport +30 -0
  24. data/ext/eigen/eigen3/Eigen/QR +45 -0
  25. data/ext/eigen/eigen3/Eigen/QtAlignedMalloc +34 -0
  26. data/ext/eigen/eigen3/Eigen/SPQRSupport +29 -0
  27. data/ext/eigen/eigen3/Eigen/SVD +37 -0
  28. data/ext/eigen/eigen3/Eigen/Sparse +27 -0
  29. data/ext/eigen/eigen3/Eigen/SparseCore +64 -0
  30. data/ext/eigen/eigen3/Eigen/SparseLU +49 -0
  31. data/ext/eigen/eigen3/Eigen/SparseQR +33 -0
  32. data/ext/eigen/eigen3/Eigen/StdDeque +27 -0
  33. data/ext/eigen/eigen3/Eigen/StdList +26 -0
  34. data/ext/eigen/eigen3/Eigen/StdVector +27 -0
  35. data/ext/eigen/eigen3/Eigen/SuperLUSupport +59 -0
  36. data/ext/eigen/eigen3/Eigen/UmfPackSupport +36 -0
  37. data/ext/eigen/eigen3/Eigen/src/Cholesky/LDLT.h +611 -0
  38. data/ext/eigen/eigen3/Eigen/src/Cholesky/LLT.h +498 -0
  39. data/ext/eigen/eigen3/Eigen/src/Cholesky/LLT_MKL.h +102 -0
  40. data/ext/eigen/eigen3/Eigen/src/CholmodSupport/CholmodSupport.h +607 -0
  41. data/ext/eigen/eigen3/Eigen/src/Core/Array.h +323 -0
  42. data/ext/eigen/eigen3/Eigen/src/Core/ArrayBase.h +226 -0
  43. data/ext/eigen/eigen3/Eigen/src/Core/ArrayWrapper.h +264 -0
  44. data/ext/eigen/eigen3/Eigen/src/Core/Assign.h +590 -0
  45. data/ext/eigen/eigen3/Eigen/src/Core/Assign_MKL.h +224 -0
  46. data/ext/eigen/eigen3/Eigen/src/Core/BandMatrix.h +334 -0
  47. data/ext/eigen/eigen3/Eigen/src/Core/Block.h +406 -0
  48. data/ext/eigen/eigen3/Eigen/src/Core/BooleanRedux.h +154 -0
  49. data/ext/eigen/eigen3/Eigen/src/Core/CommaInitializer.h +154 -0
  50. data/ext/eigen/eigen3/Eigen/src/Core/CoreIterators.h +61 -0
  51. data/ext/eigen/eigen3/Eigen/src/Core/CwiseBinaryOp.h +230 -0
  52. data/ext/eigen/eigen3/Eigen/src/Core/CwiseNullaryOp.h +864 -0
  53. data/ext/eigen/eigen3/Eigen/src/Core/CwiseUnaryOp.h +126 -0
  54. data/ext/eigen/eigen3/Eigen/src/Core/CwiseUnaryView.h +139 -0
  55. data/ext/eigen/eigen3/Eigen/src/Core/DenseBase.h +521 -0
  56. data/ext/eigen/eigen3/Eigen/src/Core/DenseCoeffsBase.h +754 -0
  57. data/ext/eigen/eigen3/Eigen/src/Core/DenseStorage.h +434 -0
  58. data/ext/eigen/eigen3/Eigen/src/Core/Diagonal.h +237 -0
  59. data/ext/eigen/eigen3/Eigen/src/Core/DiagonalMatrix.h +313 -0
  60. data/ext/eigen/eigen3/Eigen/src/Core/DiagonalProduct.h +131 -0
  61. data/ext/eigen/eigen3/Eigen/src/Core/Dot.h +263 -0
  62. data/ext/eigen/eigen3/Eigen/src/Core/EigenBase.h +131 -0
  63. data/ext/eigen/eigen3/Eigen/src/Core/Flagged.h +140 -0
  64. data/ext/eigen/eigen3/Eigen/src/Core/ForceAlignedAccess.h +146 -0
  65. data/ext/eigen/eigen3/Eigen/src/Core/Functors.h +1026 -0
  66. data/ext/eigen/eigen3/Eigen/src/Core/Fuzzy.h +150 -0
  67. data/ext/eigen/eigen3/Eigen/src/Core/GeneralProduct.h +635 -0
  68. data/ext/eigen/eigen3/Eigen/src/Core/GenericPacketMath.h +350 -0
  69. data/ext/eigen/eigen3/Eigen/src/Core/GlobalFunctions.h +92 -0
  70. data/ext/eigen/eigen3/Eigen/src/Core/IO.h +250 -0
  71. data/ext/eigen/eigen3/Eigen/src/Core/Map.h +192 -0
  72. data/ext/eigen/eigen3/Eigen/src/Core/MapBase.h +247 -0
  73. data/ext/eigen/eigen3/Eigen/src/Core/MathFunctions.h +768 -0
  74. data/ext/eigen/eigen3/Eigen/src/Core/Matrix.h +420 -0
  75. data/ext/eigen/eigen3/Eigen/src/Core/MatrixBase.h +563 -0
  76. data/ext/eigen/eigen3/Eigen/src/Core/NestByValue.h +111 -0
  77. data/ext/eigen/eigen3/Eigen/src/Core/NoAlias.h +134 -0
  78. data/ext/eigen/eigen3/Eigen/src/Core/NumTraits.h +150 -0
  79. data/ext/eigen/eigen3/Eigen/src/Core/PermutationMatrix.h +721 -0
  80. data/ext/eigen/eigen3/Eigen/src/Core/PlainObjectBase.h +822 -0
  81. data/ext/eigen/eigen3/Eigen/src/Core/ProductBase.h +290 -0
  82. data/ext/eigen/eigen3/Eigen/src/Core/Random.h +152 -0
  83. data/ext/eigen/eigen3/Eigen/src/Core/Redux.h +409 -0
  84. data/ext/eigen/eigen3/Eigen/src/Core/Ref.h +278 -0
  85. data/ext/eigen/eigen3/Eigen/src/Core/Replicate.h +177 -0
  86. data/ext/eigen/eigen3/Eigen/src/Core/ReturnByValue.h +99 -0
  87. data/ext/eigen/eigen3/Eigen/src/Core/Reverse.h +224 -0
  88. data/ext/eigen/eigen3/Eigen/src/Core/Select.h +162 -0
  89. data/ext/eigen/eigen3/Eigen/src/Core/SelfAdjointView.h +314 -0
  90. data/ext/eigen/eigen3/Eigen/src/Core/SelfCwiseBinaryOp.h +191 -0
  91. data/ext/eigen/eigen3/Eigen/src/Core/SolveTriangular.h +260 -0
  92. data/ext/eigen/eigen3/Eigen/src/Core/StableNorm.h +203 -0
  93. data/ext/eigen/eigen3/Eigen/src/Core/Stride.h +108 -0
  94. data/ext/eigen/eigen3/Eigen/src/Core/Swap.h +126 -0
  95. data/ext/eigen/eigen3/Eigen/src/Core/Transpose.h +419 -0
  96. data/ext/eigen/eigen3/Eigen/src/Core/Transpositions.h +436 -0
  97. data/ext/eigen/eigen3/Eigen/src/Core/TriangularMatrix.h +839 -0
  98. data/ext/eigen/eigen3/Eigen/src/Core/VectorBlock.h +95 -0
  99. data/ext/eigen/eigen3/Eigen/src/Core/VectorwiseOp.h +642 -0
  100. data/ext/eigen/eigen3/Eigen/src/Core/Visitor.h +237 -0
  101. data/ext/eigen/eigen3/Eigen/src/Core/arch/AltiVec/Complex.h +217 -0
  102. data/ext/eigen/eigen3/Eigen/src/Core/arch/AltiVec/PacketMath.h +501 -0
  103. data/ext/eigen/eigen3/Eigen/src/Core/arch/Default/Settings.h +49 -0
  104. data/ext/eigen/eigen3/Eigen/src/Core/arch/NEON/Complex.h +253 -0
  105. data/ext/eigen/eigen3/Eigen/src/Core/arch/NEON/PacketMath.h +420 -0
  106. data/ext/eigen/eigen3/Eigen/src/Core/arch/SSE/Complex.h +442 -0
  107. data/ext/eigen/eigen3/Eigen/src/Core/arch/SSE/MathFunctions.h +475 -0
  108. data/ext/eigen/eigen3/Eigen/src/Core/arch/SSE/PacketMath.h +649 -0
  109. data/ext/eigen/eigen3/Eigen/src/Core/products/CoeffBasedProduct.h +476 -0
  110. data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralBlockPanelKernel.h +1341 -0
  111. data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralMatrixMatrix.h +427 -0
  112. data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h +278 -0
  113. data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_MKL.h +146 -0
  114. data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralMatrixMatrix_MKL.h +118 -0
  115. data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralMatrixVector.h +566 -0
  116. data/ext/eigen/eigen3/Eigen/src/Core/products/GeneralMatrixVector_MKL.h +131 -0
  117. data/ext/eigen/eigen3/Eigen/src/Core/products/Parallelizer.h +162 -0
  118. data/ext/eigen/eigen3/Eigen/src/Core/products/SelfadjointMatrixMatrix.h +436 -0
  119. data/ext/eigen/eigen3/Eigen/src/Core/products/SelfadjointMatrixMatrix_MKL.h +295 -0
  120. data/ext/eigen/eigen3/Eigen/src/Core/products/SelfadjointMatrixVector.h +281 -0
  121. data/ext/eigen/eigen3/Eigen/src/Core/products/SelfadjointMatrixVector_MKL.h +114 -0
  122. data/ext/eigen/eigen3/Eigen/src/Core/products/SelfadjointProduct.h +123 -0
  123. data/ext/eigen/eigen3/Eigen/src/Core/products/SelfadjointRank2Update.h +93 -0
  124. data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularMatrixMatrix.h +427 -0
  125. data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularMatrixMatrix_MKL.h +309 -0
  126. data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularMatrixVector.h +348 -0
  127. data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularMatrixVector_MKL.h +247 -0
  128. data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularSolverMatrix.h +332 -0
  129. data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularSolverMatrix_MKL.h +155 -0
  130. data/ext/eigen/eigen3/Eigen/src/Core/products/TriangularSolverVector.h +139 -0
  131. data/ext/eigen/eigen3/Eigen/src/Core/util/BlasUtil.h +264 -0
  132. data/ext/eigen/eigen3/Eigen/src/Core/util/Constants.h +451 -0
  133. data/ext/eigen/eigen3/Eigen/src/Core/util/DisableStupidWarnings.h +40 -0
  134. data/ext/eigen/eigen3/Eigen/src/Core/util/ForwardDeclarations.h +302 -0
  135. data/ext/eigen/eigen3/Eigen/src/Core/util/MKL_support.h +158 -0
  136. data/ext/eigen/eigen3/Eigen/src/Core/util/Macros.h +451 -0
  137. data/ext/eigen/eigen3/Eigen/src/Core/util/Memory.h +977 -0
  138. data/ext/eigen/eigen3/Eigen/src/Core/util/Meta.h +243 -0
  139. data/ext/eigen/eigen3/Eigen/src/Core/util/NonMPL2.h +3 -0
  140. data/ext/eigen/eigen3/Eigen/src/Core/util/ReenableStupidWarnings.h +14 -0
  141. data/ext/eigen/eigen3/Eigen/src/Core/util/StaticAssert.h +208 -0
  142. data/ext/eigen/eigen3/Eigen/src/Core/util/XprHelper.h +469 -0
  143. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Block.h +126 -0
  144. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Cwise.h +192 -0
  145. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/CwiseOperators.h +298 -0
  146. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/AlignedBox.h +159 -0
  147. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/All.h +115 -0
  148. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/AngleAxis.h +214 -0
  149. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/Hyperplane.h +254 -0
  150. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/ParametrizedLine.h +141 -0
  151. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/Quaternion.h +495 -0
  152. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/Rotation2D.h +145 -0
  153. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/RotationBase.h +123 -0
  154. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/Scaling.h +167 -0
  155. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/Transform.h +786 -0
  156. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Geometry/Translation.h +184 -0
  157. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/LU.h +120 -0
  158. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Lazy.h +71 -0
  159. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/LeastSquares.h +169 -0
  160. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Macros.h +20 -0
  161. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/MathFunctions.h +57 -0
  162. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Memory.h +45 -0
  163. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Meta.h +75 -0
  164. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/Minor.h +117 -0
  165. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/QR.h +67 -0
  166. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/SVD.h +637 -0
  167. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/TriangularSolver.h +42 -0
  168. data/ext/eigen/eigen3/Eigen/src/Eigen2Support/VectorBlock.h +94 -0
  169. data/ext/eigen/eigen3/Eigen/src/Eigenvalues/ComplexEigenSolver.h +341 -0
  170. data/ext/eigen/eigen3/Eigen/src/Eigenvalues/ComplexSchur.h +456 -0
  171. data/ext/eigen/eigen3/Eigen/src/Eigenvalues/ComplexSchur_MKL.h +94 -0
  172. data/ext/eigen/eigen3/Eigen/src/Eigenvalues/EigenSolver.h +607 -0
  173. data/ext/eigen/eigen3/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h +350 -0
  174. data/ext/eigen/eigen3/Eigen/src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h +227 -0
  175. data/ext/eigen/eigen3/Eigen/src/Eigenvalues/HessenbergDecomposition.h +373 -0
  176. data/ext/eigen/eigen3/Eigen/src/Eigenvalues/MatrixBaseEigenvalues.h +160 -0
  177. data/ext/eigen/eigen3/Eigen/src/Eigenvalues/RealQZ.h +624 -0
  178. data/ext/eigen/eigen3/Eigen/src/Eigenvalues/RealSchur.h +525 -0
  179. data/ext/eigen/eigen3/Eigen/src/Eigenvalues/RealSchur_MKL.h +83 -0
  180. data/ext/eigen/eigen3/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h +801 -0
  181. data/ext/eigen/eigen3/Eigen/src/Eigenvalues/SelfAdjointEigenSolver_MKL.h +92 -0
  182. data/ext/eigen/eigen3/Eigen/src/Eigenvalues/Tridiagonalization.h +557 -0
  183. data/ext/eigen/eigen3/Eigen/src/Geometry/AlignedBox.h +392 -0
  184. data/ext/eigen/eigen3/Eigen/src/Geometry/AngleAxis.h +233 -0
  185. data/ext/eigen/eigen3/Eigen/src/Geometry/EulerAngles.h +104 -0
  186. data/ext/eigen/eigen3/Eigen/src/Geometry/Homogeneous.h +307 -0
  187. data/ext/eigen/eigen3/Eigen/src/Geometry/Hyperplane.h +280 -0
  188. data/ext/eigen/eigen3/Eigen/src/Geometry/OrthoMethods.h +218 -0
  189. data/ext/eigen/eigen3/Eigen/src/Geometry/ParametrizedLine.h +195 -0
  190. data/ext/eigen/eigen3/Eigen/src/Geometry/Quaternion.h +776 -0
  191. data/ext/eigen/eigen3/Eigen/src/Geometry/Rotation2D.h +160 -0
  192. data/ext/eigen/eigen3/Eigen/src/Geometry/RotationBase.h +206 -0
  193. data/ext/eigen/eigen3/Eigen/src/Geometry/Scaling.h +166 -0
  194. data/ext/eigen/eigen3/Eigen/src/Geometry/Transform.h +1455 -0
  195. data/ext/eigen/eigen3/Eigen/src/Geometry/Translation.h +206 -0
  196. data/ext/eigen/eigen3/Eigen/src/Geometry/Umeyama.h +177 -0
  197. data/ext/eigen/eigen3/Eigen/src/Geometry/arch/Geometry_SSE.h +115 -0
  198. data/ext/eigen/eigen3/Eigen/src/Householder/BlockHouseholder.h +68 -0
  199. data/ext/eigen/eigen3/Eigen/src/Householder/Householder.h +171 -0
  200. data/ext/eigen/eigen3/Eigen/src/Householder/HouseholderSequence.h +441 -0
  201. data/ext/eigen/eigen3/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h +149 -0
  202. data/ext/eigen/eigen3/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h +263 -0
  203. data/ext/eigen/eigen3/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h +256 -0
  204. data/ext/eigen/eigen3/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h +282 -0
  205. data/ext/eigen/eigen3/Eigen/src/Jacobi/Jacobi.h +433 -0
  206. data/ext/eigen/eigen3/Eigen/src/LU/Determinant.h +101 -0
  207. data/ext/eigen/eigen3/Eigen/src/LU/FullPivLU.h +751 -0
  208. data/ext/eigen/eigen3/Eigen/src/LU/Inverse.h +400 -0
  209. data/ext/eigen/eigen3/Eigen/src/LU/PartialPivLU.h +509 -0
  210. data/ext/eigen/eigen3/Eigen/src/LU/PartialPivLU_MKL.h +85 -0
  211. data/ext/eigen/eigen3/Eigen/src/LU/arch/Inverse_SSE.h +329 -0
  212. data/ext/eigen/eigen3/Eigen/src/MetisSupport/MetisSupport.h +137 -0
  213. data/ext/eigen/eigen3/Eigen/src/OrderingMethods/Amd.h +444 -0
  214. data/ext/eigen/eigen3/Eigen/src/OrderingMethods/Eigen_Colamd.h +1850 -0
  215. data/ext/eigen/eigen3/Eigen/src/PaStiXSupport/PaStiXSupport.h +721 -0
  216. data/ext/eigen/eigen3/Eigen/src/PardisoSupport/PardisoSupport.h +592 -0
  217. data/ext/eigen/eigen3/Eigen/src/QR/ColPivHouseholderQR.h +580 -0
  218. data/ext/eigen/eigen3/Eigen/src/QR/ColPivHouseholderQR_MKL.h +99 -0
  219. data/ext/eigen/eigen3/Eigen/src/QR/FullPivHouseholderQR.h +622 -0
  220. data/ext/eigen/eigen3/Eigen/src/QR/HouseholderQR.h +388 -0
  221. data/ext/eigen/eigen3/Eigen/src/QR/HouseholderQR_MKL.h +71 -0
  222. data/ext/eigen/eigen3/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h +338 -0
  223. data/ext/eigen/eigen3/Eigen/src/SVD/JacobiSVD.h +976 -0
  224. data/ext/eigen/eigen3/Eigen/src/SVD/JacobiSVD_MKL.h +92 -0
  225. data/ext/eigen/eigen3/Eigen/src/SVD/UpperBidiagonalization.h +148 -0
  226. data/ext/eigen/eigen3/Eigen/src/SparseCholesky/SimplicialCholesky.h +671 -0
  227. data/ext/eigen/eigen3/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h +199 -0
  228. data/ext/eigen/eigen3/Eigen/src/SparseCore/AmbiVector.h +373 -0
  229. data/ext/eigen/eigen3/Eigen/src/SparseCore/CompressedStorage.h +233 -0
  230. data/ext/eigen/eigen3/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h +245 -0
  231. data/ext/eigen/eigen3/Eigen/src/SparseCore/MappedSparseMatrix.h +181 -0
  232. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseBlock.h +537 -0
  233. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseColEtree.h +206 -0
  234. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseCwiseBinaryOp.h +325 -0
  235. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseCwiseUnaryOp.h +163 -0
  236. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseDenseProduct.h +311 -0
  237. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseDiagonalProduct.h +196 -0
  238. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseDot.h +101 -0
  239. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseFuzzy.h +26 -0
  240. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseMatrix.h +1262 -0
  241. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseMatrixBase.h +461 -0
  242. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparsePermutation.h +148 -0
  243. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseProduct.h +188 -0
  244. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseRedux.h +45 -0
  245. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseSelfAdjointView.h +507 -0
  246. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseSparseProductWithPruning.h +150 -0
  247. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseTranspose.h +63 -0
  248. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseTriangularView.h +179 -0
  249. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseUtil.h +172 -0
  250. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseVector.h +448 -0
  251. data/ext/eigen/eigen3/Eigen/src/SparseCore/SparseView.h +99 -0
  252. data/ext/eigen/eigen3/Eigen/src/SparseCore/TriangularSolver.h +334 -0
  253. data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU.h +806 -0
  254. data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLUImpl.h +66 -0
  255. data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_Memory.h +227 -0
  256. data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_Structs.h +111 -0
  257. data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h +298 -0
  258. data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_Utils.h +80 -0
  259. data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_column_bmod.h +180 -0
  260. data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_column_dfs.h +177 -0
  261. data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h +106 -0
  262. data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_gemm_kernel.h +279 -0
  263. data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h +127 -0
  264. data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_kernel_bmod.h +130 -0
  265. data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_panel_bmod.h +223 -0
  266. data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_panel_dfs.h +258 -0
  267. data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_pivotL.h +137 -0
  268. data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_pruneL.h +135 -0
  269. data/ext/eigen/eigen3/Eigen/src/SparseLU/SparseLU_relax_snode.h +83 -0
  270. data/ext/eigen/eigen3/Eigen/src/SparseQR/SparseQR.h +714 -0
  271. data/ext/eigen/eigen3/Eigen/src/StlSupport/StdDeque.h +134 -0
  272. data/ext/eigen/eigen3/Eigen/src/StlSupport/StdList.h +114 -0
  273. data/ext/eigen/eigen3/Eigen/src/StlSupport/StdVector.h +126 -0
  274. data/ext/eigen/eigen3/Eigen/src/StlSupport/details.h +84 -0
  275. data/ext/eigen/eigen3/Eigen/src/SuperLUSupport/SuperLUSupport.h +1026 -0
  276. data/ext/eigen/eigen3/Eigen/src/UmfPackSupport/UmfPackSupport.h +474 -0
  277. data/ext/eigen/eigen3/Eigen/src/misc/Image.h +84 -0
  278. data/ext/eigen/eigen3/Eigen/src/misc/Kernel.h +81 -0
  279. data/ext/eigen/eigen3/Eigen/src/misc/Solve.h +76 -0
  280. data/ext/eigen/eigen3/Eigen/src/misc/SparseSolve.h +128 -0
  281. data/ext/eigen/eigen3/Eigen/src/misc/blas.h +658 -0
  282. data/ext/eigen/eigen3/Eigen/src/plugins/ArrayCwiseBinaryOps.h +253 -0
  283. data/ext/eigen/eigen3/Eigen/src/plugins/ArrayCwiseUnaryOps.h +187 -0
  284. data/ext/eigen/eigen3/Eigen/src/plugins/BlockMethods.h +935 -0
  285. data/ext/eigen/eigen3/Eigen/src/plugins/CommonCwiseBinaryOps.h +46 -0
  286. data/ext/eigen/eigen3/Eigen/src/plugins/CommonCwiseUnaryOps.h +172 -0
  287. data/ext/eigen/eigen3/Eigen/src/plugins/MatrixCwiseBinaryOps.h +143 -0
  288. data/ext/eigen/eigen3/Eigen/src/plugins/MatrixCwiseUnaryOps.h +52 -0
  289. data/ext/eigen/eigen3/signature_of_eigen3_matrix_library +1 -0
  290. data/ext/eigen/eigen_wrap.cxx +19420 -10396
  291. data/ext/eigen/extconf.rb +37 -2
  292. data/lib/eigen.rb +146 -3
  293. metadata +294 -7
@@ -0,0 +1,218 @@
1
+ // This file is part of Eigen, a lightweight C++ template library
2
+ // for linear algebra.
3
+ //
4
+ // Copyright (C) 2008-2009 Gael Guennebaud <gael.guennebaud@inria.fr>
5
+ // Copyright (C) 2006-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_ORTHOMETHODS_H
12
+ #define EIGEN_ORTHOMETHODS_H
13
+
14
+ namespace Eigen {
15
+
16
+ /** \geometry_module
17
+ *
18
+ * \returns the cross product of \c *this and \a other
19
+ *
20
+ * Here is a very good explanation of cross-product: http://xkcd.com/199/
21
+ * \sa MatrixBase::cross3()
22
+ */
23
+ template<typename Derived>
24
+ template<typename OtherDerived>
25
+ inline typename MatrixBase<Derived>::template cross_product_return_type<OtherDerived>::type
26
+ MatrixBase<Derived>::cross(const MatrixBase<OtherDerived>& other) const
27
+ {
28
+ EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Derived,3)
29
+ EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,3)
30
+
31
+ // Note that there is no need for an expression here since the compiler
32
+ // optimize such a small temporary very well (even within a complex expression)
33
+ typename internal::nested<Derived,2>::type lhs(derived());
34
+ typename internal::nested<OtherDerived,2>::type rhs(other.derived());
35
+ return typename cross_product_return_type<OtherDerived>::type(
36
+ numext::conj(lhs.coeff(1) * rhs.coeff(2) - lhs.coeff(2) * rhs.coeff(1)),
37
+ numext::conj(lhs.coeff(2) * rhs.coeff(0) - lhs.coeff(0) * rhs.coeff(2)),
38
+ numext::conj(lhs.coeff(0) * rhs.coeff(1) - lhs.coeff(1) * rhs.coeff(0))
39
+ );
40
+ }
41
+
42
+ namespace internal {
43
+
44
+ template< int Arch,typename VectorLhs,typename VectorRhs,
45
+ typename Scalar = typename VectorLhs::Scalar,
46
+ bool Vectorizable = bool((VectorLhs::Flags&VectorRhs::Flags)&PacketAccessBit)>
47
+ struct cross3_impl {
48
+ static inline typename internal::plain_matrix_type<VectorLhs>::type
49
+ run(const VectorLhs& lhs, const VectorRhs& rhs)
50
+ {
51
+ return typename internal::plain_matrix_type<VectorLhs>::type(
52
+ numext::conj(lhs.coeff(1) * rhs.coeff(2) - lhs.coeff(2) * rhs.coeff(1)),
53
+ numext::conj(lhs.coeff(2) * rhs.coeff(0) - lhs.coeff(0) * rhs.coeff(2)),
54
+ numext::conj(lhs.coeff(0) * rhs.coeff(1) - lhs.coeff(1) * rhs.coeff(0)),
55
+ 0
56
+ );
57
+ }
58
+ };
59
+
60
+ }
61
+
62
+ /** \geometry_module
63
+ *
64
+ * \returns the cross product of \c *this and \a other using only the x, y, and z coefficients
65
+ *
66
+ * The size of \c *this and \a other must be four. This function is especially useful
67
+ * when using 4D vectors instead of 3D ones to get advantage of SSE/AltiVec vectorization.
68
+ *
69
+ * \sa MatrixBase::cross()
70
+ */
71
+ template<typename Derived>
72
+ template<typename OtherDerived>
73
+ inline typename MatrixBase<Derived>::PlainObject
74
+ MatrixBase<Derived>::cross3(const MatrixBase<OtherDerived>& other) const
75
+ {
76
+ EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Derived,4)
77
+ EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,4)
78
+
79
+ typedef typename internal::nested<Derived,2>::type DerivedNested;
80
+ typedef typename internal::nested<OtherDerived,2>::type OtherDerivedNested;
81
+ DerivedNested lhs(derived());
82
+ OtherDerivedNested rhs(other.derived());
83
+
84
+ return internal::cross3_impl<Architecture::Target,
85
+ typename internal::remove_all<DerivedNested>::type,
86
+ typename internal::remove_all<OtherDerivedNested>::type>::run(lhs,rhs);
87
+ }
88
+
89
+ /** \returns a matrix expression of the cross product of each column or row
90
+ * of the referenced expression with the \a other vector.
91
+ *
92
+ * The referenced matrix must have one dimension equal to 3.
93
+ * The result matrix has the same dimensions than the referenced one.
94
+ *
95
+ * \geometry_module
96
+ *
97
+ * \sa MatrixBase::cross() */
98
+ template<typename ExpressionType, int Direction>
99
+ template<typename OtherDerived>
100
+ const typename VectorwiseOp<ExpressionType,Direction>::CrossReturnType
101
+ VectorwiseOp<ExpressionType,Direction>::cross(const MatrixBase<OtherDerived>& other) const
102
+ {
103
+ EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,3)
104
+ EIGEN_STATIC_ASSERT((internal::is_same<Scalar, typename OtherDerived::Scalar>::value),
105
+ YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
106
+
107
+ CrossReturnType res(_expression().rows(),_expression().cols());
108
+ if(Direction==Vertical)
109
+ {
110
+ eigen_assert(CrossReturnType::RowsAtCompileTime==3 && "the matrix must have exactly 3 rows");
111
+ res.row(0) = (_expression().row(1) * other.coeff(2) - _expression().row(2) * other.coeff(1)).conjugate();
112
+ res.row(1) = (_expression().row(2) * other.coeff(0) - _expression().row(0) * other.coeff(2)).conjugate();
113
+ res.row(2) = (_expression().row(0) * other.coeff(1) - _expression().row(1) * other.coeff(0)).conjugate();
114
+ }
115
+ else
116
+ {
117
+ eigen_assert(CrossReturnType::ColsAtCompileTime==3 && "the matrix must have exactly 3 columns");
118
+ res.col(0) = (_expression().col(1) * other.coeff(2) - _expression().col(2) * other.coeff(1)).conjugate();
119
+ res.col(1) = (_expression().col(2) * other.coeff(0) - _expression().col(0) * other.coeff(2)).conjugate();
120
+ res.col(2) = (_expression().col(0) * other.coeff(1) - _expression().col(1) * other.coeff(0)).conjugate();
121
+ }
122
+ return res;
123
+ }
124
+
125
+ namespace internal {
126
+
127
+ template<typename Derived, int Size = Derived::SizeAtCompileTime>
128
+ struct unitOrthogonal_selector
129
+ {
130
+ typedef typename plain_matrix_type<Derived>::type VectorType;
131
+ typedef typename traits<Derived>::Scalar Scalar;
132
+ typedef typename NumTraits<Scalar>::Real RealScalar;
133
+ typedef typename Derived::Index Index;
134
+ typedef Matrix<Scalar,2,1> Vector2;
135
+ static inline VectorType run(const Derived& src)
136
+ {
137
+ VectorType perp = VectorType::Zero(src.size());
138
+ Index maxi = 0;
139
+ Index sndi = 0;
140
+ src.cwiseAbs().maxCoeff(&maxi);
141
+ if (maxi==0)
142
+ sndi = 1;
143
+ RealScalar invnm = RealScalar(1)/(Vector2() << src.coeff(sndi),src.coeff(maxi)).finished().norm();
144
+ perp.coeffRef(maxi) = -numext::conj(src.coeff(sndi)) * invnm;
145
+ perp.coeffRef(sndi) = numext::conj(src.coeff(maxi)) * invnm;
146
+
147
+ return perp;
148
+ }
149
+ };
150
+
151
+ template<typename Derived>
152
+ struct unitOrthogonal_selector<Derived,3>
153
+ {
154
+ typedef typename plain_matrix_type<Derived>::type VectorType;
155
+ typedef typename traits<Derived>::Scalar Scalar;
156
+ typedef typename NumTraits<Scalar>::Real RealScalar;
157
+ static inline VectorType run(const Derived& src)
158
+ {
159
+ VectorType perp;
160
+ /* Let us compute the crossed product of *this with a vector
161
+ * that is not too close to being colinear to *this.
162
+ */
163
+
164
+ /* unless the x and y coords are both close to zero, we can
165
+ * simply take ( -y, x, 0 ) and normalize it.
166
+ */
167
+ if((!isMuchSmallerThan(src.x(), src.z()))
168
+ || (!isMuchSmallerThan(src.y(), src.z())))
169
+ {
170
+ RealScalar invnm = RealScalar(1)/src.template head<2>().norm();
171
+ perp.coeffRef(0) = -numext::conj(src.y())*invnm;
172
+ perp.coeffRef(1) = numext::conj(src.x())*invnm;
173
+ perp.coeffRef(2) = 0;
174
+ }
175
+ /* if both x and y are close to zero, then the vector is close
176
+ * to the z-axis, so it's far from colinear to the x-axis for instance.
177
+ * So we take the crossed product with (1,0,0) and normalize it.
178
+ */
179
+ else
180
+ {
181
+ RealScalar invnm = RealScalar(1)/src.template tail<2>().norm();
182
+ perp.coeffRef(0) = 0;
183
+ perp.coeffRef(1) = -numext::conj(src.z())*invnm;
184
+ perp.coeffRef(2) = numext::conj(src.y())*invnm;
185
+ }
186
+
187
+ return perp;
188
+ }
189
+ };
190
+
191
+ template<typename Derived>
192
+ struct unitOrthogonal_selector<Derived,2>
193
+ {
194
+ typedef typename plain_matrix_type<Derived>::type VectorType;
195
+ static inline VectorType run(const Derived& src)
196
+ { return VectorType(-numext::conj(src.y()), numext::conj(src.x())).normalized(); }
197
+ };
198
+
199
+ } // end namespace internal
200
+
201
+ /** \returns a unit vector which is orthogonal to \c *this
202
+ *
203
+ * The size of \c *this must be at least 2. If the size is exactly 2,
204
+ * then the returned vector is a counter clock wise rotation of \c *this, i.e., (-y,x).normalized().
205
+ *
206
+ * \sa cross()
207
+ */
208
+ template<typename Derived>
209
+ typename MatrixBase<Derived>::PlainObject
210
+ MatrixBase<Derived>::unitOrthogonal() const
211
+ {
212
+ EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
213
+ return internal::unitOrthogonal_selector<Derived>::run(derived());
214
+ }
215
+
216
+ } // end namespace Eigen
217
+
218
+ #endif // EIGEN_ORTHOMETHODS_H
@@ -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
+ * \param _Scalar the scalar type, i.e., the type of the coefficients
27
+ * \param _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 DenseIndex Index;
41
+ typedef Matrix<Scalar,AmbientDimAtCompileTime,1,Options> VectorType;
42
+
43
+ /** Default constructor without initialization */
44
+ inline ParametrizedLine() {}
45
+
46
+ template<int OtherOptions>
47
+ 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
+ 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
+ ParametrizedLine(const VectorType& origin, const VectorType& direction)
59
+ : m_origin(origin), m_direction(direction) {}
60
+
61
+ template <int OtherOptions>
62
+ explicit ParametrizedLine(const Hyperplane<_Scalar, _AmbientDim, OtherOptions>& hyperplane);
63
+
64
+ /** Constructs a parametrized line going from \a p0 to \a p1. */
65
+ static inline ParametrizedLine Through(const VectorType& p0, const VectorType& p1)
66
+ { return ParametrizedLine(p0, (p1-p0).normalized()); }
67
+
68
+ ~ParametrizedLine() {}
69
+
70
+ /** \returns the dimension in which the line holds */
71
+ inline Index dim() const { return m_direction.size(); }
72
+
73
+ const VectorType& origin() const { return m_origin; }
74
+ VectorType& origin() { return m_origin; }
75
+
76
+ const VectorType& direction() const { return m_direction; }
77
+ 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
+ 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
+ RealScalar distance(const VectorType& p) const { using std::sqrt; return sqrt(squaredDistance(p)); }
91
+
92
+ /** \returns the projection of a point \a p onto the line \c *this. */
93
+ VectorType projection(const VectorType& p) const
94
+ { return origin() + direction().dot(p-origin()) * direction(); }
95
+
96
+ VectorType pointAt(const Scalar& t) const;
97
+
98
+ template <int OtherOptions>
99
+ Scalar intersectionParameter(const Hyperplane<_Scalar, _AmbientDim, OtherOptions>& hyperplane) const;
100
+
101
+ template <int OtherOptions>
102
+ Scalar intersection(const Hyperplane<_Scalar, _AmbientDim, OtherOptions>& hyperplane) const;
103
+
104
+ template <int OtherOptions>
105
+ 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
+ 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
+ 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
+ bool isApprox(const ParametrizedLine& other, 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
+ 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
+ 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
+ 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
+ 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
+ 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,776 @@
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
+ typedef RotationBase<Derived, 3> Base;
38
+ public:
39
+ using Base::operator*;
40
+ using Base::derived;
41
+
42
+ typedef typename internal::traits<Derived>::Scalar Scalar;
43
+ typedef typename NumTraits<Scalar>::Real RealScalar;
44
+ typedef typename internal::traits<Derived>::Coefficients Coefficients;
45
+ enum {
46
+ Flags = Eigen::internal::traits<Derived>::Flags
47
+ };
48
+
49
+ // typedef typename Matrix<Scalar,4,1> Coefficients;
50
+ /** the type of a 3D vector */
51
+ typedef Matrix<Scalar,3,1> Vector3;
52
+ /** the equivalent rotation matrix type */
53
+ typedef Matrix<Scalar,3,3> Matrix3;
54
+ /** the equivalent angle-axis type */
55
+ typedef AngleAxis<Scalar> AngleAxisType;
56
+
57
+
58
+
59
+ /** \returns the \c x coefficient */
60
+ inline Scalar x() const { return this->derived().coeffs().coeff(0); }
61
+ /** \returns the \c y coefficient */
62
+ inline Scalar y() const { return this->derived().coeffs().coeff(1); }
63
+ /** \returns the \c z coefficient */
64
+ inline Scalar z() const { return this->derived().coeffs().coeff(2); }
65
+ /** \returns the \c w coefficient */
66
+ inline Scalar w() const { return this->derived().coeffs().coeff(3); }
67
+
68
+ /** \returns a reference to the \c x coefficient */
69
+ inline Scalar& x() { return this->derived().coeffs().coeffRef(0); }
70
+ /** \returns a reference to the \c y coefficient */
71
+ inline Scalar& y() { return this->derived().coeffs().coeffRef(1); }
72
+ /** \returns a reference to the \c z coefficient */
73
+ inline Scalar& z() { return this->derived().coeffs().coeffRef(2); }
74
+ /** \returns a reference to the \c w coefficient */
75
+ inline Scalar& w() { return this->derived().coeffs().coeffRef(3); }
76
+
77
+ /** \returns a read-only vector expression of the imaginary part (x,y,z) */
78
+ inline const VectorBlock<const Coefficients,3> vec() const { return coeffs().template head<3>(); }
79
+
80
+ /** \returns a vector expression of the imaginary part (x,y,z) */
81
+ inline VectorBlock<Coefficients,3> vec() { return coeffs().template head<3>(); }
82
+
83
+ /** \returns a read-only vector expression of the coefficients (x,y,z,w) */
84
+ inline const typename internal::traits<Derived>::Coefficients& coeffs() const { return derived().coeffs(); }
85
+
86
+ /** \returns a vector expression of the coefficients (x,y,z,w) */
87
+ inline typename internal::traits<Derived>::Coefficients& coeffs() { return derived().coeffs(); }
88
+
89
+ EIGEN_STRONG_INLINE QuaternionBase<Derived>& operator=(const QuaternionBase<Derived>& other);
90
+ template<class OtherDerived> EIGEN_STRONG_INLINE Derived& operator=(const QuaternionBase<OtherDerived>& other);
91
+
92
+ // disabled this copy operator as it is giving very strange compilation errors when compiling
93
+ // test_stdvector with GCC 4.4.2. This looks like a GCC bug though, so feel free to re-enable it if it's
94
+ // useful; however notice that we already have the templated operator= above and e.g. in MatrixBase
95
+ // we didn't have to add, in addition to templated operator=, such a non-templated copy operator.
96
+ // Derived& operator=(const QuaternionBase& other)
97
+ // { return operator=<Derived>(other); }
98
+
99
+ Derived& operator=(const AngleAxisType& aa);
100
+ template<class OtherDerived> Derived& operator=(const MatrixBase<OtherDerived>& m);
101
+
102
+ /** \returns a quaternion representing an identity rotation
103
+ * \sa MatrixBase::Identity()
104
+ */
105
+ static inline Quaternion<Scalar> Identity() { return Quaternion<Scalar>(Scalar(1), Scalar(0), Scalar(0), Scalar(0)); }
106
+
107
+ /** \sa QuaternionBase::Identity(), MatrixBase::setIdentity()
108
+ */
109
+ inline QuaternionBase& setIdentity() { coeffs() << Scalar(0), Scalar(0), Scalar(0), Scalar(1); return *this; }
110
+
111
+ /** \returns the squared norm of the quaternion's coefficients
112
+ * \sa QuaternionBase::norm(), MatrixBase::squaredNorm()
113
+ */
114
+ inline Scalar squaredNorm() const { return coeffs().squaredNorm(); }
115
+
116
+ /** \returns the norm of the quaternion's coefficients
117
+ * \sa QuaternionBase::squaredNorm(), MatrixBase::norm()
118
+ */
119
+ inline Scalar norm() const { return coeffs().norm(); }
120
+
121
+ /** Normalizes the quaternion \c *this
122
+ * \sa normalized(), MatrixBase::normalize() */
123
+ inline void normalize() { coeffs().normalize(); }
124
+ /** \returns a normalized copy of \c *this
125
+ * \sa normalize(), MatrixBase::normalized() */
126
+ inline Quaternion<Scalar> normalized() const { return Quaternion<Scalar>(coeffs().normalized()); }
127
+
128
+ /** \returns the dot product of \c *this and \a other
129
+ * Geometrically speaking, the dot product of two unit quaternions
130
+ * corresponds to the cosine of half the angle between the two rotations.
131
+ * \sa angularDistance()
132
+ */
133
+ template<class OtherDerived> inline Scalar dot(const QuaternionBase<OtherDerived>& other) const { return coeffs().dot(other.coeffs()); }
134
+
135
+ template<class OtherDerived> Scalar angularDistance(const QuaternionBase<OtherDerived>& other) const;
136
+
137
+ /** \returns an equivalent 3x3 rotation matrix */
138
+ Matrix3 toRotationMatrix() const;
139
+
140
+ /** \returns the quaternion which transform \a a into \a b through a rotation */
141
+ template<typename Derived1, typename Derived2>
142
+ Derived& setFromTwoVectors(const MatrixBase<Derived1>& a, const MatrixBase<Derived2>& b);
143
+
144
+ template<class OtherDerived> EIGEN_STRONG_INLINE Quaternion<Scalar> operator* (const QuaternionBase<OtherDerived>& q) const;
145
+ template<class OtherDerived> EIGEN_STRONG_INLINE Derived& operator*= (const QuaternionBase<OtherDerived>& q);
146
+
147
+ /** \returns the quaternion describing the inverse rotation */
148
+ Quaternion<Scalar> inverse() const;
149
+
150
+ /** \returns the conjugated quaternion */
151
+ Quaternion<Scalar> conjugate() const;
152
+
153
+ template<class OtherDerived> Quaternion<Scalar> slerp(const Scalar& t, const QuaternionBase<OtherDerived>& other) const;
154
+
155
+ /** \returns \c true if \c *this is approximately equal to \a other, within the precision
156
+ * determined by \a prec.
157
+ *
158
+ * \sa MatrixBase::isApprox() */
159
+ template<class OtherDerived>
160
+ bool isApprox(const QuaternionBase<OtherDerived>& other, const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const
161
+ { return coeffs().isApprox(other.coeffs(), prec); }
162
+
163
+ /** return the result vector of \a v through the rotation*/
164
+ EIGEN_STRONG_INLINE Vector3 _transformVector(const Vector3& v) const;
165
+
166
+ /** \returns \c *this with scalar type casted to \a NewScalarType
167
+ *
168
+ * Note that if \a NewScalarType is equal to the current scalar type of \c *this
169
+ * then this function smartly returns a const reference to \c *this.
170
+ */
171
+ template<typename NewScalarType>
172
+ inline typename internal::cast_return_type<Derived,Quaternion<NewScalarType> >::type cast() const
173
+ {
174
+ return typename internal::cast_return_type<Derived,Quaternion<NewScalarType> >::type(derived());
175
+ }
176
+
177
+ #ifdef EIGEN_QUATERNIONBASE_PLUGIN
178
+ # include EIGEN_QUATERNIONBASE_PLUGIN
179
+ #endif
180
+ };
181
+
182
+ /***************************************************************************
183
+ * Definition/implementation of Quaternion<Scalar>
184
+ ***************************************************************************/
185
+
186
+ /** \geometry_module \ingroup Geometry_Module
187
+ *
188
+ * \class Quaternion
189
+ *
190
+ * \brief The quaternion class used to represent 3D orientations and rotations
191
+ *
192
+ * \tparam _Scalar the scalar type, i.e., the type of the coefficients
193
+ * \tparam _Options controls the memory alignment of the coefficients. Can be \# AutoAlign or \# DontAlign. Default is AutoAlign.
194
+ *
195
+ * This class represents a quaternion \f$ w+xi+yj+zk \f$ that is a convenient representation of
196
+ * orientations and rotations of objects in three dimensions. Compared to other representations
197
+ * like Euler angles or 3x3 matrices, quaternions offer the following advantages:
198
+ * \li \b compact storage (4 scalars)
199
+ * \li \b efficient to compose (28 flops),
200
+ * \li \b stable spherical interpolation
201
+ *
202
+ * The following two typedefs are provided for convenience:
203
+ * \li \c Quaternionf for \c float
204
+ * \li \c Quaterniond for \c double
205
+ *
206
+ * \warning Operations interpreting the quaternion as rotation have undefined behavior if the quaternion is not normalized.
207
+ *
208
+ * \sa class AngleAxis, class Transform
209
+ */
210
+
211
+ namespace internal {
212
+ template<typename _Scalar,int _Options>
213
+ struct traits<Quaternion<_Scalar,_Options> >
214
+ {
215
+ typedef Quaternion<_Scalar,_Options> PlainObject;
216
+ typedef _Scalar Scalar;
217
+ typedef Matrix<_Scalar,4,1,_Options> Coefficients;
218
+ enum{
219
+ IsAligned = internal::traits<Coefficients>::Flags & AlignedBit,
220
+ Flags = IsAligned ? (AlignedBit | LvalueBit) : LvalueBit
221
+ };
222
+ };
223
+ }
224
+
225
+ template<typename _Scalar, int _Options>
226
+ class Quaternion : public QuaternionBase<Quaternion<_Scalar,_Options> >
227
+ {
228
+ typedef QuaternionBase<Quaternion<_Scalar,_Options> > Base;
229
+ enum { IsAligned = internal::traits<Quaternion>::IsAligned };
230
+
231
+ public:
232
+ typedef _Scalar Scalar;
233
+
234
+ EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Quaternion)
235
+ using Base::operator*=;
236
+
237
+ typedef typename internal::traits<Quaternion>::Coefficients Coefficients;
238
+ typedef typename Base::AngleAxisType AngleAxisType;
239
+
240
+ /** Default constructor leaving the quaternion uninitialized. */
241
+ inline Quaternion() {}
242
+
243
+ /** Constructs and initializes the quaternion \f$ w+xi+yj+zk \f$ from
244
+ * its four coefficients \a w, \a x, \a y and \a z.
245
+ *
246
+ * \warning Note the order of the arguments: the real \a w coefficient first,
247
+ * while internally the coefficients are stored in the following order:
248
+ * [\c x, \c y, \c z, \c w]
249
+ */
250
+ inline Quaternion(const Scalar& w, const Scalar& x, const Scalar& y, const Scalar& z) : m_coeffs(x, y, z, w){}
251
+
252
+ /** Constructs and initialize a quaternion from the array data */
253
+ inline Quaternion(const Scalar* data) : m_coeffs(data) {}
254
+
255
+ /** Copy constructor */
256
+ template<class Derived> EIGEN_STRONG_INLINE Quaternion(const QuaternionBase<Derived>& other) { this->Base::operator=(other); }
257
+
258
+ /** Constructs and initializes a quaternion from the angle-axis \a aa */
259
+ explicit inline Quaternion(const AngleAxisType& aa) { *this = aa; }
260
+
261
+ /** Constructs and initializes a quaternion from either:
262
+ * - a rotation matrix expression,
263
+ * - a 4D vector expression representing quaternion coefficients.
264
+ */
265
+ template<typename Derived>
266
+ explicit inline Quaternion(const MatrixBase<Derived>& other) { *this = other; }
267
+
268
+ /** Explicit copy constructor with scalar conversion */
269
+ template<typename OtherScalar, int OtherOptions>
270
+ explicit inline Quaternion(const Quaternion<OtherScalar, OtherOptions>& other)
271
+ { m_coeffs = other.coeffs().template cast<Scalar>(); }
272
+
273
+ template<typename Derived1, typename Derived2>
274
+ static Quaternion FromTwoVectors(const MatrixBase<Derived1>& a, const MatrixBase<Derived2>& b);
275
+
276
+ inline Coefficients& coeffs() { return m_coeffs;}
277
+ inline const Coefficients& coeffs() const { return m_coeffs;}
278
+
279
+ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(IsAligned)
280
+
281
+ protected:
282
+ Coefficients m_coeffs;
283
+
284
+ #ifndef EIGEN_PARSED_BY_DOXYGEN
285
+ static EIGEN_STRONG_INLINE void _check_template_params()
286
+ {
287
+ EIGEN_STATIC_ASSERT( (_Options & DontAlign) == _Options,
288
+ INVALID_MATRIX_TEMPLATE_PARAMETERS)
289
+ }
290
+ #endif
291
+ };
292
+
293
+ /** \ingroup Geometry_Module
294
+ * single precision quaternion type */
295
+ typedef Quaternion<float> Quaternionf;
296
+ /** \ingroup Geometry_Module
297
+ * double precision quaternion type */
298
+ typedef Quaternion<double> Quaterniond;
299
+
300
+ /***************************************************************************
301
+ * Specialization of Map<Quaternion<Scalar>>
302
+ ***************************************************************************/
303
+
304
+ namespace internal {
305
+ template<typename _Scalar, int _Options>
306
+ struct traits<Map<Quaternion<_Scalar>, _Options> > : traits<Quaternion<_Scalar, (int(_Options)&Aligned)==Aligned ? AutoAlign : DontAlign> >
307
+ {
308
+ typedef Map<Matrix<_Scalar,4,1>, _Options> Coefficients;
309
+ };
310
+ }
311
+
312
+ namespace internal {
313
+ template<typename _Scalar, int _Options>
314
+ struct traits<Map<const Quaternion<_Scalar>, _Options> > : traits<Quaternion<_Scalar, (int(_Options)&Aligned)==Aligned ? AutoAlign : DontAlign> >
315
+ {
316
+ typedef Map<const Matrix<_Scalar,4,1>, _Options> Coefficients;
317
+ typedef traits<Quaternion<_Scalar, (int(_Options)&Aligned)==Aligned ? AutoAlign : DontAlign> > TraitsBase;
318
+ enum {
319
+ Flags = TraitsBase::Flags & ~LvalueBit
320
+ };
321
+ };
322
+ }
323
+
324
+ /** \ingroup Geometry_Module
325
+ * \brief Quaternion expression mapping a constant memory buffer
326
+ *
327
+ * \tparam _Scalar the type of the Quaternion coefficients
328
+ * \tparam _Options see class Map
329
+ *
330
+ * This is a specialization of class Map for Quaternion. This class allows to view
331
+ * a 4 scalar memory buffer as an Eigen's Quaternion object.
332
+ *
333
+ * \sa class Map, class Quaternion, class QuaternionBase
334
+ */
335
+ template<typename _Scalar, int _Options>
336
+ class Map<const Quaternion<_Scalar>, _Options >
337
+ : public QuaternionBase<Map<const Quaternion<_Scalar>, _Options> >
338
+ {
339
+ typedef QuaternionBase<Map<const Quaternion<_Scalar>, _Options> > Base;
340
+
341
+ public:
342
+ typedef _Scalar Scalar;
343
+ typedef typename internal::traits<Map>::Coefficients Coefficients;
344
+ EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map)
345
+ using Base::operator*=;
346
+
347
+ /** Constructs a Mapped Quaternion object from the pointer \a coeffs
348
+ *
349
+ * The pointer \a coeffs must reference the four coefficients of Quaternion in the following order:
350
+ * \code *coeffs == {x, y, z, w} \endcode
351
+ *
352
+ * If the template parameter _Options is set to #Aligned, then the pointer coeffs must be aligned. */
353
+ EIGEN_STRONG_INLINE Map(const Scalar* coeffs) : m_coeffs(coeffs) {}
354
+
355
+ inline const Coefficients& coeffs() const { return m_coeffs;}
356
+
357
+ protected:
358
+ const Coefficients m_coeffs;
359
+ };
360
+
361
+ /** \ingroup Geometry_Module
362
+ * \brief Expression of a quaternion from a memory buffer
363
+ *
364
+ * \tparam _Scalar the type of the Quaternion coefficients
365
+ * \tparam _Options see class Map
366
+ *
367
+ * This is a specialization of class Map for Quaternion. This class allows to view
368
+ * a 4 scalar memory buffer as an Eigen's Quaternion object.
369
+ *
370
+ * \sa class Map, class Quaternion, class QuaternionBase
371
+ */
372
+ template<typename _Scalar, int _Options>
373
+ class Map<Quaternion<_Scalar>, _Options >
374
+ : public QuaternionBase<Map<Quaternion<_Scalar>, _Options> >
375
+ {
376
+ typedef QuaternionBase<Map<Quaternion<_Scalar>, _Options> > Base;
377
+
378
+ public:
379
+ typedef _Scalar Scalar;
380
+ typedef typename internal::traits<Map>::Coefficients Coefficients;
381
+ EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map)
382
+ using Base::operator*=;
383
+
384
+ /** Constructs a Mapped Quaternion object from the pointer \a coeffs
385
+ *
386
+ * The pointer \a coeffs must reference the four coefficients of Quaternion in the following order:
387
+ * \code *coeffs == {x, y, z, w} \endcode
388
+ *
389
+ * If the template parameter _Options is set to #Aligned, then the pointer coeffs must be aligned. */
390
+ EIGEN_STRONG_INLINE Map(Scalar* coeffs) : m_coeffs(coeffs) {}
391
+
392
+ inline Coefficients& coeffs() { return m_coeffs; }
393
+ inline const Coefficients& coeffs() const { return m_coeffs; }
394
+
395
+ protected:
396
+ Coefficients m_coeffs;
397
+ };
398
+
399
+ /** \ingroup Geometry_Module
400
+ * Map an unaligned array of single precision scalars as a quaternion */
401
+ typedef Map<Quaternion<float>, 0> QuaternionMapf;
402
+ /** \ingroup Geometry_Module
403
+ * Map an unaligned array of double precision scalars as a quaternion */
404
+ typedef Map<Quaternion<double>, 0> QuaternionMapd;
405
+ /** \ingroup Geometry_Module
406
+ * Map a 16-byte aligned array of single precision scalars as a quaternion */
407
+ typedef Map<Quaternion<float>, Aligned> QuaternionMapAlignedf;
408
+ /** \ingroup Geometry_Module
409
+ * Map a 16-byte aligned array of double precision scalars as a quaternion */
410
+ typedef Map<Quaternion<double>, Aligned> QuaternionMapAlignedd;
411
+
412
+ /***************************************************************************
413
+ * Implementation of QuaternionBase methods
414
+ ***************************************************************************/
415
+
416
+ // Generic Quaternion * Quaternion product
417
+ // This product can be specialized for a given architecture via the Arch template argument.
418
+ namespace internal {
419
+ template<int Arch, class Derived1, class Derived2, typename Scalar, int _Options> struct quat_product
420
+ {
421
+ static EIGEN_STRONG_INLINE Quaternion<Scalar> run(const QuaternionBase<Derived1>& a, const QuaternionBase<Derived2>& b){
422
+ return Quaternion<Scalar>
423
+ (
424
+ a.w() * b.w() - a.x() * b.x() - a.y() * b.y() - a.z() * b.z(),
425
+ a.w() * b.x() + a.x() * b.w() + a.y() * b.z() - a.z() * b.y(),
426
+ a.w() * b.y() + a.y() * b.w() + a.z() * b.x() - a.x() * b.z(),
427
+ a.w() * b.z() + a.z() * b.w() + a.x() * b.y() - a.y() * b.x()
428
+ );
429
+ }
430
+ };
431
+ }
432
+
433
+ /** \returns the concatenation of two rotations as a quaternion-quaternion product */
434
+ template <class Derived>
435
+ template <class OtherDerived>
436
+ EIGEN_STRONG_INLINE Quaternion<typename internal::traits<Derived>::Scalar>
437
+ QuaternionBase<Derived>::operator* (const QuaternionBase<OtherDerived>& other) const
438
+ {
439
+ EIGEN_STATIC_ASSERT((internal::is_same<typename Derived::Scalar, typename OtherDerived::Scalar>::value),
440
+ YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
441
+ return internal::quat_product<Architecture::Target, Derived, OtherDerived,
442
+ typename internal::traits<Derived>::Scalar,
443
+ internal::traits<Derived>::IsAligned && internal::traits<OtherDerived>::IsAligned>::run(*this, other);
444
+ }
445
+
446
+ /** \sa operator*(Quaternion) */
447
+ template <class Derived>
448
+ template <class OtherDerived>
449
+ EIGEN_STRONG_INLINE Derived& QuaternionBase<Derived>::operator*= (const QuaternionBase<OtherDerived>& other)
450
+ {
451
+ derived() = derived() * other.derived();
452
+ return derived();
453
+ }
454
+
455
+ /** Rotation of a vector by a quaternion.
456
+ * \remarks If the quaternion is used to rotate several points (>1)
457
+ * then it is much more efficient to first convert it to a 3x3 Matrix.
458
+ * Comparison of the operation cost for n transformations:
459
+ * - Quaternion2: 30n
460
+ * - Via a Matrix3: 24 + 15n
461
+ */
462
+ template <class Derived>
463
+ EIGEN_STRONG_INLINE typename QuaternionBase<Derived>::Vector3
464
+ QuaternionBase<Derived>::_transformVector(const Vector3& v) const
465
+ {
466
+ // Note that this algorithm comes from the optimization by hand
467
+ // of the conversion to a Matrix followed by a Matrix/Vector product.
468
+ // It appears to be much faster than the common algorithm found
469
+ // in the literature (30 versus 39 flops). It also requires two
470
+ // Vector3 as temporaries.
471
+ Vector3 uv = this->vec().cross(v);
472
+ uv += uv;
473
+ return v + this->w() * uv + this->vec().cross(uv);
474
+ }
475
+
476
+ template<class Derived>
477
+ EIGEN_STRONG_INLINE QuaternionBase<Derived>& QuaternionBase<Derived>::operator=(const QuaternionBase<Derived>& other)
478
+ {
479
+ coeffs() = other.coeffs();
480
+ return derived();
481
+ }
482
+
483
+ template<class Derived>
484
+ template<class OtherDerived>
485
+ EIGEN_STRONG_INLINE Derived& QuaternionBase<Derived>::operator=(const QuaternionBase<OtherDerived>& other)
486
+ {
487
+ coeffs() = other.coeffs();
488
+ return derived();
489
+ }
490
+
491
+ /** Set \c *this from an angle-axis \a aa and returns a reference to \c *this
492
+ */
493
+ template<class Derived>
494
+ EIGEN_STRONG_INLINE Derived& QuaternionBase<Derived>::operator=(const AngleAxisType& aa)
495
+ {
496
+ using std::cos;
497
+ using std::sin;
498
+ Scalar ha = Scalar(0.5)*aa.angle(); // Scalar(0.5) to suppress precision loss warnings
499
+ this->w() = cos(ha);
500
+ this->vec() = sin(ha) * aa.axis();
501
+ return derived();
502
+ }
503
+
504
+ /** Set \c *this from the expression \a xpr:
505
+ * - if \a xpr is a 4x1 vector, then \a xpr is assumed to be a quaternion
506
+ * - if \a xpr is a 3x3 matrix, then \a xpr is assumed to be rotation matrix
507
+ * and \a xpr is converted to a quaternion
508
+ */
509
+
510
+ template<class Derived>
511
+ template<class MatrixDerived>
512
+ inline Derived& QuaternionBase<Derived>::operator=(const MatrixBase<MatrixDerived>& xpr)
513
+ {
514
+ EIGEN_STATIC_ASSERT((internal::is_same<typename Derived::Scalar, typename MatrixDerived::Scalar>::value),
515
+ YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
516
+ internal::quaternionbase_assign_impl<MatrixDerived>::run(*this, xpr.derived());
517
+ return derived();
518
+ }
519
+
520
+ /** Convert the quaternion to a 3x3 rotation matrix. The quaternion is required to
521
+ * be normalized, otherwise the result is undefined.
522
+ */
523
+ template<class Derived>
524
+ inline typename QuaternionBase<Derived>::Matrix3
525
+ QuaternionBase<Derived>::toRotationMatrix(void) const
526
+ {
527
+ // NOTE if inlined, then gcc 4.2 and 4.4 get rid of the temporary (not gcc 4.3 !!)
528
+ // if not inlined then the cost of the return by value is huge ~ +35%,
529
+ // however, not inlining this function is an order of magnitude slower, so
530
+ // it has to be inlined, and so the return by value is not an issue
531
+ Matrix3 res;
532
+
533
+ const Scalar tx = Scalar(2)*this->x();
534
+ const Scalar ty = Scalar(2)*this->y();
535
+ const Scalar tz = Scalar(2)*this->z();
536
+ const Scalar twx = tx*this->w();
537
+ const Scalar twy = ty*this->w();
538
+ const Scalar twz = tz*this->w();
539
+ const Scalar txx = tx*this->x();
540
+ const Scalar txy = ty*this->x();
541
+ const Scalar txz = tz*this->x();
542
+ const Scalar tyy = ty*this->y();
543
+ const Scalar tyz = tz*this->y();
544
+ const Scalar tzz = tz*this->z();
545
+
546
+ res.coeffRef(0,0) = Scalar(1)-(tyy+tzz);
547
+ res.coeffRef(0,1) = txy-twz;
548
+ res.coeffRef(0,2) = txz+twy;
549
+ res.coeffRef(1,0) = txy+twz;
550
+ res.coeffRef(1,1) = Scalar(1)-(txx+tzz);
551
+ res.coeffRef(1,2) = tyz-twx;
552
+ res.coeffRef(2,0) = txz-twy;
553
+ res.coeffRef(2,1) = tyz+twx;
554
+ res.coeffRef(2,2) = Scalar(1)-(txx+tyy);
555
+
556
+ return res;
557
+ }
558
+
559
+ /** Sets \c *this to be a quaternion representing a rotation between
560
+ * the two arbitrary vectors \a a and \a b. In other words, the built
561
+ * rotation represent a rotation sending the line of direction \a a
562
+ * to the line of direction \a b, both lines passing through the origin.
563
+ *
564
+ * \returns a reference to \c *this.
565
+ *
566
+ * Note that the two input vectors do \b not have to be normalized, and
567
+ * do not need to have the same norm.
568
+ */
569
+ template<class Derived>
570
+ template<typename Derived1, typename Derived2>
571
+ inline Derived& QuaternionBase<Derived>::setFromTwoVectors(const MatrixBase<Derived1>& a, const MatrixBase<Derived2>& b)
572
+ {
573
+ using std::max;
574
+ using std::sqrt;
575
+ Vector3 v0 = a.normalized();
576
+ Vector3 v1 = b.normalized();
577
+ Scalar c = v1.dot(v0);
578
+
579
+ // if dot == -1, vectors are nearly opposites
580
+ // => accurately compute the rotation axis by computing the
581
+ // intersection of the two planes. This is done by solving:
582
+ // x^T v0 = 0
583
+ // x^T v1 = 0
584
+ // under the constraint:
585
+ // ||x|| = 1
586
+ // which yields a singular value problem
587
+ if (c < Scalar(-1)+NumTraits<Scalar>::dummy_precision())
588
+ {
589
+ c = (max)(c,Scalar(-1));
590
+ Matrix<Scalar,2,3> m; m << v0.transpose(), v1.transpose();
591
+ JacobiSVD<Matrix<Scalar,2,3> > svd(m, ComputeFullV);
592
+ Vector3 axis = svd.matrixV().col(2);
593
+
594
+ Scalar w2 = (Scalar(1)+c)*Scalar(0.5);
595
+ this->w() = sqrt(w2);
596
+ this->vec() = axis * sqrt(Scalar(1) - w2);
597
+ return derived();
598
+ }
599
+ Vector3 axis = v0.cross(v1);
600
+ Scalar s = sqrt((Scalar(1)+c)*Scalar(2));
601
+ Scalar invs = Scalar(1)/s;
602
+ this->vec() = axis * invs;
603
+ this->w() = s * Scalar(0.5);
604
+
605
+ return derived();
606
+ }
607
+
608
+
609
+ /** Returns a quaternion representing a rotation between
610
+ * the two arbitrary vectors \a a and \a b. In other words, the built
611
+ * rotation represent a rotation sending the line of direction \a a
612
+ * to the line of direction \a b, both lines passing through the origin.
613
+ *
614
+ * \returns resulting quaternion
615
+ *
616
+ * Note that the two input vectors do \b not have to be normalized, and
617
+ * do not need to have the same norm.
618
+ */
619
+ template<typename Scalar, int Options>
620
+ template<typename Derived1, typename Derived2>
621
+ Quaternion<Scalar,Options> Quaternion<Scalar,Options>::FromTwoVectors(const MatrixBase<Derived1>& a, const MatrixBase<Derived2>& b)
622
+ {
623
+ Quaternion quat;
624
+ quat.setFromTwoVectors(a, b);
625
+ return quat;
626
+ }
627
+
628
+
629
+ /** \returns the multiplicative inverse of \c *this
630
+ * Note that in most cases, i.e., if you simply want the opposite rotation,
631
+ * and/or the quaternion is normalized, then it is enough to use the conjugate.
632
+ *
633
+ * \sa QuaternionBase::conjugate()
634
+ */
635
+ template <class Derived>
636
+ inline Quaternion<typename internal::traits<Derived>::Scalar> QuaternionBase<Derived>::inverse() const
637
+ {
638
+ // FIXME should this function be called multiplicativeInverse and conjugate() be called inverse() or opposite() ??
639
+ Scalar n2 = this->squaredNorm();
640
+ if (n2 > Scalar(0))
641
+ return Quaternion<Scalar>(conjugate().coeffs() / n2);
642
+ else
643
+ {
644
+ // return an invalid result to flag the error
645
+ return Quaternion<Scalar>(Coefficients::Zero());
646
+ }
647
+ }
648
+
649
+ /** \returns the conjugate of the \c *this which is equal to the multiplicative inverse
650
+ * if the quaternion is normalized.
651
+ * The conjugate of a quaternion represents the opposite rotation.
652
+ *
653
+ * \sa Quaternion2::inverse()
654
+ */
655
+ template <class Derived>
656
+ inline Quaternion<typename internal::traits<Derived>::Scalar>
657
+ QuaternionBase<Derived>::conjugate() const
658
+ {
659
+ return Quaternion<Scalar>(this->w(),-this->x(),-this->y(),-this->z());
660
+ }
661
+
662
+ /** \returns the angle (in radian) between two rotations
663
+ * \sa dot()
664
+ */
665
+ template <class Derived>
666
+ template <class OtherDerived>
667
+ inline typename internal::traits<Derived>::Scalar
668
+ QuaternionBase<Derived>::angularDistance(const QuaternionBase<OtherDerived>& other) const
669
+ {
670
+ using std::atan2;
671
+ using std::abs;
672
+ Quaternion<Scalar> d = (*this) * other.conjugate();
673
+ return Scalar(2) * atan2( d.vec().norm(), abs(d.w()) );
674
+ }
675
+
676
+
677
+
678
+ /** \returns the spherical linear interpolation between the two quaternions
679
+ * \c *this and \a other at the parameter \a t in [0;1].
680
+ *
681
+ * This represents an interpolation for a constant motion between \c *this and \a other,
682
+ * see also http://en.wikipedia.org/wiki/Slerp.
683
+ */
684
+ template <class Derived>
685
+ template <class OtherDerived>
686
+ Quaternion<typename internal::traits<Derived>::Scalar>
687
+ QuaternionBase<Derived>::slerp(const Scalar& t, const QuaternionBase<OtherDerived>& other) const
688
+ {
689
+ using std::acos;
690
+ using std::sin;
691
+ using std::abs;
692
+ static const Scalar one = Scalar(1) - NumTraits<Scalar>::epsilon();
693
+ Scalar d = this->dot(other);
694
+ Scalar absD = abs(d);
695
+
696
+ Scalar scale0;
697
+ Scalar scale1;
698
+
699
+ if(absD>=one)
700
+ {
701
+ scale0 = Scalar(1) - t;
702
+ scale1 = t;
703
+ }
704
+ else
705
+ {
706
+ // theta is the angle between the 2 quaternions
707
+ Scalar theta = acos(absD);
708
+ Scalar sinTheta = sin(theta);
709
+
710
+ scale0 = sin( ( Scalar(1) - t ) * theta) / sinTheta;
711
+ scale1 = sin( ( t * theta) ) / sinTheta;
712
+ }
713
+ if(d<Scalar(0)) scale1 = -scale1;
714
+
715
+ return Quaternion<Scalar>(scale0 * coeffs() + scale1 * other.coeffs());
716
+ }
717
+
718
+ namespace internal {
719
+
720
+ // set from a rotation matrix
721
+ template<typename Other>
722
+ struct quaternionbase_assign_impl<Other,3,3>
723
+ {
724
+ typedef typename Other::Scalar Scalar;
725
+ typedef DenseIndex Index;
726
+ template<class Derived> static inline void run(QuaternionBase<Derived>& q, const Other& mat)
727
+ {
728
+ using std::sqrt;
729
+ // This algorithm comes from "Quaternion Calculus and Fast Animation",
730
+ // Ken Shoemake, 1987 SIGGRAPH course notes
731
+ Scalar t = mat.trace();
732
+ if (t > Scalar(0))
733
+ {
734
+ t = sqrt(t + Scalar(1.0));
735
+ q.w() = Scalar(0.5)*t;
736
+ t = Scalar(0.5)/t;
737
+ q.x() = (mat.coeff(2,1) - mat.coeff(1,2)) * t;
738
+ q.y() = (mat.coeff(0,2) - mat.coeff(2,0)) * t;
739
+ q.z() = (mat.coeff(1,0) - mat.coeff(0,1)) * t;
740
+ }
741
+ else
742
+ {
743
+ DenseIndex i = 0;
744
+ if (mat.coeff(1,1) > mat.coeff(0,0))
745
+ i = 1;
746
+ if (mat.coeff(2,2) > mat.coeff(i,i))
747
+ i = 2;
748
+ DenseIndex j = (i+1)%3;
749
+ DenseIndex k = (j+1)%3;
750
+
751
+ t = sqrt(mat.coeff(i,i)-mat.coeff(j,j)-mat.coeff(k,k) + Scalar(1.0));
752
+ q.coeffs().coeffRef(i) = Scalar(0.5) * t;
753
+ t = Scalar(0.5)/t;
754
+ q.w() = (mat.coeff(k,j)-mat.coeff(j,k))*t;
755
+ q.coeffs().coeffRef(j) = (mat.coeff(j,i)+mat.coeff(i,j))*t;
756
+ q.coeffs().coeffRef(k) = (mat.coeff(k,i)+mat.coeff(i,k))*t;
757
+ }
758
+ }
759
+ };
760
+
761
+ // set from a vector of coefficients assumed to be a quaternion
762
+ template<typename Other>
763
+ struct quaternionbase_assign_impl<Other,4,1>
764
+ {
765
+ typedef typename Other::Scalar Scalar;
766
+ template<class Derived> static inline void run(QuaternionBase<Derived>& q, const Other& vec)
767
+ {
768
+ q.coeffs() = vec;
769
+ }
770
+ };
771
+
772
+ } // end namespace internal
773
+
774
+ } // end namespace Eigen
775
+
776
+ #endif // EIGEN_QUATERNION_H