tomoto 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (420) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +3 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +123 -0
  5. data/ext/tomoto/ext.cpp +245 -0
  6. data/ext/tomoto/extconf.rb +28 -0
  7. data/lib/tomoto.rb +12 -0
  8. data/lib/tomoto/ct.rb +11 -0
  9. data/lib/tomoto/hdp.rb +11 -0
  10. data/lib/tomoto/lda.rb +67 -0
  11. data/lib/tomoto/version.rb +3 -0
  12. data/vendor/EigenRand/EigenRand/Core.h +1139 -0
  13. data/vendor/EigenRand/EigenRand/Dists/Basic.h +111 -0
  14. data/vendor/EigenRand/EigenRand/Dists/Discrete.h +877 -0
  15. data/vendor/EigenRand/EigenRand/Dists/GammaPoisson.h +108 -0
  16. data/vendor/EigenRand/EigenRand/Dists/NormalExp.h +626 -0
  17. data/vendor/EigenRand/EigenRand/EigenRand +19 -0
  18. data/vendor/EigenRand/EigenRand/Macro.h +24 -0
  19. data/vendor/EigenRand/EigenRand/MorePacketMath.h +978 -0
  20. data/vendor/EigenRand/EigenRand/PacketFilter.h +286 -0
  21. data/vendor/EigenRand/EigenRand/PacketRandomEngine.h +624 -0
  22. data/vendor/EigenRand/EigenRand/RandUtils.h +413 -0
  23. data/vendor/EigenRand/EigenRand/doc.h +220 -0
  24. data/vendor/EigenRand/LICENSE +21 -0
  25. data/vendor/EigenRand/README.md +288 -0
  26. data/vendor/eigen/COPYING.BSD +26 -0
  27. data/vendor/eigen/COPYING.GPL +674 -0
  28. data/vendor/eigen/COPYING.LGPL +502 -0
  29. data/vendor/eigen/COPYING.MINPACK +52 -0
  30. data/vendor/eigen/COPYING.MPL2 +373 -0
  31. data/vendor/eigen/COPYING.README +18 -0
  32. data/vendor/eigen/Eigen/CMakeLists.txt +19 -0
  33. data/vendor/eigen/Eigen/Cholesky +46 -0
  34. data/vendor/eigen/Eigen/CholmodSupport +48 -0
  35. data/vendor/eigen/Eigen/Core +537 -0
  36. data/vendor/eigen/Eigen/Dense +7 -0
  37. data/vendor/eigen/Eigen/Eigen +2 -0
  38. data/vendor/eigen/Eigen/Eigenvalues +61 -0
  39. data/vendor/eigen/Eigen/Geometry +62 -0
  40. data/vendor/eigen/Eigen/Householder +30 -0
  41. data/vendor/eigen/Eigen/IterativeLinearSolvers +48 -0
  42. data/vendor/eigen/Eigen/Jacobi +33 -0
  43. data/vendor/eigen/Eigen/LU +50 -0
  44. data/vendor/eigen/Eigen/MetisSupport +35 -0
  45. data/vendor/eigen/Eigen/OrderingMethods +73 -0
  46. data/vendor/eigen/Eigen/PaStiXSupport +48 -0
  47. data/vendor/eigen/Eigen/PardisoSupport +35 -0
  48. data/vendor/eigen/Eigen/QR +51 -0
  49. data/vendor/eigen/Eigen/QtAlignedMalloc +40 -0
  50. data/vendor/eigen/Eigen/SPQRSupport +34 -0
  51. data/vendor/eigen/Eigen/SVD +51 -0
  52. data/vendor/eigen/Eigen/Sparse +36 -0
  53. data/vendor/eigen/Eigen/SparseCholesky +45 -0
  54. data/vendor/eigen/Eigen/SparseCore +69 -0
  55. data/vendor/eigen/Eigen/SparseLU +46 -0
  56. data/vendor/eigen/Eigen/SparseQR +37 -0
  57. data/vendor/eigen/Eigen/StdDeque +27 -0
  58. data/vendor/eigen/Eigen/StdList +26 -0
  59. data/vendor/eigen/Eigen/StdVector +27 -0
  60. data/vendor/eigen/Eigen/SuperLUSupport +64 -0
  61. data/vendor/eigen/Eigen/UmfPackSupport +40 -0
  62. data/vendor/eigen/Eigen/src/Cholesky/LDLT.h +673 -0
  63. data/vendor/eigen/Eigen/src/Cholesky/LLT.h +542 -0
  64. data/vendor/eigen/Eigen/src/Cholesky/LLT_LAPACKE.h +99 -0
  65. data/vendor/eigen/Eigen/src/CholmodSupport/CholmodSupport.h +639 -0
  66. data/vendor/eigen/Eigen/src/Core/Array.h +329 -0
  67. data/vendor/eigen/Eigen/src/Core/ArrayBase.h +226 -0
  68. data/vendor/eigen/Eigen/src/Core/ArrayWrapper.h +209 -0
  69. data/vendor/eigen/Eigen/src/Core/Assign.h +90 -0
  70. data/vendor/eigen/Eigen/src/Core/AssignEvaluator.h +935 -0
  71. data/vendor/eigen/Eigen/src/Core/Assign_MKL.h +178 -0
  72. data/vendor/eigen/Eigen/src/Core/BandMatrix.h +353 -0
  73. data/vendor/eigen/Eigen/src/Core/Block.h +452 -0
  74. data/vendor/eigen/Eigen/src/Core/BooleanRedux.h +164 -0
  75. data/vendor/eigen/Eigen/src/Core/CommaInitializer.h +160 -0
  76. data/vendor/eigen/Eigen/src/Core/ConditionEstimator.h +175 -0
  77. data/vendor/eigen/Eigen/src/Core/CoreEvaluators.h +1688 -0
  78. data/vendor/eigen/Eigen/src/Core/CoreIterators.h +127 -0
  79. data/vendor/eigen/Eigen/src/Core/CwiseBinaryOp.h +184 -0
  80. data/vendor/eigen/Eigen/src/Core/CwiseNullaryOp.h +866 -0
  81. data/vendor/eigen/Eigen/src/Core/CwiseTernaryOp.h +197 -0
  82. data/vendor/eigen/Eigen/src/Core/CwiseUnaryOp.h +103 -0
  83. data/vendor/eigen/Eigen/src/Core/CwiseUnaryView.h +128 -0
  84. data/vendor/eigen/Eigen/src/Core/DenseBase.h +611 -0
  85. data/vendor/eigen/Eigen/src/Core/DenseCoeffsBase.h +681 -0
  86. data/vendor/eigen/Eigen/src/Core/DenseStorage.h +570 -0
  87. data/vendor/eigen/Eigen/src/Core/Diagonal.h +260 -0
  88. data/vendor/eigen/Eigen/src/Core/DiagonalMatrix.h +343 -0
  89. data/vendor/eigen/Eigen/src/Core/DiagonalProduct.h +28 -0
  90. data/vendor/eigen/Eigen/src/Core/Dot.h +318 -0
  91. data/vendor/eigen/Eigen/src/Core/EigenBase.h +159 -0
  92. data/vendor/eigen/Eigen/src/Core/ForceAlignedAccess.h +146 -0
  93. data/vendor/eigen/Eigen/src/Core/Fuzzy.h +155 -0
  94. data/vendor/eigen/Eigen/src/Core/GeneralProduct.h +455 -0
  95. data/vendor/eigen/Eigen/src/Core/GenericPacketMath.h +593 -0
  96. data/vendor/eigen/Eigen/src/Core/GlobalFunctions.h +187 -0
  97. data/vendor/eigen/Eigen/src/Core/IO.h +225 -0
  98. data/vendor/eigen/Eigen/src/Core/Inverse.h +118 -0
  99. data/vendor/eigen/Eigen/src/Core/Map.h +171 -0
  100. data/vendor/eigen/Eigen/src/Core/MapBase.h +303 -0
  101. data/vendor/eigen/Eigen/src/Core/MathFunctions.h +1415 -0
  102. data/vendor/eigen/Eigen/src/Core/MathFunctionsImpl.h +101 -0
  103. data/vendor/eigen/Eigen/src/Core/Matrix.h +459 -0
  104. data/vendor/eigen/Eigen/src/Core/MatrixBase.h +529 -0
  105. data/vendor/eigen/Eigen/src/Core/NestByValue.h +110 -0
  106. data/vendor/eigen/Eigen/src/Core/NoAlias.h +108 -0
  107. data/vendor/eigen/Eigen/src/Core/NumTraits.h +248 -0
  108. data/vendor/eigen/Eigen/src/Core/PermutationMatrix.h +633 -0
  109. data/vendor/eigen/Eigen/src/Core/PlainObjectBase.h +1035 -0
  110. data/vendor/eigen/Eigen/src/Core/Product.h +186 -0
  111. data/vendor/eigen/Eigen/src/Core/ProductEvaluators.h +1112 -0
  112. data/vendor/eigen/Eigen/src/Core/Random.h +182 -0
  113. data/vendor/eigen/Eigen/src/Core/Redux.h +505 -0
  114. data/vendor/eigen/Eigen/src/Core/Ref.h +283 -0
  115. data/vendor/eigen/Eigen/src/Core/Replicate.h +142 -0
  116. data/vendor/eigen/Eigen/src/Core/ReturnByValue.h +117 -0
  117. data/vendor/eigen/Eigen/src/Core/Reverse.h +211 -0
  118. data/vendor/eigen/Eigen/src/Core/Select.h +162 -0
  119. data/vendor/eigen/Eigen/src/Core/SelfAdjointView.h +352 -0
  120. data/vendor/eigen/Eigen/src/Core/SelfCwiseBinaryOp.h +47 -0
  121. data/vendor/eigen/Eigen/src/Core/Solve.h +188 -0
  122. data/vendor/eigen/Eigen/src/Core/SolveTriangular.h +235 -0
  123. data/vendor/eigen/Eigen/src/Core/SolverBase.h +130 -0
  124. data/vendor/eigen/Eigen/src/Core/StableNorm.h +221 -0
  125. data/vendor/eigen/Eigen/src/Core/Stride.h +111 -0
  126. data/vendor/eigen/Eigen/src/Core/Swap.h +67 -0
  127. data/vendor/eigen/Eigen/src/Core/Transpose.h +403 -0
  128. data/vendor/eigen/Eigen/src/Core/Transpositions.h +407 -0
  129. data/vendor/eigen/Eigen/src/Core/TriangularMatrix.h +983 -0
  130. data/vendor/eigen/Eigen/src/Core/VectorBlock.h +96 -0
  131. data/vendor/eigen/Eigen/src/Core/VectorwiseOp.h +695 -0
  132. data/vendor/eigen/Eigen/src/Core/Visitor.h +273 -0
  133. data/vendor/eigen/Eigen/src/Core/arch/AVX/Complex.h +451 -0
  134. data/vendor/eigen/Eigen/src/Core/arch/AVX/MathFunctions.h +439 -0
  135. data/vendor/eigen/Eigen/src/Core/arch/AVX/PacketMath.h +637 -0
  136. data/vendor/eigen/Eigen/src/Core/arch/AVX/TypeCasting.h +51 -0
  137. data/vendor/eigen/Eigen/src/Core/arch/AVX512/MathFunctions.h +391 -0
  138. data/vendor/eigen/Eigen/src/Core/arch/AVX512/PacketMath.h +1316 -0
  139. data/vendor/eigen/Eigen/src/Core/arch/AltiVec/Complex.h +430 -0
  140. data/vendor/eigen/Eigen/src/Core/arch/AltiVec/MathFunctions.h +322 -0
  141. data/vendor/eigen/Eigen/src/Core/arch/AltiVec/PacketMath.h +1061 -0
  142. data/vendor/eigen/Eigen/src/Core/arch/CUDA/Complex.h +103 -0
  143. data/vendor/eigen/Eigen/src/Core/arch/CUDA/Half.h +674 -0
  144. data/vendor/eigen/Eigen/src/Core/arch/CUDA/MathFunctions.h +91 -0
  145. data/vendor/eigen/Eigen/src/Core/arch/CUDA/PacketMath.h +333 -0
  146. data/vendor/eigen/Eigen/src/Core/arch/CUDA/PacketMathHalf.h +1124 -0
  147. data/vendor/eigen/Eigen/src/Core/arch/CUDA/TypeCasting.h +212 -0
  148. data/vendor/eigen/Eigen/src/Core/arch/Default/ConjHelper.h +29 -0
  149. data/vendor/eigen/Eigen/src/Core/arch/Default/Settings.h +49 -0
  150. data/vendor/eigen/Eigen/src/Core/arch/NEON/Complex.h +490 -0
  151. data/vendor/eigen/Eigen/src/Core/arch/NEON/MathFunctions.h +91 -0
  152. data/vendor/eigen/Eigen/src/Core/arch/NEON/PacketMath.h +760 -0
  153. data/vendor/eigen/Eigen/src/Core/arch/SSE/Complex.h +471 -0
  154. data/vendor/eigen/Eigen/src/Core/arch/SSE/MathFunctions.h +562 -0
  155. data/vendor/eigen/Eigen/src/Core/arch/SSE/PacketMath.h +895 -0
  156. data/vendor/eigen/Eigen/src/Core/arch/SSE/TypeCasting.h +77 -0
  157. data/vendor/eigen/Eigen/src/Core/arch/ZVector/Complex.h +397 -0
  158. data/vendor/eigen/Eigen/src/Core/arch/ZVector/MathFunctions.h +137 -0
  159. data/vendor/eigen/Eigen/src/Core/arch/ZVector/PacketMath.h +945 -0
  160. data/vendor/eigen/Eigen/src/Core/functors/AssignmentFunctors.h +168 -0
  161. data/vendor/eigen/Eigen/src/Core/functors/BinaryFunctors.h +475 -0
  162. data/vendor/eigen/Eigen/src/Core/functors/NullaryFunctors.h +188 -0
  163. data/vendor/eigen/Eigen/src/Core/functors/StlFunctors.h +136 -0
  164. data/vendor/eigen/Eigen/src/Core/functors/TernaryFunctors.h +25 -0
  165. data/vendor/eigen/Eigen/src/Core/functors/UnaryFunctors.h +792 -0
  166. data/vendor/eigen/Eigen/src/Core/products/GeneralBlockPanelKernel.h +2156 -0
  167. data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixMatrix.h +492 -0
  168. data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h +311 -0
  169. data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_BLAS.h +145 -0
  170. data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixMatrix_BLAS.h +122 -0
  171. data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixVector.h +619 -0
  172. data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixVector_BLAS.h +136 -0
  173. data/vendor/eigen/Eigen/src/Core/products/Parallelizer.h +163 -0
  174. data/vendor/eigen/Eigen/src/Core/products/SelfadjointMatrixMatrix.h +521 -0
  175. data/vendor/eigen/Eigen/src/Core/products/SelfadjointMatrixMatrix_BLAS.h +287 -0
  176. data/vendor/eigen/Eigen/src/Core/products/SelfadjointMatrixVector.h +260 -0
  177. data/vendor/eigen/Eigen/src/Core/products/SelfadjointMatrixVector_BLAS.h +118 -0
  178. data/vendor/eigen/Eigen/src/Core/products/SelfadjointProduct.h +133 -0
  179. data/vendor/eigen/Eigen/src/Core/products/SelfadjointRank2Update.h +93 -0
  180. data/vendor/eigen/Eigen/src/Core/products/TriangularMatrixMatrix.h +466 -0
  181. data/vendor/eigen/Eigen/src/Core/products/TriangularMatrixMatrix_BLAS.h +315 -0
  182. data/vendor/eigen/Eigen/src/Core/products/TriangularMatrixVector.h +350 -0
  183. data/vendor/eigen/Eigen/src/Core/products/TriangularMatrixVector_BLAS.h +255 -0
  184. data/vendor/eigen/Eigen/src/Core/products/TriangularSolverMatrix.h +335 -0
  185. data/vendor/eigen/Eigen/src/Core/products/TriangularSolverMatrix_BLAS.h +163 -0
  186. data/vendor/eigen/Eigen/src/Core/products/TriangularSolverVector.h +145 -0
  187. data/vendor/eigen/Eigen/src/Core/util/BlasUtil.h +398 -0
  188. data/vendor/eigen/Eigen/src/Core/util/Constants.h +547 -0
  189. data/vendor/eigen/Eigen/src/Core/util/DisableStupidWarnings.h +83 -0
  190. data/vendor/eigen/Eigen/src/Core/util/ForwardDeclarations.h +302 -0
  191. data/vendor/eigen/Eigen/src/Core/util/MKL_support.h +130 -0
  192. data/vendor/eigen/Eigen/src/Core/util/Macros.h +1001 -0
  193. data/vendor/eigen/Eigen/src/Core/util/Memory.h +993 -0
  194. data/vendor/eigen/Eigen/src/Core/util/Meta.h +534 -0
  195. data/vendor/eigen/Eigen/src/Core/util/NonMPL2.h +3 -0
  196. data/vendor/eigen/Eigen/src/Core/util/ReenableStupidWarnings.h +27 -0
  197. data/vendor/eigen/Eigen/src/Core/util/StaticAssert.h +218 -0
  198. data/vendor/eigen/Eigen/src/Core/util/XprHelper.h +821 -0
  199. data/vendor/eigen/Eigen/src/Eigenvalues/ComplexEigenSolver.h +346 -0
  200. data/vendor/eigen/Eigen/src/Eigenvalues/ComplexSchur.h +459 -0
  201. data/vendor/eigen/Eigen/src/Eigenvalues/ComplexSchur_LAPACKE.h +91 -0
  202. data/vendor/eigen/Eigen/src/Eigenvalues/EigenSolver.h +622 -0
  203. data/vendor/eigen/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h +418 -0
  204. data/vendor/eigen/Eigen/src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h +226 -0
  205. data/vendor/eigen/Eigen/src/Eigenvalues/HessenbergDecomposition.h +374 -0
  206. data/vendor/eigen/Eigen/src/Eigenvalues/MatrixBaseEigenvalues.h +158 -0
  207. data/vendor/eigen/Eigen/src/Eigenvalues/RealQZ.h +654 -0
  208. data/vendor/eigen/Eigen/src/Eigenvalues/RealSchur.h +546 -0
  209. data/vendor/eigen/Eigen/src/Eigenvalues/RealSchur_LAPACKE.h +77 -0
  210. data/vendor/eigen/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h +870 -0
  211. data/vendor/eigen/Eigen/src/Eigenvalues/SelfAdjointEigenSolver_LAPACKE.h +87 -0
  212. data/vendor/eigen/Eigen/src/Eigenvalues/Tridiagonalization.h +556 -0
  213. data/vendor/eigen/Eigen/src/Geometry/AlignedBox.h +392 -0
  214. data/vendor/eigen/Eigen/src/Geometry/AngleAxis.h +247 -0
  215. data/vendor/eigen/Eigen/src/Geometry/EulerAngles.h +114 -0
  216. data/vendor/eigen/Eigen/src/Geometry/Homogeneous.h +497 -0
  217. data/vendor/eigen/Eigen/src/Geometry/Hyperplane.h +282 -0
  218. data/vendor/eigen/Eigen/src/Geometry/OrthoMethods.h +234 -0
  219. data/vendor/eigen/Eigen/src/Geometry/ParametrizedLine.h +195 -0
  220. data/vendor/eigen/Eigen/src/Geometry/Quaternion.h +814 -0
  221. data/vendor/eigen/Eigen/src/Geometry/Rotation2D.h +199 -0
  222. data/vendor/eigen/Eigen/src/Geometry/RotationBase.h +206 -0
  223. data/vendor/eigen/Eigen/src/Geometry/Scaling.h +170 -0
  224. data/vendor/eigen/Eigen/src/Geometry/Transform.h +1542 -0
  225. data/vendor/eigen/Eigen/src/Geometry/Translation.h +208 -0
  226. data/vendor/eigen/Eigen/src/Geometry/Umeyama.h +166 -0
  227. data/vendor/eigen/Eigen/src/Geometry/arch/Geometry_SSE.h +161 -0
  228. data/vendor/eigen/Eigen/src/Householder/BlockHouseholder.h +103 -0
  229. data/vendor/eigen/Eigen/src/Householder/Householder.h +172 -0
  230. data/vendor/eigen/Eigen/src/Householder/HouseholderSequence.h +470 -0
  231. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h +226 -0
  232. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h +228 -0
  233. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h +246 -0
  234. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/IncompleteCholesky.h +400 -0
  235. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h +462 -0
  236. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h +394 -0
  237. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/LeastSquareConjugateGradient.h +216 -0
  238. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/SolveWithGuess.h +115 -0
  239. data/vendor/eigen/Eigen/src/Jacobi/Jacobi.h +462 -0
  240. data/vendor/eigen/Eigen/src/LU/Determinant.h +101 -0
  241. data/vendor/eigen/Eigen/src/LU/FullPivLU.h +891 -0
  242. data/vendor/eigen/Eigen/src/LU/InverseImpl.h +415 -0
  243. data/vendor/eigen/Eigen/src/LU/PartialPivLU.h +611 -0
  244. data/vendor/eigen/Eigen/src/LU/PartialPivLU_LAPACKE.h +83 -0
  245. data/vendor/eigen/Eigen/src/LU/arch/Inverse_SSE.h +338 -0
  246. data/vendor/eigen/Eigen/src/MetisSupport/MetisSupport.h +137 -0
  247. data/vendor/eigen/Eigen/src/OrderingMethods/Amd.h +445 -0
  248. data/vendor/eigen/Eigen/src/OrderingMethods/Eigen_Colamd.h +1843 -0
  249. data/vendor/eigen/Eigen/src/OrderingMethods/Ordering.h +157 -0
  250. data/vendor/eigen/Eigen/src/PaStiXSupport/PaStiXSupport.h +678 -0
  251. data/vendor/eigen/Eigen/src/PardisoSupport/PardisoSupport.h +543 -0
  252. data/vendor/eigen/Eigen/src/QR/ColPivHouseholderQR.h +653 -0
  253. data/vendor/eigen/Eigen/src/QR/ColPivHouseholderQR_LAPACKE.h +97 -0
  254. data/vendor/eigen/Eigen/src/QR/CompleteOrthogonalDecomposition.h +562 -0
  255. data/vendor/eigen/Eigen/src/QR/FullPivHouseholderQR.h +676 -0
  256. data/vendor/eigen/Eigen/src/QR/HouseholderQR.h +409 -0
  257. data/vendor/eigen/Eigen/src/QR/HouseholderQR_LAPACKE.h +68 -0
  258. data/vendor/eigen/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h +313 -0
  259. data/vendor/eigen/Eigen/src/SVD/BDCSVD.h +1246 -0
  260. data/vendor/eigen/Eigen/src/SVD/JacobiSVD.h +804 -0
  261. data/vendor/eigen/Eigen/src/SVD/JacobiSVD_LAPACKE.h +91 -0
  262. data/vendor/eigen/Eigen/src/SVD/SVDBase.h +315 -0
  263. data/vendor/eigen/Eigen/src/SVD/UpperBidiagonalization.h +414 -0
  264. data/vendor/eigen/Eigen/src/SparseCholesky/SimplicialCholesky.h +689 -0
  265. data/vendor/eigen/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h +199 -0
  266. data/vendor/eigen/Eigen/src/SparseCore/AmbiVector.h +377 -0
  267. data/vendor/eigen/Eigen/src/SparseCore/CompressedStorage.h +258 -0
  268. data/vendor/eigen/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h +352 -0
  269. data/vendor/eigen/Eigen/src/SparseCore/MappedSparseMatrix.h +67 -0
  270. data/vendor/eigen/Eigen/src/SparseCore/SparseAssign.h +216 -0
  271. data/vendor/eigen/Eigen/src/SparseCore/SparseBlock.h +603 -0
  272. data/vendor/eigen/Eigen/src/SparseCore/SparseColEtree.h +206 -0
  273. data/vendor/eigen/Eigen/src/SparseCore/SparseCompressedBase.h +341 -0
  274. data/vendor/eigen/Eigen/src/SparseCore/SparseCwiseBinaryOp.h +726 -0
  275. data/vendor/eigen/Eigen/src/SparseCore/SparseCwiseUnaryOp.h +148 -0
  276. data/vendor/eigen/Eigen/src/SparseCore/SparseDenseProduct.h +320 -0
  277. data/vendor/eigen/Eigen/src/SparseCore/SparseDiagonalProduct.h +138 -0
  278. data/vendor/eigen/Eigen/src/SparseCore/SparseDot.h +98 -0
  279. data/vendor/eigen/Eigen/src/SparseCore/SparseFuzzy.h +29 -0
  280. data/vendor/eigen/Eigen/src/SparseCore/SparseMap.h +305 -0
  281. data/vendor/eigen/Eigen/src/SparseCore/SparseMatrix.h +1403 -0
  282. data/vendor/eigen/Eigen/src/SparseCore/SparseMatrixBase.h +405 -0
  283. data/vendor/eigen/Eigen/src/SparseCore/SparsePermutation.h +178 -0
  284. data/vendor/eigen/Eigen/src/SparseCore/SparseProduct.h +169 -0
  285. data/vendor/eigen/Eigen/src/SparseCore/SparseRedux.h +49 -0
  286. data/vendor/eigen/Eigen/src/SparseCore/SparseRef.h +397 -0
  287. data/vendor/eigen/Eigen/src/SparseCore/SparseSelfAdjointView.h +656 -0
  288. data/vendor/eigen/Eigen/src/SparseCore/SparseSolverBase.h +124 -0
  289. data/vendor/eigen/Eigen/src/SparseCore/SparseSparseProductWithPruning.h +198 -0
  290. data/vendor/eigen/Eigen/src/SparseCore/SparseTranspose.h +92 -0
  291. data/vendor/eigen/Eigen/src/SparseCore/SparseTriangularView.h +189 -0
  292. data/vendor/eigen/Eigen/src/SparseCore/SparseUtil.h +178 -0
  293. data/vendor/eigen/Eigen/src/SparseCore/SparseVector.h +478 -0
  294. data/vendor/eigen/Eigen/src/SparseCore/SparseView.h +253 -0
  295. data/vendor/eigen/Eigen/src/SparseCore/TriangularSolver.h +315 -0
  296. data/vendor/eigen/Eigen/src/SparseLU/SparseLU.h +773 -0
  297. data/vendor/eigen/Eigen/src/SparseLU/SparseLUImpl.h +66 -0
  298. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_Memory.h +226 -0
  299. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_Structs.h +110 -0
  300. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h +301 -0
  301. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_Utils.h +80 -0
  302. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_column_bmod.h +181 -0
  303. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_column_dfs.h +179 -0
  304. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h +107 -0
  305. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_gemm_kernel.h +280 -0
  306. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h +126 -0
  307. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_kernel_bmod.h +130 -0
  308. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_panel_bmod.h +223 -0
  309. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_panel_dfs.h +258 -0
  310. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_pivotL.h +137 -0
  311. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_pruneL.h +136 -0
  312. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_relax_snode.h +83 -0
  313. data/vendor/eigen/Eigen/src/SparseQR/SparseQR.h +745 -0
  314. data/vendor/eigen/Eigen/src/StlSupport/StdDeque.h +126 -0
  315. data/vendor/eigen/Eigen/src/StlSupport/StdList.h +106 -0
  316. data/vendor/eigen/Eigen/src/StlSupport/StdVector.h +131 -0
  317. data/vendor/eigen/Eigen/src/StlSupport/details.h +84 -0
  318. data/vendor/eigen/Eigen/src/SuperLUSupport/SuperLUSupport.h +1027 -0
  319. data/vendor/eigen/Eigen/src/UmfPackSupport/UmfPackSupport.h +506 -0
  320. data/vendor/eigen/Eigen/src/misc/Image.h +82 -0
  321. data/vendor/eigen/Eigen/src/misc/Kernel.h +79 -0
  322. data/vendor/eigen/Eigen/src/misc/RealSvd2x2.h +55 -0
  323. data/vendor/eigen/Eigen/src/misc/blas.h +440 -0
  324. data/vendor/eigen/Eigen/src/misc/lapack.h +152 -0
  325. data/vendor/eigen/Eigen/src/misc/lapacke.h +16291 -0
  326. data/vendor/eigen/Eigen/src/misc/lapacke_mangling.h +17 -0
  327. data/vendor/eigen/Eigen/src/plugins/ArrayCwiseBinaryOps.h +332 -0
  328. data/vendor/eigen/Eigen/src/plugins/ArrayCwiseUnaryOps.h +552 -0
  329. data/vendor/eigen/Eigen/src/plugins/BlockMethods.h +1058 -0
  330. data/vendor/eigen/Eigen/src/plugins/CommonCwiseBinaryOps.h +115 -0
  331. data/vendor/eigen/Eigen/src/plugins/CommonCwiseUnaryOps.h +163 -0
  332. data/vendor/eigen/Eigen/src/plugins/MatrixCwiseBinaryOps.h +152 -0
  333. data/vendor/eigen/Eigen/src/plugins/MatrixCwiseUnaryOps.h +85 -0
  334. data/vendor/eigen/README.md +3 -0
  335. data/vendor/eigen/bench/README.txt +55 -0
  336. data/vendor/eigen/bench/btl/COPYING +340 -0
  337. data/vendor/eigen/bench/btl/README +154 -0
  338. data/vendor/eigen/bench/tensors/README +21 -0
  339. data/vendor/eigen/blas/README.txt +6 -0
  340. data/vendor/eigen/demos/mandelbrot/README +10 -0
  341. data/vendor/eigen/demos/mix_eigen_and_c/README +9 -0
  342. data/vendor/eigen/demos/opengl/README +13 -0
  343. data/vendor/eigen/unsupported/Eigen/CXX11/src/Tensor/README.md +1760 -0
  344. data/vendor/eigen/unsupported/README.txt +50 -0
  345. data/vendor/tomotopy/LICENSE +21 -0
  346. data/vendor/tomotopy/README.kr.rst +375 -0
  347. data/vendor/tomotopy/README.rst +382 -0
  348. data/vendor/tomotopy/src/Labeling/FoRelevance.cpp +362 -0
  349. data/vendor/tomotopy/src/Labeling/FoRelevance.h +88 -0
  350. data/vendor/tomotopy/src/Labeling/Labeler.h +50 -0
  351. data/vendor/tomotopy/src/TopicModel/CT.h +37 -0
  352. data/vendor/tomotopy/src/TopicModel/CTModel.cpp +13 -0
  353. data/vendor/tomotopy/src/TopicModel/CTModel.hpp +293 -0
  354. data/vendor/tomotopy/src/TopicModel/DMR.h +51 -0
  355. data/vendor/tomotopy/src/TopicModel/DMRModel.cpp +13 -0
  356. data/vendor/tomotopy/src/TopicModel/DMRModel.hpp +374 -0
  357. data/vendor/tomotopy/src/TopicModel/DT.h +65 -0
  358. data/vendor/tomotopy/src/TopicModel/DTM.h +22 -0
  359. data/vendor/tomotopy/src/TopicModel/DTModel.cpp +15 -0
  360. data/vendor/tomotopy/src/TopicModel/DTModel.hpp +572 -0
  361. data/vendor/tomotopy/src/TopicModel/GDMR.h +37 -0
  362. data/vendor/tomotopy/src/TopicModel/GDMRModel.cpp +14 -0
  363. data/vendor/tomotopy/src/TopicModel/GDMRModel.hpp +485 -0
  364. data/vendor/tomotopy/src/TopicModel/HDP.h +74 -0
  365. data/vendor/tomotopy/src/TopicModel/HDPModel.cpp +13 -0
  366. data/vendor/tomotopy/src/TopicModel/HDPModel.hpp +592 -0
  367. data/vendor/tomotopy/src/TopicModel/HLDA.h +40 -0
  368. data/vendor/tomotopy/src/TopicModel/HLDAModel.cpp +13 -0
  369. data/vendor/tomotopy/src/TopicModel/HLDAModel.hpp +681 -0
  370. data/vendor/tomotopy/src/TopicModel/HPA.h +27 -0
  371. data/vendor/tomotopy/src/TopicModel/HPAModel.cpp +21 -0
  372. data/vendor/tomotopy/src/TopicModel/HPAModel.hpp +588 -0
  373. data/vendor/tomotopy/src/TopicModel/LDA.h +144 -0
  374. data/vendor/tomotopy/src/TopicModel/LDACVB0Model.hpp +442 -0
  375. data/vendor/tomotopy/src/TopicModel/LDAModel.cpp +13 -0
  376. data/vendor/tomotopy/src/TopicModel/LDAModel.hpp +1058 -0
  377. data/vendor/tomotopy/src/TopicModel/LLDA.h +45 -0
  378. data/vendor/tomotopy/src/TopicModel/LLDAModel.cpp +13 -0
  379. data/vendor/tomotopy/src/TopicModel/LLDAModel.hpp +203 -0
  380. data/vendor/tomotopy/src/TopicModel/MGLDA.h +63 -0
  381. data/vendor/tomotopy/src/TopicModel/MGLDAModel.cpp +17 -0
  382. data/vendor/tomotopy/src/TopicModel/MGLDAModel.hpp +558 -0
  383. data/vendor/tomotopy/src/TopicModel/PA.h +43 -0
  384. data/vendor/tomotopy/src/TopicModel/PAModel.cpp +13 -0
  385. data/vendor/tomotopy/src/TopicModel/PAModel.hpp +467 -0
  386. data/vendor/tomotopy/src/TopicModel/PLDA.h +17 -0
  387. data/vendor/tomotopy/src/TopicModel/PLDAModel.cpp +13 -0
  388. data/vendor/tomotopy/src/TopicModel/PLDAModel.hpp +214 -0
  389. data/vendor/tomotopy/src/TopicModel/SLDA.h +54 -0
  390. data/vendor/tomotopy/src/TopicModel/SLDAModel.cpp +17 -0
  391. data/vendor/tomotopy/src/TopicModel/SLDAModel.hpp +456 -0
  392. data/vendor/tomotopy/src/TopicModel/TopicModel.hpp +692 -0
  393. data/vendor/tomotopy/src/Utils/AliasMethod.hpp +169 -0
  394. data/vendor/tomotopy/src/Utils/Dictionary.h +80 -0
  395. data/vendor/tomotopy/src/Utils/EigenAddonOps.hpp +181 -0
  396. data/vendor/tomotopy/src/Utils/LBFGS.h +202 -0
  397. data/vendor/tomotopy/src/Utils/LBFGS/LineSearchBacktracking.h +120 -0
  398. data/vendor/tomotopy/src/Utils/LBFGS/LineSearchBracketing.h +122 -0
  399. data/vendor/tomotopy/src/Utils/LBFGS/Param.h +213 -0
  400. data/vendor/tomotopy/src/Utils/LUT.hpp +82 -0
  401. data/vendor/tomotopy/src/Utils/MultiNormalDistribution.hpp +69 -0
  402. data/vendor/tomotopy/src/Utils/PolyaGamma.hpp +200 -0
  403. data/vendor/tomotopy/src/Utils/PolyaGammaHybrid.hpp +672 -0
  404. data/vendor/tomotopy/src/Utils/ThreadPool.hpp +150 -0
  405. data/vendor/tomotopy/src/Utils/Trie.hpp +220 -0
  406. data/vendor/tomotopy/src/Utils/TruncMultiNormal.hpp +94 -0
  407. data/vendor/tomotopy/src/Utils/Utils.hpp +337 -0
  408. data/vendor/tomotopy/src/Utils/avx_gamma.h +46 -0
  409. data/vendor/tomotopy/src/Utils/avx_mathfun.h +736 -0
  410. data/vendor/tomotopy/src/Utils/exception.h +28 -0
  411. data/vendor/tomotopy/src/Utils/math.h +281 -0
  412. data/vendor/tomotopy/src/Utils/rtnorm.hpp +2690 -0
  413. data/vendor/tomotopy/src/Utils/sample.hpp +192 -0
  414. data/vendor/tomotopy/src/Utils/serializer.hpp +695 -0
  415. data/vendor/tomotopy/src/Utils/slp.hpp +131 -0
  416. data/vendor/tomotopy/src/Utils/sse_gamma.h +48 -0
  417. data/vendor/tomotopy/src/Utils/sse_mathfun.h +710 -0
  418. data/vendor/tomotopy/src/Utils/text.hpp +49 -0
  419. data/vendor/tomotopy/src/Utils/tvector.hpp +543 -0
  420. metadata +531 -0
