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,654 @@
1
+ // This file is part of Eigen, a lightweight C++ template library
2
+ // for linear algebra.
3
+ //
4
+ // Copyright (C) 2012 Alexey Korepanov <kaikaikai@yandex.ru>
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_REAL_QZ_H
11
+ #define EIGEN_REAL_QZ_H
12
+
13
+ namespace Eigen {
14
+
15
+ /** \eigenvalues_module \ingroup Eigenvalues_Module
16
+ *
17
+ *
18
+ * \class RealQZ
19
+ *
20
+ * \brief Performs a real QZ decomposition of a pair of square matrices
21
+ *
22
+ * \tparam _MatrixType the type of the matrix of which we are computing the
23
+ * real QZ decomposition; this is expected to be an instantiation of the
24
+ * Matrix class template.
25
+ *
26
+ * Given a real square matrices A and B, this class computes the real QZ
27
+ * decomposition: \f$ A = Q S Z \f$, \f$ B = Q T Z \f$ where Q and Z are
28
+ * real orthogonal matrixes, T is upper-triangular matrix, and S is upper
29
+ * quasi-triangular matrix. An orthogonal matrix is a matrix whose
30
+ * inverse is equal to its transpose, \f$ U^{-1} = U^T \f$. A quasi-triangular
31
+ * matrix is a block-triangular matrix whose diagonal consists of 1-by-1
32
+ * blocks and 2-by-2 blocks where further reduction is impossible due to
33
+ * complex eigenvalues.
34
+ *
35
+ * The eigenvalues of the pencil \f$ A - z B \f$ can be obtained from
36
+ * 1x1 and 2x2 blocks on the diagonals of S and T.
37
+ *
38
+ * Call the function compute() to compute the real QZ decomposition of a
39
+ * given pair of matrices. Alternatively, you can use the
40
+ * RealQZ(const MatrixType& B, const MatrixType& B, bool computeQZ)
41
+ * constructor which computes the real QZ decomposition at construction
42
+ * time. Once the decomposition is computed, you can use the matrixS(),
43
+ * matrixT(), matrixQ() and matrixZ() functions to retrieve the matrices
44
+ * S, T, Q and Z in the decomposition. If computeQZ==false, some time
45
+ * is saved by not computing matrices Q and Z.
46
+ *
47
+ * Example: \include RealQZ_compute.cpp
48
+ * Output: \include RealQZ_compute.out
49
+ *
50
+ * \note The implementation is based on the algorithm in "Matrix Computations"
51
+ * by Gene H. Golub and Charles F. Van Loan, and a paper "An algorithm for
52
+ * generalized eigenvalue problems" by C.B.Moler and G.W.Stewart.
53
+ *
54
+ * \sa class RealSchur, class ComplexSchur, class EigenSolver, class ComplexEigenSolver
55
+ */
56
+
57
+ template<typename _MatrixType> class RealQZ
58
+ {
59
+ public:
60
+ typedef _MatrixType MatrixType;
61
+ enum {
62
+ RowsAtCompileTime = MatrixType::RowsAtCompileTime,
63
+ ColsAtCompileTime = MatrixType::ColsAtCompileTime,
64
+ Options = MatrixType::Options,
65
+ MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
66
+ MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
67
+ };
68
+ typedef typename MatrixType::Scalar Scalar;
69
+ typedef std::complex<typename NumTraits<Scalar>::Real> ComplexScalar;
70
+ typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3
71
+
72
+ typedef Matrix<ComplexScalar, ColsAtCompileTime, 1, Options & ~RowMajor, MaxColsAtCompileTime, 1> EigenvalueType;
73
+ typedef Matrix<Scalar, ColsAtCompileTime, 1, Options & ~RowMajor, MaxColsAtCompileTime, 1> ColumnVectorType;
74
+
75
+ /** \brief Default constructor.
76
+ *
77
+ * \param [in] size Positive integer, size of the matrix whose QZ decomposition will be computed.
78
+ *
79
+ * The default constructor is useful in cases in which the user intends to
80
+ * perform decompositions via compute(). The \p size parameter is only
81
+ * used as a hint. It is not an error to give a wrong \p size, but it may
82
+ * impair performance.
83
+ *
84
+ * \sa compute() for an example.
85
+ */
86
+ explicit RealQZ(Index size = RowsAtCompileTime==Dynamic ? 1 : RowsAtCompileTime) :
87
+ m_S(size, size),
88
+ m_T(size, size),
89
+ m_Q(size, size),
90
+ m_Z(size, size),
91
+ m_workspace(size*2),
92
+ m_maxIters(400),
93
+ m_isInitialized(false)
94
+ { }
95
+
96
+ /** \brief Constructor; computes real QZ decomposition of given matrices
97
+ *
98
+ * \param[in] A Matrix A.
99
+ * \param[in] B Matrix B.
100
+ * \param[in] computeQZ If false, A and Z are not computed.
101
+ *
102
+ * This constructor calls compute() to compute the QZ decomposition.
103
+ */
104
+ RealQZ(const MatrixType& A, const MatrixType& B, bool computeQZ = true) :
105
+ m_S(A.rows(),A.cols()),
106
+ m_T(A.rows(),A.cols()),
107
+ m_Q(A.rows(),A.cols()),
108
+ m_Z(A.rows(),A.cols()),
109
+ m_workspace(A.rows()*2),
110
+ m_maxIters(400),
111
+ m_isInitialized(false) {
112
+ compute(A, B, computeQZ);
113
+ }
114
+
115
+ /** \brief Returns matrix Q in the QZ decomposition.
116
+ *
117
+ * \returns A const reference to the matrix Q.
118
+ */
119
+ const MatrixType& matrixQ() const {
120
+ eigen_assert(m_isInitialized && "RealQZ is not initialized.");
121
+ eigen_assert(m_computeQZ && "The matrices Q and Z have not been computed during the QZ decomposition.");
122
+ return m_Q;
123
+ }
124
+
125
+ /** \brief Returns matrix Z in the QZ decomposition.
126
+ *
127
+ * \returns A const reference to the matrix Z.
128
+ */
129
+ const MatrixType& matrixZ() const {
130
+ eigen_assert(m_isInitialized && "RealQZ is not initialized.");
131
+ eigen_assert(m_computeQZ && "The matrices Q and Z have not been computed during the QZ decomposition.");
132
+ return m_Z;
133
+ }
134
+
135
+ /** \brief Returns matrix S in the QZ decomposition.
136
+ *
137
+ * \returns A const reference to the matrix S.
138
+ */
139
+ const MatrixType& matrixS() const {
140
+ eigen_assert(m_isInitialized && "RealQZ is not initialized.");
141
+ return m_S;
142
+ }
143
+
144
+ /** \brief Returns matrix S in the QZ decomposition.
145
+ *
146
+ * \returns A const reference to the matrix S.
147
+ */
148
+ const MatrixType& matrixT() const {
149
+ eigen_assert(m_isInitialized && "RealQZ is not initialized.");
150
+ return m_T;
151
+ }
152
+
153
+ /** \brief Computes QZ decomposition of given matrix.
154
+ *
155
+ * \param[in] A Matrix A.
156
+ * \param[in] B Matrix B.
157
+ * \param[in] computeQZ If false, A and Z are not computed.
158
+ * \returns Reference to \c *this
159
+ */
160
+ RealQZ& compute(const MatrixType& A, const MatrixType& B, bool computeQZ = true);
161
+
162
+ /** \brief Reports whether previous computation was successful.
163
+ *
164
+ * \returns \c Success if computation was succesful, \c NoConvergence otherwise.
165
+ */
166
+ ComputationInfo info() const
167
+ {
168
+ eigen_assert(m_isInitialized && "RealQZ is not initialized.");
169
+ return m_info;
170
+ }
171
+
172
+ /** \brief Returns number of performed QR-like iterations.
173
+ */
174
+ Index iterations() const
175
+ {
176
+ eigen_assert(m_isInitialized && "RealQZ is not initialized.");
177
+ return m_global_iter;
178
+ }
179
+
180
+ /** Sets the maximal number of iterations allowed to converge to one eigenvalue
181
+ * or decouple the problem.
182
+ */
183
+ RealQZ& setMaxIterations(Index maxIters)
184
+ {
185
+ m_maxIters = maxIters;
186
+ return *this;
187
+ }
188
+
189
+ private:
190
+
191
+ MatrixType m_S, m_T, m_Q, m_Z;
192
+ Matrix<Scalar,Dynamic,1> m_workspace;
193
+ ComputationInfo m_info;
194
+ Index m_maxIters;
195
+ bool m_isInitialized;
196
+ bool m_computeQZ;
197
+ Scalar m_normOfT, m_normOfS;
198
+ Index m_global_iter;
199
+
200
+ typedef Matrix<Scalar,3,1> Vector3s;
201
+ typedef Matrix<Scalar,2,1> Vector2s;
202
+ typedef Matrix<Scalar,2,2> Matrix2s;
203
+ typedef JacobiRotation<Scalar> JRs;
204
+
205
+ void hessenbergTriangular();
206
+ void computeNorms();
207
+ Index findSmallSubdiagEntry(Index iu);
208
+ Index findSmallDiagEntry(Index f, Index l);
209
+ void splitOffTwoRows(Index i);
210
+ void pushDownZero(Index z, Index f, Index l);
211
+ void step(Index f, Index l, Index iter);
212
+
213
+ }; // RealQZ
214
+
215
+ /** \internal Reduces S and T to upper Hessenberg - triangular form */
216
+ template<typename MatrixType>
217
+ void RealQZ<MatrixType>::hessenbergTriangular()
218
+ {
219
+
220
+ const Index dim = m_S.cols();
221
+
222
+ // perform QR decomposition of T, overwrite T with R, save Q
223
+ HouseholderQR<MatrixType> qrT(m_T);
224
+ m_T = qrT.matrixQR();
225
+ m_T.template triangularView<StrictlyLower>().setZero();
226
+ m_Q = qrT.householderQ();
227
+ // overwrite S with Q* S
228
+ m_S.applyOnTheLeft(m_Q.adjoint());
229
+ // init Z as Identity
230
+ if (m_computeQZ)
231
+ m_Z = MatrixType::Identity(dim,dim);
232
+ // reduce S to upper Hessenberg with Givens rotations
233
+ for (Index j=0; j<=dim-3; j++) {
234
+ for (Index i=dim-1; i>=j+2; i--) {
235
+ JRs G;
236
+ // kill S(i,j)
237
+ if(m_S.coeff(i,j) != 0)
238
+ {
239
+ G.makeGivens(m_S.coeff(i-1,j), m_S.coeff(i,j), &m_S.coeffRef(i-1, j));
240
+ m_S.coeffRef(i,j) = Scalar(0.0);
241
+ m_S.rightCols(dim-j-1).applyOnTheLeft(i-1,i,G.adjoint());
242
+ m_T.rightCols(dim-i+1).applyOnTheLeft(i-1,i,G.adjoint());
243
+ // update Q
244
+ if (m_computeQZ)
245
+ m_Q.applyOnTheRight(i-1,i,G);
246
+ }
247
+ // kill T(i,i-1)
248
+ if(m_T.coeff(i,i-1)!=Scalar(0))
249
+ {
250
+ G.makeGivens(m_T.coeff(i,i), m_T.coeff(i,i-1), &m_T.coeffRef(i,i));
251
+ m_T.coeffRef(i,i-1) = Scalar(0.0);
252
+ m_S.applyOnTheRight(i,i-1,G);
253
+ m_T.topRows(i).applyOnTheRight(i,i-1,G);
254
+ // update Z
255
+ if (m_computeQZ)
256
+ m_Z.applyOnTheLeft(i,i-1,G.adjoint());
257
+ }
258
+ }
259
+ }
260
+ }
261
+
262
+ /** \internal Computes vector L1 norms of S and T when in Hessenberg-Triangular form already */
263
+ template<typename MatrixType>
264
+ inline void RealQZ<MatrixType>::computeNorms()
265
+ {
266
+ const Index size = m_S.cols();
267
+ m_normOfS = Scalar(0.0);
268
+ m_normOfT = Scalar(0.0);
269
+ for (Index j = 0; j < size; ++j)
270
+ {
271
+ m_normOfS += m_S.col(j).segment(0, (std::min)(size,j+2)).cwiseAbs().sum();
272
+ m_normOfT += m_T.row(j).segment(j, size - j).cwiseAbs().sum();
273
+ }
274
+ }
275
+
276
+
277
+ /** \internal Look for single small sub-diagonal element S(res, res-1) and return res (or 0) */
278
+ template<typename MatrixType>
279
+ inline Index RealQZ<MatrixType>::findSmallSubdiagEntry(Index iu)
280
+ {
281
+ using std::abs;
282
+ Index res = iu;
283
+ while (res > 0)
284
+ {
285
+ Scalar s = abs(m_S.coeff(res-1,res-1)) + abs(m_S.coeff(res,res));
286
+ if (s == Scalar(0.0))
287
+ s = m_normOfS;
288
+ if (abs(m_S.coeff(res,res-1)) < NumTraits<Scalar>::epsilon() * s)
289
+ break;
290
+ res--;
291
+ }
292
+ return res;
293
+ }
294
+
295
+ /** \internal Look for single small diagonal element T(res, res) for res between f and l, and return res (or f-1) */
296
+ template<typename MatrixType>
297
+ inline Index RealQZ<MatrixType>::findSmallDiagEntry(Index f, Index l)
298
+ {
299
+ using std::abs;
300
+ Index res = l;
301
+ while (res >= f) {
302
+ if (abs(m_T.coeff(res,res)) <= NumTraits<Scalar>::epsilon() * m_normOfT)
303
+ break;
304
+ res--;
305
+ }
306
+ return res;
307
+ }
308
+
309
+ /** \internal decouple 2x2 diagonal block in rows i, i+1 if eigenvalues are real */
310
+ template<typename MatrixType>
311
+ inline void RealQZ<MatrixType>::splitOffTwoRows(Index i)
312
+ {
313
+ using std::abs;
314
+ using std::sqrt;
315
+ const Index dim=m_S.cols();
316
+ if (abs(m_S.coeff(i+1,i))==Scalar(0))
317
+ return;
318
+ Index j = findSmallDiagEntry(i,i+1);
319
+ if (j==i-1)
320
+ {
321
+ // block of (S T^{-1})
322
+ Matrix2s STi = m_T.template block<2,2>(i,i).template triangularView<Upper>().
323
+ template solve<OnTheRight>(m_S.template block<2,2>(i,i));
324
+ Scalar p = Scalar(0.5)*(STi(0,0)-STi(1,1));
325
+ Scalar q = p*p + STi(1,0)*STi(0,1);
326
+ if (q>=0) {
327
+ Scalar z = sqrt(q);
328
+ // one QR-like iteration for ABi - lambda I
329
+ // is enough - when we know exact eigenvalue in advance,
330
+ // convergence is immediate
331
+ JRs G;
332
+ if (p>=0)
333
+ G.makeGivens(p + z, STi(1,0));
334
+ else
335
+ G.makeGivens(p - z, STi(1,0));
336
+ m_S.rightCols(dim-i).applyOnTheLeft(i,i+1,G.adjoint());
337
+ m_T.rightCols(dim-i).applyOnTheLeft(i,i+1,G.adjoint());
338
+ // update Q
339
+ if (m_computeQZ)
340
+ m_Q.applyOnTheRight(i,i+1,G);
341
+
342
+ G.makeGivens(m_T.coeff(i+1,i+1), m_T.coeff(i+1,i));
343
+ m_S.topRows(i+2).applyOnTheRight(i+1,i,G);
344
+ m_T.topRows(i+2).applyOnTheRight(i+1,i,G);
345
+ // update Z
346
+ if (m_computeQZ)
347
+ m_Z.applyOnTheLeft(i+1,i,G.adjoint());
348
+
349
+ m_S.coeffRef(i+1,i) = Scalar(0.0);
350
+ m_T.coeffRef(i+1,i) = Scalar(0.0);
351
+ }
352
+ }
353
+ else
354
+ {
355
+ pushDownZero(j,i,i+1);
356
+ }
357
+ }
358
+
359
+ /** \internal use zero in T(z,z) to zero S(l,l-1), working in block f..l */
360
+ template<typename MatrixType>
361
+ inline void RealQZ<MatrixType>::pushDownZero(Index z, Index f, Index l)
362
+ {
363
+ JRs G;
364
+ const Index dim = m_S.cols();
365
+ for (Index zz=z; zz<l; zz++)
366
+ {
367
+ // push 0 down
368
+ Index firstColS = zz>f ? (zz-1) : zz;
369
+ G.makeGivens(m_T.coeff(zz, zz+1), m_T.coeff(zz+1, zz+1));
370
+ m_S.rightCols(dim-firstColS).applyOnTheLeft(zz,zz+1,G.adjoint());
371
+ m_T.rightCols(dim-zz).applyOnTheLeft(zz,zz+1,G.adjoint());
372
+ m_T.coeffRef(zz+1,zz+1) = Scalar(0.0);
373
+ // update Q
374
+ if (m_computeQZ)
375
+ m_Q.applyOnTheRight(zz,zz+1,G);
376
+ // kill S(zz+1, zz-1)
377
+ if (zz>f)
378
+ {
379
+ G.makeGivens(m_S.coeff(zz+1, zz), m_S.coeff(zz+1,zz-1));
380
+ m_S.topRows(zz+2).applyOnTheRight(zz, zz-1,G);
381
+ m_T.topRows(zz+1).applyOnTheRight(zz, zz-1,G);
382
+ m_S.coeffRef(zz+1,zz-1) = Scalar(0.0);
383
+ // update Z
384
+ if (m_computeQZ)
385
+ m_Z.applyOnTheLeft(zz,zz-1,G.adjoint());
386
+ }
387
+ }
388
+ // finally kill S(l,l-1)
389
+ G.makeGivens(m_S.coeff(l,l), m_S.coeff(l,l-1));
390
+ m_S.applyOnTheRight(l,l-1,G);
391
+ m_T.applyOnTheRight(l,l-1,G);
392
+ m_S.coeffRef(l,l-1)=Scalar(0.0);
393
+ // update Z
394
+ if (m_computeQZ)
395
+ m_Z.applyOnTheLeft(l,l-1,G.adjoint());
396
+ }
397
+
398
+ /** \internal QR-like iterative step for block f..l */
399
+ template<typename MatrixType>
400
+ inline void RealQZ<MatrixType>::step(Index f, Index l, Index iter)
401
+ {
402
+ using std::abs;
403
+ const Index dim = m_S.cols();
404
+
405
+ // x, y, z
406
+ Scalar x, y, z;
407
+ if (iter==10)
408
+ {
409
+ // Wilkinson ad hoc shift
410
+ const Scalar
411
+ a11=m_S.coeff(f+0,f+0), a12=m_S.coeff(f+0,f+1),
412
+ a21=m_S.coeff(f+1,f+0), a22=m_S.coeff(f+1,f+1), a32=m_S.coeff(f+2,f+1),
413
+ b12=m_T.coeff(f+0,f+1),
414
+ b11i=Scalar(1.0)/m_T.coeff(f+0,f+0),
415
+ b22i=Scalar(1.0)/m_T.coeff(f+1,f+1),
416
+ a87=m_S.coeff(l-1,l-2),
417
+ a98=m_S.coeff(l-0,l-1),
418
+ b77i=Scalar(1.0)/m_T.coeff(l-2,l-2),
419
+ b88i=Scalar(1.0)/m_T.coeff(l-1,l-1);
420
+ Scalar ss = abs(a87*b77i) + abs(a98*b88i),
421
+ lpl = Scalar(1.5)*ss,
422
+ ll = ss*ss;
423
+ x = ll + a11*a11*b11i*b11i - lpl*a11*b11i + a12*a21*b11i*b22i
424
+ - a11*a21*b12*b11i*b11i*b22i;
425
+ y = a11*a21*b11i*b11i - lpl*a21*b11i + a21*a22*b11i*b22i
426
+ - a21*a21*b12*b11i*b11i*b22i;
427
+ z = a21*a32*b11i*b22i;
428
+ }
429
+ else if (iter==16)
430
+ {
431
+ // another exceptional shift
432
+ x = m_S.coeff(f,f)/m_T.coeff(f,f)-m_S.coeff(l,l)/m_T.coeff(l,l) + m_S.coeff(l,l-1)*m_T.coeff(l-1,l) /
433
+ (m_T.coeff(l-1,l-1)*m_T.coeff(l,l));
434
+ y = m_S.coeff(f+1,f)/m_T.coeff(f,f);
435
+ z = 0;
436
+ }
437
+ else if (iter>23 && !(iter%8))
438
+ {
439
+ // extremely exceptional shift
440
+ x = internal::random<Scalar>(-1.0,1.0);
441
+ y = internal::random<Scalar>(-1.0,1.0);
442
+ z = internal::random<Scalar>(-1.0,1.0);
443
+ }
444
+ else
445
+ {
446
+ // Compute the shifts: (x,y,z,0...) = (AB^-1 - l1 I) (AB^-1 - l2 I) e1
447
+ // where l1 and l2 are the eigenvalues of the 2x2 matrix C = U V^-1 where
448
+ // U and V are 2x2 bottom right sub matrices of A and B. Thus:
449
+ // = AB^-1AB^-1 + l1 l2 I - (l1+l2)(AB^-1)
450
+ // = AB^-1AB^-1 + det(M) - tr(M)(AB^-1)
451
+ // Since we are only interested in having x, y, z with a correct ratio, we have:
452
+ const Scalar
453
+ a11 = m_S.coeff(f,f), a12 = m_S.coeff(f,f+1),
454
+ a21 = m_S.coeff(f+1,f), a22 = m_S.coeff(f+1,f+1),
455
+ a32 = m_S.coeff(f+2,f+1),
456
+
457
+ a88 = m_S.coeff(l-1,l-1), a89 = m_S.coeff(l-1,l),
458
+ a98 = m_S.coeff(l,l-1), a99 = m_S.coeff(l,l),
459
+
460
+ b11 = m_T.coeff(f,f), b12 = m_T.coeff(f,f+1),
461
+ b22 = m_T.coeff(f+1,f+1),
462
+
463
+ b88 = m_T.coeff(l-1,l-1), b89 = m_T.coeff(l-1,l),
464
+ b99 = m_T.coeff(l,l);
465
+
466
+ x = ( (a88/b88 - a11/b11)*(a99/b99 - a11/b11) - (a89/b99)*(a98/b88) + (a98/b88)*(b89/b99)*(a11/b11) ) * (b11/a21)
467
+ + a12/b22 - (a11/b11)*(b12/b22);
468
+ y = (a22/b22-a11/b11) - (a21/b11)*(b12/b22) - (a88/b88-a11/b11) - (a99/b99-a11/b11) + (a98/b88)*(b89/b99);
469
+ z = a32/b22;
470
+ }
471
+
472
+ JRs G;
473
+
474
+ for (Index k=f; k<=l-2; k++)
475
+ {
476
+ // variables for Householder reflections
477
+ Vector2s essential2;
478
+ Scalar tau, beta;
479
+
480
+ Vector3s hr(x,y,z);
481
+
482
+ // Q_k to annihilate S(k+1,k-1) and S(k+2,k-1)
483
+ hr.makeHouseholderInPlace(tau, beta);
484
+ essential2 = hr.template bottomRows<2>();
485
+ Index fc=(std::max)(k-1,Index(0)); // first col to update
486
+ m_S.template middleRows<3>(k).rightCols(dim-fc).applyHouseholderOnTheLeft(essential2, tau, m_workspace.data());
487
+ m_T.template middleRows<3>(k).rightCols(dim-fc).applyHouseholderOnTheLeft(essential2, tau, m_workspace.data());
488
+ if (m_computeQZ)
489
+ m_Q.template middleCols<3>(k).applyHouseholderOnTheRight(essential2, tau, m_workspace.data());
490
+ if (k>f)
491
+ m_S.coeffRef(k+2,k-1) = m_S.coeffRef(k+1,k-1) = Scalar(0.0);
492
+
493
+ // Z_{k1} to annihilate T(k+2,k+1) and T(k+2,k)
494
+ hr << m_T.coeff(k+2,k+2),m_T.coeff(k+2,k),m_T.coeff(k+2,k+1);
495
+ hr.makeHouseholderInPlace(tau, beta);
496
+ essential2 = hr.template bottomRows<2>();
497
+ {
498
+ Index lr = (std::min)(k+4,dim); // last row to update
499
+ Map<Matrix<Scalar,Dynamic,1> > tmp(m_workspace.data(),lr);
500
+ // S
501
+ tmp = m_S.template middleCols<2>(k).topRows(lr) * essential2;
502
+ tmp += m_S.col(k+2).head(lr);
503
+ m_S.col(k+2).head(lr) -= tau*tmp;
504
+ m_S.template middleCols<2>(k).topRows(lr) -= (tau*tmp) * essential2.adjoint();
505
+ // T
506
+ tmp = m_T.template middleCols<2>(k).topRows(lr) * essential2;
507
+ tmp += m_T.col(k+2).head(lr);
508
+ m_T.col(k+2).head(lr) -= tau*tmp;
509
+ m_T.template middleCols<2>(k).topRows(lr) -= (tau*tmp) * essential2.adjoint();
510
+ }
511
+ if (m_computeQZ)
512
+ {
513
+ // Z
514
+ Map<Matrix<Scalar,1,Dynamic> > tmp(m_workspace.data(),dim);
515
+ tmp = essential2.adjoint()*(m_Z.template middleRows<2>(k));
516
+ tmp += m_Z.row(k+2);
517
+ m_Z.row(k+2) -= tau*tmp;
518
+ m_Z.template middleRows<2>(k) -= essential2 * (tau*tmp);
519
+ }
520
+ m_T.coeffRef(k+2,k) = m_T.coeffRef(k+2,k+1) = Scalar(0.0);
521
+
522
+ // Z_{k2} to annihilate T(k+1,k)
523
+ G.makeGivens(m_T.coeff(k+1,k+1), m_T.coeff(k+1,k));
524
+ m_S.applyOnTheRight(k+1,k,G);
525
+ m_T.applyOnTheRight(k+1,k,G);
526
+ // update Z
527
+ if (m_computeQZ)
528
+ m_Z.applyOnTheLeft(k+1,k,G.adjoint());
529
+ m_T.coeffRef(k+1,k) = Scalar(0.0);
530
+
531
+ // update x,y,z
532
+ x = m_S.coeff(k+1,k);
533
+ y = m_S.coeff(k+2,k);
534
+ if (k < l-2)
535
+ z = m_S.coeff(k+3,k);
536
+ } // loop over k
537
+
538
+ // Q_{n-1} to annihilate y = S(l,l-2)
539
+ G.makeGivens(x,y);
540
+ m_S.applyOnTheLeft(l-1,l,G.adjoint());
541
+ m_T.applyOnTheLeft(l-1,l,G.adjoint());
542
+ if (m_computeQZ)
543
+ m_Q.applyOnTheRight(l-1,l,G);
544
+ m_S.coeffRef(l,l-2) = Scalar(0.0);
545
+
546
+ // Z_{n-1} to annihilate T(l,l-1)
547
+ G.makeGivens(m_T.coeff(l,l),m_T.coeff(l,l-1));
548
+ m_S.applyOnTheRight(l,l-1,G);
549
+ m_T.applyOnTheRight(l,l-1,G);
550
+ if (m_computeQZ)
551
+ m_Z.applyOnTheLeft(l,l-1,G.adjoint());
552
+ m_T.coeffRef(l,l-1) = Scalar(0.0);
553
+ }
554
+
555
+ template<typename MatrixType>
556
+ RealQZ<MatrixType>& RealQZ<MatrixType>::compute(const MatrixType& A_in, const MatrixType& B_in, bool computeQZ)
557
+ {
558
+
559
+ const Index dim = A_in.cols();
560
+
561
+ eigen_assert (A_in.rows()==dim && A_in.cols()==dim
562
+ && B_in.rows()==dim && B_in.cols()==dim
563
+ && "Need square matrices of the same dimension");
564
+
565
+ m_isInitialized = true;
566
+ m_computeQZ = computeQZ;
567
+ m_S = A_in; m_T = B_in;
568
+ m_workspace.resize(dim*2);
569
+ m_global_iter = 0;
570
+
571
+ // entrance point: hessenberg triangular decomposition
572
+ hessenbergTriangular();
573
+ // compute L1 vector norms of T, S into m_normOfS, m_normOfT
574
+ computeNorms();
575
+
576
+ Index l = dim-1,
577
+ f,
578
+ local_iter = 0;
579
+
580
+ while (l>0 && local_iter<m_maxIters)
581
+ {
582
+ f = findSmallSubdiagEntry(l);
583
+ // now rows and columns f..l (including) decouple from the rest of the problem
584
+ if (f>0) m_S.coeffRef(f,f-1) = Scalar(0.0);
585
+ if (f == l) // One root found
586
+ {
587
+ l--;
588
+ local_iter = 0;
589
+ }
590
+ else if (f == l-1) // Two roots found
591
+ {
592
+ splitOffTwoRows(f);
593
+ l -= 2;
594
+ local_iter = 0;
595
+ }
596
+ else // No convergence yet
597
+ {
598
+ // if there's zero on diagonal of T, we can isolate an eigenvalue with Givens rotations
599
+ Index z = findSmallDiagEntry(f,l);
600
+ if (z>=f)
601
+ {
602
+ // zero found
603
+ pushDownZero(z,f,l);
604
+ }
605
+ else
606
+ {
607
+ // We are sure now that S.block(f,f, l-f+1,l-f+1) is underuced upper-Hessenberg
608
+ // and T.block(f,f, l-f+1,l-f+1) is invertible uper-triangular, which allows to
609
+ // apply a QR-like iteration to rows and columns f..l.
610
+ step(f,l, local_iter);
611
+ local_iter++;
612
+ m_global_iter++;
613
+ }
614
+ }
615
+ }
616
+ // check if we converged before reaching iterations limit
617
+ m_info = (local_iter<m_maxIters) ? Success : NoConvergence;
618
+
619
+ // For each non triangular 2x2 diagonal block of S,
620
+ // reduce the respective 2x2 diagonal block of T to positive diagonal form using 2x2 SVD.
621
+ // This step is not mandatory for QZ, but it does help further extraction of eigenvalues/eigenvectors,
622
+ // and is in par with Lapack/Matlab QZ.
623
+ if(m_info==Success)
624
+ {
625
+ for(Index i=0; i<dim-1; ++i)
626
+ {
627
+ if(m_S.coeff(i+1, i) != Scalar(0))
628
+ {
629
+ JacobiRotation<Scalar> j_left, j_right;
630
+ internal::real_2x2_jacobi_svd(m_T, i, i+1, &j_left, &j_right);
631
+
632
+ // Apply resulting Jacobi rotations
633
+ m_S.applyOnTheLeft(i,i+1,j_left);
634
+ m_S.applyOnTheRight(i,i+1,j_right);
635
+ m_T.applyOnTheLeft(i,i+1,j_left);
636
+ m_T.applyOnTheRight(i,i+1,j_right);
637
+ m_T(i+1,i) = m_T(i,i+1) = Scalar(0);
638
+
639
+ if(m_computeQZ) {
640
+ m_Q.applyOnTheRight(i,i+1,j_left.transpose());
641
+ m_Z.applyOnTheLeft(i,i+1,j_right.transpose());
642
+ }
643
+
644
+ i++;
645
+ }
646
+ }
647
+ }
648
+
649
+ return *this;
650
+ } // end compute
651
+
652
+ } // end namespace Eigen
653
+
654
+ #endif //EIGEN_REAL_QZ