ruby-eigen 0.0.9 → 0.0.10.pre1

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 (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,192 @@
1
+ // This file is part of Eigen, a lightweight C++ template library
2
+ // for linear algebra.
3
+ //
4
+ // Copyright (C) 2007-2010 Benoit Jacob <jacob.benoit.1@gmail.com>
5
+ // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.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_MAP_H
12
+ #define EIGEN_MAP_H
13
+
14
+ namespace Eigen {
15
+
16
+ /** \class Map
17
+ * \ingroup Core_Module
18
+ *
19
+ * \brief A matrix or vector expression mapping an existing array of data.
20
+ *
21
+ * \tparam PlainObjectType the equivalent matrix type of the mapped data
22
+ * \tparam MapOptions specifies whether the pointer is \c #Aligned, or \c #Unaligned.
23
+ * The default is \c #Unaligned.
24
+ * \tparam StrideType optionally specifies strides. By default, Map assumes the memory layout
25
+ * of an ordinary, contiguous array. This can be overridden by specifying strides.
26
+ * The type passed here must be a specialization of the Stride template, see examples below.
27
+ *
28
+ * This class represents a matrix or vector expression mapping an existing array of data.
29
+ * It can be used to let Eigen interface without any overhead with non-Eigen data structures,
30
+ * such as plain C arrays or structures from other libraries. By default, it assumes that the
31
+ * data is laid out contiguously in memory. You can however override this by explicitly specifying
32
+ * inner and outer strides.
33
+ *
34
+ * Here's an example of simply mapping a contiguous array as a \ref TopicStorageOrders "column-major" matrix:
35
+ * \include Map_simple.cpp
36
+ * Output: \verbinclude Map_simple.out
37
+ *
38
+ * If you need to map non-contiguous arrays, you can do so by specifying strides:
39
+ *
40
+ * Here's an example of mapping an array as a vector, specifying an inner stride, that is, the pointer
41
+ * increment between two consecutive coefficients. Here, we're specifying the inner stride as a compile-time
42
+ * fixed value.
43
+ * \include Map_inner_stride.cpp
44
+ * Output: \verbinclude Map_inner_stride.out
45
+ *
46
+ * Here's an example of mapping an array while specifying an outer stride. Here, since we're mapping
47
+ * as a column-major matrix, 'outer stride' means the pointer increment between two consecutive columns.
48
+ * Here, we're specifying the outer stride as a runtime parameter. Note that here \c OuterStride<> is
49
+ * a short version of \c OuterStride<Dynamic> because the default template parameter of OuterStride
50
+ * is \c Dynamic
51
+ * \include Map_outer_stride.cpp
52
+ * Output: \verbinclude Map_outer_stride.out
53
+ *
54
+ * For more details and for an example of specifying both an inner and an outer stride, see class Stride.
55
+ *
56
+ * \b Tip: to change the array of data mapped by a Map object, you can use the C++
57
+ * placement new syntax:
58
+ *
59
+ * Example: \include Map_placement_new.cpp
60
+ * Output: \verbinclude Map_placement_new.out
61
+ *
62
+ * This class is the return type of PlainObjectBase::Map() but can also be used directly.
63
+ *
64
+ * \sa PlainObjectBase::Map(), \ref TopicStorageOrders
65
+ */
66
+
67
+ namespace internal {
68
+ template<typename PlainObjectType, int MapOptions, typename StrideType>
69
+ struct traits<Map<PlainObjectType, MapOptions, StrideType> >
70
+ : public traits<PlainObjectType>
71
+ {
72
+ typedef traits<PlainObjectType> TraitsBase;
73
+ typedef typename PlainObjectType::Index Index;
74
+ typedef typename PlainObjectType::Scalar Scalar;
75
+ enum {
76
+ InnerStrideAtCompileTime = StrideType::InnerStrideAtCompileTime == 0
77
+ ? int(PlainObjectType::InnerStrideAtCompileTime)
78
+ : int(StrideType::InnerStrideAtCompileTime),
79
+ OuterStrideAtCompileTime = StrideType::OuterStrideAtCompileTime == 0
80
+ ? int(PlainObjectType::OuterStrideAtCompileTime)
81
+ : int(StrideType::OuterStrideAtCompileTime),
82
+ HasNoInnerStride = InnerStrideAtCompileTime == 1,
83
+ HasNoOuterStride = StrideType::OuterStrideAtCompileTime == 0,
84
+ HasNoStride = HasNoInnerStride && HasNoOuterStride,
85
+ IsAligned = bool(EIGEN_ALIGN) && ((int(MapOptions)&Aligned)==Aligned),
86
+ IsDynamicSize = PlainObjectType::SizeAtCompileTime==Dynamic,
87
+ KeepsPacketAccess = bool(HasNoInnerStride)
88
+ && ( bool(IsDynamicSize)
89
+ || HasNoOuterStride
90
+ || ( OuterStrideAtCompileTime!=Dynamic
91
+ && ((static_cast<int>(sizeof(Scalar))*OuterStrideAtCompileTime)%16)==0 ) ),
92
+ Flags0 = TraitsBase::Flags & (~NestByRefBit),
93
+ Flags1 = IsAligned ? (int(Flags0) | AlignedBit) : (int(Flags0) & ~AlignedBit),
94
+ Flags2 = (bool(HasNoStride) || bool(PlainObjectType::IsVectorAtCompileTime))
95
+ ? int(Flags1) : int(Flags1 & ~LinearAccessBit),
96
+ Flags3 = is_lvalue<PlainObjectType>::value ? int(Flags2) : (int(Flags2) & ~LvalueBit),
97
+ Flags = KeepsPacketAccess ? int(Flags3) : (int(Flags3) & ~PacketAccessBit)
98
+ };
99
+ private:
100
+ enum { Options }; // Expressions don't have Options
101
+ };
102
+ }
103
+
104
+ template<typename PlainObjectType, int MapOptions, typename StrideType> class Map
105
+ : public MapBase<Map<PlainObjectType, MapOptions, StrideType> >
106
+ {
107
+ public:
108
+
109
+ typedef MapBase<Map> Base;
110
+ EIGEN_DENSE_PUBLIC_INTERFACE(Map)
111
+
112
+ typedef typename Base::PointerType PointerType;
113
+ #if EIGEN2_SUPPORT_STAGE <= STAGE30_FULL_EIGEN3_API
114
+ typedef const Scalar* PointerArgType;
115
+ inline PointerType cast_to_pointer_type(PointerArgType ptr) { return const_cast<PointerType>(ptr); }
116
+ #else
117
+ typedef PointerType PointerArgType;
118
+ inline PointerType cast_to_pointer_type(PointerArgType ptr) { return ptr; }
119
+ #endif
120
+
121
+ inline Index innerStride() const
122
+ {
123
+ return StrideType::InnerStrideAtCompileTime != 0 ? m_stride.inner() : 1;
124
+ }
125
+
126
+ inline Index outerStride() const
127
+ {
128
+ return StrideType::OuterStrideAtCompileTime != 0 ? m_stride.outer()
129
+ : IsVectorAtCompileTime ? this->size()
130
+ : int(Flags)&RowMajorBit ? this->cols()
131
+ : this->rows();
132
+ }
133
+
134
+ /** Constructor in the fixed-size case.
135
+ *
136
+ * \param dataPtr pointer to the array to map
137
+ * \param a_stride optional Stride object, passing the strides.
138
+ */
139
+ inline Map(PointerArgType dataPtr, const StrideType& a_stride = StrideType())
140
+ : Base(cast_to_pointer_type(dataPtr)), m_stride(a_stride)
141
+ {
142
+ PlainObjectType::Base::_check_template_params();
143
+ }
144
+
145
+ /** Constructor in the dynamic-size vector case.
146
+ *
147
+ * \param dataPtr pointer to the array to map
148
+ * \param a_size the size of the vector expression
149
+ * \param a_stride optional Stride object, passing the strides.
150
+ */
151
+ inline Map(PointerArgType dataPtr, Index a_size, const StrideType& a_stride = StrideType())
152
+ : Base(cast_to_pointer_type(dataPtr), a_size), m_stride(a_stride)
153
+ {
154
+ PlainObjectType::Base::_check_template_params();
155
+ }
156
+
157
+ /** Constructor in the dynamic-size matrix case.
158
+ *
159
+ * \param dataPtr pointer to the array to map
160
+ * \param nbRows the number of rows of the matrix expression
161
+ * \param nbCols the number of columns of the matrix expression
162
+ * \param a_stride optional Stride object, passing the strides.
163
+ */
164
+ inline Map(PointerArgType dataPtr, Index nbRows, Index nbCols, const StrideType& a_stride = StrideType())
165
+ : Base(cast_to_pointer_type(dataPtr), nbRows, nbCols), m_stride(a_stride)
166
+ {
167
+ PlainObjectType::Base::_check_template_params();
168
+ }
169
+
170
+ EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map)
171
+
172
+ protected:
173
+ StrideType m_stride;
174
+ };
175
+
176
+ template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
177
+ inline Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>
178
+ ::Array(const Scalar *data)
179
+ {
180
+ this->_set_noalias(Eigen::Map<const Array>(data));
181
+ }
182
+
183
+ template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
184
+ inline Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>
185
+ ::Matrix(const Scalar *data)
186
+ {
187
+ this->_set_noalias(Eigen::Map<const Matrix>(data));
188
+ }
189
+
190
+ } // end namespace Eigen
191
+
192
+ #endif // EIGEN_MAP_H
@@ -0,0 +1,247 @@
1
+ // This file is part of Eigen, a lightweight C++ template library
2
+ // for linear algebra.
3
+ //
4
+ // Copyright (C) 2007-2010 Benoit Jacob <jacob.benoit.1@gmail.com>
5
+ // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.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_MAPBASE_H
12
+ #define EIGEN_MAPBASE_H
13
+
14
+ #define EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS(Derived) \
15
+ EIGEN_STATIC_ASSERT((int(internal::traits<Derived>::Flags) & LinearAccessBit) || Derived::IsVectorAtCompileTime, \
16
+ YOU_ARE_TRYING_TO_USE_AN_INDEX_BASED_ACCESSOR_ON_AN_EXPRESSION_THAT_DOES_NOT_SUPPORT_THAT)
17
+
18
+ namespace Eigen {
19
+
20
+ /** \class MapBase
21
+ * \ingroup Core_Module
22
+ *
23
+ * \brief Base class for Map and Block expression with direct access
24
+ *
25
+ * \sa class Map, class Block
26
+ */
27
+ template<typename Derived> class MapBase<Derived, ReadOnlyAccessors>
28
+ : public internal::dense_xpr_base<Derived>::type
29
+ {
30
+ public:
31
+
32
+ typedef typename internal::dense_xpr_base<Derived>::type Base;
33
+ enum {
34
+ RowsAtCompileTime = internal::traits<Derived>::RowsAtCompileTime,
35
+ ColsAtCompileTime = internal::traits<Derived>::ColsAtCompileTime,
36
+ SizeAtCompileTime = Base::SizeAtCompileTime
37
+ };
38
+
39
+ typedef typename internal::traits<Derived>::StorageKind StorageKind;
40
+ typedef typename internal::traits<Derived>::Index Index;
41
+ typedef typename internal::traits<Derived>::Scalar Scalar;
42
+ typedef typename internal::packet_traits<Scalar>::type PacketScalar;
43
+ typedef typename NumTraits<Scalar>::Real RealScalar;
44
+ typedef typename internal::conditional<
45
+ bool(internal::is_lvalue<Derived>::value),
46
+ Scalar *,
47
+ const Scalar *>::type
48
+ PointerType;
49
+
50
+ using Base::derived;
51
+ // using Base::RowsAtCompileTime;
52
+ // using Base::ColsAtCompileTime;
53
+ // using Base::SizeAtCompileTime;
54
+ using Base::MaxRowsAtCompileTime;
55
+ using Base::MaxColsAtCompileTime;
56
+ using Base::MaxSizeAtCompileTime;
57
+ using Base::IsVectorAtCompileTime;
58
+ using Base::Flags;
59
+ using Base::IsRowMajor;
60
+
61
+ using Base::rows;
62
+ using Base::cols;
63
+ using Base::size;
64
+ using Base::coeff;
65
+ using Base::coeffRef;
66
+ using Base::lazyAssign;
67
+ using Base::eval;
68
+
69
+ using Base::innerStride;
70
+ using Base::outerStride;
71
+ using Base::rowStride;
72
+ using Base::colStride;
73
+
74
+ // bug 217 - compile error on ICC 11.1
75
+ using Base::operator=;
76
+
77
+ typedef typename Base::CoeffReturnType CoeffReturnType;
78
+
79
+ inline Index rows() const { return m_rows.value(); }
80
+ inline Index cols() const { return m_cols.value(); }
81
+
82
+ /** Returns a pointer to the first coefficient of the matrix or vector.
83
+ *
84
+ * \note When addressing this data, make sure to honor the strides returned by innerStride() and outerStride().
85
+ *
86
+ * \sa innerStride(), outerStride()
87
+ */
88
+ inline const Scalar* data() const { return m_data; }
89
+
90
+ inline const Scalar& coeff(Index rowId, Index colId) const
91
+ {
92
+ return m_data[colId * colStride() + rowId * rowStride()];
93
+ }
94
+
95
+ inline const Scalar& coeff(Index index) const
96
+ {
97
+ EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS(Derived)
98
+ return m_data[index * innerStride()];
99
+ }
100
+
101
+ inline const Scalar& coeffRef(Index rowId, Index colId) const
102
+ {
103
+ return this->m_data[colId * colStride() + rowId * rowStride()];
104
+ }
105
+
106
+ inline const Scalar& coeffRef(Index index) const
107
+ {
108
+ EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS(Derived)
109
+ return this->m_data[index * innerStride()];
110
+ }
111
+
112
+ template<int LoadMode>
113
+ inline PacketScalar packet(Index rowId, Index colId) const
114
+ {
115
+ return internal::ploadt<PacketScalar, LoadMode>
116
+ (m_data + (colId * colStride() + rowId * rowStride()));
117
+ }
118
+
119
+ template<int LoadMode>
120
+ inline PacketScalar packet(Index index) const
121
+ {
122
+ EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS(Derived)
123
+ return internal::ploadt<PacketScalar, LoadMode>(m_data + index * innerStride());
124
+ }
125
+
126
+ explicit inline MapBase(PointerType dataPtr) : m_data(dataPtr), m_rows(RowsAtCompileTime), m_cols(ColsAtCompileTime)
127
+ {
128
+ EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
129
+ checkSanity();
130
+ }
131
+
132
+ inline MapBase(PointerType dataPtr, Index vecSize)
133
+ : m_data(dataPtr),
134
+ m_rows(RowsAtCompileTime == Dynamic ? vecSize : Index(RowsAtCompileTime)),
135
+ m_cols(ColsAtCompileTime == Dynamic ? vecSize : Index(ColsAtCompileTime))
136
+ {
137
+ EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
138
+ eigen_assert(vecSize >= 0);
139
+ eigen_assert(dataPtr == 0 || SizeAtCompileTime == Dynamic || SizeAtCompileTime == vecSize);
140
+ checkSanity();
141
+ }
142
+
143
+ inline MapBase(PointerType dataPtr, Index nbRows, Index nbCols)
144
+ : m_data(dataPtr), m_rows(nbRows), m_cols(nbCols)
145
+ {
146
+ eigen_assert( (dataPtr == 0)
147
+ || ( nbRows >= 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == nbRows)
148
+ && nbCols >= 0 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == nbCols)));
149
+ checkSanity();
150
+ }
151
+
152
+ protected:
153
+
154
+ void checkSanity() const
155
+ {
156
+ EIGEN_STATIC_ASSERT(EIGEN_IMPLIES(internal::traits<Derived>::Flags&PacketAccessBit,
157
+ internal::inner_stride_at_compile_time<Derived>::ret==1),
158
+ PACKET_ACCESS_REQUIRES_TO_HAVE_INNER_STRIDE_FIXED_TO_1);
159
+ eigen_assert(EIGEN_IMPLIES(internal::traits<Derived>::Flags&AlignedBit, (size_t(m_data) % 16) == 0)
160
+ && "input pointer is not aligned on a 16 byte boundary");
161
+ }
162
+
163
+ PointerType m_data;
164
+ const internal::variable_if_dynamic<Index, RowsAtCompileTime> m_rows;
165
+ const internal::variable_if_dynamic<Index, ColsAtCompileTime> m_cols;
166
+ };
167
+
168
+ template<typename Derived> class MapBase<Derived, WriteAccessors>
169
+ : public MapBase<Derived, ReadOnlyAccessors>
170
+ {
171
+ typedef MapBase<Derived, ReadOnlyAccessors> ReadOnlyMapBase;
172
+ public:
173
+
174
+ typedef MapBase<Derived, ReadOnlyAccessors> Base;
175
+
176
+ typedef typename Base::Scalar Scalar;
177
+ typedef typename Base::PacketScalar PacketScalar;
178
+ typedef typename Base::Index Index;
179
+ typedef typename Base::PointerType PointerType;
180
+
181
+ using Base::derived;
182
+ using Base::rows;
183
+ using Base::cols;
184
+ using Base::size;
185
+ using Base::coeff;
186
+ using Base::coeffRef;
187
+
188
+ using Base::innerStride;
189
+ using Base::outerStride;
190
+ using Base::rowStride;
191
+ using Base::colStride;
192
+
193
+ typedef typename internal::conditional<
194
+ internal::is_lvalue<Derived>::value,
195
+ Scalar,
196
+ const Scalar
197
+ >::type ScalarWithConstIfNotLvalue;
198
+
199
+ inline const Scalar* data() const { return this->m_data; }
200
+ inline ScalarWithConstIfNotLvalue* data() { return this->m_data; } // no const-cast here so non-const-correct code will give a compile error
201
+
202
+ inline ScalarWithConstIfNotLvalue& coeffRef(Index row, Index col)
203
+ {
204
+ return this->m_data[col * colStride() + row * rowStride()];
205
+ }
206
+
207
+ inline ScalarWithConstIfNotLvalue& coeffRef(Index index)
208
+ {
209
+ EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS(Derived)
210
+ return this->m_data[index * innerStride()];
211
+ }
212
+
213
+ template<int StoreMode>
214
+ inline void writePacket(Index row, Index col, const PacketScalar& val)
215
+ {
216
+ internal::pstoret<Scalar, PacketScalar, StoreMode>
217
+ (this->m_data + (col * colStride() + row * rowStride()), val);
218
+ }
219
+
220
+ template<int StoreMode>
221
+ inline void writePacket(Index index, const PacketScalar& val)
222
+ {
223
+ EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS(Derived)
224
+ internal::pstoret<Scalar, PacketScalar, StoreMode>
225
+ (this->m_data + index * innerStride(), val);
226
+ }
227
+
228
+ explicit inline MapBase(PointerType dataPtr) : Base(dataPtr) {}
229
+ inline MapBase(PointerType dataPtr, Index vecSize) : Base(dataPtr, vecSize) {}
230
+ inline MapBase(PointerType dataPtr, Index nbRows, Index nbCols) : Base(dataPtr, nbRows, nbCols) {}
231
+
232
+ Derived& operator=(const MapBase& other)
233
+ {
234
+ ReadOnlyMapBase::Base::operator=(other);
235
+ return derived();
236
+ }
237
+
238
+ // In theory we could simply refer to Base:Base::operator=, but MSVC does not like Base::Base,
239
+ // see bugs 821 and 920.
240
+ using ReadOnlyMapBase::Base::operator=;
241
+ };
242
+
243
+ #undef EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS
244
+
245
+ } // end namespace Eigen
246
+
247
+ #endif // EIGEN_MAPBASE_H
@@ -0,0 +1,768 @@
1
+ // This file is part of Eigen, a lightweight C++ template library
2
+ // for linear algebra.
3
+ //
4
+ // Copyright (C) 2006-2010 Benoit Jacob <jacob.benoit.1@gmail.com>
5
+ //
6
+ // This Source Code Form is subject to the terms of the Mozilla
7
+ // Public License v. 2.0. If a copy of the MPL was not distributed
8
+ // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9
+
10
+ #ifndef EIGEN_MATHFUNCTIONS_H
11
+ #define EIGEN_MATHFUNCTIONS_H
12
+
13
+ namespace Eigen {
14
+
15
+ namespace internal {
16
+
17
+ /** \internal \struct global_math_functions_filtering_base
18
+ *
19
+ * What it does:
20
+ * Defines a typedef 'type' as follows:
21
+ * - if type T has a member typedef Eigen_BaseClassForSpecializationOfGlobalMathFuncImpl, then
22
+ * global_math_functions_filtering_base<T>::type is a typedef for it.
23
+ * - otherwise, global_math_functions_filtering_base<T>::type is a typedef for T.
24
+ *
25
+ * How it's used:
26
+ * To allow to defined the global math functions (like sin...) in certain cases, like the Array expressions.
27
+ * When you do sin(array1+array2), the object array1+array2 has a complicated expression type, all what you want to know
28
+ * is that it inherits ArrayBase. So we implement a partial specialization of sin_impl for ArrayBase<Derived>.
29
+ * So we must make sure to use sin_impl<ArrayBase<Derived> > and not sin_impl<Derived>, otherwise our partial specialization
30
+ * won't be used. How does sin know that? That's exactly what global_math_functions_filtering_base tells it.
31
+ *
32
+ * How it's implemented:
33
+ * SFINAE in the style of enable_if. Highly susceptible of breaking compilers. With GCC, it sure does work, but if you replace
34
+ * the typename dummy by an integer template parameter, it doesn't work anymore!
35
+ */
36
+
37
+ template<typename T, typename dummy = void>
38
+ struct global_math_functions_filtering_base
39
+ {
40
+ typedef T type;
41
+ };
42
+
43
+ template<typename T> struct always_void { typedef void type; };
44
+
45
+ template<typename T>
46
+ struct global_math_functions_filtering_base
47
+ <T,
48
+ typename always_void<typename T::Eigen_BaseClassForSpecializationOfGlobalMathFuncImpl>::type
49
+ >
50
+ {
51
+ typedef typename T::Eigen_BaseClassForSpecializationOfGlobalMathFuncImpl type;
52
+ };
53
+
54
+ #define EIGEN_MATHFUNC_IMPL(func, scalar) Eigen::internal::func##_impl<typename Eigen::internal::global_math_functions_filtering_base<scalar>::type>
55
+ #define EIGEN_MATHFUNC_RETVAL(func, scalar) typename Eigen::internal::func##_retval<typename Eigen::internal::global_math_functions_filtering_base<scalar>::type>::type
56
+
57
+ /****************************************************************************
58
+ * Implementation of real *
59
+ ****************************************************************************/
60
+
61
+ template<typename Scalar, bool IsComplex = NumTraits<Scalar>::IsComplex>
62
+ struct real_default_impl
63
+ {
64
+ typedef typename NumTraits<Scalar>::Real RealScalar;
65
+ static inline RealScalar run(const Scalar& x)
66
+ {
67
+ return x;
68
+ }
69
+ };
70
+
71
+ template<typename Scalar>
72
+ struct real_default_impl<Scalar,true>
73
+ {
74
+ typedef typename NumTraits<Scalar>::Real RealScalar;
75
+ static inline RealScalar run(const Scalar& x)
76
+ {
77
+ using std::real;
78
+ return real(x);
79
+ }
80
+ };
81
+
82
+ template<typename Scalar> struct real_impl : real_default_impl<Scalar> {};
83
+
84
+ template<typename Scalar>
85
+ struct real_retval
86
+ {
87
+ typedef typename NumTraits<Scalar>::Real type;
88
+ };
89
+
90
+
91
+ /****************************************************************************
92
+ * Implementation of imag *
93
+ ****************************************************************************/
94
+
95
+ template<typename Scalar, bool IsComplex = NumTraits<Scalar>::IsComplex>
96
+ struct imag_default_impl
97
+ {
98
+ typedef typename NumTraits<Scalar>::Real RealScalar;
99
+ static inline RealScalar run(const Scalar&)
100
+ {
101
+ return RealScalar(0);
102
+ }
103
+ };
104
+
105
+ template<typename Scalar>
106
+ struct imag_default_impl<Scalar,true>
107
+ {
108
+ typedef typename NumTraits<Scalar>::Real RealScalar;
109
+ static inline RealScalar run(const Scalar& x)
110
+ {
111
+ using std::imag;
112
+ return imag(x);
113
+ }
114
+ };
115
+
116
+ template<typename Scalar> struct imag_impl : imag_default_impl<Scalar> {};
117
+
118
+ template<typename Scalar>
119
+ struct imag_retval
120
+ {
121
+ typedef typename NumTraits<Scalar>::Real type;
122
+ };
123
+
124
+ /****************************************************************************
125
+ * Implementation of real_ref *
126
+ ****************************************************************************/
127
+
128
+ template<typename Scalar>
129
+ struct real_ref_impl
130
+ {
131
+ typedef typename NumTraits<Scalar>::Real RealScalar;
132
+ static inline RealScalar& run(Scalar& x)
133
+ {
134
+ return reinterpret_cast<RealScalar*>(&x)[0];
135
+ }
136
+ static inline const RealScalar& run(const Scalar& x)
137
+ {
138
+ return reinterpret_cast<const RealScalar*>(&x)[0];
139
+ }
140
+ };
141
+
142
+ template<typename Scalar>
143
+ struct real_ref_retval
144
+ {
145
+ typedef typename NumTraits<Scalar>::Real & type;
146
+ };
147
+
148
+ /****************************************************************************
149
+ * Implementation of imag_ref *
150
+ ****************************************************************************/
151
+
152
+ template<typename Scalar, bool IsComplex>
153
+ struct imag_ref_default_impl
154
+ {
155
+ typedef typename NumTraits<Scalar>::Real RealScalar;
156
+ static inline RealScalar& run(Scalar& x)
157
+ {
158
+ return reinterpret_cast<RealScalar*>(&x)[1];
159
+ }
160
+ static inline const RealScalar& run(const Scalar& x)
161
+ {
162
+ return reinterpret_cast<RealScalar*>(&x)[1];
163
+ }
164
+ };
165
+
166
+ template<typename Scalar>
167
+ struct imag_ref_default_impl<Scalar, false>
168
+ {
169
+ static inline Scalar run(Scalar&)
170
+ {
171
+ return Scalar(0);
172
+ }
173
+ static inline const Scalar run(const Scalar&)
174
+ {
175
+ return Scalar(0);
176
+ }
177
+ };
178
+
179
+ template<typename Scalar>
180
+ struct imag_ref_impl : imag_ref_default_impl<Scalar, NumTraits<Scalar>::IsComplex> {};
181
+
182
+ template<typename Scalar>
183
+ struct imag_ref_retval
184
+ {
185
+ typedef typename NumTraits<Scalar>::Real & type;
186
+ };
187
+
188
+ /****************************************************************************
189
+ * Implementation of conj *
190
+ ****************************************************************************/
191
+
192
+ template<typename Scalar, bool IsComplex = NumTraits<Scalar>::IsComplex>
193
+ struct conj_impl
194
+ {
195
+ static inline Scalar run(const Scalar& x)
196
+ {
197
+ return x;
198
+ }
199
+ };
200
+
201
+ template<typename Scalar>
202
+ struct conj_impl<Scalar,true>
203
+ {
204
+ static inline Scalar run(const Scalar& x)
205
+ {
206
+ using std::conj;
207
+ return conj(x);
208
+ }
209
+ };
210
+
211
+ template<typename Scalar>
212
+ struct conj_retval
213
+ {
214
+ typedef Scalar type;
215
+ };
216
+
217
+ /****************************************************************************
218
+ * Implementation of abs2 *
219
+ ****************************************************************************/
220
+
221
+ template<typename Scalar>
222
+ struct abs2_impl
223
+ {
224
+ typedef typename NumTraits<Scalar>::Real RealScalar;
225
+ static inline RealScalar run(const Scalar& x)
226
+ {
227
+ return x*x;
228
+ }
229
+ };
230
+
231
+ template<typename RealScalar>
232
+ struct abs2_impl<std::complex<RealScalar> >
233
+ {
234
+ static inline RealScalar run(const std::complex<RealScalar>& x)
235
+ {
236
+ return real(x)*real(x) + imag(x)*imag(x);
237
+ }
238
+ };
239
+
240
+ template<typename Scalar>
241
+ struct abs2_retval
242
+ {
243
+ typedef typename NumTraits<Scalar>::Real type;
244
+ };
245
+
246
+ /****************************************************************************
247
+ * Implementation of norm1 *
248
+ ****************************************************************************/
249
+
250
+ template<typename Scalar, bool IsComplex>
251
+ struct norm1_default_impl
252
+ {
253
+ typedef typename NumTraits<Scalar>::Real RealScalar;
254
+ static inline RealScalar run(const Scalar& x)
255
+ {
256
+ using std::abs;
257
+ return abs(real(x)) + abs(imag(x));
258
+ }
259
+ };
260
+
261
+ template<typename Scalar>
262
+ struct norm1_default_impl<Scalar, false>
263
+ {
264
+ static inline Scalar run(const Scalar& x)
265
+ {
266
+ using std::abs;
267
+ return abs(x);
268
+ }
269
+ };
270
+
271
+ template<typename Scalar>
272
+ struct norm1_impl : norm1_default_impl<Scalar, NumTraits<Scalar>::IsComplex> {};
273
+
274
+ template<typename Scalar>
275
+ struct norm1_retval
276
+ {
277
+ typedef typename NumTraits<Scalar>::Real type;
278
+ };
279
+
280
+ /****************************************************************************
281
+ * Implementation of hypot *
282
+ ****************************************************************************/
283
+
284
+ template<typename Scalar>
285
+ struct hypot_impl
286
+ {
287
+ typedef typename NumTraits<Scalar>::Real RealScalar;
288
+ static inline RealScalar run(const Scalar& x, const Scalar& y)
289
+ {
290
+ using std::max;
291
+ using std::min;
292
+ using std::abs;
293
+ using std::sqrt;
294
+ RealScalar _x = abs(x);
295
+ RealScalar _y = abs(y);
296
+ RealScalar p = (max)(_x, _y);
297
+ if(p==RealScalar(0)) return RealScalar(0);
298
+ RealScalar q = (min)(_x, _y);
299
+ RealScalar qp = q/p;
300
+ return p * sqrt(RealScalar(1) + qp*qp);
301
+ }
302
+ };
303
+
304
+ template<typename Scalar>
305
+ struct hypot_retval
306
+ {
307
+ typedef typename NumTraits<Scalar>::Real type;
308
+ };
309
+
310
+ /****************************************************************************
311
+ * Implementation of cast *
312
+ ****************************************************************************/
313
+
314
+ template<typename OldType, typename NewType>
315
+ struct cast_impl
316
+ {
317
+ static inline NewType run(const OldType& x)
318
+ {
319
+ return static_cast<NewType>(x);
320
+ }
321
+ };
322
+
323
+ // here, for once, we're plainly returning NewType: we don't want cast to do weird things.
324
+
325
+ template<typename OldType, typename NewType>
326
+ inline NewType cast(const OldType& x)
327
+ {
328
+ return cast_impl<OldType, NewType>::run(x);
329
+ }
330
+
331
+ /****************************************************************************
332
+ * Implementation of atanh2 *
333
+ ****************************************************************************/
334
+
335
+ template<typename Scalar, bool IsInteger>
336
+ struct atanh2_default_impl
337
+ {
338
+ typedef Scalar retval;
339
+ typedef typename NumTraits<Scalar>::Real RealScalar;
340
+ static inline Scalar run(const Scalar& x, const Scalar& y)
341
+ {
342
+ using std::abs;
343
+ using std::log;
344
+ using std::sqrt;
345
+ Scalar z = x / y;
346
+ if (y == Scalar(0) || abs(z) > sqrt(NumTraits<RealScalar>::epsilon()))
347
+ return RealScalar(0.5) * log((y + x) / (y - x));
348
+ else
349
+ return z + z*z*z / RealScalar(3);
350
+ }
351
+ };
352
+
353
+ template<typename Scalar>
354
+ struct atanh2_default_impl<Scalar, true>
355
+ {
356
+ static inline Scalar run(const Scalar&, const Scalar&)
357
+ {
358
+ EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar)
359
+ return Scalar(0);
360
+ }
361
+ };
362
+
363
+ template<typename Scalar>
364
+ struct atanh2_impl : atanh2_default_impl<Scalar, NumTraits<Scalar>::IsInteger> {};
365
+
366
+ template<typename Scalar>
367
+ struct atanh2_retval
368
+ {
369
+ typedef Scalar type;
370
+ };
371
+
372
+ /****************************************************************************
373
+ * Implementation of pow *
374
+ ****************************************************************************/
375
+
376
+ template<typename Scalar, bool IsInteger>
377
+ struct pow_default_impl
378
+ {
379
+ typedef Scalar retval;
380
+ static inline Scalar run(const Scalar& x, const Scalar& y)
381
+ {
382
+ using std::pow;
383
+ return pow(x, y);
384
+ }
385
+ };
386
+
387
+ template<typename Scalar>
388
+ struct pow_default_impl<Scalar, true>
389
+ {
390
+ static inline Scalar run(Scalar x, Scalar y)
391
+ {
392
+ Scalar res(1);
393
+ eigen_assert(!NumTraits<Scalar>::IsSigned || y >= 0);
394
+ if(y & 1) res *= x;
395
+ y >>= 1;
396
+ while(y)
397
+ {
398
+ x *= x;
399
+ if(y&1) res *= x;
400
+ y >>= 1;
401
+ }
402
+ return res;
403
+ }
404
+ };
405
+
406
+ template<typename Scalar>
407
+ struct pow_impl : pow_default_impl<Scalar, NumTraits<Scalar>::IsInteger> {};
408
+
409
+ template<typename Scalar>
410
+ struct pow_retval
411
+ {
412
+ typedef Scalar type;
413
+ };
414
+
415
+ /****************************************************************************
416
+ * Implementation of random *
417
+ ****************************************************************************/
418
+
419
+ template<typename Scalar,
420
+ bool IsComplex,
421
+ bool IsInteger>
422
+ struct random_default_impl {};
423
+
424
+ template<typename Scalar>
425
+ struct random_impl : random_default_impl<Scalar, NumTraits<Scalar>::IsComplex, NumTraits<Scalar>::IsInteger> {};
426
+
427
+ template<typename Scalar>
428
+ struct random_retval
429
+ {
430
+ typedef Scalar type;
431
+ };
432
+
433
+ template<typename Scalar> inline EIGEN_MATHFUNC_RETVAL(random, Scalar) random(const Scalar& x, const Scalar& y);
434
+ template<typename Scalar> inline EIGEN_MATHFUNC_RETVAL(random, Scalar) random();
435
+
436
+ template<typename Scalar>
437
+ struct random_default_impl<Scalar, false, false>
438
+ {
439
+ static inline Scalar run(const Scalar& x, const Scalar& y)
440
+ {
441
+ return x + (y-x) * Scalar(std::rand()) / Scalar(RAND_MAX);
442
+ }
443
+ static inline Scalar run()
444
+ {
445
+ return run(Scalar(NumTraits<Scalar>::IsSigned ? -1 : 0), Scalar(1));
446
+ }
447
+ };
448
+
449
+ enum {
450
+ floor_log2_terminate,
451
+ floor_log2_move_up,
452
+ floor_log2_move_down,
453
+ floor_log2_bogus
454
+ };
455
+
456
+ template<unsigned int n, int lower, int upper> struct floor_log2_selector
457
+ {
458
+ enum { middle = (lower + upper) / 2,
459
+ value = (upper <= lower + 1) ? int(floor_log2_terminate)
460
+ : (n < (1 << middle)) ? int(floor_log2_move_down)
461
+ : (n==0) ? int(floor_log2_bogus)
462
+ : int(floor_log2_move_up)
463
+ };
464
+ };
465
+
466
+ template<unsigned int n,
467
+ int lower = 0,
468
+ int upper = sizeof(unsigned int) * CHAR_BIT - 1,
469
+ int selector = floor_log2_selector<n, lower, upper>::value>
470
+ struct floor_log2 {};
471
+
472
+ template<unsigned int n, int lower, int upper>
473
+ struct floor_log2<n, lower, upper, floor_log2_move_down>
474
+ {
475
+ enum { value = floor_log2<n, lower, floor_log2_selector<n, lower, upper>::middle>::value };
476
+ };
477
+
478
+ template<unsigned int n, int lower, int upper>
479
+ struct floor_log2<n, lower, upper, floor_log2_move_up>
480
+ {
481
+ enum { value = floor_log2<n, floor_log2_selector<n, lower, upper>::middle, upper>::value };
482
+ };
483
+
484
+ template<unsigned int n, int lower, int upper>
485
+ struct floor_log2<n, lower, upper, floor_log2_terminate>
486
+ {
487
+ enum { value = (n >= ((unsigned int)(1) << (lower+1))) ? lower+1 : lower };
488
+ };
489
+
490
+ template<unsigned int n, int lower, int upper>
491
+ struct floor_log2<n, lower, upper, floor_log2_bogus>
492
+ {
493
+ // no value, error at compile time
494
+ };
495
+
496
+ template<typename Scalar>
497
+ struct random_default_impl<Scalar, false, true>
498
+ {
499
+ typedef typename NumTraits<Scalar>::NonInteger NonInteger;
500
+
501
+ static inline Scalar run(const Scalar& x, const Scalar& y)
502
+ {
503
+ return x + Scalar((NonInteger(y)-x+1) * std::rand() / (RAND_MAX + NonInteger(1)));
504
+ }
505
+
506
+ static inline Scalar run()
507
+ {
508
+ #ifdef EIGEN_MAKING_DOCS
509
+ return run(Scalar(NumTraits<Scalar>::IsSigned ? -10 : 0), Scalar(10));
510
+ #else
511
+ enum { rand_bits = floor_log2<(unsigned int)(RAND_MAX)+1>::value,
512
+ scalar_bits = sizeof(Scalar) * CHAR_BIT,
513
+ shift = EIGEN_PLAIN_ENUM_MAX(0, int(rand_bits) - int(scalar_bits)),
514
+ offset = NumTraits<Scalar>::IsSigned ? (1 << (EIGEN_PLAIN_ENUM_MIN(rand_bits,scalar_bits)-1)) : 0
515
+ };
516
+ return Scalar((std::rand() >> shift) - offset);
517
+ #endif
518
+ }
519
+ };
520
+
521
+ template<typename Scalar>
522
+ struct random_default_impl<Scalar, true, false>
523
+ {
524
+ static inline Scalar run(const Scalar& x, const Scalar& y)
525
+ {
526
+ return Scalar(random(real(x), real(y)),
527
+ random(imag(x), imag(y)));
528
+ }
529
+ static inline Scalar run()
530
+ {
531
+ typedef typename NumTraits<Scalar>::Real RealScalar;
532
+ return Scalar(random<RealScalar>(), random<RealScalar>());
533
+ }
534
+ };
535
+
536
+ template<typename Scalar>
537
+ inline EIGEN_MATHFUNC_RETVAL(random, Scalar) random(const Scalar& x, const Scalar& y)
538
+ {
539
+ return EIGEN_MATHFUNC_IMPL(random, Scalar)::run(x, y);
540
+ }
541
+
542
+ template<typename Scalar>
543
+ inline EIGEN_MATHFUNC_RETVAL(random, Scalar) random()
544
+ {
545
+ return EIGEN_MATHFUNC_IMPL(random, Scalar)::run();
546
+ }
547
+
548
+ } // end namespace internal
549
+
550
+ /****************************************************************************
551
+ * Generic math function *
552
+ ****************************************************************************/
553
+
554
+ namespace numext {
555
+
556
+ template<typename Scalar>
557
+ inline EIGEN_MATHFUNC_RETVAL(real, Scalar) real(const Scalar& x)
558
+ {
559
+ return EIGEN_MATHFUNC_IMPL(real, Scalar)::run(x);
560
+ }
561
+
562
+ template<typename Scalar>
563
+ inline typename internal::add_const_on_value_type< EIGEN_MATHFUNC_RETVAL(real_ref, Scalar) >::type real_ref(const Scalar& x)
564
+ {
565
+ return internal::real_ref_impl<Scalar>::run(x);
566
+ }
567
+
568
+ template<typename Scalar>
569
+ inline EIGEN_MATHFUNC_RETVAL(real_ref, Scalar) real_ref(Scalar& x)
570
+ {
571
+ return EIGEN_MATHFUNC_IMPL(real_ref, Scalar)::run(x);
572
+ }
573
+
574
+ template<typename Scalar>
575
+ inline EIGEN_MATHFUNC_RETVAL(imag, Scalar) imag(const Scalar& x)
576
+ {
577
+ return EIGEN_MATHFUNC_IMPL(imag, Scalar)::run(x);
578
+ }
579
+
580
+ template<typename Scalar>
581
+ inline typename internal::add_const_on_value_type< EIGEN_MATHFUNC_RETVAL(imag_ref, Scalar) >::type imag_ref(const Scalar& x)
582
+ {
583
+ return internal::imag_ref_impl<Scalar>::run(x);
584
+ }
585
+
586
+ template<typename Scalar>
587
+ inline EIGEN_MATHFUNC_RETVAL(imag_ref, Scalar) imag_ref(Scalar& x)
588
+ {
589
+ return EIGEN_MATHFUNC_IMPL(imag_ref, Scalar)::run(x);
590
+ }
591
+
592
+ template<typename Scalar>
593
+ inline EIGEN_MATHFUNC_RETVAL(conj, Scalar) conj(const Scalar& x)
594
+ {
595
+ return EIGEN_MATHFUNC_IMPL(conj, Scalar)::run(x);
596
+ }
597
+
598
+ template<typename Scalar>
599
+ inline EIGEN_MATHFUNC_RETVAL(abs2, Scalar) abs2(const Scalar& x)
600
+ {
601
+ return EIGEN_MATHFUNC_IMPL(abs2, Scalar)::run(x);
602
+ }
603
+
604
+ template<typename Scalar>
605
+ inline EIGEN_MATHFUNC_RETVAL(norm1, Scalar) norm1(const Scalar& x)
606
+ {
607
+ return EIGEN_MATHFUNC_IMPL(norm1, Scalar)::run(x);
608
+ }
609
+
610
+ template<typename Scalar>
611
+ inline EIGEN_MATHFUNC_RETVAL(hypot, Scalar) hypot(const Scalar& x, const Scalar& y)
612
+ {
613
+ return EIGEN_MATHFUNC_IMPL(hypot, Scalar)::run(x, y);
614
+ }
615
+
616
+ template<typename Scalar>
617
+ inline EIGEN_MATHFUNC_RETVAL(atanh2, Scalar) atanh2(const Scalar& x, const Scalar& y)
618
+ {
619
+ return EIGEN_MATHFUNC_IMPL(atanh2, Scalar)::run(x, y);
620
+ }
621
+
622
+ template<typename Scalar>
623
+ inline EIGEN_MATHFUNC_RETVAL(pow, Scalar) pow(const Scalar& x, const Scalar& y)
624
+ {
625
+ return EIGEN_MATHFUNC_IMPL(pow, Scalar)::run(x, y);
626
+ }
627
+
628
+ // std::isfinite is non standard, so let's define our own version,
629
+ // even though it is not very efficient.
630
+ template<typename T> bool (isfinite)(const T& x)
631
+ {
632
+ return x<NumTraits<T>::highest() && x>NumTraits<T>::lowest();
633
+ }
634
+
635
+ } // end namespace numext
636
+
637
+ namespace internal {
638
+
639
+ /****************************************************************************
640
+ * Implementation of fuzzy comparisons *
641
+ ****************************************************************************/
642
+
643
+ template<typename Scalar,
644
+ bool IsComplex,
645
+ bool IsInteger>
646
+ struct scalar_fuzzy_default_impl {};
647
+
648
+ template<typename Scalar>
649
+ struct scalar_fuzzy_default_impl<Scalar, false, false>
650
+ {
651
+ typedef typename NumTraits<Scalar>::Real RealScalar;
652
+ template<typename OtherScalar>
653
+ static inline bool isMuchSmallerThan(const Scalar& x, const OtherScalar& y, const RealScalar& prec)
654
+ {
655
+ using std::abs;
656
+ return abs(x) <= abs(y) * prec;
657
+ }
658
+ static inline bool isApprox(const Scalar& x, const Scalar& y, const RealScalar& prec)
659
+ {
660
+ using std::min;
661
+ using std::abs;
662
+ return abs(x - y) <= (min)(abs(x), abs(y)) * prec;
663
+ }
664
+ static inline bool isApproxOrLessThan(const Scalar& x, const Scalar& y, const RealScalar& prec)
665
+ {
666
+ return x <= y || isApprox(x, y, prec);
667
+ }
668
+ };
669
+
670
+ template<typename Scalar>
671
+ struct scalar_fuzzy_default_impl<Scalar, false, true>
672
+ {
673
+ typedef typename NumTraits<Scalar>::Real RealScalar;
674
+ template<typename OtherScalar>
675
+ static inline bool isMuchSmallerThan(const Scalar& x, const Scalar&, const RealScalar&)
676
+ {
677
+ return x == Scalar(0);
678
+ }
679
+ static inline bool isApprox(const Scalar& x, const Scalar& y, const RealScalar&)
680
+ {
681
+ return x == y;
682
+ }
683
+ static inline bool isApproxOrLessThan(const Scalar& x, const Scalar& y, const RealScalar&)
684
+ {
685
+ return x <= y;
686
+ }
687
+ };
688
+
689
+ template<typename Scalar>
690
+ struct scalar_fuzzy_default_impl<Scalar, true, false>
691
+ {
692
+ typedef typename NumTraits<Scalar>::Real RealScalar;
693
+ template<typename OtherScalar>
694
+ static inline bool isMuchSmallerThan(const Scalar& x, const OtherScalar& y, const RealScalar& prec)
695
+ {
696
+ return numext::abs2(x) <= numext::abs2(y) * prec * prec;
697
+ }
698
+ static inline bool isApprox(const Scalar& x, const Scalar& y, const RealScalar& prec)
699
+ {
700
+ using std::min;
701
+ return numext::abs2(x - y) <= (min)(numext::abs2(x), numext::abs2(y)) * prec * prec;
702
+ }
703
+ };
704
+
705
+ template<typename Scalar>
706
+ struct scalar_fuzzy_impl : scalar_fuzzy_default_impl<Scalar, NumTraits<Scalar>::IsComplex, NumTraits<Scalar>::IsInteger> {};
707
+
708
+ template<typename Scalar, typename OtherScalar>
709
+ inline bool isMuchSmallerThan(const Scalar& x, const OtherScalar& y,
710
+ typename NumTraits<Scalar>::Real precision = NumTraits<Scalar>::dummy_precision())
711
+ {
712
+ return scalar_fuzzy_impl<Scalar>::template isMuchSmallerThan<OtherScalar>(x, y, precision);
713
+ }
714
+
715
+ template<typename Scalar>
716
+ inline bool isApprox(const Scalar& x, const Scalar& y,
717
+ typename NumTraits<Scalar>::Real precision = NumTraits<Scalar>::dummy_precision())
718
+ {
719
+ return scalar_fuzzy_impl<Scalar>::isApprox(x, y, precision);
720
+ }
721
+
722
+ template<typename Scalar>
723
+ inline bool isApproxOrLessThan(const Scalar& x, const Scalar& y,
724
+ typename NumTraits<Scalar>::Real precision = NumTraits<Scalar>::dummy_precision())
725
+ {
726
+ return scalar_fuzzy_impl<Scalar>::isApproxOrLessThan(x, y, precision);
727
+ }
728
+
729
+ /******************************************
730
+ *** The special case of the bool type ***
731
+ ******************************************/
732
+
733
+ template<> struct random_impl<bool>
734
+ {
735
+ static inline bool run()
736
+ {
737
+ return random<int>(0,1)==0 ? false : true;
738
+ }
739
+ };
740
+
741
+ template<> struct scalar_fuzzy_impl<bool>
742
+ {
743
+ typedef bool RealScalar;
744
+
745
+ template<typename OtherScalar>
746
+ static inline bool isMuchSmallerThan(const bool& x, const bool&, const bool&)
747
+ {
748
+ return !x;
749
+ }
750
+
751
+ static inline bool isApprox(bool x, bool y, bool)
752
+ {
753
+ return x == y;
754
+ }
755
+
756
+ static inline bool isApproxOrLessThan(const bool& x, const bool& y, const bool&)
757
+ {
758
+ return (!x) || y;
759
+ }
760
+
761
+ };
762
+
763
+
764
+ } // end namespace internal
765
+
766
+ } // end namespace Eigen
767
+
768
+ #endif // EIGEN_MATHFUNCTIONS_H