@@ -0,0 +1,127 @@
1
+ // This file is part of Eigen, a lightweight C++ template library
2
+ // for linear algebra.
3
+ //
4
+ // Copyright (C) 2008-2014 Gael Guennebaud <gael.guennebaud@inria.fr>
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_COREITERATORS_H
11
+ #define EIGEN_COREITERATORS_H
12
+
13
+ namespace Eigen {
14
+
15
+ /* This file contains the respective InnerIterator definition of the expressions defined in Eigen/Core
16
+ */
17
+
18
+ namespace internal {
19
+
20
+ template<typename XprType, typename EvaluatorKind>
21
+ class inner_iterator_selector;
22
+
23
+ }
24
+
25
+ /** \class InnerIterator
26
+ * \brief An InnerIterator allows to loop over the element of any matrix expression.
27
+ *
28
+ * \warning To be used with care because an evaluator is constructed every time an InnerIterator iterator is constructed.
29
+ *
30
+ * TODO: add a usage example
31
+ */
32
+ template<typename XprType>
33
+ class InnerIterator
34
+ {
35
+ protected:
36
+ typedef internal::inner_iterator_selector<XprType, typename internal::evaluator_traits<XprType>::Kind> IteratorType;
37
+ typedef internal::evaluator<XprType> EvaluatorType;
38
+ typedef typename internal::traits<XprType>::Scalar Scalar;
39
+ public:
40
+ /** Construct an iterator over the \a outerId -th row or column of \a xpr */
41
+ InnerIterator(const XprType &xpr, const Index &outerId)
42
+ : m_eval(xpr), m_iter(m_eval, outerId, xpr.innerSize())
43
+ {}
44
+
45
+ /// \returns the value of the current coefficient.
46
+ EIGEN_STRONG_INLINE Scalar value() const { return m_iter.value(); }
47
+ /** Increment the iterator \c *this to the next non-zero coefficient.
48
+ * Explicit zeros are not skipped over. To skip explicit zeros, see class SparseView
49
+ */
50
+ EIGEN_STRONG_INLINE InnerIterator& operator++() { m_iter.operator++(); return *this; }
51
+ /// \returns the column or row index of the current coefficient.
52
+ EIGEN_STRONG_INLINE Index index() const { return m_iter.index(); }
53
+ /// \returns the row index of the current coefficient.
54
+ EIGEN_STRONG_INLINE Index row() const { return m_iter.row(); }
55
+ /// \returns the column index of the current coefficient.
56
+ EIGEN_STRONG_INLINE Index col() const { return m_iter.col(); }
57
+ /// \returns \c true if the iterator \c *this still references a valid coefficient.
58
+ EIGEN_STRONG_INLINE operator bool() const { return m_iter; }
59
+
60
+ protected:
61
+ EvaluatorType m_eval;
62
+ IteratorType m_iter;
63
+ private:
64
+ // If you get here, then you're not using the right InnerIterator type, e.g.:
65
+ // SparseMatrix<double,RowMajor> A;
66
+ // SparseMatrix<double>::InnerIterator it(A,0);
67
+ template<typename T> InnerIterator(const EigenBase<T>&,Index outer);
68
+ };
69
+
70
+ namespace internal {
71
+
72
+ // Generic inner iterator implementation for dense objects
73
+ template<typename XprType>
74
+ class inner_iterator_selector<XprType, IndexBased>
75
+ {
76
+ protected:
77
+ typedef evaluator<XprType> EvaluatorType;
78
+ typedef typename traits<XprType>::Scalar Scalar;
79
+ enum { IsRowMajor = (XprType::Flags&RowMajorBit)==RowMajorBit };
80
+
81
+ public:
82
+ EIGEN_STRONG_INLINE inner_iterator_selector(const EvaluatorType &eval, const Index &outerId, const Index &innerSize)
83
+ : m_eval(eval), m_inner(0), m_outer(outerId), m_end(innerSize)
84
+ {}
85
+
86
+ EIGEN_STRONG_INLINE Scalar value() const
87
+ {
88
+ return (IsRowMajor) ? m_eval.coeff(m_outer, m_inner)
89
+ : m_eval.coeff(m_inner, m_outer);
90
+ }
91
+
92
+ EIGEN_STRONG_INLINE inner_iterator_selector& operator++() { m_inner++; return *this; }
93
+
94
+ EIGEN_STRONG_INLINE Index index() const { return m_inner; }
95
+ inline Index row() const { return IsRowMajor ? m_outer : index(); }
96
+ inline Index col() const { return IsRowMajor ? index() : m_outer; }
97
+
98
+ EIGEN_STRONG_INLINE operator bool() const { return m_inner < m_end && m_inner>=0; }
99
+
100
+ protected:
101
+ const EvaluatorType& m_eval;
102
+ Index m_inner;
103
+ const Index m_outer;
104
+ const Index m_end;
105
+ };
106
+
107
+ // For iterator-based evaluator, inner-iterator is already implemented as
108
+ // evaluator<>::InnerIterator
109
+ template<typename XprType>
110
+ class inner_iterator_selector<XprType, IteratorBased>
111
+ : public evaluator<XprType>::InnerIterator
112
+ {
113
+ protected:
114
+ typedef typename evaluator<XprType>::InnerIterator Base;
115
+ typedef evaluator<XprType> EvaluatorType;
116
+
117
+ public:
118
+ EIGEN_STRONG_INLINE inner_iterator_selector(const EvaluatorType &eval, const Index &outerId, const Index &/*innerSize*/)
119
+ : Base(eval, outerId)
120
+ {}
121
+ };
122
+
123
+ } // end namespace internal
124
+
125
+ } // end namespace Eigen
126
+
127
+ #endif // EIGEN_COREITERATORS_H
@@ -0,0 +1,184 @@
1
+ // This file is part of Eigen, a lightweight C++ template library
2
+ // for linear algebra.
3
+ //
4
+ // Copyright (C) 2008-2014 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_CWISE_BINARY_OP_H
12
+ #define EIGEN_CWISE_BINARY_OP_H
13
+
14
+ namespace Eigen {
15
+
16
+ namespace internal {
17
+ template<typename BinaryOp, typename Lhs, typename Rhs>
18
+ struct traits<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >
19
+ {
20
+ // we must not inherit from traits<Lhs> since it has
21
+ // the potential to cause problems with MSVC
22
+ typedef typename remove_all<Lhs>::type Ancestor;
23
+ typedef typename traits<Ancestor>::XprKind XprKind;
24
+ enum {
25
+ RowsAtCompileTime = traits<Ancestor>::RowsAtCompileTime,
26
+ ColsAtCompileTime = traits<Ancestor>::ColsAtCompileTime,
27
+ MaxRowsAtCompileTime = traits<Ancestor>::MaxRowsAtCompileTime,
28
+ MaxColsAtCompileTime = traits<Ancestor>::MaxColsAtCompileTime
29
+ };
30
+
31
+ // even though we require Lhs and Rhs to have the same scalar type (see CwiseBinaryOp constructor),
32
+ // we still want to handle the case when the result type is different.
33
+ typedef typename result_of<
34
+ BinaryOp(
35
+ const typename Lhs::Scalar&,
36
+ const typename Rhs::Scalar&
37
+ )
38
+ >::type Scalar;
39
+ typedef typename cwise_promote_storage_type<typename traits<Lhs>::StorageKind,
40
+ typename traits<Rhs>::StorageKind,
41
+ BinaryOp>::ret StorageKind;
42
+ typedef typename promote_index_type<typename traits<Lhs>::StorageIndex,
43
+ typename traits<Rhs>::StorageIndex>::type StorageIndex;
44
+ typedef typename Lhs::Nested LhsNested;
45
+ typedef typename Rhs::Nested RhsNested;
46
+ typedef typename remove_reference<LhsNested>::type _LhsNested;
47
+ typedef typename remove_reference<RhsNested>::type _RhsNested;
48
+ enum {
49
+ Flags = cwise_promote_storage_order<typename traits<Lhs>::StorageKind,typename traits<Rhs>::StorageKind,_LhsNested::Flags & RowMajorBit,_RhsNested::Flags & RowMajorBit>::value
50
+ };
51
+ };
52
+ } // end namespace internal
53
+
54
+ template<typename BinaryOp, typename Lhs, typename Rhs, typename StorageKind>
55
+ class CwiseBinaryOpImpl;
56
+
57
+ /** \class CwiseBinaryOp
58
+ * \ingroup Core_Module
59
+ *
60
+ * \brief Generic expression where a coefficient-wise binary operator is applied to two expressions
61
+ *
62
+ * \tparam BinaryOp template functor implementing the operator
63
+ * \tparam LhsType the type of the left-hand side
64
+ * \tparam RhsType the type of the right-hand side
65
+ *
66
+ * This class represents an expression where a coefficient-wise binary operator is applied to two expressions.
67
+ * It is the return type of binary operators, by which we mean only those binary operators where
68
+ * both the left-hand side and the right-hand side are Eigen expressions.
69
+ * For example, the return type of matrix1+matrix2 is a CwiseBinaryOp.
70
+ *
71
+ * Most of the time, this is the only way that it is used, so you typically don't have to name
72
+ * CwiseBinaryOp types explicitly.
73
+ *
74
+ * \sa MatrixBase::binaryExpr(const MatrixBase<OtherDerived> &,const CustomBinaryOp &) const, class CwiseUnaryOp, class CwiseNullaryOp
75
+ */
76
+ template<typename BinaryOp, typename LhsType, typename RhsType>
77
+ class CwiseBinaryOp :
78
+ public CwiseBinaryOpImpl<
79
+ BinaryOp, LhsType, RhsType,
80
+ typename internal::cwise_promote_storage_type<typename internal::traits<LhsType>::StorageKind,
81
+ typename internal::traits<RhsType>::StorageKind,
82
+ BinaryOp>::ret>,
83
+ internal::no_assignment_operator
84
+ {
85
+ public:
86
+
87
+ typedef typename internal::remove_all<BinaryOp>::type Functor;
88
+ typedef typename internal::remove_all<LhsType>::type Lhs;
89
+ typedef typename internal::remove_all<RhsType>::type Rhs;
90
+
91
+ typedef typename CwiseBinaryOpImpl<
92
+ BinaryOp, LhsType, RhsType,
93
+ typename internal::cwise_promote_storage_type<typename internal::traits<LhsType>::StorageKind,
94
+ typename internal::traits<Rhs>::StorageKind,
95
+ BinaryOp>::ret>::Base Base;
96
+ EIGEN_GENERIC_PUBLIC_INTERFACE(CwiseBinaryOp)
97
+
98
+ typedef typename internal::ref_selector<LhsType>::type LhsNested;
99
+ typedef typename internal::ref_selector<RhsType>::type RhsNested;
100
+ typedef typename internal::remove_reference<LhsNested>::type _LhsNested;
101
+ typedef typename internal::remove_reference<RhsNested>::type _RhsNested;
102
+
103
+ EIGEN_DEVICE_FUNC
104
+ EIGEN_STRONG_INLINE CwiseBinaryOp(const Lhs& aLhs, const Rhs& aRhs, const BinaryOp& func = BinaryOp())
105
+ : m_lhs(aLhs), m_rhs(aRhs), m_functor(func)
106
+ {
107
+ EIGEN_CHECK_BINARY_COMPATIBILIY(BinaryOp,typename Lhs::Scalar,typename Rhs::Scalar);
108
+ // require the sizes to match
109
+ EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Lhs, Rhs)
110
+ eigen_assert(aLhs.rows() == aRhs.rows() && aLhs.cols() == aRhs.cols());
111
+ }
112
+
113
+ EIGEN_DEVICE_FUNC
114
+ EIGEN_STRONG_INLINE Index rows() const {
115
+ // return the fixed size type if available to enable compile time optimizations
116
+ if (internal::traits<typename internal::remove_all<LhsNested>::type>::RowsAtCompileTime==Dynamic)
117
+ return m_rhs.rows();
118
+ else
119
+ return m_lhs.rows();
120
+ }
121
+ EIGEN_DEVICE_FUNC
122
+ EIGEN_STRONG_INLINE Index cols() const {
123
+ // return the fixed size type if available to enable compile time optimizations
124
+ if (internal::traits<typename internal::remove_all<LhsNested>::type>::ColsAtCompileTime==Dynamic)
125
+ return m_rhs.cols();
126
+ else
127
+ return m_lhs.cols();
128
+ }
129
+
130
+ /** \returns the left hand side nested expression */
131
+ EIGEN_DEVICE_FUNC
132
+ const _LhsNested& lhs() const { return m_lhs; }
133
+ /** \returns the right hand side nested expression */
134
+ EIGEN_DEVICE_FUNC
135
+ const _RhsNested& rhs() const { return m_rhs; }
136
+ /** \returns the functor representing the binary operation */
137
+ EIGEN_DEVICE_FUNC
138
+ const BinaryOp& functor() const { return m_functor; }
139
+
140
+ protected:
141
+ LhsNested m_lhs;
142
+ RhsNested m_rhs;
143
+ const BinaryOp m_functor;
144
+ };
145
+
146
+ // Generic API dispatcher
147
+ template<typename BinaryOp, typename Lhs, typename Rhs, typename StorageKind>
148
+ class CwiseBinaryOpImpl
149
+ : public internal::generic_xpr_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >::type
150
+ {
151
+ public:
152
+ typedef typename internal::generic_xpr_base<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >::type Base;
153
+ };
154
+
155
+ /** replaces \c *this by \c *this - \a other.
156
+ *
157
+ * \returns a reference to \c *this
158
+ */
159
+ template<typename Derived>
160
+ template<typename OtherDerived>
161
+ EIGEN_STRONG_INLINE Derived &
162
+ MatrixBase<Derived>::operator-=(const MatrixBase<OtherDerived> &other)
163
+ {
164
+ call_assignment(derived(), other.derived(), internal::sub_assign_op<Scalar,typename OtherDerived::Scalar>());
165
+ return derived();
166
+ }
167
+
168
+ /** replaces \c *this by \c *this + \a other.
169
+ *
170
+ * \returns a reference to \c *this
171
+ */
172
+ template<typename Derived>
173
+ template<typename OtherDerived>
174
+ EIGEN_STRONG_INLINE Derived &
175
+ MatrixBase<Derived>::operator+=(const MatrixBase<OtherDerived>& other)
176
+ {
177
+ call_assignment(derived(), other.derived(), internal::add_assign_op<Scalar,typename OtherDerived::Scalar>());
178
+ return derived();
179
+ }
180
+
181
+ } // end namespace Eigen
182
+
183
+ #endif // EIGEN_CWISE_BINARY_OP_H
184
+
@@ -0,0 +1,866 @@
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
+ //
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_CWISE_NULLARY_OP_H
11
+ #define EIGEN_CWISE_NULLARY_OP_H
12
+
13
+ namespace Eigen {
14
+
15
+ namespace internal {
16
+ template<typename NullaryOp, typename PlainObjectType>
17
+ struct traits<CwiseNullaryOp<NullaryOp, PlainObjectType> > : traits<PlainObjectType>
18
+ {
19
+ enum {
20
+ Flags = traits<PlainObjectType>::Flags & RowMajorBit
21
+ };
22
+ };
23
+
24
+ } // namespace internal
25
+
26
+ /** \class CwiseNullaryOp
27
+ * \ingroup Core_Module
28
+ *
29
+ * \brief Generic expression of a matrix where all coefficients are defined by a functor
30
+ *
31
+ * \tparam NullaryOp template functor implementing the operator
32
+ * \tparam PlainObjectType the underlying plain matrix/array type
33
+ *
34
+ * This class represents an expression of a generic nullary operator.
35
+ * It is the return type of the Ones(), Zero(), Constant(), Identity() and Random() methods,
36
+ * and most of the time this is the only way it is used.
37
+ *
38
+ * However, if you want to write a function returning such an expression, you
39
+ * will need to use this class.
40
+ *
41
+ * The functor NullaryOp must expose one of the following method:
42
+ <table class="manual">
43
+ <tr ><td>\c operator()() </td><td>if the procedural generation does not depend on the coefficient entries (e.g., random numbers)</td></tr>
44
+ <tr class="alt"><td>\c operator()(Index i)</td><td>if the procedural generation makes sense for vectors only and that it depends on the coefficient index \c i (e.g., linspace) </td></tr>
45
+ <tr ><td>\c operator()(Index i,Index j)</td><td>if the procedural generation depends on the matrix coordinates \c i, \c j (e.g., to generate a checkerboard with 0 and 1)</td></tr>
46
+ </table>
47
+ * It is also possible to expose the last two operators if the generation makes sense for matrices but can be optimized for vectors.
48
+ *
49
+ * See DenseBase::NullaryExpr(Index,const CustomNullaryOp&) for an example binding
50
+ * C++11 random number generators.
51
+ *
52
+ * A nullary expression can also be used to implement custom sophisticated matrix manipulations
53
+ * that cannot be covered by the existing set of natively supported matrix manipulations.
54
+ * See this \ref TopicCustomizing_NullaryExpr "page" for some examples and additional explanations
55
+ * on the behavior of CwiseNullaryOp.
56
+ *
57
+ * \sa class CwiseUnaryOp, class CwiseBinaryOp, DenseBase::NullaryExpr
58
+ */
59
+ template<typename NullaryOp, typename PlainObjectType>
60
+ class CwiseNullaryOp : public internal::dense_xpr_base< CwiseNullaryOp<NullaryOp, PlainObjectType> >::type, internal::no_assignment_operator
61
+ {
62
+ public:
63
+
64
+ typedef typename internal::dense_xpr_base<CwiseNullaryOp>::type Base;
65
+ EIGEN_DENSE_PUBLIC_INTERFACE(CwiseNullaryOp)
66
+
67
+ EIGEN_DEVICE_FUNC
68
+ CwiseNullaryOp(Index rows, Index cols, const NullaryOp& func = NullaryOp())
69
+ : m_rows(rows), m_cols(cols), m_functor(func)
70
+ {
71
+ eigen_assert(rows >= 0
72
+ && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows)
73
+ && cols >= 0
74
+ && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols));
75
+ }
76
+
77
+ EIGEN_DEVICE_FUNC
78
+ EIGEN_STRONG_INLINE Index rows() const { return m_rows.value(); }
79
+ EIGEN_DEVICE_FUNC
80
+ EIGEN_STRONG_INLINE Index cols() const { return m_cols.value(); }
81
+
82
+ /** \returns the functor representing the nullary operation */
83
+ EIGEN_DEVICE_FUNC
84
+ const NullaryOp& functor() const { return m_functor; }
85
+
86
+ protected:
87
+ const internal::variable_if_dynamic<Index, RowsAtCompileTime> m_rows;
88
+ const internal::variable_if_dynamic<Index, ColsAtCompileTime> m_cols;
89
+ const NullaryOp m_functor;
90
+ };
91
+
92
+
93
+ /** \returns an expression of a matrix defined by a custom functor \a func
94
+ *
95
+ * The parameters \a rows and \a cols are the number of rows and of columns of
96
+ * the returned matrix. Must be compatible with this MatrixBase type.
97
+ *
98
+ * This variant is meant to be used for dynamic-size matrix types. For fixed-size types,
99
+ * it is redundant to pass \a rows and \a cols as arguments, so Zero() should be used
100
+ * instead.
101
+ *
102
+ * The template parameter \a CustomNullaryOp is the type of the functor.
103
+ *
104
+ * \sa class CwiseNullaryOp
105
+ */
106
+ template<typename Derived>
107
+ template<typename CustomNullaryOp>
108
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseNullaryOp<CustomNullaryOp, typename DenseBase<Derived>::PlainObject>
109
+ DenseBase<Derived>::NullaryExpr(Index rows, Index cols, const CustomNullaryOp& func)
110
+ {
111
+ return CwiseNullaryOp<CustomNullaryOp, PlainObject>(rows, cols, func);
112
+ }
113
+
114
+ /** \returns an expression of a matrix defined by a custom functor \a func
115
+ *
116
+ * The parameter \a size is the size of the returned vector.
117
+ * Must be compatible with this MatrixBase type.
118
+ *
119
+ * \only_for_vectors
120
+ *
121
+ * This variant is meant to be used for dynamic-size vector types. For fixed-size types,
122
+ * it is redundant to pass \a size as argument, so Zero() should be used
123
+ * instead.
124
+ *
125
+ * The template parameter \a CustomNullaryOp is the type of the functor.
126
+ *
127
+ * Here is an example with C++11 random generators: \include random_cpp11.cpp
128
+ * Output: \verbinclude random_cpp11.out
129
+ *
130
+ * \sa class CwiseNullaryOp
131
+ */
132
+ template<typename Derived>
133
+ template<typename CustomNullaryOp>
134
+ EIGEN_STRONG_INLINE const CwiseNullaryOp<CustomNullaryOp, typename DenseBase<Derived>::PlainObject>
135
+ DenseBase<Derived>::NullaryExpr(Index size, const CustomNullaryOp& func)
136
+ {
137
+ EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
138
+ if(RowsAtCompileTime == 1) return CwiseNullaryOp<CustomNullaryOp, PlainObject>(1, size, func);
139
+ else return CwiseNullaryOp<CustomNullaryOp, PlainObject>(size, 1, func);
140
+ }
141
+
142
+ /** \returns an expression of a matrix defined by a custom functor \a func
143
+ *
144
+ * This variant is only for fixed-size DenseBase types. For dynamic-size types, you
145
+ * need to use the variants taking size arguments.
146
+ *
147
+ * The template parameter \a CustomNullaryOp is the type of the functor.
148
+ *
149
+ * \sa class CwiseNullaryOp
150
+ */
151
+ template<typename Derived>
152
+ template<typename CustomNullaryOp>
153
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const CwiseNullaryOp<CustomNullaryOp, typename DenseBase<Derived>::PlainObject>
154
+ DenseBase<Derived>::NullaryExpr(const CustomNullaryOp& func)
155
+ {
156
+ return CwiseNullaryOp<CustomNullaryOp, PlainObject>(RowsAtCompileTime, ColsAtCompileTime, func);
157
+ }
158
+
159
+ /** \returns an expression of a constant matrix of value \a value
160
+ *
161
+ * The parameters \a rows and \a cols are the number of rows and of columns of
162
+ * the returned matrix. Must be compatible with this DenseBase type.
163
+ *
164
+ * This variant is meant to be used for dynamic-size matrix types. For fixed-size types,
165
+ * it is redundant to pass \a rows and \a cols as arguments, so Zero() should be used
166
+ * instead.
167
+ *
168
+ * The template parameter \a CustomNullaryOp is the type of the functor.
169
+ *
170
+ * \sa class CwiseNullaryOp
171
+ */
172
+ template<typename Derived>
173
+ EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType
174
+ DenseBase<Derived>::Constant(Index rows, Index cols, const Scalar& value)
175
+ {
176
+ return DenseBase<Derived>::NullaryExpr(rows, cols, internal::scalar_constant_op<Scalar>(value));
177
+ }
178
+
179
+ /** \returns an expression of a constant matrix of value \a value
180
+ *
181
+ * The parameter \a size is the size of the returned vector.
182
+ * Must be compatible with this DenseBase type.
183
+ *
184
+ * \only_for_vectors
185
+ *
186
+ * This variant is meant to be used for dynamic-size vector types. For fixed-size types,
187
+ * it is redundant to pass \a size as argument, so Zero() should be used
188
+ * instead.
189
+ *
190
+ * The template parameter \a CustomNullaryOp is the type of the functor.
191
+ *
192
+ * \sa class CwiseNullaryOp
193
+ */
194
+ template<typename Derived>
195
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType
196
+ DenseBase<Derived>::Constant(Index size, const Scalar& value)
197
+ {
198
+ return DenseBase<Derived>::NullaryExpr(size, internal::scalar_constant_op<Scalar>(value));
199
+ }
200
+
201
+ /** \returns an expression of a constant matrix of value \a value
202
+ *
203
+ * This variant is only for fixed-size DenseBase types. For dynamic-size types, you
204
+ * need to use the variants taking size arguments.
205
+ *
206
+ * The template parameter \a CustomNullaryOp is the type of the functor.
207
+ *
208
+ * \sa class CwiseNullaryOp
209
+ */
210
+ template<typename Derived>
211
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType
212
+ DenseBase<Derived>::Constant(const Scalar& value)
213
+ {
214
+ EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
215
+ return DenseBase<Derived>::NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, internal::scalar_constant_op<Scalar>(value));
216
+ }
217
+
218
+ /** \deprecated because of accuracy loss. In Eigen 3.3, it is an alias for LinSpaced(Index,const Scalar&,const Scalar&)
219
+ *
220
+ * \sa LinSpaced(Index,Scalar,Scalar), setLinSpaced(Index,const Scalar&,const Scalar&)
221
+ */
222
+ template<typename Derived>
223
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::RandomAccessLinSpacedReturnType
224
+ DenseBase<Derived>::LinSpaced(Sequential_t, Index size, const Scalar& low, const Scalar& high)
225
+ {
226
+ EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
227
+ return DenseBase<Derived>::NullaryExpr(size, internal::linspaced_op<Scalar,PacketScalar>(low,high,size));
228
+ }
229
+
230
+ /** \deprecated because of accuracy loss. In Eigen 3.3, it is an alias for LinSpaced(const Scalar&,const Scalar&)
231
+ *
232
+ * \sa LinSpaced(Scalar,Scalar)
233
+ */
234
+ template<typename Derived>
235
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::RandomAccessLinSpacedReturnType
236
+ DenseBase<Derived>::LinSpaced(Sequential_t, const Scalar& low, const Scalar& high)
237
+ {
238
+ EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
239
+ EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
240
+ return DenseBase<Derived>::NullaryExpr(Derived::SizeAtCompileTime, internal::linspaced_op<Scalar,PacketScalar>(low,high,Derived::SizeAtCompileTime));
241
+ }
242
+
243
+ /**
244
+ * \brief Sets a linearly spaced vector.
245
+ *
246
+ * The function generates 'size' equally spaced values in the closed interval [low,high].
247
+ * When size is set to 1, a vector of length 1 containing 'high' is returned.
248
+ *
249
+ * \only_for_vectors
250
+ *
251
+ * Example: \include DenseBase_LinSpaced.cpp
252
+ * Output: \verbinclude DenseBase_LinSpaced.out
253
+ *
254
+ * For integer scalar types, an even spacing is possible if and only if the length of the range,
255
+ * i.e., \c high-low is a scalar multiple of \c size-1, or if \c size is a scalar multiple of the
256
+ * number of values \c high-low+1 (meaning each value can be repeated the same number of time).
257
+ * If one of these two considions is not satisfied, then \c high is lowered to the largest value
258
+ * satisfying one of this constraint.
259
+ * Here are some examples:
260
+ *
261
+ * Example: \include DenseBase_LinSpacedInt.cpp
262
+ * Output: \verbinclude DenseBase_LinSpacedInt.out
263
+ *
264
+ * \sa setLinSpaced(Index,const Scalar&,const Scalar&), CwiseNullaryOp
265
+ */
266
+ template<typename Derived>
267
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::RandomAccessLinSpacedReturnType
268
+ DenseBase<Derived>::LinSpaced(Index size, const Scalar& low, const Scalar& high)
269
+ {
270
+ EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
271
+ return DenseBase<Derived>::NullaryExpr(size, internal::linspaced_op<Scalar,PacketScalar>(low,high,size));
272
+ }
273
+
274
+ /**
275
+ * \copydoc DenseBase::LinSpaced(Index, const Scalar&, const Scalar&)
276
+ * Special version for fixed size types which does not require the size parameter.
277
+ */
278
+ template<typename Derived>
279
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::RandomAccessLinSpacedReturnType
280
+ DenseBase<Derived>::LinSpaced(const Scalar& low, const Scalar& high)
281
+ {
282
+ EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
283
+ EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
284
+ return DenseBase<Derived>::NullaryExpr(Derived::SizeAtCompileTime, internal::linspaced_op<Scalar,PacketScalar>(low,high,Derived::SizeAtCompileTime));
285
+ }
286
+
287
+ /** \returns true if all coefficients in this matrix are approximately equal to \a val, to within precision \a prec */
288
+ template<typename Derived>
289
+ EIGEN_DEVICE_FUNC bool DenseBase<Derived>::isApproxToConstant
290
+ (const Scalar& val, const RealScalar& prec) const
291
+ {
292
+ typename internal::nested_eval<Derived,1>::type self(derived());
293
+ for(Index j = 0; j < cols(); ++j)
294
+ for(Index i = 0; i < rows(); ++i)
295
+ if(!internal::isApprox(self.coeff(i, j), val, prec))
296
+ return false;
297
+ return true;
298
+ }
299
+
300
+ /** This is just an alias for isApproxToConstant().
301
+ *
302
+ * \returns true if all coefficients in this matrix are approximately equal to \a value, to within precision \a prec */
303
+ template<typename Derived>
304
+ EIGEN_DEVICE_FUNC bool DenseBase<Derived>::isConstant
305
+ (const Scalar& val, const RealScalar& prec) const
306
+ {
307
+ return isApproxToConstant(val, prec);
308
+ }
309
+
310
+ /** Alias for setConstant(): sets all coefficients in this expression to \a val.
311
+ *
312
+ * \sa setConstant(), Constant(), class CwiseNullaryOp
313
+ */
314
+ template<typename Derived>
315
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void DenseBase<Derived>::fill(const Scalar& val)
316
+ {
317
+ setConstant(val);
318
+ }
319
+
320
+ /** Sets all coefficients in this expression to value \a val.
321
+ *
322
+ * \sa fill(), setConstant(Index,const Scalar&), setConstant(Index,Index,const Scalar&), setZero(), setOnes(), Constant(), class CwiseNullaryOp, setZero(), setOnes()
323
+ */
324
+ template<typename Derived>
325
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setConstant(const Scalar& val)
326
+ {
327
+ return derived() = Constant(rows(), cols(), val);
328
+ }
329
+
330
+ /** Resizes to the given \a size, and sets all coefficients in this expression to the given value \a val.
331
+ *
332
+ * \only_for_vectors
333
+ *
334
+ * Example: \include Matrix_setConstant_int.cpp
335
+ * Output: \verbinclude Matrix_setConstant_int.out
336
+ *
337
+ * \sa MatrixBase::setConstant(const Scalar&), setConstant(Index,Index,const Scalar&), class CwiseNullaryOp, MatrixBase::Constant(const Scalar&)
338
+ */
339
+ template<typename Derived>
340
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived&
341
+ PlainObjectBase<Derived>::setConstant(Index size, const Scalar& val)
342
+ {
343
+ resize(size);
344
+ return setConstant(val);
345
+ }
346
+
347
+ /** Resizes to the given size, and sets all coefficients in this expression to the given value \a val.
348
+ *
349
+ * \param rows the new number of rows
350
+ * \param cols the new number of columns
351
+ * \param val the value to which all coefficients are set
352
+ *
353
+ * Example: \include Matrix_setConstant_int_int.cpp
354
+ * Output: \verbinclude Matrix_setConstant_int_int.out
355
+ *
356
+ * \sa MatrixBase::setConstant(const Scalar&), setConstant(Index,const Scalar&), class CwiseNullaryOp, MatrixBase::Constant(const Scalar&)
357
+ */
358
+ template<typename Derived>
359
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived&
360
+ PlainObjectBase<Derived>::setConstant(Index rows, Index cols, const Scalar& val)
361
+ {
362
+ resize(rows, cols);
363
+ return setConstant(val);
364
+ }
365
+
366
+ /**
367
+ * \brief Sets a linearly spaced vector.
368
+ *
369
+ * The function generates 'size' equally spaced values in the closed interval [low,high].
370
+ * When size is set to 1, a vector of length 1 containing 'high' is returned.
371
+ *
372
+ * \only_for_vectors
373
+ *
374
+ * Example: \include DenseBase_setLinSpaced.cpp
375
+ * Output: \verbinclude DenseBase_setLinSpaced.out
376
+ *
377
+ * For integer scalar types, do not miss the explanations on the definition
378
+ * of \link LinSpaced(Index,const Scalar&,const Scalar&) even spacing \endlink.
379
+ *
380
+ * \sa LinSpaced(Index,const Scalar&,const Scalar&), CwiseNullaryOp
381
+ */
382
+ template<typename Derived>
383
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setLinSpaced(Index newSize, const Scalar& low, const Scalar& high)
384
+ {
385
+ EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
386
+ return derived() = Derived::NullaryExpr(newSize, internal::linspaced_op<Scalar,PacketScalar>(low,high,newSize));
387
+ }
388
+
389
+ /**
390
+ * \brief Sets a linearly spaced vector.
391
+ *
392
+ * The function fills \c *this with equally spaced values in the closed interval [low,high].
393
+ * When size is set to 1, a vector of length 1 containing 'high' is returned.
394
+ *
395
+ * \only_for_vectors
396
+ *
397
+ * For integer scalar types, do not miss the explanations on the definition
398
+ * of \link LinSpaced(Index,const Scalar&,const Scalar&) even spacing \endlink.
399
+ *
400
+ * \sa LinSpaced(Index,const Scalar&,const Scalar&), setLinSpaced(Index, const Scalar&, const Scalar&), CwiseNullaryOp
401
+ */
402
+ template<typename Derived>
403
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setLinSpaced(const Scalar& low, const Scalar& high)
404
+ {
405
+ EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
406
+ return setLinSpaced(size(), low, high);
407
+ }
408
+
409
+ // zero:
410
+
411
+ /** \returns an expression of a zero matrix.
412
+ *
413
+ * The parameters \a rows and \a cols are the number of rows and of columns of
414
+ * the returned matrix. Must be compatible with this MatrixBase type.
415
+ *
416
+ * This variant is meant to be used for dynamic-size matrix types. For fixed-size types,
417
+ * it is redundant to pass \a rows and \a cols as arguments, so Zero() should be used
418
+ * instead.
419
+ *
420
+ * Example: \include MatrixBase_zero_int_int.cpp
421
+ * Output: \verbinclude MatrixBase_zero_int_int.out
422
+ *
423
+ * \sa Zero(), Zero(Index)
424
+ */
425
+ template<typename Derived>
426
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType
427
+ DenseBase<Derived>::Zero(Index rows, Index cols)
428
+ {
429
+ return Constant(rows, cols, Scalar(0));
430
+ }
431
+
432
+ /** \returns an expression of a zero vector.
433
+ *
434
+ * The parameter \a size is the size of the returned vector.
435
+ * Must be compatible with this MatrixBase type.
436
+ *
437
+ * \only_for_vectors
438
+ *
439
+ * This variant is meant to be used for dynamic-size vector types. For fixed-size types,
440
+ * it is redundant to pass \a size as argument, so Zero() should be used
441
+ * instead.
442
+ *
443
+ * Example: \include MatrixBase_zero_int.cpp
444
+ * Output: \verbinclude MatrixBase_zero_int.out
445
+ *
446
+ * \sa Zero(), Zero(Index,Index)
447
+ */
448
+ template<typename Derived>
449
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType
450
+ DenseBase<Derived>::Zero(Index size)
451
+ {
452
+ return Constant(size, Scalar(0));
453
+ }
454
+
455
+ /** \returns an expression of a fixed-size zero matrix or vector.
456
+ *
457
+ * This variant is only for fixed-size MatrixBase types. For dynamic-size types, you
458
+ * need to use the variants taking size arguments.
459
+ *
460
+ * Example: \include MatrixBase_zero.cpp
461
+ * Output: \verbinclude MatrixBase_zero.out
462
+ *
463
+ * \sa Zero(Index), Zero(Index,Index)
464
+ */
465
+ template<typename Derived>
466
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType
467
+ DenseBase<Derived>::Zero()
468
+ {
469
+ return Constant(Scalar(0));
470
+ }
471
+
472
+ /** \returns true if *this is approximately equal to the zero matrix,
473
+ * within the precision given by \a prec.
474
+ *
475
+ * Example: \include MatrixBase_isZero.cpp
476
+ * Output: \verbinclude MatrixBase_isZero.out
477
+ *
478
+ * \sa class CwiseNullaryOp, Zero()
479
+ */
480
+ template<typename Derived>
481
+ EIGEN_DEVICE_FUNC bool DenseBase<Derived>::isZero(const RealScalar& prec) const
482
+ {
483
+ typename internal::nested_eval<Derived,1>::type self(derived());
484
+ for(Index j = 0; j < cols(); ++j)
485
+ for(Index i = 0; i < rows(); ++i)
486
+ if(!internal::isMuchSmallerThan(self.coeff(i, j), static_cast<Scalar>(1), prec))
487
+ return false;
488
+ return true;
489
+ }
490
+
491
+ /** Sets all coefficients in this expression to zero.
492
+ *
493
+ * Example: \include MatrixBase_setZero.cpp
494
+ * Output: \verbinclude MatrixBase_setZero.out
495
+ *
496
+ * \sa class CwiseNullaryOp, Zero()
497
+ */
498
+ template<typename Derived>
499
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setZero()
500
+ {
501
+ return setConstant(Scalar(0));
502
+ }
503
+
504
+ /** Resizes to the given \a size, and sets all coefficients in this expression to zero.
505
+ *
506
+ * \only_for_vectors
507
+ *
508
+ * Example: \include Matrix_setZero_int.cpp
509
+ * Output: \verbinclude Matrix_setZero_int.out
510
+ *
511
+ * \sa DenseBase::setZero(), setZero(Index,Index), class CwiseNullaryOp, DenseBase::Zero()
512
+ */
513
+ template<typename Derived>
514
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived&
515
+ PlainObjectBase<Derived>::setZero(Index newSize)
516
+ {
517
+ resize(newSize);
518
+ return setConstant(Scalar(0));
519
+ }
520
+
521
+ /** Resizes to the given size, and sets all coefficients in this expression to zero.
522
+ *
523
+ * \param rows the new number of rows
524
+ * \param cols the new number of columns
525
+ *
526
+ * Example: \include Matrix_setZero_int_int.cpp
527
+ * Output: \verbinclude Matrix_setZero_int_int.out
528
+ *
529
+ * \sa DenseBase::setZero(), setZero(Index), class CwiseNullaryOp, DenseBase::Zero()
530
+ */
531
+ template<typename Derived>
532
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived&
533
+ PlainObjectBase<Derived>::setZero(Index rows, Index cols)
534
+ {
535
+ resize(rows, cols);
536
+ return setConstant(Scalar(0));
537
+ }
538
+
539
+ // ones:
540
+
541
+ /** \returns an expression of a matrix where all coefficients equal one.
542
+ *
543
+ * The parameters \a rows and \a cols are the number of rows and of columns of
544
+ * the returned matrix. Must be compatible with this MatrixBase type.
545
+ *
546
+ * This variant is meant to be used for dynamic-size matrix types. For fixed-size types,
547
+ * it is redundant to pass \a rows and \a cols as arguments, so Ones() should be used
548
+ * instead.
549
+ *
550
+ * Example: \include MatrixBase_ones_int_int.cpp
551
+ * Output: \verbinclude MatrixBase_ones_int_int.out
552
+ *
553
+ * \sa Ones(), Ones(Index), isOnes(), class Ones
554
+ */
555
+ template<typename Derived>
556
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType
557
+ DenseBase<Derived>::Ones(Index rows, Index cols)
558
+ {
559
+ return Constant(rows, cols, Scalar(1));
560
+ }
561
+
562
+ /** \returns an expression of a vector where all coefficients equal one.
563
+ *
564
+ * The parameter \a newSize is the size of the returned vector.
565
+ * Must be compatible with this MatrixBase type.
566
+ *
567
+ * \only_for_vectors
568
+ *
569
+ * This variant is meant to be used for dynamic-size vector types. For fixed-size types,
570
+ * it is redundant to pass \a size as argument, so Ones() should be used
571
+ * instead.
572
+ *
573
+ * Example: \include MatrixBase_ones_int.cpp
574
+ * Output: \verbinclude MatrixBase_ones_int.out
575
+ *
576
+ * \sa Ones(), Ones(Index,Index), isOnes(), class Ones
577
+ */
578
+ template<typename Derived>
579
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType
580
+ DenseBase<Derived>::Ones(Index newSize)
581
+ {
582
+ return Constant(newSize, Scalar(1));
583
+ }
584
+
585
+ /** \returns an expression of a fixed-size matrix or vector where all coefficients equal one.
586
+ *
587
+ * This variant is only for fixed-size MatrixBase types. For dynamic-size types, you
588
+ * need to use the variants taking size arguments.
589
+ *
590
+ * Example: \include MatrixBase_ones.cpp
591
+ * Output: \verbinclude MatrixBase_ones.out
592
+ *
593
+ * \sa Ones(Index), Ones(Index,Index), isOnes(), class Ones
594
+ */
595
+ template<typename Derived>
596
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType
597
+ DenseBase<Derived>::Ones()
598
+ {
599
+ return Constant(Scalar(1));
600
+ }
601
+
602
+ /** \returns true if *this is approximately equal to the matrix where all coefficients
603
+ * are equal to 1, within the precision given by \a prec.
604
+ *
605
+ * Example: \include MatrixBase_isOnes.cpp
606
+ * Output: \verbinclude MatrixBase_isOnes.out
607
+ *
608
+ * \sa class CwiseNullaryOp, Ones()
609
+ */
610
+ template<typename Derived>
611
+ EIGEN_DEVICE_FUNC bool DenseBase<Derived>::isOnes
612
+ (const RealScalar& prec) const
613
+ {
614
+ return isApproxToConstant(Scalar(1), prec);
615
+ }
616
+
617
+ /** Sets all coefficients in this expression to one.
618
+ *
619
+ * Example: \include MatrixBase_setOnes.cpp
620
+ * Output: \verbinclude MatrixBase_setOnes.out
621
+ *
622
+ * \sa class CwiseNullaryOp, Ones()
623
+ */
624
+ template<typename Derived>
625
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setOnes()
626
+ {
627
+ return setConstant(Scalar(1));
628
+ }
629
+
630
+ /** Resizes to the given \a newSize, and sets all coefficients in this expression to one.
631
+ *
632
+ * \only_for_vectors
633
+ *
634
+ * Example: \include Matrix_setOnes_int.cpp
635
+ * Output: \verbinclude Matrix_setOnes_int.out
636
+ *
637
+ * \sa MatrixBase::setOnes(), setOnes(Index,Index), class CwiseNullaryOp, MatrixBase::Ones()
638
+ */
639
+ template<typename Derived>
640
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived&
641
+ PlainObjectBase<Derived>::setOnes(Index newSize)
642
+ {
643
+ resize(newSize);
644
+ return setConstant(Scalar(1));
645
+ }
646
+
647
+ /** Resizes to the given size, and sets all coefficients in this expression to one.
648
+ *
649
+ * \param rows the new number of rows
650
+ * \param cols the new number of columns
651
+ *
652
+ * Example: \include Matrix_setOnes_int_int.cpp
653
+ * Output: \verbinclude Matrix_setOnes_int_int.out
654
+ *
655
+ * \sa MatrixBase::setOnes(), setOnes(Index), class CwiseNullaryOp, MatrixBase::Ones()
656
+ */
657
+ template<typename Derived>
658
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived&
659
+ PlainObjectBase<Derived>::setOnes(Index rows, Index cols)
660
+ {
661
+ resize(rows, cols);
662
+ return setConstant(Scalar(1));
663
+ }
664
+
665
+ // Identity:
666
+
667
+ /** \returns an expression of the identity matrix (not necessarily square).
668
+ *
669
+ * The parameters \a rows and \a cols are the number of rows and of columns of
670
+ * the returned matrix. Must be compatible with this MatrixBase type.
671
+ *
672
+ * This variant is meant to be used for dynamic-size matrix types. For fixed-size types,
673
+ * it is redundant to pass \a rows and \a cols as arguments, so Identity() should be used
674
+ * instead.
675
+ *
676
+ * Example: \include MatrixBase_identity_int_int.cpp
677
+ * Output: \verbinclude MatrixBase_identity_int_int.out
678
+ *
679
+ * \sa Identity(), setIdentity(), isIdentity()
680
+ */
681
+ template<typename Derived>
682
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::IdentityReturnType
683
+ MatrixBase<Derived>::Identity(Index rows, Index cols)
684
+ {
685
+ return DenseBase<Derived>::NullaryExpr(rows, cols, internal::scalar_identity_op<Scalar>());
686
+ }
687
+
688
+ /** \returns an expression of the identity matrix (not necessarily square).
689
+ *
690
+ * This variant is only for fixed-size MatrixBase types. For dynamic-size types, you
691
+ * need to use the variant taking size arguments.
692
+ *
693
+ * Example: \include MatrixBase_identity.cpp
694
+ * Output: \verbinclude MatrixBase_identity.out
695
+ *
696
+ * \sa Identity(Index,Index), setIdentity(), isIdentity()
697
+ */
698
+ template<typename Derived>
699
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::IdentityReturnType
700
+ MatrixBase<Derived>::Identity()
701
+ {
702
+ EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
703
+ return MatrixBase<Derived>::NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, internal::scalar_identity_op<Scalar>());
704
+ }
705
+
706
+ /** \returns true if *this is approximately equal to the identity matrix
707
+ * (not necessarily square),
708
+ * within the precision given by \a prec.
709
+ *
710
+ * Example: \include MatrixBase_isIdentity.cpp
711
+ * Output: \verbinclude MatrixBase_isIdentity.out
712
+ *
713
+ * \sa class CwiseNullaryOp, Identity(), Identity(Index,Index), setIdentity()
714
+ */
715
+ template<typename Derived>
716
+ bool MatrixBase<Derived>::isIdentity
717
+ (const RealScalar& prec) const
718
+ {
719
+ typename internal::nested_eval<Derived,1>::type self(derived());
720
+ for(Index j = 0; j < cols(); ++j)
721
+ {
722
+ for(Index i = 0; i < rows(); ++i)
723
+ {
724
+ if(i == j)
725
+ {
726
+ if(!internal::isApprox(self.coeff(i, j), static_cast<Scalar>(1), prec))
727
+ return false;
728
+ }
729
+ else
730
+ {
731
+ if(!internal::isMuchSmallerThan(self.coeff(i, j), static_cast<RealScalar>(1), prec))
732
+ return false;
733
+ }
734
+ }
735
+ }
736
+ return true;
737
+ }
738
+
739
+ namespace internal {
740
+
741
+ template<typename Derived, bool Big = (Derived::SizeAtCompileTime>=16)>
742
+ struct setIdentity_impl
743
+ {
744
+ EIGEN_DEVICE_FUNC
745
+ static EIGEN_STRONG_INLINE Derived& run(Derived& m)
746
+ {
747
+ return m = Derived::Identity(m.rows(), m.cols());
748
+ }
749
+ };
750
+
751
+ template<typename Derived>
752
+ struct setIdentity_impl<Derived, true>
753
+ {
754
+ EIGEN_DEVICE_FUNC
755
+ static EIGEN_STRONG_INLINE Derived& run(Derived& m)
756
+ {
757
+ m.setZero();
758
+ const Index size = numext::mini(m.rows(), m.cols());
759
+ for(Index i = 0; i < size; ++i) m.coeffRef(i,i) = typename Derived::Scalar(1);
760
+ return m;
761
+ }
762
+ };
763
+
764
+ } // end namespace internal
765
+
766
+ /** Writes the identity expression (not necessarily square) into *this.
767
+ *
768
+ * Example: \include MatrixBase_setIdentity.cpp
769
+ * Output: \verbinclude MatrixBase_setIdentity.out
770
+ *
771
+ * \sa class CwiseNullaryOp, Identity(), Identity(Index,Index), isIdentity()
772
+ */
773
+ template<typename Derived>
774
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::setIdentity()
775
+ {
776
+ return internal::setIdentity_impl<Derived>::run(derived());
777
+ }
778
+
779
+ /** \brief Resizes to the given size, and writes the identity expression (not necessarily square) into *this.
780
+ *
781
+ * \param rows the new number of rows
782
+ * \param cols the new number of columns
783
+ *
784
+ * Example: \include Matrix_setIdentity_int_int.cpp
785
+ * Output: \verbinclude Matrix_setIdentity_int_int.out
786
+ *
787
+ * \sa MatrixBase::setIdentity(), class CwiseNullaryOp, MatrixBase::Identity()
788
+ */
789
+ template<typename Derived>
790
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::setIdentity(Index rows, Index cols)
791
+ {
792
+ derived().resize(rows, cols);
793
+ return setIdentity();
794
+ }
795
+
796
+ /** \returns an expression of the i-th unit (basis) vector.
797
+ *
798
+ * \only_for_vectors
799
+ *
800
+ * \sa MatrixBase::Unit(Index), MatrixBase::UnitX(), MatrixBase::UnitY(), MatrixBase::UnitZ(), MatrixBase::UnitW()
801
+ */
802
+ template<typename Derived>
803
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::BasisReturnType MatrixBase<Derived>::Unit(Index newSize, Index i)
804
+ {
805
+ EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
806
+ return BasisReturnType(SquareMatrixType::Identity(newSize,newSize), i);
807
+ }
808
+
809
+ /** \returns an expression of the i-th unit (basis) vector.
810
+ *
811
+ * \only_for_vectors
812
+ *
813
+ * This variant is for fixed-size vector only.
814
+ *
815
+ * \sa MatrixBase::Unit(Index,Index), MatrixBase::UnitX(), MatrixBase::UnitY(), MatrixBase::UnitZ(), MatrixBase::UnitW()
816
+ */
817
+ template<typename Derived>
818
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::BasisReturnType MatrixBase<Derived>::Unit(Index i)
819
+ {
820
+ EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
821
+ return BasisReturnType(SquareMatrixType::Identity(),i);
822
+ }
823
+
824
+ /** \returns an expression of the X axis unit vector (1{,0}^*)
825
+ *
826
+ * \only_for_vectors
827
+ *
828
+ * \sa MatrixBase::Unit(Index,Index), MatrixBase::Unit(Index), MatrixBase::UnitY(), MatrixBase::UnitZ(), MatrixBase::UnitW()
829
+ */
830
+ template<typename Derived>
831
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::BasisReturnType MatrixBase<Derived>::UnitX()
832
+ { return Derived::Unit(0); }
833
+
834
+ /** \returns an expression of the Y axis unit vector (0,1{,0}^*)
835
+ *
836
+ * \only_for_vectors
837
+ *
838
+ * \sa MatrixBase::Unit(Index,Index), MatrixBase::Unit(Index), MatrixBase::UnitY(), MatrixBase::UnitZ(), MatrixBase::UnitW()
839
+ */
840
+ template<typename Derived>
841
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::BasisReturnType MatrixBase<Derived>::UnitY()
842
+ { return Derived::Unit(1); }
843
+
844
+ /** \returns an expression of the Z axis unit vector (0,0,1{,0}^*)
845
+ *
846
+ * \only_for_vectors
847
+ *
848
+ * \sa MatrixBase::Unit(Index,Index), MatrixBase::Unit(Index), MatrixBase::UnitY(), MatrixBase::UnitZ(), MatrixBase::UnitW()
849
+ */
850
+ template<typename Derived>
851
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::BasisReturnType MatrixBase<Derived>::UnitZ()
852
+ { return Derived::Unit(2); }
853
+
854
+ /** \returns an expression of the W axis unit vector (0,0,0,1)
855
+ *
856
+ * \only_for_vectors
857
+ *
858
+ * \sa MatrixBase::Unit(Index,Index), MatrixBase::Unit(Index), MatrixBase::UnitY(), MatrixBase::UnitZ(), MatrixBase::UnitW()
859
+ */
860
+ template<typename Derived>
861
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::BasisReturnType MatrixBase<Derived>::UnitW()
862
+ { return Derived::Unit(3); }
863
+
864
+ } // end namespace Eigen
865
+
866
+ #endif // EIGEN_CWISE_NULLARY_OP_H