tomoto 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (420) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +3 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +123 -0
  5. data/ext/tomoto/ext.cpp +245 -0
  6. data/ext/tomoto/extconf.rb +28 -0
  7. data/lib/tomoto.rb +12 -0
  8. data/lib/tomoto/ct.rb +11 -0
  9. data/lib/tomoto/hdp.rb +11 -0
  10. data/lib/tomoto/lda.rb +67 -0
  11. data/lib/tomoto/version.rb +3 -0
  12. data/vendor/EigenRand/EigenRand/Core.h +1139 -0
  13. data/vendor/EigenRand/EigenRand/Dists/Basic.h +111 -0
  14. data/vendor/EigenRand/EigenRand/Dists/Discrete.h +877 -0
  15. data/vendor/EigenRand/EigenRand/Dists/GammaPoisson.h +108 -0
  16. data/vendor/EigenRand/EigenRand/Dists/NormalExp.h +626 -0
  17. data/vendor/EigenRand/EigenRand/EigenRand +19 -0
  18. data/vendor/EigenRand/EigenRand/Macro.h +24 -0
  19. data/vendor/EigenRand/EigenRand/MorePacketMath.h +978 -0
  20. data/vendor/EigenRand/EigenRand/PacketFilter.h +286 -0
  21. data/vendor/EigenRand/EigenRand/PacketRandomEngine.h +624 -0
  22. data/vendor/EigenRand/EigenRand/RandUtils.h +413 -0
  23. data/vendor/EigenRand/EigenRand/doc.h +220 -0
  24. data/vendor/EigenRand/LICENSE +21 -0
  25. data/vendor/EigenRand/README.md +288 -0
  26. data/vendor/eigen/COPYING.BSD +26 -0
  27. data/vendor/eigen/COPYING.GPL +674 -0
  28. data/vendor/eigen/COPYING.LGPL +502 -0
  29. data/vendor/eigen/COPYING.MINPACK +52 -0
  30. data/vendor/eigen/COPYING.MPL2 +373 -0
  31. data/vendor/eigen/COPYING.README +18 -0
  32. data/vendor/eigen/Eigen/CMakeLists.txt +19 -0
  33. data/vendor/eigen/Eigen/Cholesky +46 -0
  34. data/vendor/eigen/Eigen/CholmodSupport +48 -0
  35. data/vendor/eigen/Eigen/Core +537 -0
  36. data/vendor/eigen/Eigen/Dense +7 -0
  37. data/vendor/eigen/Eigen/Eigen +2 -0
  38. data/vendor/eigen/Eigen/Eigenvalues +61 -0
  39. data/vendor/eigen/Eigen/Geometry +62 -0
  40. data/vendor/eigen/Eigen/Householder +30 -0
  41. data/vendor/eigen/Eigen/IterativeLinearSolvers +48 -0
  42. data/vendor/eigen/Eigen/Jacobi +33 -0
  43. data/vendor/eigen/Eigen/LU +50 -0
  44. data/vendor/eigen/Eigen/MetisSupport +35 -0
  45. data/vendor/eigen/Eigen/OrderingMethods +73 -0
  46. data/vendor/eigen/Eigen/PaStiXSupport +48 -0
  47. data/vendor/eigen/Eigen/PardisoSupport +35 -0
  48. data/vendor/eigen/Eigen/QR +51 -0
  49. data/vendor/eigen/Eigen/QtAlignedMalloc +40 -0
  50. data/vendor/eigen/Eigen/SPQRSupport +34 -0
  51. data/vendor/eigen/Eigen/SVD +51 -0
  52. data/vendor/eigen/Eigen/Sparse +36 -0
  53. data/vendor/eigen/Eigen/SparseCholesky +45 -0
  54. data/vendor/eigen/Eigen/SparseCore +69 -0
  55. data/vendor/eigen/Eigen/SparseLU +46 -0
  56. data/vendor/eigen/Eigen/SparseQR +37 -0
  57. data/vendor/eigen/Eigen/StdDeque +27 -0
  58. data/vendor/eigen/Eigen/StdList +26 -0
  59. data/vendor/eigen/Eigen/StdVector +27 -0
  60. data/vendor/eigen/Eigen/SuperLUSupport +64 -0
  61. data/vendor/eigen/Eigen/UmfPackSupport +40 -0
  62. data/vendor/eigen/Eigen/src/Cholesky/LDLT.h +673 -0
  63. data/vendor/eigen/Eigen/src/Cholesky/LLT.h +542 -0
  64. data/vendor/eigen/Eigen/src/Cholesky/LLT_LAPACKE.h +99 -0
  65. data/vendor/eigen/Eigen/src/CholmodSupport/CholmodSupport.h +639 -0
  66. data/vendor/eigen/Eigen/src/Core/Array.h +329 -0
  67. data/vendor/eigen/Eigen/src/Core/ArrayBase.h +226 -0
  68. data/vendor/eigen/Eigen/src/Core/ArrayWrapper.h +209 -0
  69. data/vendor/eigen/Eigen/src/Core/Assign.h +90 -0
  70. data/vendor/eigen/Eigen/src/Core/AssignEvaluator.h +935 -0
  71. data/vendor/eigen/Eigen/src/Core/Assign_MKL.h +178 -0
  72. data/vendor/eigen/Eigen/src/Core/BandMatrix.h +353 -0
  73. data/vendor/eigen/Eigen/src/Core/Block.h +452 -0
  74. data/vendor/eigen/Eigen/src/Core/BooleanRedux.h +164 -0
  75. data/vendor/eigen/Eigen/src/Core/CommaInitializer.h +160 -0
  76. data/vendor/eigen/Eigen/src/Core/ConditionEstimator.h +175 -0
  77. data/vendor/eigen/Eigen/src/Core/CoreEvaluators.h +1688 -0
  78. data/vendor/eigen/Eigen/src/Core/CoreIterators.h +127 -0
  79. data/vendor/eigen/Eigen/src/Core/CwiseBinaryOp.h +184 -0
  80. data/vendor/eigen/Eigen/src/Core/CwiseNullaryOp.h +866 -0
  81. data/vendor/eigen/Eigen/src/Core/CwiseTernaryOp.h +197 -0
  82. data/vendor/eigen/Eigen/src/Core/CwiseUnaryOp.h +103 -0
  83. data/vendor/eigen/Eigen/src/Core/CwiseUnaryView.h +128 -0
  84. data/vendor/eigen/Eigen/src/Core/DenseBase.h +611 -0
  85. data/vendor/eigen/Eigen/src/Core/DenseCoeffsBase.h +681 -0
  86. data/vendor/eigen/Eigen/src/Core/DenseStorage.h +570 -0
  87. data/vendor/eigen/Eigen/src/Core/Diagonal.h +260 -0
  88. data/vendor/eigen/Eigen/src/Core/DiagonalMatrix.h +343 -0
  89. data/vendor/eigen/Eigen/src/Core/DiagonalProduct.h +28 -0
  90. data/vendor/eigen/Eigen/src/Core/Dot.h +318 -0
  91. data/vendor/eigen/Eigen/src/Core/EigenBase.h +159 -0
  92. data/vendor/eigen/Eigen/src/Core/ForceAlignedAccess.h +146 -0
  93. data/vendor/eigen/Eigen/src/Core/Fuzzy.h +155 -0
  94. data/vendor/eigen/Eigen/src/Core/GeneralProduct.h +455 -0
  95. data/vendor/eigen/Eigen/src/Core/GenericPacketMath.h +593 -0
  96. data/vendor/eigen/Eigen/src/Core/GlobalFunctions.h +187 -0
  97. data/vendor/eigen/Eigen/src/Core/IO.h +225 -0
  98. data/vendor/eigen/Eigen/src/Core/Inverse.h +118 -0
  99. data/vendor/eigen/Eigen/src/Core/Map.h +171 -0
  100. data/vendor/eigen/Eigen/src/Core/MapBase.h +303 -0
  101. data/vendor/eigen/Eigen/src/Core/MathFunctions.h +1415 -0
  102. data/vendor/eigen/Eigen/src/Core/MathFunctionsImpl.h +101 -0
  103. data/vendor/eigen/Eigen/src/Core/Matrix.h +459 -0
  104. data/vendor/eigen/Eigen/src/Core/MatrixBase.h +529 -0
  105. data/vendor/eigen/Eigen/src/Core/NestByValue.h +110 -0
  106. data/vendor/eigen/Eigen/src/Core/NoAlias.h +108 -0
  107. data/vendor/eigen/Eigen/src/Core/NumTraits.h +248 -0
  108. data/vendor/eigen/Eigen/src/Core/PermutationMatrix.h +633 -0
  109. data/vendor/eigen/Eigen/src/Core/PlainObjectBase.h +1035 -0
  110. data/vendor/eigen/Eigen/src/Core/Product.h +186 -0
  111. data/vendor/eigen/Eigen/src/Core/ProductEvaluators.h +1112 -0
  112. data/vendor/eigen/Eigen/src/Core/Random.h +182 -0
  113. data/vendor/eigen/Eigen/src/Core/Redux.h +505 -0
  114. data/vendor/eigen/Eigen/src/Core/Ref.h +283 -0
  115. data/vendor/eigen/Eigen/src/Core/Replicate.h +142 -0
  116. data/vendor/eigen/Eigen/src/Core/ReturnByValue.h +117 -0
  117. data/vendor/eigen/Eigen/src/Core/Reverse.h +211 -0
  118. data/vendor/eigen/Eigen/src/Core/Select.h +162 -0
  119. data/vendor/eigen/Eigen/src/Core/SelfAdjointView.h +352 -0
  120. data/vendor/eigen/Eigen/src/Core/SelfCwiseBinaryOp.h +47 -0
  121. data/vendor/eigen/Eigen/src/Core/Solve.h +188 -0
  122. data/vendor/eigen/Eigen/src/Core/SolveTriangular.h +235 -0
  123. data/vendor/eigen/Eigen/src/Core/SolverBase.h +130 -0
  124. data/vendor/eigen/Eigen/src/Core/StableNorm.h +221 -0
  125. data/vendor/eigen/Eigen/src/Core/Stride.h +111 -0
  126. data/vendor/eigen/Eigen/src/Core/Swap.h +67 -0
  127. data/vendor/eigen/Eigen/src/Core/Transpose.h +403 -0
  128. data/vendor/eigen/Eigen/src/Core/Transpositions.h +407 -0
  129. data/vendor/eigen/Eigen/src/Core/TriangularMatrix.h +983 -0
  130. data/vendor/eigen/Eigen/src/Core/VectorBlock.h +96 -0
  131. data/vendor/eigen/Eigen/src/Core/VectorwiseOp.h +695 -0
  132. data/vendor/eigen/Eigen/src/Core/Visitor.h +273 -0
  133. data/vendor/eigen/Eigen/src/Core/arch/AVX/Complex.h +451 -0
  134. data/vendor/eigen/Eigen/src/Core/arch/AVX/MathFunctions.h +439 -0
  135. data/vendor/eigen/Eigen/src/Core/arch/AVX/PacketMath.h +637 -0
  136. data/vendor/eigen/Eigen/src/Core/arch/AVX/TypeCasting.h +51 -0
  137. data/vendor/eigen/Eigen/src/Core/arch/AVX512/MathFunctions.h +391 -0
  138. data/vendor/eigen/Eigen/src/Core/arch/AVX512/PacketMath.h +1316 -0
  139. data/vendor/eigen/Eigen/src/Core/arch/AltiVec/Complex.h +430 -0
  140. data/vendor/eigen/Eigen/src/Core/arch/AltiVec/MathFunctions.h +322 -0
  141. data/vendor/eigen/Eigen/src/Core/arch/AltiVec/PacketMath.h +1061 -0
  142. data/vendor/eigen/Eigen/src/Core/arch/CUDA/Complex.h +103 -0
  143. data/vendor/eigen/Eigen/src/Core/arch/CUDA/Half.h +674 -0
  144. data/vendor/eigen/Eigen/src/Core/arch/CUDA/MathFunctions.h +91 -0
  145. data/vendor/eigen/Eigen/src/Core/arch/CUDA/PacketMath.h +333 -0
  146. data/vendor/eigen/Eigen/src/Core/arch/CUDA/PacketMathHalf.h +1124 -0
  147. data/vendor/eigen/Eigen/src/Core/arch/CUDA/TypeCasting.h +212 -0
  148. data/vendor/eigen/Eigen/src/Core/arch/Default/ConjHelper.h +29 -0
  149. data/vendor/eigen/Eigen/src/Core/arch/Default/Settings.h +49 -0
  150. data/vendor/eigen/Eigen/src/Core/arch/NEON/Complex.h +490 -0
  151. data/vendor/eigen/Eigen/src/Core/arch/NEON/MathFunctions.h +91 -0
  152. data/vendor/eigen/Eigen/src/Core/arch/NEON/PacketMath.h +760 -0
  153. data/vendor/eigen/Eigen/src/Core/arch/SSE/Complex.h +471 -0
  154. data/vendor/eigen/Eigen/src/Core/arch/SSE/MathFunctions.h +562 -0
  155. data/vendor/eigen/Eigen/src/Core/arch/SSE/PacketMath.h +895 -0
  156. data/vendor/eigen/Eigen/src/Core/arch/SSE/TypeCasting.h +77 -0
  157. data/vendor/eigen/Eigen/src/Core/arch/ZVector/Complex.h +397 -0
  158. data/vendor/eigen/Eigen/src/Core/arch/ZVector/MathFunctions.h +137 -0
  159. data/vendor/eigen/Eigen/src/Core/arch/ZVector/PacketMath.h +945 -0
  160. data/vendor/eigen/Eigen/src/Core/functors/AssignmentFunctors.h +168 -0
  161. data/vendor/eigen/Eigen/src/Core/functors/BinaryFunctors.h +475 -0
  162. data/vendor/eigen/Eigen/src/Core/functors/NullaryFunctors.h +188 -0
  163. data/vendor/eigen/Eigen/src/Core/functors/StlFunctors.h +136 -0
  164. data/vendor/eigen/Eigen/src/Core/functors/TernaryFunctors.h +25 -0
  165. data/vendor/eigen/Eigen/src/Core/functors/UnaryFunctors.h +792 -0
  166. data/vendor/eigen/Eigen/src/Core/products/GeneralBlockPanelKernel.h +2156 -0
  167. data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixMatrix.h +492 -0
  168. data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h +311 -0
  169. data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_BLAS.h +145 -0
  170. data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixMatrix_BLAS.h +122 -0
  171. data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixVector.h +619 -0
  172. data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixVector_BLAS.h +136 -0
  173. data/vendor/eigen/Eigen/src/Core/products/Parallelizer.h +163 -0
  174. data/vendor/eigen/Eigen/src/Core/products/SelfadjointMatrixMatrix.h +521 -0
  175. data/vendor/eigen/Eigen/src/Core/products/SelfadjointMatrixMatrix_BLAS.h +287 -0
  176. data/vendor/eigen/Eigen/src/Core/products/SelfadjointMatrixVector.h +260 -0
  177. data/vendor/eigen/Eigen/src/Core/products/SelfadjointMatrixVector_BLAS.h +118 -0
  178. data/vendor/eigen/Eigen/src/Core/products/SelfadjointProduct.h +133 -0
  179. data/vendor/eigen/Eigen/src/Core/products/SelfadjointRank2Update.h +93 -0
  180. data/vendor/eigen/Eigen/src/Core/products/TriangularMatrixMatrix.h +466 -0
  181. data/vendor/eigen/Eigen/src/Core/products/TriangularMatrixMatrix_BLAS.h +315 -0
  182. data/vendor/eigen/Eigen/src/Core/products/TriangularMatrixVector.h +350 -0
  183. data/vendor/eigen/Eigen/src/Core/products/TriangularMatrixVector_BLAS.h +255 -0
  184. data/vendor/eigen/Eigen/src/Core/products/TriangularSolverMatrix.h +335 -0
  185. data/vendor/eigen/Eigen/src/Core/products/TriangularSolverMatrix_BLAS.h +163 -0
  186. data/vendor/eigen/Eigen/src/Core/products/TriangularSolverVector.h +145 -0
  187. data/vendor/eigen/Eigen/src/Core/util/BlasUtil.h +398 -0
  188. data/vendor/eigen/Eigen/src/Core/util/Constants.h +547 -0
  189. data/vendor/eigen/Eigen/src/Core/util/DisableStupidWarnings.h +83 -0
  190. data/vendor/eigen/Eigen/src/Core/util/ForwardDeclarations.h +302 -0
  191. data/vendor/eigen/Eigen/src/Core/util/MKL_support.h +130 -0
  192. data/vendor/eigen/Eigen/src/Core/util/Macros.h +1001 -0
  193. data/vendor/eigen/Eigen/src/Core/util/Memory.h +993 -0
  194. data/vendor/eigen/Eigen/src/Core/util/Meta.h +534 -0
  195. data/vendor/eigen/Eigen/src/Core/util/NonMPL2.h +3 -0
  196. data/vendor/eigen/Eigen/src/Core/util/ReenableStupidWarnings.h +27 -0
  197. data/vendor/eigen/Eigen/src/Core/util/StaticAssert.h +218 -0
  198. data/vendor/eigen/Eigen/src/Core/util/XprHelper.h +821 -0
  199. data/vendor/eigen/Eigen/src/Eigenvalues/ComplexEigenSolver.h +346 -0
  200. data/vendor/eigen/Eigen/src/Eigenvalues/ComplexSchur.h +459 -0
  201. data/vendor/eigen/Eigen/src/Eigenvalues/ComplexSchur_LAPACKE.h +91 -0
  202. data/vendor/eigen/Eigen/src/Eigenvalues/EigenSolver.h +622 -0
  203. data/vendor/eigen/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h +418 -0
  204. data/vendor/eigen/Eigen/src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h +226 -0
  205. data/vendor/eigen/Eigen/src/Eigenvalues/HessenbergDecomposition.h +374 -0
  206. data/vendor/eigen/Eigen/src/Eigenvalues/MatrixBaseEigenvalues.h +158 -0
  207. data/vendor/eigen/Eigen/src/Eigenvalues/RealQZ.h +654 -0
  208. data/vendor/eigen/Eigen/src/Eigenvalues/RealSchur.h +546 -0
  209. data/vendor/eigen/Eigen/src/Eigenvalues/RealSchur_LAPACKE.h +77 -0
  210. data/vendor/eigen/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h +870 -0
  211. data/vendor/eigen/Eigen/src/Eigenvalues/SelfAdjointEigenSolver_LAPACKE.h +87 -0
  212. data/vendor/eigen/Eigen/src/Eigenvalues/Tridiagonalization.h +556 -0
  213. data/vendor/eigen/Eigen/src/Geometry/AlignedBox.h +392 -0
  214. data/vendor/eigen/Eigen/src/Geometry/AngleAxis.h +247 -0
  215. data/vendor/eigen/Eigen/src/Geometry/EulerAngles.h +114 -0
  216. data/vendor/eigen/Eigen/src/Geometry/Homogeneous.h +497 -0
  217. data/vendor/eigen/Eigen/src/Geometry/Hyperplane.h +282 -0
  218. data/vendor/eigen/Eigen/src/Geometry/OrthoMethods.h +234 -0
  219. data/vendor/eigen/Eigen/src/Geometry/ParametrizedLine.h +195 -0
  220. data/vendor/eigen/Eigen/src/Geometry/Quaternion.h +814 -0
  221. data/vendor/eigen/Eigen/src/Geometry/Rotation2D.h +199 -0
  222. data/vendor/eigen/Eigen/src/Geometry/RotationBase.h +206 -0
  223. data/vendor/eigen/Eigen/src/Geometry/Scaling.h +170 -0
  224. data/vendor/eigen/Eigen/src/Geometry/Transform.h +1542 -0
  225. data/vendor/eigen/Eigen/src/Geometry/Translation.h +208 -0
  226. data/vendor/eigen/Eigen/src/Geometry/Umeyama.h +166 -0
  227. data/vendor/eigen/Eigen/src/Geometry/arch/Geometry_SSE.h +161 -0
  228. data/vendor/eigen/Eigen/src/Householder/BlockHouseholder.h +103 -0
  229. data/vendor/eigen/Eigen/src/Householder/Householder.h +172 -0
  230. data/vendor/eigen/Eigen/src/Householder/HouseholderSequence.h +470 -0
  231. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h +226 -0
  232. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h +228 -0
  233. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h +246 -0
  234. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/IncompleteCholesky.h +400 -0
  235. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h +462 -0
  236. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h +394 -0
  237. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/LeastSquareConjugateGradient.h +216 -0
  238. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/SolveWithGuess.h +115 -0
  239. data/vendor/eigen/Eigen/src/Jacobi/Jacobi.h +462 -0
  240. data/vendor/eigen/Eigen/src/LU/Determinant.h +101 -0
  241. data/vendor/eigen/Eigen/src/LU/FullPivLU.h +891 -0
  242. data/vendor/eigen/Eigen/src/LU/InverseImpl.h +415 -0
  243. data/vendor/eigen/Eigen/src/LU/PartialPivLU.h +611 -0
  244. data/vendor/eigen/Eigen/src/LU/PartialPivLU_LAPACKE.h +83 -0
  245. data/vendor/eigen/Eigen/src/LU/arch/Inverse_SSE.h +338 -0
  246. data/vendor/eigen/Eigen/src/MetisSupport/MetisSupport.h +137 -0
  247. data/vendor/eigen/Eigen/src/OrderingMethods/Amd.h +445 -0
  248. data/vendor/eigen/Eigen/src/OrderingMethods/Eigen_Colamd.h +1843 -0
  249. data/vendor/eigen/Eigen/src/OrderingMethods/Ordering.h +157 -0
  250. data/vendor/eigen/Eigen/src/PaStiXSupport/PaStiXSupport.h +678 -0
  251. data/vendor/eigen/Eigen/src/PardisoSupport/PardisoSupport.h +543 -0
  252. data/vendor/eigen/Eigen/src/QR/ColPivHouseholderQR.h +653 -0
  253. data/vendor/eigen/Eigen/src/QR/ColPivHouseholderQR_LAPACKE.h +97 -0
  254. data/vendor/eigen/Eigen/src/QR/CompleteOrthogonalDecomposition.h +562 -0
  255. data/vendor/eigen/Eigen/src/QR/FullPivHouseholderQR.h +676 -0
  256. data/vendor/eigen/Eigen/src/QR/HouseholderQR.h +409 -0
  257. data/vendor/eigen/Eigen/src/QR/HouseholderQR_LAPACKE.h +68 -0
  258. data/vendor/eigen/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h +313 -0
  259. data/vendor/eigen/Eigen/src/SVD/BDCSVD.h +1246 -0
  260. data/vendor/eigen/Eigen/src/SVD/JacobiSVD.h +804 -0
  261. data/vendor/eigen/Eigen/src/SVD/JacobiSVD_LAPACKE.h +91 -0
  262. data/vendor/eigen/Eigen/src/SVD/SVDBase.h +315 -0
  263. data/vendor/eigen/Eigen/src/SVD/UpperBidiagonalization.h +414 -0
  264. data/vendor/eigen/Eigen/src/SparseCholesky/SimplicialCholesky.h +689 -0
  265. data/vendor/eigen/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h +199 -0
  266. data/vendor/eigen/Eigen/src/SparseCore/AmbiVector.h +377 -0
  267. data/vendor/eigen/Eigen/src/SparseCore/CompressedStorage.h +258 -0
  268. data/vendor/eigen/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h +352 -0
  269. data/vendor/eigen/Eigen/src/SparseCore/MappedSparseMatrix.h +67 -0
  270. data/vendor/eigen/Eigen/src/SparseCore/SparseAssign.h +216 -0
  271. data/vendor/eigen/Eigen/src/SparseCore/SparseBlock.h +603 -0
  272. data/vendor/eigen/Eigen/src/SparseCore/SparseColEtree.h +206 -0
  273. data/vendor/eigen/Eigen/src/SparseCore/SparseCompressedBase.h +341 -0
  274. data/vendor/eigen/Eigen/src/SparseCore/SparseCwiseBinaryOp.h +726 -0
  275. data/vendor/eigen/Eigen/src/SparseCore/SparseCwiseUnaryOp.h +148 -0
  276. data/vendor/eigen/Eigen/src/SparseCore/SparseDenseProduct.h +320 -0
  277. data/vendor/eigen/Eigen/src/SparseCore/SparseDiagonalProduct.h +138 -0
  278. data/vendor/eigen/Eigen/src/SparseCore/SparseDot.h +98 -0
  279. data/vendor/eigen/Eigen/src/SparseCore/SparseFuzzy.h +29 -0
  280. data/vendor/eigen/Eigen/src/SparseCore/SparseMap.h +305 -0
  281. data/vendor/eigen/Eigen/src/SparseCore/SparseMatrix.h +1403 -0
  282. data/vendor/eigen/Eigen/src/SparseCore/SparseMatrixBase.h +405 -0
  283. data/vendor/eigen/Eigen/src/SparseCore/SparsePermutation.h +178 -0
  284. data/vendor/eigen/Eigen/src/SparseCore/SparseProduct.h +169 -0
  285. data/vendor/eigen/Eigen/src/SparseCore/SparseRedux.h +49 -0
  286. data/vendor/eigen/Eigen/src/SparseCore/SparseRef.h +397 -0
  287. data/vendor/eigen/Eigen/src/SparseCore/SparseSelfAdjointView.h +656 -0
  288. data/vendor/eigen/Eigen/src/SparseCore/SparseSolverBase.h +124 -0
  289. data/vendor/eigen/Eigen/src/SparseCore/SparseSparseProductWithPruning.h +198 -0
  290. data/vendor/eigen/Eigen/src/SparseCore/SparseTranspose.h +92 -0
  291. data/vendor/eigen/Eigen/src/SparseCore/SparseTriangularView.h +189 -0
  292. data/vendor/eigen/Eigen/src/SparseCore/SparseUtil.h +178 -0
  293. data/vendor/eigen/Eigen/src/SparseCore/SparseVector.h +478 -0
  294. data/vendor/eigen/Eigen/src/SparseCore/SparseView.h +253 -0
  295. data/vendor/eigen/Eigen/src/SparseCore/TriangularSolver.h +315 -0
  296. data/vendor/eigen/Eigen/src/SparseLU/SparseLU.h +773 -0
  297. data/vendor/eigen/Eigen/src/SparseLU/SparseLUImpl.h +66 -0
  298. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_Memory.h +226 -0
  299. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_Structs.h +110 -0
  300. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h +301 -0
  301. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_Utils.h +80 -0
  302. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_column_bmod.h +181 -0
  303. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_column_dfs.h +179 -0
  304. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h +107 -0
  305. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_gemm_kernel.h +280 -0
  306. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h +126 -0
  307. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_kernel_bmod.h +130 -0
  308. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_panel_bmod.h +223 -0
  309. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_panel_dfs.h +258 -0
  310. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_pivotL.h +137 -0
  311. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_pruneL.h +136 -0
  312. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_relax_snode.h +83 -0
  313. data/vendor/eigen/Eigen/src/SparseQR/SparseQR.h +745 -0
  314. data/vendor/eigen/Eigen/src/StlSupport/StdDeque.h +126 -0
  315. data/vendor/eigen/Eigen/src/StlSupport/StdList.h +106 -0
  316. data/vendor/eigen/Eigen/src/StlSupport/StdVector.h +131 -0
  317. data/vendor/eigen/Eigen/src/StlSupport/details.h +84 -0
  318. data/vendor/eigen/Eigen/src/SuperLUSupport/SuperLUSupport.h +1027 -0
  319. data/vendor/eigen/Eigen/src/UmfPackSupport/UmfPackSupport.h +506 -0
  320. data/vendor/eigen/Eigen/src/misc/Image.h +82 -0
  321. data/vendor/eigen/Eigen/src/misc/Kernel.h +79 -0
  322. data/vendor/eigen/Eigen/src/misc/RealSvd2x2.h +55 -0
  323. data/vendor/eigen/Eigen/src/misc/blas.h +440 -0
  324. data/vendor/eigen/Eigen/src/misc/lapack.h +152 -0
  325. data/vendor/eigen/Eigen/src/misc/lapacke.h +16291 -0
  326. data/vendor/eigen/Eigen/src/misc/lapacke_mangling.h +17 -0
  327. data/vendor/eigen/Eigen/src/plugins/ArrayCwiseBinaryOps.h +332 -0
  328. data/vendor/eigen/Eigen/src/plugins/ArrayCwiseUnaryOps.h +552 -0
  329. data/vendor/eigen/Eigen/src/plugins/BlockMethods.h +1058 -0
  330. data/vendor/eigen/Eigen/src/plugins/CommonCwiseBinaryOps.h +115 -0
  331. data/vendor/eigen/Eigen/src/plugins/CommonCwiseUnaryOps.h +163 -0
  332. data/vendor/eigen/Eigen/src/plugins/MatrixCwiseBinaryOps.h +152 -0
  333. data/vendor/eigen/Eigen/src/plugins/MatrixCwiseUnaryOps.h +85 -0
  334. data/vendor/eigen/README.md +3 -0
  335. data/vendor/eigen/bench/README.txt +55 -0
  336. data/vendor/eigen/bench/btl/COPYING +340 -0
  337. data/vendor/eigen/bench/btl/README +154 -0
  338. data/vendor/eigen/bench/tensors/README +21 -0
  339. data/vendor/eigen/blas/README.txt +6 -0
  340. data/vendor/eigen/demos/mandelbrot/README +10 -0
  341. data/vendor/eigen/demos/mix_eigen_and_c/README +9 -0
  342. data/vendor/eigen/demos/opengl/README +13 -0
  343. data/vendor/eigen/unsupported/Eigen/CXX11/src/Tensor/README.md +1760 -0
  344. data/vendor/eigen/unsupported/README.txt +50 -0
  345. data/vendor/tomotopy/LICENSE +21 -0
  346. data/vendor/tomotopy/README.kr.rst +375 -0
  347. data/vendor/tomotopy/README.rst +382 -0
  348. data/vendor/tomotopy/src/Labeling/FoRelevance.cpp +362 -0
  349. data/vendor/tomotopy/src/Labeling/FoRelevance.h +88 -0
  350. data/vendor/tomotopy/src/Labeling/Labeler.h +50 -0
  351. data/vendor/tomotopy/src/TopicModel/CT.h +37 -0
  352. data/vendor/tomotopy/src/TopicModel/CTModel.cpp +13 -0
  353. data/vendor/tomotopy/src/TopicModel/CTModel.hpp +293 -0
  354. data/vendor/tomotopy/src/TopicModel/DMR.h +51 -0
  355. data/vendor/tomotopy/src/TopicModel/DMRModel.cpp +13 -0
  356. data/vendor/tomotopy/src/TopicModel/DMRModel.hpp +374 -0
  357. data/vendor/tomotopy/src/TopicModel/DT.h +65 -0
  358. data/vendor/tomotopy/src/TopicModel/DTM.h +22 -0
  359. data/vendor/tomotopy/src/TopicModel/DTModel.cpp +15 -0
  360. data/vendor/tomotopy/src/TopicModel/DTModel.hpp +572 -0
  361. data/vendor/tomotopy/src/TopicModel/GDMR.h +37 -0
  362. data/vendor/tomotopy/src/TopicModel/GDMRModel.cpp +14 -0
  363. data/vendor/tomotopy/src/TopicModel/GDMRModel.hpp +485 -0
  364. data/vendor/tomotopy/src/TopicModel/HDP.h +74 -0
  365. data/vendor/tomotopy/src/TopicModel/HDPModel.cpp +13 -0
  366. data/vendor/tomotopy/src/TopicModel/HDPModel.hpp +592 -0
  367. data/vendor/tomotopy/src/TopicModel/HLDA.h +40 -0
  368. data/vendor/tomotopy/src/TopicModel/HLDAModel.cpp +13 -0
  369. data/vendor/tomotopy/src/TopicModel/HLDAModel.hpp +681 -0
  370. data/vendor/tomotopy/src/TopicModel/HPA.h +27 -0
  371. data/vendor/tomotopy/src/TopicModel/HPAModel.cpp +21 -0
  372. data/vendor/tomotopy/src/TopicModel/HPAModel.hpp +588 -0
  373. data/vendor/tomotopy/src/TopicModel/LDA.h +144 -0
  374. data/vendor/tomotopy/src/TopicModel/LDACVB0Model.hpp +442 -0
  375. data/vendor/tomotopy/src/TopicModel/LDAModel.cpp +13 -0
  376. data/vendor/tomotopy/src/TopicModel/LDAModel.hpp +1058 -0
  377. data/vendor/tomotopy/src/TopicModel/LLDA.h +45 -0
  378. data/vendor/tomotopy/src/TopicModel/LLDAModel.cpp +13 -0
  379. data/vendor/tomotopy/src/TopicModel/LLDAModel.hpp +203 -0
  380. data/vendor/tomotopy/src/TopicModel/MGLDA.h +63 -0
  381. data/vendor/tomotopy/src/TopicModel/MGLDAModel.cpp +17 -0
  382. data/vendor/tomotopy/src/TopicModel/MGLDAModel.hpp +558 -0
  383. data/vendor/tomotopy/src/TopicModel/PA.h +43 -0
  384. data/vendor/tomotopy/src/TopicModel/PAModel.cpp +13 -0
  385. data/vendor/tomotopy/src/TopicModel/PAModel.hpp +467 -0
  386. data/vendor/tomotopy/src/TopicModel/PLDA.h +17 -0
  387. data/vendor/tomotopy/src/TopicModel/PLDAModel.cpp +13 -0
  388. data/vendor/tomotopy/src/TopicModel/PLDAModel.hpp +214 -0
  389. data/vendor/tomotopy/src/TopicModel/SLDA.h +54 -0
  390. data/vendor/tomotopy/src/TopicModel/SLDAModel.cpp +17 -0
  391. data/vendor/tomotopy/src/TopicModel/SLDAModel.hpp +456 -0
  392. data/vendor/tomotopy/src/TopicModel/TopicModel.hpp +692 -0
  393. data/vendor/tomotopy/src/Utils/AliasMethod.hpp +169 -0
  394. data/vendor/tomotopy/src/Utils/Dictionary.h +80 -0
  395. data/vendor/tomotopy/src/Utils/EigenAddonOps.hpp +181 -0
  396. data/vendor/tomotopy/src/Utils/LBFGS.h +202 -0
  397. data/vendor/tomotopy/src/Utils/LBFGS/LineSearchBacktracking.h +120 -0
  398. data/vendor/tomotopy/src/Utils/LBFGS/LineSearchBracketing.h +122 -0
  399. data/vendor/tomotopy/src/Utils/LBFGS/Param.h +213 -0
  400. data/vendor/tomotopy/src/Utils/LUT.hpp +82 -0
  401. data/vendor/tomotopy/src/Utils/MultiNormalDistribution.hpp +69 -0
  402. data/vendor/tomotopy/src/Utils/PolyaGamma.hpp +200 -0
  403. data/vendor/tomotopy/src/Utils/PolyaGammaHybrid.hpp +672 -0
  404. data/vendor/tomotopy/src/Utils/ThreadPool.hpp +150 -0
  405. data/vendor/tomotopy/src/Utils/Trie.hpp +220 -0
  406. data/vendor/tomotopy/src/Utils/TruncMultiNormal.hpp +94 -0
  407. data/vendor/tomotopy/src/Utils/Utils.hpp +337 -0
  408. data/vendor/tomotopy/src/Utils/avx_gamma.h +46 -0
  409. data/vendor/tomotopy/src/Utils/avx_mathfun.h +736 -0
  410. data/vendor/tomotopy/src/Utils/exception.h +28 -0
  411. data/vendor/tomotopy/src/Utils/math.h +281 -0
  412. data/vendor/tomotopy/src/Utils/rtnorm.hpp +2690 -0
  413. data/vendor/tomotopy/src/Utils/sample.hpp +192 -0
  414. data/vendor/tomotopy/src/Utils/serializer.hpp +695 -0
  415. data/vendor/tomotopy/src/Utils/slp.hpp +131 -0
  416. data/vendor/tomotopy/src/Utils/sse_gamma.h +48 -0
  417. data/vendor/tomotopy/src/Utils/sse_mathfun.h +710 -0
  418. data/vendor/tomotopy/src/Utils/text.hpp +49 -0
  419. data/vendor/tomotopy/src/Utils/tvector.hpp +543 -0
  420. metadata +531 -0
@@ -0,0 +1,407 @@
1
+ // This file is part of Eigen, a lightweight C++ template library
2
+ // for linear algebra.
3
+ //
4
+ // Copyright (C) 2010-2011 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_TRANSPOSITIONS_H
11
+ #define EIGEN_TRANSPOSITIONS_H
12
+
13
+ namespace Eigen {
14
+
15
+ template<typename Derived>
16
+ class TranspositionsBase
17
+ {
18
+ typedef internal::traits<Derived> Traits;
19
+
20
+ public:
21
+
22
+ typedef typename Traits::IndicesType IndicesType;
23
+ typedef typename IndicesType::Scalar StorageIndex;
24
+ typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3
25
+
26
+ Derived& derived() { return *static_cast<Derived*>(this); }
27
+ const Derived& derived() const { return *static_cast<const Derived*>(this); }
28
+
29
+ /** Copies the \a other transpositions into \c *this */
30
+ template<typename OtherDerived>
31
+ Derived& operator=(const TranspositionsBase<OtherDerived>& other)
32
+ {
33
+ indices() = other.indices();
34
+ return derived();
35
+ }
36
+
37
+ #ifndef EIGEN_PARSED_BY_DOXYGEN
38
+ /** This is a special case of the templated operator=. Its purpose is to
39
+ * prevent a default operator= from hiding the templated operator=.
40
+ */
41
+ Derived& operator=(const TranspositionsBase& other)
42
+ {
43
+ indices() = other.indices();
44
+ return derived();
45
+ }
46
+ #endif
47
+
48
+ /** \returns the number of transpositions */
49
+ Index size() const { return indices().size(); }
50
+ /** \returns the number of rows of the equivalent permutation matrix */
51
+ Index rows() const { return indices().size(); }
52
+ /** \returns the number of columns of the equivalent permutation matrix */
53
+ Index cols() const { return indices().size(); }
54
+
55
+ /** Direct access to the underlying index vector */
56
+ inline const StorageIndex& coeff(Index i) const { return indices().coeff(i); }
57
+ /** Direct access to the underlying index vector */
58
+ inline StorageIndex& coeffRef(Index i) { return indices().coeffRef(i); }
59
+ /** Direct access to the underlying index vector */
60
+ inline const StorageIndex& operator()(Index i) const { return indices()(i); }
61
+ /** Direct access to the underlying index vector */
62
+ inline StorageIndex& operator()(Index i) { return indices()(i); }
63
+ /** Direct access to the underlying index vector */
64
+ inline const StorageIndex& operator[](Index i) const { return indices()(i); }
65
+ /** Direct access to the underlying index vector */
66
+ inline StorageIndex& operator[](Index i) { return indices()(i); }
67
+
68
+ /** const version of indices(). */
69
+ const IndicesType& indices() const { return derived().indices(); }
70
+ /** \returns a reference to the stored array representing the transpositions. */
71
+ IndicesType& indices() { return derived().indices(); }
72
+
73
+ /** Resizes to given size. */
74
+ inline void resize(Index newSize)
75
+ {
76
+ indices().resize(newSize);
77
+ }
78
+
79
+ /** Sets \c *this to represents an identity transformation */
80
+ void setIdentity()
81
+ {
82
+ for(StorageIndex i = 0; i < indices().size(); ++i)
83
+ coeffRef(i) = i;
84
+ }
85
+
86
+ // FIXME: do we want such methods ?
87
+ // might be usefull when the target matrix expression is complex, e.g.:
88
+ // object.matrix().block(..,..,..,..) = trans * object.matrix().block(..,..,..,..);
89
+ /*
90
+ template<typename MatrixType>
91
+ void applyForwardToRows(MatrixType& mat) const
92
+ {
93
+ for(Index k=0 ; k<size() ; ++k)
94
+ if(m_indices(k)!=k)
95
+ mat.row(k).swap(mat.row(m_indices(k)));
96
+ }
97
+
98
+ template<typename MatrixType>
99
+ void applyBackwardToRows(MatrixType& mat) const
100
+ {
101
+ for(Index k=size()-1 ; k>=0 ; --k)
102
+ if(m_indices(k)!=k)
103
+ mat.row(k).swap(mat.row(m_indices(k)));
104
+ }
105
+ */
106
+
107
+ /** \returns the inverse transformation */
108
+ inline Transpose<TranspositionsBase> inverse() const
109
+ { return Transpose<TranspositionsBase>(derived()); }
110
+
111
+ /** \returns the tranpose transformation */
112
+ inline Transpose<TranspositionsBase> transpose() const
113
+ { return Transpose<TranspositionsBase>(derived()); }
114
+
115
+ protected:
116
+ };
117
+
118
+ namespace internal {
119
+ template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndex>
120
+ struct traits<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex> >
121
+ : traits<PermutationMatrix<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex> >
122
+ {
123
+ typedef Matrix<_StorageIndex, SizeAtCompileTime, 1, 0, MaxSizeAtCompileTime, 1> IndicesType;
124
+ typedef TranspositionsStorage StorageKind;
125
+ };
126
+ }
127
+
128
+ /** \class Transpositions
129
+ * \ingroup Core_Module
130
+ *
131
+ * \brief Represents a sequence of transpositions (row/column interchange)
132
+ *
133
+ * \tparam SizeAtCompileTime the number of transpositions, or Dynamic
134
+ * \tparam MaxSizeAtCompileTime the maximum number of transpositions, or Dynamic. This optional parameter defaults to SizeAtCompileTime. Most of the time, you should not have to specify it.
135
+ *
136
+ * This class represents a permutation transformation as a sequence of \em n transpositions
137
+ * \f$[T_{n-1} \ldots T_{i} \ldots T_{0}]\f$. It is internally stored as a vector of integers \c indices.
138
+ * Each transposition \f$ T_{i} \f$ applied on the left of a matrix (\f$ T_{i} M\f$) interchanges
139
+ * the rows \c i and \c indices[i] of the matrix \c M.
140
+ * A transposition applied on the right (e.g., \f$ M T_{i}\f$) yields a column interchange.
141
+ *
142
+ * Compared to the class PermutationMatrix, such a sequence of transpositions is what is
143
+ * computed during a decomposition with pivoting, and it is faster when applying the permutation in-place.
144
+ *
145
+ * To apply a sequence of transpositions to a matrix, simply use the operator * as in the following example:
146
+ * \code
147
+ * Transpositions tr;
148
+ * MatrixXf mat;
149
+ * mat = tr * mat;
150
+ * \endcode
151
+ * In this example, we detect that the matrix appears on both side, and so the transpositions
152
+ * are applied in-place without any temporary or extra copy.
153
+ *
154
+ * \sa class PermutationMatrix
155
+ */
156
+
157
+ template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndex>
158
+ class Transpositions : public TranspositionsBase<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex> >
159
+ {
160
+ typedef internal::traits<Transpositions> Traits;
161
+ public:
162
+
163
+ typedef TranspositionsBase<Transpositions> Base;
164
+ typedef typename Traits::IndicesType IndicesType;
165
+ typedef typename IndicesType::Scalar StorageIndex;
166
+
167
+ inline Transpositions() {}
168
+
169
+ /** Copy constructor. */
170
+ template<typename OtherDerived>
171
+ inline Transpositions(const TranspositionsBase<OtherDerived>& other)
172
+ : m_indices(other.indices()) {}
173
+
174
+ #ifndef EIGEN_PARSED_BY_DOXYGEN
175
+ /** Standard copy constructor. Defined only to prevent a default copy constructor
176
+ * from hiding the other templated constructor */
177
+ inline Transpositions(const Transpositions& other) : m_indices(other.indices()) {}
178
+ #endif
179
+
180
+ /** Generic constructor from expression of the transposition indices. */
181
+ template<typename Other>
182
+ explicit inline Transpositions(const MatrixBase<Other>& indices) : m_indices(indices)
183
+ {}
184
+
185
+ /** Copies the \a other transpositions into \c *this */
186
+ template<typename OtherDerived>
187
+ Transpositions& operator=(const TranspositionsBase<OtherDerived>& other)
188
+ {
189
+ return Base::operator=(other);
190
+ }
191
+
192
+ #ifndef EIGEN_PARSED_BY_DOXYGEN
193
+ /** This is a special case of the templated operator=. Its purpose is to
194
+ * prevent a default operator= from hiding the templated operator=.
195
+ */
196
+ Transpositions& operator=(const Transpositions& other)
197
+ {
198
+ m_indices = other.m_indices;
199
+ return *this;
200
+ }
201
+ #endif
202
+
203
+ /** Constructs an uninitialized permutation matrix of given size.
204
+ */
205
+ inline Transpositions(Index size) : m_indices(size)
206
+ {}
207
+
208
+ /** const version of indices(). */
209
+ const IndicesType& indices() const { return m_indices; }
210
+ /** \returns a reference to the stored array representing the transpositions. */
211
+ IndicesType& indices() { return m_indices; }
212
+
213
+ protected:
214
+
215
+ IndicesType m_indices;
216
+ };
217
+
218
+
219
+ namespace internal {
220
+ template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndex, int _PacketAccess>
221
+ struct traits<Map<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex>,_PacketAccess> >
222
+ : traits<PermutationMatrix<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex> >
223
+ {
224
+ typedef Map<const Matrix<_StorageIndex,SizeAtCompileTime,1,0,MaxSizeAtCompileTime,1>, _PacketAccess> IndicesType;
225
+ typedef _StorageIndex StorageIndex;
226
+ typedef TranspositionsStorage StorageKind;
227
+ };
228
+ }
229
+
230
+ template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndex, int PacketAccess>
231
+ class Map<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex>,PacketAccess>
232
+ : public TranspositionsBase<Map<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex>,PacketAccess> >
233
+ {
234
+ typedef internal::traits<Map> Traits;
235
+ public:
236
+
237
+ typedef TranspositionsBase<Map> Base;
238
+ typedef typename Traits::IndicesType IndicesType;
239
+ typedef typename IndicesType::Scalar StorageIndex;
240
+
241
+ explicit inline Map(const StorageIndex* indicesPtr)
242
+ : m_indices(indicesPtr)
243
+ {}
244
+
245
+ inline Map(const StorageIndex* indicesPtr, Index size)
246
+ : m_indices(indicesPtr,size)
247
+ {}
248
+
249
+ /** Copies the \a other transpositions into \c *this */
250
+ template<typename OtherDerived>
251
+ Map& operator=(const TranspositionsBase<OtherDerived>& other)
252
+ {
253
+ return Base::operator=(other);
254
+ }
255
+
256
+ #ifndef EIGEN_PARSED_BY_DOXYGEN
257
+ /** This is a special case of the templated operator=. Its purpose is to
258
+ * prevent a default operator= from hiding the templated operator=.
259
+ */
260
+ Map& operator=(const Map& other)
261
+ {
262
+ m_indices = other.m_indices;
263
+ return *this;
264
+ }
265
+ #endif
266
+
267
+ /** const version of indices(). */
268
+ const IndicesType& indices() const { return m_indices; }
269
+
270
+ /** \returns a reference to the stored array representing the transpositions. */
271
+ IndicesType& indices() { return m_indices; }
272
+
273
+ protected:
274
+
275
+ IndicesType m_indices;
276
+ };
277
+
278
+ namespace internal {
279
+ template<typename _IndicesType>
280
+ struct traits<TranspositionsWrapper<_IndicesType> >
281
+ : traits<PermutationWrapper<_IndicesType> >
282
+ {
283
+ typedef TranspositionsStorage StorageKind;
284
+ };
285
+ }
286
+
287
+ template<typename _IndicesType>
288
+ class TranspositionsWrapper
289
+ : public TranspositionsBase<TranspositionsWrapper<_IndicesType> >
290
+ {
291
+ typedef internal::traits<TranspositionsWrapper> Traits;
292
+ public:
293
+
294
+ typedef TranspositionsBase<TranspositionsWrapper> Base;
295
+ typedef typename Traits::IndicesType IndicesType;
296
+ typedef typename IndicesType::Scalar StorageIndex;
297
+
298
+ explicit inline TranspositionsWrapper(IndicesType& indices)
299
+ : m_indices(indices)
300
+ {}
301
+
302
+ /** Copies the \a other transpositions into \c *this */
303
+ template<typename OtherDerived>
304
+ TranspositionsWrapper& operator=(const TranspositionsBase<OtherDerived>& other)
305
+ {
306
+ return Base::operator=(other);
307
+ }
308
+
309
+ #ifndef EIGEN_PARSED_BY_DOXYGEN
310
+ /** This is a special case of the templated operator=. Its purpose is to
311
+ * prevent a default operator= from hiding the templated operator=.
312
+ */
313
+ TranspositionsWrapper& operator=(const TranspositionsWrapper& other)
314
+ {
315
+ m_indices = other.m_indices;
316
+ return *this;
317
+ }
318
+ #endif
319
+
320
+ /** const version of indices(). */
321
+ const IndicesType& indices() const { return m_indices; }
322
+
323
+ /** \returns a reference to the stored array representing the transpositions. */
324
+ IndicesType& indices() { return m_indices; }
325
+
326
+ protected:
327
+
328
+ typename IndicesType::Nested m_indices;
329
+ };
330
+
331
+
332
+
333
+ /** \returns the \a matrix with the \a transpositions applied to the columns.
334
+ */
335
+ template<typename MatrixDerived, typename TranspositionsDerived>
336
+ EIGEN_DEVICE_FUNC
337
+ const Product<MatrixDerived, TranspositionsDerived, AliasFreeProduct>
338
+ operator*(const MatrixBase<MatrixDerived> &matrix,
339
+ const TranspositionsBase<TranspositionsDerived>& transpositions)
340
+ {
341
+ return Product<MatrixDerived, TranspositionsDerived, AliasFreeProduct>
342
+ (matrix.derived(), transpositions.derived());
343
+ }
344
+
345
+ /** \returns the \a matrix with the \a transpositions applied to the rows.
346
+ */
347
+ template<typename TranspositionsDerived, typename MatrixDerived>
348
+ EIGEN_DEVICE_FUNC
349
+ const Product<TranspositionsDerived, MatrixDerived, AliasFreeProduct>
350
+ operator*(const TranspositionsBase<TranspositionsDerived> &transpositions,
351
+ const MatrixBase<MatrixDerived>& matrix)
352
+ {
353
+ return Product<TranspositionsDerived, MatrixDerived, AliasFreeProduct>
354
+ (transpositions.derived(), matrix.derived());
355
+ }
356
+
357
+ // Template partial specialization for transposed/inverse transpositions
358
+
359
+ namespace internal {
360
+
361
+ template<typename Derived>
362
+ struct traits<Transpose<TranspositionsBase<Derived> > >
363
+ : traits<Derived>
364
+ {};
365
+
366
+ } // end namespace internal
367
+
368
+ template<typename TranspositionsDerived>
369
+ class Transpose<TranspositionsBase<TranspositionsDerived> >
370
+ {
371
+ typedef TranspositionsDerived TranspositionType;
372
+ typedef typename TranspositionType::IndicesType IndicesType;
373
+ public:
374
+
375
+ explicit Transpose(const TranspositionType& t) : m_transpositions(t) {}
376
+
377
+ Index size() const { return m_transpositions.size(); }
378
+ Index rows() const { return m_transpositions.size(); }
379
+ Index cols() const { return m_transpositions.size(); }
380
+
381
+ /** \returns the \a matrix with the inverse transpositions applied to the columns.
382
+ */
383
+ template<typename OtherDerived> friend
384
+ const Product<OtherDerived, Transpose, AliasFreeProduct>
385
+ operator*(const MatrixBase<OtherDerived>& matrix, const Transpose& trt)
386
+ {
387
+ return Product<OtherDerived, Transpose, AliasFreeProduct>(matrix.derived(), trt);
388
+ }
389
+
390
+ /** \returns the \a matrix with the inverse transpositions applied to the rows.
391
+ */
392
+ template<typename OtherDerived>
393
+ const Product<Transpose, OtherDerived, AliasFreeProduct>
394
+ operator*(const MatrixBase<OtherDerived>& matrix) const
395
+ {
396
+ return Product<Transpose, OtherDerived, AliasFreeProduct>(*this, matrix.derived());
397
+ }
398
+
399
+ const TranspositionType& nestedExpression() const { return m_transpositions; }
400
+
401
+ protected:
402
+ const TranspositionType& m_transpositions;
403
+ };
404
+
405
+ } // end namespace Eigen
406
+
407
+ #endif // EIGEN_TRANSPOSITIONS_H
@@ -0,0 +1,983 @@
1
+ // This file is part of Eigen, a lightweight C++ template library
2
+ // for linear algebra.
3
+ //
4
+ // Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>
5
+ // Copyright (C) 2008-2009 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_TRIANGULARMATRIX_H
12
+ #define EIGEN_TRIANGULARMATRIX_H
13
+
14
+ namespace Eigen {
15
+
16
+ namespace internal {
17
+
18
+ template<int Side, typename TriangularType, typename Rhs> struct triangular_solve_retval;
19
+
20
+ }
21
+
22
+ /** \class TriangularBase
23
+ * \ingroup Core_Module
24
+ *
25
+ * \brief Base class for triangular part in a matrix
26
+ */
27
+ template<typename Derived> class TriangularBase : public EigenBase<Derived>
28
+ {
29
+ public:
30
+
31
+ enum {
32
+ Mode = internal::traits<Derived>::Mode,
33
+ RowsAtCompileTime = internal::traits<Derived>::RowsAtCompileTime,
34
+ ColsAtCompileTime = internal::traits<Derived>::ColsAtCompileTime,
35
+ MaxRowsAtCompileTime = internal::traits<Derived>::MaxRowsAtCompileTime,
36
+ MaxColsAtCompileTime = internal::traits<Derived>::MaxColsAtCompileTime,
37
+
38
+ SizeAtCompileTime = (internal::size_at_compile_time<internal::traits<Derived>::RowsAtCompileTime,
39
+ internal::traits<Derived>::ColsAtCompileTime>::ret),
40
+ /**< This is equal to the number of coefficients, i.e. the number of
41
+ * rows times the number of columns, or to \a Dynamic if this is not
42
+ * known at compile-time. \sa RowsAtCompileTime, ColsAtCompileTime */
43
+
44
+ MaxSizeAtCompileTime = (internal::size_at_compile_time<internal::traits<Derived>::MaxRowsAtCompileTime,
45
+ internal::traits<Derived>::MaxColsAtCompileTime>::ret)
46
+
47
+ };
48
+ typedef typename internal::traits<Derived>::Scalar Scalar;
49
+ typedef typename internal::traits<Derived>::StorageKind StorageKind;
50
+ typedef typename internal::traits<Derived>::StorageIndex StorageIndex;
51
+ typedef typename internal::traits<Derived>::FullMatrixType DenseMatrixType;
52
+ typedef DenseMatrixType DenseType;
53
+ typedef Derived const& Nested;
54
+
55
+ EIGEN_DEVICE_FUNC
56
+ inline TriangularBase() { eigen_assert(!((Mode&UnitDiag) && (Mode&ZeroDiag))); }
57
+
58
+ EIGEN_DEVICE_FUNC
59
+ inline Index rows() const { return derived().rows(); }
60
+ EIGEN_DEVICE_FUNC
61
+ inline Index cols() const { return derived().cols(); }
62
+ EIGEN_DEVICE_FUNC
63
+ inline Index outerStride() const { return derived().outerStride(); }
64
+ EIGEN_DEVICE_FUNC
65
+ inline Index innerStride() const { return derived().innerStride(); }
66
+
67
+ // dummy resize function
68
+ void resize(Index rows, Index cols)
69
+ {
70
+ EIGEN_UNUSED_VARIABLE(rows);
71
+ EIGEN_UNUSED_VARIABLE(cols);
72
+ eigen_assert(rows==this->rows() && cols==this->cols());
73
+ }
74
+
75
+ EIGEN_DEVICE_FUNC
76
+ inline Scalar coeff(Index row, Index col) const { return derived().coeff(row,col); }
77
+ EIGEN_DEVICE_FUNC
78
+ inline Scalar& coeffRef(Index row, Index col) { return derived().coeffRef(row,col); }
79
+
80
+ /** \see MatrixBase::copyCoeff(row,col)
81
+ */
82
+ template<typename Other>
83
+ EIGEN_DEVICE_FUNC
84
+ EIGEN_STRONG_INLINE void copyCoeff(Index row, Index col, Other& other)
85
+ {
86
+ derived().coeffRef(row, col) = other.coeff(row, col);
87
+ }
88
+
89
+ EIGEN_DEVICE_FUNC
90
+ inline Scalar operator()(Index row, Index col) const
91
+ {
92
+ check_coordinates(row, col);
93
+ return coeff(row,col);
94
+ }
95
+ EIGEN_DEVICE_FUNC
96
+ inline Scalar& operator()(Index row, Index col)
97
+ {
98
+ check_coordinates(row, col);
99
+ return coeffRef(row,col);
100
+ }
101
+
102
+ #ifndef EIGEN_PARSED_BY_DOXYGEN
103
+ EIGEN_DEVICE_FUNC
104
+ inline const Derived& derived() const { return *static_cast<const Derived*>(this); }
105
+ EIGEN_DEVICE_FUNC
106
+ inline Derived& derived() { return *static_cast<Derived*>(this); }
107
+ #endif // not EIGEN_PARSED_BY_DOXYGEN
108
+
109
+ template<typename DenseDerived>
110
+ EIGEN_DEVICE_FUNC
111
+ void evalTo(MatrixBase<DenseDerived> &other) const;
112
+ template<typename DenseDerived>
113
+ EIGEN_DEVICE_FUNC
114
+ void evalToLazy(MatrixBase<DenseDerived> &other) const;
115
+
116
+ EIGEN_DEVICE_FUNC
117
+ DenseMatrixType toDenseMatrix() const
118
+ {
119
+ DenseMatrixType res(rows(), cols());
120
+ evalToLazy(res);
121
+ return res;
122
+ }
123
+
124
+ protected:
125
+
126
+ void check_coordinates(Index row, Index col) const
127
+ {
128
+ EIGEN_ONLY_USED_FOR_DEBUG(row);
129
+ EIGEN_ONLY_USED_FOR_DEBUG(col);
130
+ eigen_assert(col>=0 && col<cols() && row>=0 && row<rows());
131
+ const int mode = int(Mode) & ~SelfAdjoint;
132
+ EIGEN_ONLY_USED_FOR_DEBUG(mode);
133
+ eigen_assert((mode==Upper && col>=row)
134
+ || (mode==Lower && col<=row)
135
+ || ((mode==StrictlyUpper || mode==UnitUpper) && col>row)
136
+ || ((mode==StrictlyLower || mode==UnitLower) && col<row));
137
+ }
138
+
139
+ #ifdef EIGEN_INTERNAL_DEBUGGING
140
+ void check_coordinates_internal(Index row, Index col) const
141
+ {
142
+ check_coordinates(row, col);
143
+ }
144
+ #else
145
+ void check_coordinates_internal(Index , Index ) const {}
146
+ #endif
147
+
148
+ };
149
+
150
+ /** \class TriangularView
151
+ * \ingroup Core_Module
152
+ *
153
+ * \brief Expression of a triangular part in a matrix
154
+ *
155
+ * \param MatrixType the type of the object in which we are taking the triangular part
156
+ * \param Mode the kind of triangular matrix expression to construct. Can be #Upper,
157
+ * #Lower, #UnitUpper, #UnitLower, #StrictlyUpper, or #StrictlyLower.
158
+ * This is in fact a bit field; it must have either #Upper or #Lower,
159
+ * and additionally it may have #UnitDiag or #ZeroDiag or neither.
160
+ *
161
+ * This class represents a triangular part of a matrix, not necessarily square. Strictly speaking, for rectangular
162
+ * matrices one should speak of "trapezoid" parts. This class is the return type
163
+ * of MatrixBase::triangularView() and SparseMatrixBase::triangularView(), and most of the time this is the only way it is used.
164
+ *
165
+ * \sa MatrixBase::triangularView()
166
+ */
167
+ namespace internal {
168
+ template<typename MatrixType, unsigned int _Mode>
169
+ struct traits<TriangularView<MatrixType, _Mode> > : traits<MatrixType>
170
+ {
171
+ typedef typename ref_selector<MatrixType>::non_const_type MatrixTypeNested;
172
+ typedef typename remove_reference<MatrixTypeNested>::type MatrixTypeNestedNonRef;
173
+ typedef typename remove_all<MatrixTypeNested>::type MatrixTypeNestedCleaned;
174
+ typedef typename MatrixType::PlainObject FullMatrixType;
175
+ typedef MatrixType ExpressionType;
176
+ enum {
177
+ Mode = _Mode,
178
+ FlagsLvalueBit = is_lvalue<MatrixType>::value ? LvalueBit : 0,
179
+ Flags = (MatrixTypeNestedCleaned::Flags & (HereditaryBits | FlagsLvalueBit) & (~(PacketAccessBit | DirectAccessBit | LinearAccessBit)))
180
+ };
181
+ };
182
+ }
183
+
184
+ template<typename _MatrixType, unsigned int _Mode, typename StorageKind> class TriangularViewImpl;
185
+
186
+ template<typename _MatrixType, unsigned int _Mode> class TriangularView
187
+ : public TriangularViewImpl<_MatrixType, _Mode, typename internal::traits<_MatrixType>::StorageKind >
188
+ {
189
+ public:
190
+
191
+ typedef TriangularViewImpl<_MatrixType, _Mode, typename internal::traits<_MatrixType>::StorageKind > Base;
192
+ typedef typename internal::traits<TriangularView>::Scalar Scalar;
193
+ typedef _MatrixType MatrixType;
194
+
195
+ protected:
196
+ typedef typename internal::traits<TriangularView>::MatrixTypeNested MatrixTypeNested;
197
+ typedef typename internal::traits<TriangularView>::MatrixTypeNestedNonRef MatrixTypeNestedNonRef;
198
+
199
+ typedef typename internal::remove_all<typename MatrixType::ConjugateReturnType>::type MatrixConjugateReturnType;
200
+
201
+ public:
202
+
203
+ typedef typename internal::traits<TriangularView>::StorageKind StorageKind;
204
+ typedef typename internal::traits<TriangularView>::MatrixTypeNestedCleaned NestedExpression;
205
+
206
+ enum {
207
+ Mode = _Mode,
208
+ Flags = internal::traits<TriangularView>::Flags,
209
+ TransposeMode = (Mode & Upper ? Lower : 0)
210
+ | (Mode & Lower ? Upper : 0)
211
+ | (Mode & (UnitDiag))
212
+ | (Mode & (ZeroDiag)),
213
+ IsVectorAtCompileTime = false
214
+ };
215
+
216
+ EIGEN_DEVICE_FUNC
217
+ explicit inline TriangularView(MatrixType& matrix) : m_matrix(matrix)
218
+ {}
219
+
220
+ using Base::operator=;
221
+ TriangularView& operator=(const TriangularView &other)
222
+ { return Base::operator=(other); }
223
+
224
+ /** \copydoc EigenBase::rows() */
225
+ EIGEN_DEVICE_FUNC
226
+ inline Index rows() const { return m_matrix.rows(); }
227
+ /** \copydoc EigenBase::cols() */
228
+ EIGEN_DEVICE_FUNC
229
+ inline Index cols() const { return m_matrix.cols(); }
230
+
231
+ /** \returns a const reference to the nested expression */
232
+ EIGEN_DEVICE_FUNC
233
+ const NestedExpression& nestedExpression() const { return m_matrix; }
234
+
235
+ /** \returns a reference to the nested expression */
236
+ EIGEN_DEVICE_FUNC
237
+ NestedExpression& nestedExpression() { return m_matrix; }
238
+
239
+ typedef TriangularView<const MatrixConjugateReturnType,Mode> ConjugateReturnType;
240
+ /** \sa MatrixBase::conjugate() const */
241
+ EIGEN_DEVICE_FUNC
242
+ inline const ConjugateReturnType conjugate() const
243
+ { return ConjugateReturnType(m_matrix.conjugate()); }
244
+
245
+ typedef TriangularView<const typename MatrixType::AdjointReturnType,TransposeMode> AdjointReturnType;
246
+ /** \sa MatrixBase::adjoint() const */
247
+ EIGEN_DEVICE_FUNC
248
+ inline const AdjointReturnType adjoint() const
249
+ { return AdjointReturnType(m_matrix.adjoint()); }
250
+
251
+ typedef TriangularView<typename MatrixType::TransposeReturnType,TransposeMode> TransposeReturnType;
252
+ /** \sa MatrixBase::transpose() */
253
+ EIGEN_DEVICE_FUNC
254
+ inline TransposeReturnType transpose()
255
+ {
256
+ EIGEN_STATIC_ASSERT_LVALUE(MatrixType)
257
+ typename MatrixType::TransposeReturnType tmp(m_matrix);
258
+ return TransposeReturnType(tmp);
259
+ }
260
+
261
+ typedef TriangularView<const typename MatrixType::ConstTransposeReturnType,TransposeMode> ConstTransposeReturnType;
262
+ /** \sa MatrixBase::transpose() const */
263
+ EIGEN_DEVICE_FUNC
264
+ inline const ConstTransposeReturnType transpose() const
265
+ {
266
+ return ConstTransposeReturnType(m_matrix.transpose());
267
+ }
268
+
269
+ template<typename Other>
270
+ EIGEN_DEVICE_FUNC
271
+ inline const Solve<TriangularView, Other>
272
+ solve(const MatrixBase<Other>& other) const
273
+ { return Solve<TriangularView, Other>(*this, other.derived()); }
274
+
275
+ // workaround MSVC ICE
276
+ #if EIGEN_COMP_MSVC
277
+ template<int Side, typename Other>
278
+ EIGEN_DEVICE_FUNC
279
+ inline const internal::triangular_solve_retval<Side,TriangularView, Other>
280
+ solve(const MatrixBase<Other>& other) const
281
+ { return Base::template solve<Side>(other); }
282
+ #else
283
+ using Base::solve;
284
+ #endif
285
+
286
+ /** \returns a selfadjoint view of the referenced triangular part which must be either \c #Upper or \c #Lower.
287
+ *
288
+ * This is a shortcut for \code this->nestedExpression().selfadjointView<(*this)::Mode>() \endcode
289
+ * \sa MatrixBase::selfadjointView() */
290
+ EIGEN_DEVICE_FUNC
291
+ SelfAdjointView<MatrixTypeNestedNonRef,Mode> selfadjointView()
292
+ {
293
+ EIGEN_STATIC_ASSERT((Mode&(UnitDiag|ZeroDiag))==0,PROGRAMMING_ERROR);
294
+ return SelfAdjointView<MatrixTypeNestedNonRef,Mode>(m_matrix);
295
+ }
296
+
297
+ /** This is the const version of selfadjointView() */
298
+ EIGEN_DEVICE_FUNC
299
+ const SelfAdjointView<MatrixTypeNestedNonRef,Mode> selfadjointView() const
300
+ {
301
+ EIGEN_STATIC_ASSERT((Mode&(UnitDiag|ZeroDiag))==0,PROGRAMMING_ERROR);
302
+ return SelfAdjointView<MatrixTypeNestedNonRef,Mode>(m_matrix);
303
+ }
304
+
305
+
306
+ /** \returns the determinant of the triangular matrix
307
+ * \sa MatrixBase::determinant() */
308
+ EIGEN_DEVICE_FUNC
309
+ Scalar determinant() const
310
+ {
311
+ if (Mode & UnitDiag)
312
+ return 1;
313
+ else if (Mode & ZeroDiag)
314
+ return 0;
315
+ else
316
+ return m_matrix.diagonal().prod();
317
+ }
318
+
319
+ protected:
320
+
321
+ MatrixTypeNested m_matrix;
322
+ };
323
+
324
+ /** \ingroup Core_Module
325
+ *
326
+ * \brief Base class for a triangular part in a \b dense matrix
327
+ *
328
+ * This class is an abstract base class of class TriangularView, and objects of type TriangularViewImpl cannot be instantiated.
329
+ * It extends class TriangularView with additional methods which available for dense expressions only.
330
+ *
331
+ * \sa class TriangularView, MatrixBase::triangularView()
332
+ */
333
+ template<typename _MatrixType, unsigned int _Mode> class TriangularViewImpl<_MatrixType,_Mode,Dense>
334
+ : public TriangularBase<TriangularView<_MatrixType, _Mode> >
335
+ {
336
+ public:
337
+
338
+ typedef TriangularView<_MatrixType, _Mode> TriangularViewType;
339
+ typedef TriangularBase<TriangularViewType> Base;
340
+ typedef typename internal::traits<TriangularViewType>::Scalar Scalar;
341
+
342
+ typedef _MatrixType MatrixType;
343
+ typedef typename MatrixType::PlainObject DenseMatrixType;
344
+ typedef DenseMatrixType PlainObject;
345
+
346
+ public:
347
+ using Base::evalToLazy;
348
+ using Base::derived;
349
+
350
+ typedef typename internal::traits<TriangularViewType>::StorageKind StorageKind;
351
+
352
+ enum {
353
+ Mode = _Mode,
354
+ Flags = internal::traits<TriangularViewType>::Flags
355
+ };
356
+
357
+ /** \returns the outer-stride of the underlying dense matrix
358
+ * \sa DenseCoeffsBase::outerStride() */
359
+ EIGEN_DEVICE_FUNC
360
+ inline Index outerStride() const { return derived().nestedExpression().outerStride(); }
361
+ /** \returns the inner-stride of the underlying dense matrix
362
+ * \sa DenseCoeffsBase::innerStride() */
363
+ EIGEN_DEVICE_FUNC
364
+ inline Index innerStride() const { return derived().nestedExpression().innerStride(); }
365
+
366
+ /** \sa MatrixBase::operator+=() */
367
+ template<typename Other>
368
+ EIGEN_DEVICE_FUNC
369
+ TriangularViewType& operator+=(const DenseBase<Other>& other) {
370
+ internal::call_assignment_no_alias(derived(), other.derived(), internal::add_assign_op<Scalar,typename Other::Scalar>());
371
+ return derived();
372
+ }
373
+ /** \sa MatrixBase::operator-=() */
374
+ template<typename Other>
375
+ EIGEN_DEVICE_FUNC
376
+ TriangularViewType& operator-=(const DenseBase<Other>& other) {
377
+ internal::call_assignment_no_alias(derived(), other.derived(), internal::sub_assign_op<Scalar,typename Other::Scalar>());
378
+ return derived();
379
+ }
380
+
381
+ /** \sa MatrixBase::operator*=() */
382
+ EIGEN_DEVICE_FUNC
383
+ TriangularViewType& operator*=(const typename internal::traits<MatrixType>::Scalar& other) { return *this = derived().nestedExpression() * other; }
384
+ /** \sa DenseBase::operator/=() */
385
+ EIGEN_DEVICE_FUNC
386
+ TriangularViewType& operator/=(const typename internal::traits<MatrixType>::Scalar& other) { return *this = derived().nestedExpression() / other; }
387
+
388
+ /** \sa MatrixBase::fill() */
389
+ EIGEN_DEVICE_FUNC
390
+ void fill(const Scalar& value) { setConstant(value); }
391
+ /** \sa MatrixBase::setConstant() */
392
+ EIGEN_DEVICE_FUNC
393
+ TriangularViewType& setConstant(const Scalar& value)
394
+ { return *this = MatrixType::Constant(derived().rows(), derived().cols(), value); }
395
+ /** \sa MatrixBase::setZero() */
396
+ EIGEN_DEVICE_FUNC
397
+ TriangularViewType& setZero() { return setConstant(Scalar(0)); }
398
+ /** \sa MatrixBase::setOnes() */
399
+ EIGEN_DEVICE_FUNC
400
+ TriangularViewType& setOnes() { return setConstant(Scalar(1)); }
401
+
402
+ /** \sa MatrixBase::coeff()
403
+ * \warning the coordinates must fit into the referenced triangular part
404
+ */
405
+ EIGEN_DEVICE_FUNC
406
+ inline Scalar coeff(Index row, Index col) const
407
+ {
408
+ Base::check_coordinates_internal(row, col);
409
+ return derived().nestedExpression().coeff(row, col);
410
+ }
411
+
412
+ /** \sa MatrixBase::coeffRef()
413
+ * \warning the coordinates must fit into the referenced triangular part
414
+ */
415
+ EIGEN_DEVICE_FUNC
416
+ inline Scalar& coeffRef(Index row, Index col)
417
+ {
418
+ EIGEN_STATIC_ASSERT_LVALUE(TriangularViewType);
419
+ Base::check_coordinates_internal(row, col);
420
+ return derived().nestedExpression().coeffRef(row, col);
421
+ }
422
+
423
+ /** Assigns a triangular matrix to a triangular part of a dense matrix */
424
+ template<typename OtherDerived>
425
+ EIGEN_DEVICE_FUNC
426
+ TriangularViewType& operator=(const TriangularBase<OtherDerived>& other);
427
+
428
+ /** Shortcut for\code *this = other.other.triangularView<(*this)::Mode>() \endcode */
429
+ template<typename OtherDerived>
430
+ EIGEN_DEVICE_FUNC
431
+ TriangularViewType& operator=(const MatrixBase<OtherDerived>& other);
432
+
433
+ #ifndef EIGEN_PARSED_BY_DOXYGEN
434
+ EIGEN_DEVICE_FUNC
435
+ TriangularViewType& operator=(const TriangularViewImpl& other)
436
+ { return *this = other.derived().nestedExpression(); }
437
+
438
+ /** \deprecated */
439
+ template<typename OtherDerived>
440
+ EIGEN_DEVICE_FUNC
441
+ void lazyAssign(const TriangularBase<OtherDerived>& other);
442
+
443
+ /** \deprecated */
444
+ template<typename OtherDerived>
445
+ EIGEN_DEVICE_FUNC
446
+ void lazyAssign(const MatrixBase<OtherDerived>& other);
447
+ #endif
448
+
449
+ /** Efficient triangular matrix times vector/matrix product */
450
+ template<typename OtherDerived>
451
+ EIGEN_DEVICE_FUNC
452
+ const Product<TriangularViewType,OtherDerived>
453
+ operator*(const MatrixBase<OtherDerived>& rhs) const
454
+ {
455
+ return Product<TriangularViewType,OtherDerived>(derived(), rhs.derived());
456
+ }
457
+
458
+ /** Efficient vector/matrix times triangular matrix product */
459
+ template<typename OtherDerived> friend
460
+ EIGEN_DEVICE_FUNC
461
+ const Product<OtherDerived,TriangularViewType>
462
+ operator*(const MatrixBase<OtherDerived>& lhs, const TriangularViewImpl& rhs)
463
+ {
464
+ return Product<OtherDerived,TriangularViewType>(lhs.derived(),rhs.derived());
465
+ }
466
+
467
+ /** \returns the product of the inverse of \c *this with \a other, \a *this being triangular.
468
+ *
469
+ * This function computes the inverse-matrix matrix product inverse(\c *this) * \a other if
470
+ * \a Side==OnTheLeft (the default), or the right-inverse-multiply \a other * inverse(\c *this) if
471
+ * \a Side==OnTheRight.
472
+ *
473
+ * Note that the template parameter \c Side can be ommitted, in which case \c Side==OnTheLeft
474
+ *
475
+ * The matrix \c *this must be triangular and invertible (i.e., all the coefficients of the
476
+ * diagonal must be non zero). It works as a forward (resp. backward) substitution if \c *this
477
+ * is an upper (resp. lower) triangular matrix.
478
+ *
479
+ * Example: \include Triangular_solve.cpp
480
+ * Output: \verbinclude Triangular_solve.out
481
+ *
482
+ * This function returns an expression of the inverse-multiply and can works in-place if it is assigned
483
+ * to the same matrix or vector \a other.
484
+ *
485
+ * For users coming from BLAS, this function (and more specifically solveInPlace()) offer
486
+ * all the operations supported by the \c *TRSV and \c *TRSM BLAS routines.
487
+ *
488
+ * \sa TriangularView::solveInPlace()
489
+ */
490
+ template<int Side, typename Other>
491
+ EIGEN_DEVICE_FUNC
492
+ inline const internal::triangular_solve_retval<Side,TriangularViewType, Other>
493
+ solve(const MatrixBase<Other>& other) const;
494
+
495
+ /** "in-place" version of TriangularView::solve() where the result is written in \a other
496
+ *
497
+ * \warning The parameter is only marked 'const' to make the C++ compiler accept a temporary expression here.
498
+ * This function will const_cast it, so constness isn't honored here.
499
+ *
500
+ * Note that the template parameter \c Side can be ommitted, in which case \c Side==OnTheLeft
501
+ *
502
+ * See TriangularView:solve() for the details.
503
+ */
504
+ template<int Side, typename OtherDerived>
505
+ EIGEN_DEVICE_FUNC
506
+ void solveInPlace(const MatrixBase<OtherDerived>& other) const;
507
+
508
+ template<typename OtherDerived>
509
+ EIGEN_DEVICE_FUNC
510
+ void solveInPlace(const MatrixBase<OtherDerived>& other) const
511
+ { return solveInPlace<OnTheLeft>(other); }
512
+
513
+ /** Swaps the coefficients of the common triangular parts of two matrices */
514
+ template<typename OtherDerived>
515
+ EIGEN_DEVICE_FUNC
516
+ #ifdef EIGEN_PARSED_BY_DOXYGEN
517
+ void swap(TriangularBase<OtherDerived> &other)
518
+ #else
519
+ void swap(TriangularBase<OtherDerived> const & other)
520
+ #endif
521
+ {
522
+ EIGEN_STATIC_ASSERT_LVALUE(OtherDerived);
523
+ call_assignment(derived(), other.const_cast_derived(), internal::swap_assign_op<Scalar>());
524
+ }
525
+
526
+ /** \deprecated
527
+ * Shortcut for \code (*this).swap(other.triangularView<(*this)::Mode>()) \endcode */
528
+ template<typename OtherDerived>
529
+ EIGEN_DEVICE_FUNC
530
+ void swap(MatrixBase<OtherDerived> const & other)
531
+ {
532
+ EIGEN_STATIC_ASSERT_LVALUE(OtherDerived);
533
+ call_assignment(derived(), other.const_cast_derived(), internal::swap_assign_op<Scalar>());
534
+ }
535
+
536
+ template<typename RhsType, typename DstType>
537
+ EIGEN_DEVICE_FUNC
538
+ EIGEN_STRONG_INLINE void _solve_impl(const RhsType &rhs, DstType &dst) const {
539
+ if(!internal::is_same_dense(dst,rhs))
540
+ dst = rhs;
541
+ this->solveInPlace(dst);
542
+ }
543
+
544
+ template<typename ProductType>
545
+ EIGEN_DEVICE_FUNC
546
+ EIGEN_STRONG_INLINE TriangularViewType& _assignProduct(const ProductType& prod, const Scalar& alpha, bool beta);
547
+ };
548
+
549
+ /***************************************************************************
550
+ * Implementation of triangular evaluation/assignment
551
+ ***************************************************************************/
552
+
553
+ #ifndef EIGEN_PARSED_BY_DOXYGEN
554
+ // FIXME should we keep that possibility
555
+ template<typename MatrixType, unsigned int Mode>
556
+ template<typename OtherDerived>
557
+ inline TriangularView<MatrixType, Mode>&
558
+ TriangularViewImpl<MatrixType, Mode, Dense>::operator=(const MatrixBase<OtherDerived>& other)
559
+ {
560
+ internal::call_assignment_no_alias(derived(), other.derived(), internal::assign_op<Scalar,typename OtherDerived::Scalar>());
561
+ return derived();
562
+ }
563
+
564
+ // FIXME should we keep that possibility
565
+ template<typename MatrixType, unsigned int Mode>
566
+ template<typename OtherDerived>
567
+ void TriangularViewImpl<MatrixType, Mode, Dense>::lazyAssign(const MatrixBase<OtherDerived>& other)
568
+ {
569
+ internal::call_assignment_no_alias(derived(), other.template triangularView<Mode>());
570
+ }
571
+
572
+
573
+
574
+ template<typename MatrixType, unsigned int Mode>
575
+ template<typename OtherDerived>
576
+ inline TriangularView<MatrixType, Mode>&
577
+ TriangularViewImpl<MatrixType, Mode, Dense>::operator=(const TriangularBase<OtherDerived>& other)
578
+ {
579
+ eigen_assert(Mode == int(OtherDerived::Mode));
580
+ internal::call_assignment(derived(), other.derived());
581
+ return derived();
582
+ }
583
+
584
+ template<typename MatrixType, unsigned int Mode>
585
+ template<typename OtherDerived>
586
+ void TriangularViewImpl<MatrixType, Mode, Dense>::lazyAssign(const TriangularBase<OtherDerived>& other)
587
+ {
588
+ eigen_assert(Mode == int(OtherDerived::Mode));
589
+ internal::call_assignment_no_alias(derived(), other.derived());
590
+ }
591
+ #endif
592
+
593
+ /***************************************************************************
594
+ * Implementation of TriangularBase methods
595
+ ***************************************************************************/
596
+
597
+ /** Assigns a triangular or selfadjoint matrix to a dense matrix.
598
+ * If the matrix is triangular, the opposite part is set to zero. */
599
+ template<typename Derived>
600
+ template<typename DenseDerived>
601
+ void TriangularBase<Derived>::evalTo(MatrixBase<DenseDerived> &other) const
602
+ {
603
+ evalToLazy(other.derived());
604
+ }
605
+
606
+ /***************************************************************************
607
+ * Implementation of TriangularView methods
608
+ ***************************************************************************/
609
+
610
+ /***************************************************************************
611
+ * Implementation of MatrixBase methods
612
+ ***************************************************************************/
613
+
614
+ /**
615
+ * \returns an expression of a triangular view extracted from the current matrix
616
+ *
617
+ * The parameter \a Mode can have the following values: \c #Upper, \c #StrictlyUpper, \c #UnitUpper,
618
+ * \c #Lower, \c #StrictlyLower, \c #UnitLower.
619
+ *
620
+ * Example: \include MatrixBase_triangularView.cpp
621
+ * Output: \verbinclude MatrixBase_triangularView.out
622
+ *
623
+ * \sa class TriangularView
624
+ */
625
+ template<typename Derived>
626
+ template<unsigned int Mode>
627
+ typename MatrixBase<Derived>::template TriangularViewReturnType<Mode>::Type
628
+ MatrixBase<Derived>::triangularView()
629
+ {
630
+ return typename TriangularViewReturnType<Mode>::Type(derived());
631
+ }
632
+
633
+ /** This is the const version of MatrixBase::triangularView() */
634
+ template<typename Derived>
635
+ template<unsigned int Mode>
636
+ typename MatrixBase<Derived>::template ConstTriangularViewReturnType<Mode>::Type
637
+ MatrixBase<Derived>::triangularView() const
638
+ {
639
+ return typename ConstTriangularViewReturnType<Mode>::Type(derived());
640
+ }
641
+
642
+ /** \returns true if *this is approximately equal to an upper triangular matrix,
643
+ * within the precision given by \a prec.
644
+ *
645
+ * \sa isLowerTriangular()
646
+ */
647
+ template<typename Derived>
648
+ bool MatrixBase<Derived>::isUpperTriangular(const RealScalar& prec) const
649
+ {
650
+ RealScalar maxAbsOnUpperPart = static_cast<RealScalar>(-1);
651
+ for(Index j = 0; j < cols(); ++j)
652
+ {
653
+ Index maxi = numext::mini(j, rows()-1);
654
+ for(Index i = 0; i <= maxi; ++i)
655
+ {
656
+ RealScalar absValue = numext::abs(coeff(i,j));
657
+ if(absValue > maxAbsOnUpperPart) maxAbsOnUpperPart = absValue;
658
+ }
659
+ }
660
+ RealScalar threshold = maxAbsOnUpperPart * prec;
661
+ for(Index j = 0; j < cols(); ++j)
662
+ for(Index i = j+1; i < rows(); ++i)
663
+ if(numext::abs(coeff(i, j)) > threshold) return false;
664
+ return true;
665
+ }
666
+
667
+ /** \returns true if *this is approximately equal to a lower triangular matrix,
668
+ * within the precision given by \a prec.
669
+ *
670
+ * \sa isUpperTriangular()
671
+ */
672
+ template<typename Derived>
673
+ bool MatrixBase<Derived>::isLowerTriangular(const RealScalar& prec) const
674
+ {
675
+ RealScalar maxAbsOnLowerPart = static_cast<RealScalar>(-1);
676
+ for(Index j = 0; j < cols(); ++j)
677
+ for(Index i = j; i < rows(); ++i)
678
+ {
679
+ RealScalar absValue = numext::abs(coeff(i,j));
680
+ if(absValue > maxAbsOnLowerPart) maxAbsOnLowerPart = absValue;
681
+ }
682
+ RealScalar threshold = maxAbsOnLowerPart * prec;
683
+ for(Index j = 1; j < cols(); ++j)
684
+ {
685
+ Index maxi = numext::mini(j, rows()-1);
686
+ for(Index i = 0; i < maxi; ++i)
687
+ if(numext::abs(coeff(i, j)) > threshold) return false;
688
+ }
689
+ return true;
690
+ }
691
+
692
+
693
+ /***************************************************************************
694
+ ****************************************************************************
695
+ * Evaluators and Assignment of triangular expressions
696
+ ***************************************************************************
697
+ ***************************************************************************/
698
+
699
+ namespace internal {
700
+
701
+
702
+ // TODO currently a triangular expression has the form TriangularView<.,.>
703
+ // in the future triangular-ness should be defined by the expression traits
704
+ // such that Transpose<TriangularView<.,.> > is valid. (currently TriangularBase::transpose() is overloaded to make it work)
705
+ template<typename MatrixType, unsigned int Mode>
706
+ struct evaluator_traits<TriangularView<MatrixType,Mode> >
707
+ {
708
+ typedef typename storage_kind_to_evaluator_kind<typename MatrixType::StorageKind>::Kind Kind;
709
+ typedef typename glue_shapes<typename evaluator_traits<MatrixType>::Shape, TriangularShape>::type Shape;
710
+ };
711
+
712
+ template<typename MatrixType, unsigned int Mode>
713
+ struct unary_evaluator<TriangularView<MatrixType,Mode>, IndexBased>
714
+ : evaluator<typename internal::remove_all<MatrixType>::type>
715
+ {
716
+ typedef TriangularView<MatrixType,Mode> XprType;
717
+ typedef evaluator<typename internal::remove_all<MatrixType>::type> Base;
718
+ unary_evaluator(const XprType &xpr) : Base(xpr.nestedExpression()) {}
719
+ };
720
+
721
+ // Additional assignment kinds:
722
+ struct Triangular2Triangular {};
723
+ struct Triangular2Dense {};
724
+ struct Dense2Triangular {};
725
+
726
+
727
+ template<typename Kernel, unsigned int Mode, int UnrollCount, bool ClearOpposite> struct triangular_assignment_loop;
728
+
729
+
730
+ /** \internal Specialization of the dense assignment kernel for triangular matrices.
731
+ * The main difference is that the triangular, diagonal, and opposite parts are processed through three different functions.
732
+ * \tparam UpLo must be either Lower or Upper
733
+ * \tparam Mode must be either 0, UnitDiag, ZeroDiag, or SelfAdjoint
734
+ */
735
+ template<int UpLo, int Mode, int SetOpposite, typename DstEvaluatorTypeT, typename SrcEvaluatorTypeT, typename Functor, int Version = Specialized>
736
+ class triangular_dense_assignment_kernel : public generic_dense_assignment_kernel<DstEvaluatorTypeT, SrcEvaluatorTypeT, Functor, Version>
737
+ {
738
+ protected:
739
+ typedef generic_dense_assignment_kernel<DstEvaluatorTypeT, SrcEvaluatorTypeT, Functor, Version> Base;
740
+ typedef typename Base::DstXprType DstXprType;
741
+ typedef typename Base::SrcXprType SrcXprType;
742
+ using Base::m_dst;
743
+ using Base::m_src;
744
+ using Base::m_functor;
745
+ public:
746
+
747
+ typedef typename Base::DstEvaluatorType DstEvaluatorType;
748
+ typedef typename Base::SrcEvaluatorType SrcEvaluatorType;
749
+ typedef typename Base::Scalar Scalar;
750
+ typedef typename Base::AssignmentTraits AssignmentTraits;
751
+
752
+
753
+ EIGEN_DEVICE_FUNC triangular_dense_assignment_kernel(DstEvaluatorType &dst, const SrcEvaluatorType &src, const Functor &func, DstXprType& dstExpr)
754
+ : Base(dst, src, func, dstExpr)
755
+ {}
756
+
757
+ #ifdef EIGEN_INTERNAL_DEBUGGING
758
+ EIGEN_DEVICE_FUNC void assignCoeff(Index row, Index col)
759
+ {
760
+ eigen_internal_assert(row!=col);
761
+ Base::assignCoeff(row,col);
762
+ }
763
+ #else
764
+ using Base::assignCoeff;
765
+ #endif
766
+
767
+ EIGEN_DEVICE_FUNC void assignDiagonalCoeff(Index id)
768
+ {
769
+ if(Mode==UnitDiag && SetOpposite) m_functor.assignCoeff(m_dst.coeffRef(id,id), Scalar(1));
770
+ else if(Mode==ZeroDiag && SetOpposite) m_functor.assignCoeff(m_dst.coeffRef(id,id), Scalar(0));
771
+ else if(Mode==0) Base::assignCoeff(id,id);
772
+ }
773
+
774
+ EIGEN_DEVICE_FUNC void assignOppositeCoeff(Index row, Index col)
775
+ {
776
+ eigen_internal_assert(row!=col);
777
+ if(SetOpposite)
778
+ m_functor.assignCoeff(m_dst.coeffRef(row,col), Scalar(0));
779
+ }
780
+ };
781
+
782
+ template<int Mode, bool SetOpposite, typename DstXprType, typename SrcXprType, typename Functor>
783
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
784
+ void call_triangular_assignment_loop(DstXprType& dst, const SrcXprType& src, const Functor &func)
785
+ {
786
+ typedef evaluator<DstXprType> DstEvaluatorType;
787
+ typedef evaluator<SrcXprType> SrcEvaluatorType;
788
+
789
+ SrcEvaluatorType srcEvaluator(src);
790
+
791
+ Index dstRows = src.rows();
792
+ Index dstCols = src.cols();
793
+ if((dst.rows()!=dstRows) || (dst.cols()!=dstCols))
794
+ dst.resize(dstRows, dstCols);
795
+ DstEvaluatorType dstEvaluator(dst);
796
+
797
+ typedef triangular_dense_assignment_kernel< Mode&(Lower|Upper),Mode&(UnitDiag|ZeroDiag|SelfAdjoint),SetOpposite,
798
+ DstEvaluatorType,SrcEvaluatorType,Functor> Kernel;
799
+ Kernel kernel(dstEvaluator, srcEvaluator, func, dst.const_cast_derived());
800
+
801
+ enum {
802
+ unroll = DstXprType::SizeAtCompileTime != Dynamic
803
+ && SrcEvaluatorType::CoeffReadCost < HugeCost
804
+ && DstXprType::SizeAtCompileTime * (DstEvaluatorType::CoeffReadCost+SrcEvaluatorType::CoeffReadCost) / 2 <= EIGEN_UNROLLING_LIMIT
805
+ };
806
+
807
+ triangular_assignment_loop<Kernel, Mode, unroll ? int(DstXprType::SizeAtCompileTime) : Dynamic, SetOpposite>::run(kernel);
808
+ }
809
+
810
+ template<int Mode, bool SetOpposite, typename DstXprType, typename SrcXprType>
811
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
812
+ void call_triangular_assignment_loop(DstXprType& dst, const SrcXprType& src)
813
+ {
814
+ call_triangular_assignment_loop<Mode,SetOpposite>(dst, src, internal::assign_op<typename DstXprType::Scalar,typename SrcXprType::Scalar>());
815
+ }
816
+
817
+ template<> struct AssignmentKind<TriangularShape,TriangularShape> { typedef Triangular2Triangular Kind; };
818
+ template<> struct AssignmentKind<DenseShape,TriangularShape> { typedef Triangular2Dense Kind; };
819
+ template<> struct AssignmentKind<TriangularShape,DenseShape> { typedef Dense2Triangular Kind; };
820
+
821
+
822
+ template< typename DstXprType, typename SrcXprType, typename Functor>
823
+ struct Assignment<DstXprType, SrcXprType, Functor, Triangular2Triangular>
824
+ {
825
+ EIGEN_DEVICE_FUNC static void run(DstXprType &dst, const SrcXprType &src, const Functor &func)
826
+ {
827
+ eigen_assert(int(DstXprType::Mode) == int(SrcXprType::Mode));
828
+
829
+ call_triangular_assignment_loop<DstXprType::Mode, false>(dst, src, func);
830
+ }
831
+ };
832
+
833
+ template< typename DstXprType, typename SrcXprType, typename Functor>
834
+ struct Assignment<DstXprType, SrcXprType, Functor, Triangular2Dense>
835
+ {
836
+ EIGEN_DEVICE_FUNC static void run(DstXprType &dst, const SrcXprType &src, const Functor &func)
837
+ {
838
+ call_triangular_assignment_loop<SrcXprType::Mode, (SrcXprType::Mode&SelfAdjoint)==0>(dst, src, func);
839
+ }
840
+ };
841
+
842
+ template< typename DstXprType, typename SrcXprType, typename Functor>
843
+ struct Assignment<DstXprType, SrcXprType, Functor, Dense2Triangular>
844
+ {
845
+ EIGEN_DEVICE_FUNC static void run(DstXprType &dst, const SrcXprType &src, const Functor &func)
846
+ {
847
+ call_triangular_assignment_loop<DstXprType::Mode, false>(dst, src, func);
848
+ }
849
+ };
850
+
851
+
852
+ template<typename Kernel, unsigned int Mode, int UnrollCount, bool SetOpposite>
853
+ struct triangular_assignment_loop
854
+ {
855
+ // FIXME: this is not very clean, perhaps this information should be provided by the kernel?
856
+ typedef typename Kernel::DstEvaluatorType DstEvaluatorType;
857
+ typedef typename DstEvaluatorType::XprType DstXprType;
858
+
859
+ enum {
860
+ col = (UnrollCount-1) / DstXprType::RowsAtCompileTime,
861
+ row = (UnrollCount-1) % DstXprType::RowsAtCompileTime
862
+ };
863
+
864
+ typedef typename Kernel::Scalar Scalar;
865
+
866
+ EIGEN_DEVICE_FUNC
867
+ static inline void run(Kernel &kernel)
868
+ {
869
+ triangular_assignment_loop<Kernel, Mode, UnrollCount-1, SetOpposite>::run(kernel);
870
+
871
+ if(row==col)
872
+ kernel.assignDiagonalCoeff(row);
873
+ else if( ((Mode&Lower) && row>col) || ((Mode&Upper) && row<col) )
874
+ kernel.assignCoeff(row,col);
875
+ else if(SetOpposite)
876
+ kernel.assignOppositeCoeff(row,col);
877
+ }
878
+ };
879
+
880
+ // prevent buggy user code from causing an infinite recursion
881
+ template<typename Kernel, unsigned int Mode, bool SetOpposite>
882
+ struct triangular_assignment_loop<Kernel, Mode, 0, SetOpposite>
883
+ {
884
+ EIGEN_DEVICE_FUNC
885
+ static inline void run(Kernel &) {}
886
+ };
887
+
888
+
889
+
890
+ // TODO: experiment with a recursive assignment procedure splitting the current
891
+ // triangular part into one rectangular and two triangular parts.
892
+
893
+
894
+ template<typename Kernel, unsigned int Mode, bool SetOpposite>
895
+ struct triangular_assignment_loop<Kernel, Mode, Dynamic, SetOpposite>
896
+ {
897
+ typedef typename Kernel::Scalar Scalar;
898
+ EIGEN_DEVICE_FUNC
899
+ static inline void run(Kernel &kernel)
900
+ {
901
+ for(Index j = 0; j < kernel.cols(); ++j)
902
+ {
903
+ Index maxi = numext::mini(j, kernel.rows());
904
+ Index i = 0;
905
+ if (((Mode&Lower) && SetOpposite) || (Mode&Upper))
906
+ {
907
+ for(; i < maxi; ++i)
908
+ if(Mode&Upper) kernel.assignCoeff(i, j);
909
+ else kernel.assignOppositeCoeff(i, j);
910
+ }
911
+ else
912
+ i = maxi;
913
+
914
+ if(i<kernel.rows()) // then i==j
915
+ kernel.assignDiagonalCoeff(i++);
916
+
917
+ if (((Mode&Upper) && SetOpposite) || (Mode&Lower))
918
+ {
919
+ for(; i < kernel.rows(); ++i)
920
+ if(Mode&Lower) kernel.assignCoeff(i, j);
921
+ else kernel.assignOppositeCoeff(i, j);
922
+ }
923
+ }
924
+ }
925
+ };
926
+
927
+ } // end namespace internal
928
+
929
+ /** Assigns a triangular or selfadjoint matrix to a dense matrix.
930
+ * If the matrix is triangular, the opposite part is set to zero. */
931
+ template<typename Derived>
932
+ template<typename DenseDerived>
933
+ void TriangularBase<Derived>::evalToLazy(MatrixBase<DenseDerived> &other) const
934
+ {
935
+ other.derived().resize(this->rows(), this->cols());
936
+ internal::call_triangular_assignment_loop<Derived::Mode,(Derived::Mode&SelfAdjoint)==0 /* SetOpposite */>(other.derived(), derived().nestedExpression());
937
+ }
938
+
939
+ namespace internal {
940
+
941
+ // Triangular = Product
942
+ template< typename DstXprType, typename Lhs, typename Rhs, typename Scalar>
943
+ struct Assignment<DstXprType, Product<Lhs,Rhs,DefaultProduct>, internal::assign_op<Scalar,typename Product<Lhs,Rhs,DefaultProduct>::Scalar>, Dense2Triangular>
944
+ {
945
+ typedef Product<Lhs,Rhs,DefaultProduct> SrcXprType;
946
+ static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op<Scalar,typename SrcXprType::Scalar> &)
947
+ {
948
+ Index dstRows = src.rows();
949
+ Index dstCols = src.cols();
950
+ if((dst.rows()!=dstRows) || (dst.cols()!=dstCols))
951
+ dst.resize(dstRows, dstCols);
952
+
953
+ dst._assignProduct(src, 1, 0);
954
+ }
955
+ };
956
+
957
+ // Triangular += Product
958
+ template< typename DstXprType, typename Lhs, typename Rhs, typename Scalar>
959
+ struct Assignment<DstXprType, Product<Lhs,Rhs,DefaultProduct>, internal::add_assign_op<Scalar,typename Product<Lhs,Rhs,DefaultProduct>::Scalar>, Dense2Triangular>
960
+ {
961
+ typedef Product<Lhs,Rhs,DefaultProduct> SrcXprType;
962
+ static void run(DstXprType &dst, const SrcXprType &src, const internal::add_assign_op<Scalar,typename SrcXprType::Scalar> &)
963
+ {
964
+ dst._assignProduct(src, 1, 1);
965
+ }
966
+ };
967
+
968
+ // Triangular -= Product
969
+ template< typename DstXprType, typename Lhs, typename Rhs, typename Scalar>
970
+ struct Assignment<DstXprType, Product<Lhs,Rhs,DefaultProduct>, internal::sub_assign_op<Scalar,typename Product<Lhs,Rhs,DefaultProduct>::Scalar>, Dense2Triangular>
971
+ {
972
+ typedef Product<Lhs,Rhs,DefaultProduct> SrcXprType;
973
+ static void run(DstXprType &dst, const SrcXprType &src, const internal::sub_assign_op<Scalar,typename SrcXprType::Scalar> &)
974
+ {
975
+ dst._assignProduct(src, -1, 1);
976
+ }
977
+ };
978
+
979
+ } // end namespace internal
980
+
981
+ } // end namespace Eigen
982
+
983
+ #endif // EIGEN_TRIANGULARMATRIX_H