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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +123 -0
- data/ext/tomoto/ext.cpp +245 -0
- data/ext/tomoto/extconf.rb +28 -0
- data/lib/tomoto.rb +12 -0
- data/lib/tomoto/ct.rb +11 -0
- data/lib/tomoto/hdp.rb +11 -0
- data/lib/tomoto/lda.rb +67 -0
- data/lib/tomoto/version.rb +3 -0
- data/vendor/EigenRand/EigenRand/Core.h +1139 -0
- data/vendor/EigenRand/EigenRand/Dists/Basic.h +111 -0
- data/vendor/EigenRand/EigenRand/Dists/Discrete.h +877 -0
- data/vendor/EigenRand/EigenRand/Dists/GammaPoisson.h +108 -0
- data/vendor/EigenRand/EigenRand/Dists/NormalExp.h +626 -0
- data/vendor/EigenRand/EigenRand/EigenRand +19 -0
- data/vendor/EigenRand/EigenRand/Macro.h +24 -0
- data/vendor/EigenRand/EigenRand/MorePacketMath.h +978 -0
- data/vendor/EigenRand/EigenRand/PacketFilter.h +286 -0
- data/vendor/EigenRand/EigenRand/PacketRandomEngine.h +624 -0
- data/vendor/EigenRand/EigenRand/RandUtils.h +413 -0
- data/vendor/EigenRand/EigenRand/doc.h +220 -0
- data/vendor/EigenRand/LICENSE +21 -0
- data/vendor/EigenRand/README.md +288 -0
- data/vendor/eigen/COPYING.BSD +26 -0
- data/vendor/eigen/COPYING.GPL +674 -0
- data/vendor/eigen/COPYING.LGPL +502 -0
- data/vendor/eigen/COPYING.MINPACK +52 -0
- data/vendor/eigen/COPYING.MPL2 +373 -0
- data/vendor/eigen/COPYING.README +18 -0
- data/vendor/eigen/Eigen/CMakeLists.txt +19 -0
- data/vendor/eigen/Eigen/Cholesky +46 -0
- data/vendor/eigen/Eigen/CholmodSupport +48 -0
- data/vendor/eigen/Eigen/Core +537 -0
- data/vendor/eigen/Eigen/Dense +7 -0
- data/vendor/eigen/Eigen/Eigen +2 -0
- data/vendor/eigen/Eigen/Eigenvalues +61 -0
- data/vendor/eigen/Eigen/Geometry +62 -0
- data/vendor/eigen/Eigen/Householder +30 -0
- data/vendor/eigen/Eigen/IterativeLinearSolvers +48 -0
- data/vendor/eigen/Eigen/Jacobi +33 -0
- data/vendor/eigen/Eigen/LU +50 -0
- data/vendor/eigen/Eigen/MetisSupport +35 -0
- data/vendor/eigen/Eigen/OrderingMethods +73 -0
- data/vendor/eigen/Eigen/PaStiXSupport +48 -0
- data/vendor/eigen/Eigen/PardisoSupport +35 -0
- data/vendor/eigen/Eigen/QR +51 -0
- data/vendor/eigen/Eigen/QtAlignedMalloc +40 -0
- data/vendor/eigen/Eigen/SPQRSupport +34 -0
- data/vendor/eigen/Eigen/SVD +51 -0
- data/vendor/eigen/Eigen/Sparse +36 -0
- data/vendor/eigen/Eigen/SparseCholesky +45 -0
- data/vendor/eigen/Eigen/SparseCore +69 -0
- data/vendor/eigen/Eigen/SparseLU +46 -0
- data/vendor/eigen/Eigen/SparseQR +37 -0
- data/vendor/eigen/Eigen/StdDeque +27 -0
- data/vendor/eigen/Eigen/StdList +26 -0
- data/vendor/eigen/Eigen/StdVector +27 -0
- data/vendor/eigen/Eigen/SuperLUSupport +64 -0
- data/vendor/eigen/Eigen/UmfPackSupport +40 -0
- data/vendor/eigen/Eigen/src/Cholesky/LDLT.h +673 -0
- data/vendor/eigen/Eigen/src/Cholesky/LLT.h +542 -0
- data/vendor/eigen/Eigen/src/Cholesky/LLT_LAPACKE.h +99 -0
- data/vendor/eigen/Eigen/src/CholmodSupport/CholmodSupport.h +639 -0
- data/vendor/eigen/Eigen/src/Core/Array.h +329 -0
- data/vendor/eigen/Eigen/src/Core/ArrayBase.h +226 -0
- data/vendor/eigen/Eigen/src/Core/ArrayWrapper.h +209 -0
- data/vendor/eigen/Eigen/src/Core/Assign.h +90 -0
- data/vendor/eigen/Eigen/src/Core/AssignEvaluator.h +935 -0
- data/vendor/eigen/Eigen/src/Core/Assign_MKL.h +178 -0
- data/vendor/eigen/Eigen/src/Core/BandMatrix.h +353 -0
- data/vendor/eigen/Eigen/src/Core/Block.h +452 -0
- data/vendor/eigen/Eigen/src/Core/BooleanRedux.h +164 -0
- data/vendor/eigen/Eigen/src/Core/CommaInitializer.h +160 -0
- data/vendor/eigen/Eigen/src/Core/ConditionEstimator.h +175 -0
- data/vendor/eigen/Eigen/src/Core/CoreEvaluators.h +1688 -0
- data/vendor/eigen/Eigen/src/Core/CoreIterators.h +127 -0
- data/vendor/eigen/Eigen/src/Core/CwiseBinaryOp.h +184 -0
- data/vendor/eigen/Eigen/src/Core/CwiseNullaryOp.h +866 -0
- data/vendor/eigen/Eigen/src/Core/CwiseTernaryOp.h +197 -0
- data/vendor/eigen/Eigen/src/Core/CwiseUnaryOp.h +103 -0
- data/vendor/eigen/Eigen/src/Core/CwiseUnaryView.h +128 -0
- data/vendor/eigen/Eigen/src/Core/DenseBase.h +611 -0
- data/vendor/eigen/Eigen/src/Core/DenseCoeffsBase.h +681 -0
- data/vendor/eigen/Eigen/src/Core/DenseStorage.h +570 -0
- data/vendor/eigen/Eigen/src/Core/Diagonal.h +260 -0
- data/vendor/eigen/Eigen/src/Core/DiagonalMatrix.h +343 -0
- data/vendor/eigen/Eigen/src/Core/DiagonalProduct.h +28 -0
- data/vendor/eigen/Eigen/src/Core/Dot.h +318 -0
- data/vendor/eigen/Eigen/src/Core/EigenBase.h +159 -0
- data/vendor/eigen/Eigen/src/Core/ForceAlignedAccess.h +146 -0
- data/vendor/eigen/Eigen/src/Core/Fuzzy.h +155 -0
- data/vendor/eigen/Eigen/src/Core/GeneralProduct.h +455 -0
- data/vendor/eigen/Eigen/src/Core/GenericPacketMath.h +593 -0
- data/vendor/eigen/Eigen/src/Core/GlobalFunctions.h +187 -0
- data/vendor/eigen/Eigen/src/Core/IO.h +225 -0
- data/vendor/eigen/Eigen/src/Core/Inverse.h +118 -0
- data/vendor/eigen/Eigen/src/Core/Map.h +171 -0
- data/vendor/eigen/Eigen/src/Core/MapBase.h +303 -0
- data/vendor/eigen/Eigen/src/Core/MathFunctions.h +1415 -0
- data/vendor/eigen/Eigen/src/Core/MathFunctionsImpl.h +101 -0
- data/vendor/eigen/Eigen/src/Core/Matrix.h +459 -0
- data/vendor/eigen/Eigen/src/Core/MatrixBase.h +529 -0
- data/vendor/eigen/Eigen/src/Core/NestByValue.h +110 -0
- data/vendor/eigen/Eigen/src/Core/NoAlias.h +108 -0
- data/vendor/eigen/Eigen/src/Core/NumTraits.h +248 -0
- data/vendor/eigen/Eigen/src/Core/PermutationMatrix.h +633 -0
- data/vendor/eigen/Eigen/src/Core/PlainObjectBase.h +1035 -0
- data/vendor/eigen/Eigen/src/Core/Product.h +186 -0
- data/vendor/eigen/Eigen/src/Core/ProductEvaluators.h +1112 -0
- data/vendor/eigen/Eigen/src/Core/Random.h +182 -0
- data/vendor/eigen/Eigen/src/Core/Redux.h +505 -0
- data/vendor/eigen/Eigen/src/Core/Ref.h +283 -0
- data/vendor/eigen/Eigen/src/Core/Replicate.h +142 -0
- data/vendor/eigen/Eigen/src/Core/ReturnByValue.h +117 -0
- data/vendor/eigen/Eigen/src/Core/Reverse.h +211 -0
- data/vendor/eigen/Eigen/src/Core/Select.h +162 -0
- data/vendor/eigen/Eigen/src/Core/SelfAdjointView.h +352 -0
- data/vendor/eigen/Eigen/src/Core/SelfCwiseBinaryOp.h +47 -0
- data/vendor/eigen/Eigen/src/Core/Solve.h +188 -0
- data/vendor/eigen/Eigen/src/Core/SolveTriangular.h +235 -0
- data/vendor/eigen/Eigen/src/Core/SolverBase.h +130 -0
- data/vendor/eigen/Eigen/src/Core/StableNorm.h +221 -0
- data/vendor/eigen/Eigen/src/Core/Stride.h +111 -0
- data/vendor/eigen/Eigen/src/Core/Swap.h +67 -0
- data/vendor/eigen/Eigen/src/Core/Transpose.h +403 -0
- data/vendor/eigen/Eigen/src/Core/Transpositions.h +407 -0
- data/vendor/eigen/Eigen/src/Core/TriangularMatrix.h +983 -0
- data/vendor/eigen/Eigen/src/Core/VectorBlock.h +96 -0
- data/vendor/eigen/Eigen/src/Core/VectorwiseOp.h +695 -0
- data/vendor/eigen/Eigen/src/Core/Visitor.h +273 -0
- data/vendor/eigen/Eigen/src/Core/arch/AVX/Complex.h +451 -0
- data/vendor/eigen/Eigen/src/Core/arch/AVX/MathFunctions.h +439 -0
- data/vendor/eigen/Eigen/src/Core/arch/AVX/PacketMath.h +637 -0
- data/vendor/eigen/Eigen/src/Core/arch/AVX/TypeCasting.h +51 -0
- data/vendor/eigen/Eigen/src/Core/arch/AVX512/MathFunctions.h +391 -0
- data/vendor/eigen/Eigen/src/Core/arch/AVX512/PacketMath.h +1316 -0
- data/vendor/eigen/Eigen/src/Core/arch/AltiVec/Complex.h +430 -0
- data/vendor/eigen/Eigen/src/Core/arch/AltiVec/MathFunctions.h +322 -0
- data/vendor/eigen/Eigen/src/Core/arch/AltiVec/PacketMath.h +1061 -0
- data/vendor/eigen/Eigen/src/Core/arch/CUDA/Complex.h +103 -0
- data/vendor/eigen/Eigen/src/Core/arch/CUDA/Half.h +674 -0
- data/vendor/eigen/Eigen/src/Core/arch/CUDA/MathFunctions.h +91 -0
- data/vendor/eigen/Eigen/src/Core/arch/CUDA/PacketMath.h +333 -0
- data/vendor/eigen/Eigen/src/Core/arch/CUDA/PacketMathHalf.h +1124 -0
- data/vendor/eigen/Eigen/src/Core/arch/CUDA/TypeCasting.h +212 -0
- data/vendor/eigen/Eigen/src/Core/arch/Default/ConjHelper.h +29 -0
- data/vendor/eigen/Eigen/src/Core/arch/Default/Settings.h +49 -0
- data/vendor/eigen/Eigen/src/Core/arch/NEON/Complex.h +490 -0
- data/vendor/eigen/Eigen/src/Core/arch/NEON/MathFunctions.h +91 -0
- data/vendor/eigen/Eigen/src/Core/arch/NEON/PacketMath.h +760 -0
- data/vendor/eigen/Eigen/src/Core/arch/SSE/Complex.h +471 -0
- data/vendor/eigen/Eigen/src/Core/arch/SSE/MathFunctions.h +562 -0
- data/vendor/eigen/Eigen/src/Core/arch/SSE/PacketMath.h +895 -0
- data/vendor/eigen/Eigen/src/Core/arch/SSE/TypeCasting.h +77 -0
- data/vendor/eigen/Eigen/src/Core/arch/ZVector/Complex.h +397 -0
- data/vendor/eigen/Eigen/src/Core/arch/ZVector/MathFunctions.h +137 -0
- data/vendor/eigen/Eigen/src/Core/arch/ZVector/PacketMath.h +945 -0
- data/vendor/eigen/Eigen/src/Core/functors/AssignmentFunctors.h +168 -0
- data/vendor/eigen/Eigen/src/Core/functors/BinaryFunctors.h +475 -0
- data/vendor/eigen/Eigen/src/Core/functors/NullaryFunctors.h +188 -0
- data/vendor/eigen/Eigen/src/Core/functors/StlFunctors.h +136 -0
- data/vendor/eigen/Eigen/src/Core/functors/TernaryFunctors.h +25 -0
- data/vendor/eigen/Eigen/src/Core/functors/UnaryFunctors.h +792 -0
- data/vendor/eigen/Eigen/src/Core/products/GeneralBlockPanelKernel.h +2156 -0
- data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixMatrix.h +492 -0
- data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h +311 -0
- data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_BLAS.h +145 -0
- data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixMatrix_BLAS.h +122 -0
- data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixVector.h +619 -0
- data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixVector_BLAS.h +136 -0
- data/vendor/eigen/Eigen/src/Core/products/Parallelizer.h +163 -0
- data/vendor/eigen/Eigen/src/Core/products/SelfadjointMatrixMatrix.h +521 -0
- data/vendor/eigen/Eigen/src/Core/products/SelfadjointMatrixMatrix_BLAS.h +287 -0
- data/vendor/eigen/Eigen/src/Core/products/SelfadjointMatrixVector.h +260 -0
- data/vendor/eigen/Eigen/src/Core/products/SelfadjointMatrixVector_BLAS.h +118 -0
- data/vendor/eigen/Eigen/src/Core/products/SelfadjointProduct.h +133 -0
- data/vendor/eigen/Eigen/src/Core/products/SelfadjointRank2Update.h +93 -0
- data/vendor/eigen/Eigen/src/Core/products/TriangularMatrixMatrix.h +466 -0
- data/vendor/eigen/Eigen/src/Core/products/TriangularMatrixMatrix_BLAS.h +315 -0
- data/vendor/eigen/Eigen/src/Core/products/TriangularMatrixVector.h +350 -0
- data/vendor/eigen/Eigen/src/Core/products/TriangularMatrixVector_BLAS.h +255 -0
- data/vendor/eigen/Eigen/src/Core/products/TriangularSolverMatrix.h +335 -0
- data/vendor/eigen/Eigen/src/Core/products/TriangularSolverMatrix_BLAS.h +163 -0
- data/vendor/eigen/Eigen/src/Core/products/TriangularSolverVector.h +145 -0
- data/vendor/eigen/Eigen/src/Core/util/BlasUtil.h +398 -0
- data/vendor/eigen/Eigen/src/Core/util/Constants.h +547 -0
- data/vendor/eigen/Eigen/src/Core/util/DisableStupidWarnings.h +83 -0
- data/vendor/eigen/Eigen/src/Core/util/ForwardDeclarations.h +302 -0
- data/vendor/eigen/Eigen/src/Core/util/MKL_support.h +130 -0
- data/vendor/eigen/Eigen/src/Core/util/Macros.h +1001 -0
- data/vendor/eigen/Eigen/src/Core/util/Memory.h +993 -0
- data/vendor/eigen/Eigen/src/Core/util/Meta.h +534 -0
- data/vendor/eigen/Eigen/src/Core/util/NonMPL2.h +3 -0
- data/vendor/eigen/Eigen/src/Core/util/ReenableStupidWarnings.h +27 -0
- data/vendor/eigen/Eigen/src/Core/util/StaticAssert.h +218 -0
- data/vendor/eigen/Eigen/src/Core/util/XprHelper.h +821 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/ComplexEigenSolver.h +346 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/ComplexSchur.h +459 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/ComplexSchur_LAPACKE.h +91 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/EigenSolver.h +622 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h +418 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h +226 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/HessenbergDecomposition.h +374 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/MatrixBaseEigenvalues.h +158 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/RealQZ.h +654 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/RealSchur.h +546 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/RealSchur_LAPACKE.h +77 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h +870 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/SelfAdjointEigenSolver_LAPACKE.h +87 -0
- data/vendor/eigen/Eigen/src/Eigenvalues/Tridiagonalization.h +556 -0
- data/vendor/eigen/Eigen/src/Geometry/AlignedBox.h +392 -0
- data/vendor/eigen/Eigen/src/Geometry/AngleAxis.h +247 -0
- data/vendor/eigen/Eigen/src/Geometry/EulerAngles.h +114 -0
- data/vendor/eigen/Eigen/src/Geometry/Homogeneous.h +497 -0
- data/vendor/eigen/Eigen/src/Geometry/Hyperplane.h +282 -0
- data/vendor/eigen/Eigen/src/Geometry/OrthoMethods.h +234 -0
- data/vendor/eigen/Eigen/src/Geometry/ParametrizedLine.h +195 -0
- data/vendor/eigen/Eigen/src/Geometry/Quaternion.h +814 -0
- data/vendor/eigen/Eigen/src/Geometry/Rotation2D.h +199 -0
- data/vendor/eigen/Eigen/src/Geometry/RotationBase.h +206 -0
- data/vendor/eigen/Eigen/src/Geometry/Scaling.h +170 -0
- data/vendor/eigen/Eigen/src/Geometry/Transform.h +1542 -0
- data/vendor/eigen/Eigen/src/Geometry/Translation.h +208 -0
- data/vendor/eigen/Eigen/src/Geometry/Umeyama.h +166 -0
- data/vendor/eigen/Eigen/src/Geometry/arch/Geometry_SSE.h +161 -0
- data/vendor/eigen/Eigen/src/Householder/BlockHouseholder.h +103 -0
- data/vendor/eigen/Eigen/src/Householder/Householder.h +172 -0
- data/vendor/eigen/Eigen/src/Householder/HouseholderSequence.h +470 -0
- data/vendor/eigen/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h +226 -0
- data/vendor/eigen/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h +228 -0
- data/vendor/eigen/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h +246 -0
- data/vendor/eigen/Eigen/src/IterativeLinearSolvers/IncompleteCholesky.h +400 -0
- data/vendor/eigen/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h +462 -0
- data/vendor/eigen/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h +394 -0
- data/vendor/eigen/Eigen/src/IterativeLinearSolvers/LeastSquareConjugateGradient.h +216 -0
- data/vendor/eigen/Eigen/src/IterativeLinearSolvers/SolveWithGuess.h +115 -0
- data/vendor/eigen/Eigen/src/Jacobi/Jacobi.h +462 -0
- data/vendor/eigen/Eigen/src/LU/Determinant.h +101 -0
- data/vendor/eigen/Eigen/src/LU/FullPivLU.h +891 -0
- data/vendor/eigen/Eigen/src/LU/InverseImpl.h +415 -0
- data/vendor/eigen/Eigen/src/LU/PartialPivLU.h +611 -0
- data/vendor/eigen/Eigen/src/LU/PartialPivLU_LAPACKE.h +83 -0
- data/vendor/eigen/Eigen/src/LU/arch/Inverse_SSE.h +338 -0
- data/vendor/eigen/Eigen/src/MetisSupport/MetisSupport.h +137 -0
- data/vendor/eigen/Eigen/src/OrderingMethods/Amd.h +445 -0
- data/vendor/eigen/Eigen/src/OrderingMethods/Eigen_Colamd.h +1843 -0
- data/vendor/eigen/Eigen/src/OrderingMethods/Ordering.h +157 -0
- data/vendor/eigen/Eigen/src/PaStiXSupport/PaStiXSupport.h +678 -0
- data/vendor/eigen/Eigen/src/PardisoSupport/PardisoSupport.h +543 -0
- data/vendor/eigen/Eigen/src/QR/ColPivHouseholderQR.h +653 -0
- data/vendor/eigen/Eigen/src/QR/ColPivHouseholderQR_LAPACKE.h +97 -0
- data/vendor/eigen/Eigen/src/QR/CompleteOrthogonalDecomposition.h +562 -0
- data/vendor/eigen/Eigen/src/QR/FullPivHouseholderQR.h +676 -0
- data/vendor/eigen/Eigen/src/QR/HouseholderQR.h +409 -0
- data/vendor/eigen/Eigen/src/QR/HouseholderQR_LAPACKE.h +68 -0
- data/vendor/eigen/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h +313 -0
- data/vendor/eigen/Eigen/src/SVD/BDCSVD.h +1246 -0
- data/vendor/eigen/Eigen/src/SVD/JacobiSVD.h +804 -0
- data/vendor/eigen/Eigen/src/SVD/JacobiSVD_LAPACKE.h +91 -0
- data/vendor/eigen/Eigen/src/SVD/SVDBase.h +315 -0
- data/vendor/eigen/Eigen/src/SVD/UpperBidiagonalization.h +414 -0
- data/vendor/eigen/Eigen/src/SparseCholesky/SimplicialCholesky.h +689 -0
- data/vendor/eigen/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h +199 -0
- data/vendor/eigen/Eigen/src/SparseCore/AmbiVector.h +377 -0
- data/vendor/eigen/Eigen/src/SparseCore/CompressedStorage.h +258 -0
- data/vendor/eigen/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h +352 -0
- data/vendor/eigen/Eigen/src/SparseCore/MappedSparseMatrix.h +67 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseAssign.h +216 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseBlock.h +603 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseColEtree.h +206 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseCompressedBase.h +341 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseCwiseBinaryOp.h +726 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseCwiseUnaryOp.h +148 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseDenseProduct.h +320 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseDiagonalProduct.h +138 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseDot.h +98 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseFuzzy.h +29 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseMap.h +305 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseMatrix.h +1403 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseMatrixBase.h +405 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparsePermutation.h +178 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseProduct.h +169 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseRedux.h +49 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseRef.h +397 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseSelfAdjointView.h +656 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseSolverBase.h +124 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseSparseProductWithPruning.h +198 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseTranspose.h +92 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseTriangularView.h +189 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseUtil.h +178 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseVector.h +478 -0
- data/vendor/eigen/Eigen/src/SparseCore/SparseView.h +253 -0
- data/vendor/eigen/Eigen/src/SparseCore/TriangularSolver.h +315 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU.h +773 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLUImpl.h +66 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_Memory.h +226 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_Structs.h +110 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h +301 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_Utils.h +80 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_column_bmod.h +181 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_column_dfs.h +179 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h +107 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_gemm_kernel.h +280 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h +126 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_kernel_bmod.h +130 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_panel_bmod.h +223 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_panel_dfs.h +258 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_pivotL.h +137 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_pruneL.h +136 -0
- data/vendor/eigen/Eigen/src/SparseLU/SparseLU_relax_snode.h +83 -0
- data/vendor/eigen/Eigen/src/SparseQR/SparseQR.h +745 -0
- data/vendor/eigen/Eigen/src/StlSupport/StdDeque.h +126 -0
- data/vendor/eigen/Eigen/src/StlSupport/StdList.h +106 -0
- data/vendor/eigen/Eigen/src/StlSupport/StdVector.h +131 -0
- data/vendor/eigen/Eigen/src/StlSupport/details.h +84 -0
- data/vendor/eigen/Eigen/src/SuperLUSupport/SuperLUSupport.h +1027 -0
- data/vendor/eigen/Eigen/src/UmfPackSupport/UmfPackSupport.h +506 -0
- data/vendor/eigen/Eigen/src/misc/Image.h +82 -0
- data/vendor/eigen/Eigen/src/misc/Kernel.h +79 -0
- data/vendor/eigen/Eigen/src/misc/RealSvd2x2.h +55 -0
- data/vendor/eigen/Eigen/src/misc/blas.h +440 -0
- data/vendor/eigen/Eigen/src/misc/lapack.h +152 -0
- data/vendor/eigen/Eigen/src/misc/lapacke.h +16291 -0
- data/vendor/eigen/Eigen/src/misc/lapacke_mangling.h +17 -0
- data/vendor/eigen/Eigen/src/plugins/ArrayCwiseBinaryOps.h +332 -0
- data/vendor/eigen/Eigen/src/plugins/ArrayCwiseUnaryOps.h +552 -0
- data/vendor/eigen/Eigen/src/plugins/BlockMethods.h +1058 -0
- data/vendor/eigen/Eigen/src/plugins/CommonCwiseBinaryOps.h +115 -0
- data/vendor/eigen/Eigen/src/plugins/CommonCwiseUnaryOps.h +163 -0
- data/vendor/eigen/Eigen/src/plugins/MatrixCwiseBinaryOps.h +152 -0
- data/vendor/eigen/Eigen/src/plugins/MatrixCwiseUnaryOps.h +85 -0
- data/vendor/eigen/README.md +3 -0
- data/vendor/eigen/bench/README.txt +55 -0
- data/vendor/eigen/bench/btl/COPYING +340 -0
- data/vendor/eigen/bench/btl/README +154 -0
- data/vendor/eigen/bench/tensors/README +21 -0
- data/vendor/eigen/blas/README.txt +6 -0
- data/vendor/eigen/demos/mandelbrot/README +10 -0
- data/vendor/eigen/demos/mix_eigen_and_c/README +9 -0
- data/vendor/eigen/demos/opengl/README +13 -0
- data/vendor/eigen/unsupported/Eigen/CXX11/src/Tensor/README.md +1760 -0
- data/vendor/eigen/unsupported/README.txt +50 -0
- data/vendor/tomotopy/LICENSE +21 -0
- data/vendor/tomotopy/README.kr.rst +375 -0
- data/vendor/tomotopy/README.rst +382 -0
- data/vendor/tomotopy/src/Labeling/FoRelevance.cpp +362 -0
- data/vendor/tomotopy/src/Labeling/FoRelevance.h +88 -0
- data/vendor/tomotopy/src/Labeling/Labeler.h +50 -0
- data/vendor/tomotopy/src/TopicModel/CT.h +37 -0
- data/vendor/tomotopy/src/TopicModel/CTModel.cpp +13 -0
- data/vendor/tomotopy/src/TopicModel/CTModel.hpp +293 -0
- data/vendor/tomotopy/src/TopicModel/DMR.h +51 -0
- data/vendor/tomotopy/src/TopicModel/DMRModel.cpp +13 -0
- data/vendor/tomotopy/src/TopicModel/DMRModel.hpp +374 -0
- data/vendor/tomotopy/src/TopicModel/DT.h +65 -0
- data/vendor/tomotopy/src/TopicModel/DTM.h +22 -0
- data/vendor/tomotopy/src/TopicModel/DTModel.cpp +15 -0
- data/vendor/tomotopy/src/TopicModel/DTModel.hpp +572 -0
- data/vendor/tomotopy/src/TopicModel/GDMR.h +37 -0
- data/vendor/tomotopy/src/TopicModel/GDMRModel.cpp +14 -0
- data/vendor/tomotopy/src/TopicModel/GDMRModel.hpp +485 -0
- data/vendor/tomotopy/src/TopicModel/HDP.h +74 -0
- data/vendor/tomotopy/src/TopicModel/HDPModel.cpp +13 -0
- data/vendor/tomotopy/src/TopicModel/HDPModel.hpp +592 -0
- data/vendor/tomotopy/src/TopicModel/HLDA.h +40 -0
- data/vendor/tomotopy/src/TopicModel/HLDAModel.cpp +13 -0
- data/vendor/tomotopy/src/TopicModel/HLDAModel.hpp +681 -0
- data/vendor/tomotopy/src/TopicModel/HPA.h +27 -0
- data/vendor/tomotopy/src/TopicModel/HPAModel.cpp +21 -0
- data/vendor/tomotopy/src/TopicModel/HPAModel.hpp +588 -0
- data/vendor/tomotopy/src/TopicModel/LDA.h +144 -0
- data/vendor/tomotopy/src/TopicModel/LDACVB0Model.hpp +442 -0
- data/vendor/tomotopy/src/TopicModel/LDAModel.cpp +13 -0
- data/vendor/tomotopy/src/TopicModel/LDAModel.hpp +1058 -0
- data/vendor/tomotopy/src/TopicModel/LLDA.h +45 -0
- data/vendor/tomotopy/src/TopicModel/LLDAModel.cpp +13 -0
- data/vendor/tomotopy/src/TopicModel/LLDAModel.hpp +203 -0
- data/vendor/tomotopy/src/TopicModel/MGLDA.h +63 -0
- data/vendor/tomotopy/src/TopicModel/MGLDAModel.cpp +17 -0
- data/vendor/tomotopy/src/TopicModel/MGLDAModel.hpp +558 -0
- data/vendor/tomotopy/src/TopicModel/PA.h +43 -0
- data/vendor/tomotopy/src/TopicModel/PAModel.cpp +13 -0
- data/vendor/tomotopy/src/TopicModel/PAModel.hpp +467 -0
- data/vendor/tomotopy/src/TopicModel/PLDA.h +17 -0
- data/vendor/tomotopy/src/TopicModel/PLDAModel.cpp +13 -0
- data/vendor/tomotopy/src/TopicModel/PLDAModel.hpp +214 -0
- data/vendor/tomotopy/src/TopicModel/SLDA.h +54 -0
- data/vendor/tomotopy/src/TopicModel/SLDAModel.cpp +17 -0
- data/vendor/tomotopy/src/TopicModel/SLDAModel.hpp +456 -0
- data/vendor/tomotopy/src/TopicModel/TopicModel.hpp +692 -0
- data/vendor/tomotopy/src/Utils/AliasMethod.hpp +169 -0
- data/vendor/tomotopy/src/Utils/Dictionary.h +80 -0
- data/vendor/tomotopy/src/Utils/EigenAddonOps.hpp +181 -0
- data/vendor/tomotopy/src/Utils/LBFGS.h +202 -0
- data/vendor/tomotopy/src/Utils/LBFGS/LineSearchBacktracking.h +120 -0
- data/vendor/tomotopy/src/Utils/LBFGS/LineSearchBracketing.h +122 -0
- data/vendor/tomotopy/src/Utils/LBFGS/Param.h +213 -0
- data/vendor/tomotopy/src/Utils/LUT.hpp +82 -0
- data/vendor/tomotopy/src/Utils/MultiNormalDistribution.hpp +69 -0
- data/vendor/tomotopy/src/Utils/PolyaGamma.hpp +200 -0
- data/vendor/tomotopy/src/Utils/PolyaGammaHybrid.hpp +672 -0
- data/vendor/tomotopy/src/Utils/ThreadPool.hpp +150 -0
- data/vendor/tomotopy/src/Utils/Trie.hpp +220 -0
- data/vendor/tomotopy/src/Utils/TruncMultiNormal.hpp +94 -0
- data/vendor/tomotopy/src/Utils/Utils.hpp +337 -0
- data/vendor/tomotopy/src/Utils/avx_gamma.h +46 -0
- data/vendor/tomotopy/src/Utils/avx_mathfun.h +736 -0
- data/vendor/tomotopy/src/Utils/exception.h +28 -0
- data/vendor/tomotopy/src/Utils/math.h +281 -0
- data/vendor/tomotopy/src/Utils/rtnorm.hpp +2690 -0
- data/vendor/tomotopy/src/Utils/sample.hpp +192 -0
- data/vendor/tomotopy/src/Utils/serializer.hpp +695 -0
- data/vendor/tomotopy/src/Utils/slp.hpp +131 -0
- data/vendor/tomotopy/src/Utils/sse_gamma.h +48 -0
- data/vendor/tomotopy/src/Utils/sse_mathfun.h +710 -0
- data/vendor/tomotopy/src/Utils/text.hpp +49 -0
- data/vendor/tomotopy/src/Utils/tvector.hpp +543 -0
- metadata +531 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
/**
|
|
3
|
+
* @file GammaPoisson.h
|
|
4
|
+
* @author bab2min (bab2min@gmail.com)
|
|
5
|
+
* @brief
|
|
6
|
+
* @version 0.2.0
|
|
7
|
+
* @date 2020-06-22
|
|
8
|
+
*
|
|
9
|
+
* @copyright Copyright (c) 2020
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
#ifndef EIGENRAND_DISTS_GAMMAPOISSON_H
|
|
14
|
+
#define EIGENRAND_DISTS_GAMMAPOISSON_H
|
|
15
|
+
|
|
16
|
+
#include <memory>
|
|
17
|
+
#include <iterator>
|
|
18
|
+
#include <limits>
|
|
19
|
+
|
|
20
|
+
namespace Eigen
|
|
21
|
+
{
|
|
22
|
+
namespace internal
|
|
23
|
+
{
|
|
24
|
+
template<typename Scalar, typename Rng>
|
|
25
|
+
struct scalar_negative_binomial_dist_op : public scalar_gamma_dist_op<float, Rng>
|
|
26
|
+
{
|
|
27
|
+
static_assert(std::is_same<Scalar, int32_t>::value, "uniformInt needs integral types.");
|
|
28
|
+
|
|
29
|
+
scalar_negative_binomial_dist_op(const Rng& _rng, Scalar _trials = 1, double _p = 0.5)
|
|
30
|
+
: scalar_gamma_dist_op<float, Rng>{ _rng, (float)_trials, (float)((1 - _p) / _p) }
|
|
31
|
+
|
|
32
|
+
{
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() () const
|
|
36
|
+
{
|
|
37
|
+
float v = scalar_gamma_dist_op<float, Rng>::operator()();
|
|
38
|
+
return scalar_poisson_dist_op<Scalar, Rng>{ this->rng, v }();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
template<typename Packet>
|
|
42
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp() const
|
|
43
|
+
{
|
|
44
|
+
using ur_base = scalar_uniform_real_op<float, Rng>;
|
|
45
|
+
using PacketType = decltype(reinterpret_to_float(std::declval<Packet>()));
|
|
46
|
+
|
|
47
|
+
auto mean = scalar_gamma_dist_op<float, Rng>::template packetOp<PacketType>();
|
|
48
|
+
auto res = pset1<Packet>(0);
|
|
49
|
+
PacketType val = pset1<PacketType>(1), pne_mean = pexp(pnegate(mean));
|
|
50
|
+
if (pmovemask(pcmplt(pset1<PacketType>(12), mean)) == 0)
|
|
51
|
+
{
|
|
52
|
+
while (1)
|
|
53
|
+
{
|
|
54
|
+
val = pmul(val, ur_base::template packetOp<PacketType>());
|
|
55
|
+
auto c = reinterpret_to_int(pcmplt(pne_mean, val));
|
|
56
|
+
if (pmovemask(c) == 0) break;
|
|
57
|
+
res = padd(res, pnegate(c));
|
|
58
|
+
}
|
|
59
|
+
return res;
|
|
60
|
+
}
|
|
61
|
+
else
|
|
62
|
+
{
|
|
63
|
+
auto& cm = Rand::detail::CompressMask<sizeof(Packet)>::get_inst();
|
|
64
|
+
thread_local PacketType cache_rest;
|
|
65
|
+
thread_local int cache_rest_cnt;
|
|
66
|
+
thread_local const scalar_negative_binomial_dist_op* cache_ptr = nullptr;
|
|
67
|
+
if (cache_ptr != this)
|
|
68
|
+
{
|
|
69
|
+
cache_ptr = this;
|
|
70
|
+
cache_rest = pset1<PacketType>(0);
|
|
71
|
+
cache_rest_cnt = 0;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const PacketType ppi = pset1<PacketType>(constant::pi),
|
|
75
|
+
psqrt_tmean = psqrt(pmul(pset1<PacketType>(2), mean)),
|
|
76
|
+
plog_mean = plog(mean),
|
|
77
|
+
pg1 = psub(pmul(mean, plog_mean), plgamma(padd(mean, pset1<PacketType>(1))));
|
|
78
|
+
while (1)
|
|
79
|
+
{
|
|
80
|
+
PacketType fres, yx, psin, pcos;
|
|
81
|
+
psincos(pmul(ppi, ur_base::template packetOp<PacketType>()), psin, pcos);
|
|
82
|
+
yx = pdiv(psin, pcos);
|
|
83
|
+
fres = ptruncate(padd(pmul(psqrt_tmean, yx), mean));
|
|
84
|
+
|
|
85
|
+
auto p1 = pmul(padd(pmul(yx, yx), pset1<PacketType>(1)), pset1<PacketType>(0.9));
|
|
86
|
+
auto p2 = pexp(psub(psub(pmul(fres, plog_mean), plgamma(padd(fres, pset1<PacketType>(1)))), pg1));
|
|
87
|
+
|
|
88
|
+
auto c1 = pcmple(pset1<PacketType>(0), fres);
|
|
89
|
+
auto c2 = pcmple(ur_base::template packetOp<PacketType>(), pmul(p1, p2));
|
|
90
|
+
|
|
91
|
+
auto cands = fres;
|
|
92
|
+
bool full = false;
|
|
93
|
+
cache_rest_cnt = cm.compress_append(cands, pand(c1, c2),
|
|
94
|
+
cache_rest, cache_rest_cnt, full);
|
|
95
|
+
if (full) return pcast<PacketType, Packet>(cands);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
template<typename Scalar, typename Urng>
|
|
102
|
+
struct functor_traits<scalar_negative_binomial_dist_op<Scalar, Urng> >
|
|
103
|
+
{
|
|
104
|
+
enum { Cost = HugeCost, PacketAccess = packet_traits<Scalar>::Vectorizable, IsRepeatable = false };
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
#endif
|
|
@@ -0,0 +1,626 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file NormalExp.h
|
|
3
|
+
* @author bab2min (bab2min@gmail.com)
|
|
4
|
+
* @brief
|
|
5
|
+
* @version 0.2.0
|
|
6
|
+
* @date 2020-06-22
|
|
7
|
+
*
|
|
8
|
+
* @copyright Copyright (c) 2020
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
#ifndef EIGENRAND_DISTS_NORMAL_EXP_H
|
|
14
|
+
#define EIGENRAND_DISTS_NORMAL_EXP_H
|
|
15
|
+
|
|
16
|
+
namespace Eigen
|
|
17
|
+
{
|
|
18
|
+
namespace internal
|
|
19
|
+
{
|
|
20
|
+
template<typename Scalar, typename Rng>
|
|
21
|
+
struct scalar_norm_dist_op : public scalar_uniform_real_op<Scalar, Rng>
|
|
22
|
+
{
|
|
23
|
+
static_assert(std::is_floating_point<Scalar>::value, "normalDist needs floating point types.");
|
|
24
|
+
using ur_base = scalar_uniform_real_op<Scalar, Rng>;
|
|
25
|
+
|
|
26
|
+
using ur_base::scalar_uniform_real_op;
|
|
27
|
+
|
|
28
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() () const
|
|
29
|
+
{
|
|
30
|
+
thread_local Scalar cache;
|
|
31
|
+
thread_local const scalar_norm_dist_op* cache_ptr = nullptr;
|
|
32
|
+
if (cache_ptr == this)
|
|
33
|
+
{
|
|
34
|
+
cache_ptr = nullptr;
|
|
35
|
+
return cache;
|
|
36
|
+
}
|
|
37
|
+
cache_ptr = this;
|
|
38
|
+
|
|
39
|
+
Scalar v1, v2, sx;
|
|
40
|
+
while (1)
|
|
41
|
+
{
|
|
42
|
+
v1 = 2 * ur_base::operator()() - 1;
|
|
43
|
+
v2 = 2 * ur_base::operator()() - 1;
|
|
44
|
+
sx = v1 * v1 + v2 * v2;
|
|
45
|
+
if (sx && sx < 1) break;
|
|
46
|
+
}
|
|
47
|
+
Scalar fx = std::sqrt((Scalar)-2.0 * std::log(sx) / sx);
|
|
48
|
+
cache = fx * v2;
|
|
49
|
+
return fx * v1;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
template<typename Packet>
|
|
53
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp() const
|
|
54
|
+
{
|
|
55
|
+
thread_local Packet cache;
|
|
56
|
+
thread_local const scalar_norm_dist_op* cache_ptr = nullptr;
|
|
57
|
+
if (cache_ptr == this)
|
|
58
|
+
{
|
|
59
|
+
cache_ptr = nullptr;
|
|
60
|
+
return cache;
|
|
61
|
+
}
|
|
62
|
+
cache_ptr = this;
|
|
63
|
+
Packet u1 = ur_base::template packetOp<Packet>(),
|
|
64
|
+
u2 = ur_base::template packetOp<Packet>();
|
|
65
|
+
|
|
66
|
+
u1 = psub(pset1<Packet>(1), u1);
|
|
67
|
+
|
|
68
|
+
auto radius = psqrt(pmul(pset1<Packet>(-2), plog(u1)));
|
|
69
|
+
auto theta = pmul(pset1<Packet>(2 * constant::pi), u2);
|
|
70
|
+
Packet sintheta, costheta;
|
|
71
|
+
|
|
72
|
+
psincos(theta, sintheta, costheta);
|
|
73
|
+
cache = pmul(radius, costheta);
|
|
74
|
+
return pmul(radius, sintheta);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
template<typename Scalar, typename Urng>
|
|
79
|
+
struct functor_traits<scalar_norm_dist_op<Scalar, Urng> >
|
|
80
|
+
{
|
|
81
|
+
enum { Cost = HugeCost, PacketAccess = packet_traits<Scalar>::Vectorizable, IsRepeatable = false };
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
template<typename Scalar, typename Rng>
|
|
85
|
+
struct scalar_norm_dist2_op : public scalar_norm_dist_op<Scalar, Rng>
|
|
86
|
+
{
|
|
87
|
+
static_assert(std::is_floating_point<Scalar>::value, "normalDist needs floating point types.");
|
|
88
|
+
|
|
89
|
+
Scalar mean = 0, stdev = 1;
|
|
90
|
+
|
|
91
|
+
scalar_norm_dist2_op(const Rng& _rng,
|
|
92
|
+
Scalar _mean = 0, Scalar _stdev = 1)
|
|
93
|
+
: scalar_norm_dist_op<Scalar, Rng>{ _rng },
|
|
94
|
+
mean{ _mean }, stdev{ _stdev }
|
|
95
|
+
{
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() () const
|
|
99
|
+
{
|
|
100
|
+
return scalar_norm_dist_op<Scalar, Rng>::operator()() * stdev + mean;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
template<typename Packet>
|
|
104
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp() const
|
|
105
|
+
{
|
|
106
|
+
return padd(pmul(
|
|
107
|
+
scalar_norm_dist_op<Scalar, Rng>::template packetOp<Packet>(),
|
|
108
|
+
pset1<Packet>(stdev)
|
|
109
|
+
), pset1<Packet>(mean));
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
template<typename Scalar, typename Urng>
|
|
114
|
+
struct functor_traits<scalar_norm_dist2_op<Scalar, Urng> >
|
|
115
|
+
{
|
|
116
|
+
enum { Cost = HugeCost, PacketAccess = packet_traits<Scalar>::Vectorizable, IsRepeatable = false };
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
template<typename Scalar, typename Rng>
|
|
120
|
+
struct scalar_lognorm_dist_op : public scalar_norm_dist2_op<Scalar, Rng>
|
|
121
|
+
{
|
|
122
|
+
static_assert(std::is_floating_point<Scalar>::value, "lognormalDist needs floating point types.");
|
|
123
|
+
|
|
124
|
+
using scalar_norm_dist2_op<Scalar, Rng>::scalar_norm_dist2_op;
|
|
125
|
+
|
|
126
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() () const
|
|
127
|
+
{
|
|
128
|
+
return std::exp(scalar_norm_dist2_op<Scalar, Rng>::operator()());
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
template<typename Packet>
|
|
132
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp() const
|
|
133
|
+
{
|
|
134
|
+
return pexp(scalar_norm_dist2_op<Scalar, Rng>::template packetOp<Packet>());
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
template<typename Scalar, typename Urng>
|
|
139
|
+
struct functor_traits<scalar_lognorm_dist_op<Scalar, Urng> >
|
|
140
|
+
{
|
|
141
|
+
enum { Cost = HugeCost, PacketAccess = packet_traits<Scalar>::Vectorizable, IsRepeatable = false };
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
template<typename Scalar, typename Rng>
|
|
145
|
+
struct scalar_student_t_dist_op : public scalar_uniform_real_op<Scalar, Rng>
|
|
146
|
+
{
|
|
147
|
+
static_assert(std::is_floating_point<Scalar>::value, "normalDist needs floating point types.");
|
|
148
|
+
using ur_base = scalar_uniform_real_op<Scalar, Rng>;
|
|
149
|
+
|
|
150
|
+
Scalar n;
|
|
151
|
+
|
|
152
|
+
scalar_student_t_dist_op(const Rng& _rng, Scalar _n = 1)
|
|
153
|
+
: ur_base{ _rng }, n{ _n }
|
|
154
|
+
{
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() () const
|
|
158
|
+
{
|
|
159
|
+
Scalar v1, v2, sx;
|
|
160
|
+
while (1)
|
|
161
|
+
{
|
|
162
|
+
v1 = 2 * ur_base::operator()() - 1;
|
|
163
|
+
v2 = 2 * ur_base::operator()() - 1;
|
|
164
|
+
sx = v1 * v1 + v2 * v2;
|
|
165
|
+
if (sx && sx < 1) break;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
Scalar fx = std::sqrt(n * (std::pow(sx, -2 / n) - 1) / sx);
|
|
169
|
+
return fx * v1;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
template<typename Packet>
|
|
173
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp() const
|
|
174
|
+
{
|
|
175
|
+
Packet u1 = ur_base::template packetOp<Packet>(),
|
|
176
|
+
u2 = ur_base::template packetOp<Packet>();
|
|
177
|
+
|
|
178
|
+
u1 = psub(pset1<Packet>(1), u1);
|
|
179
|
+
auto pn = pset1<Packet>(n);
|
|
180
|
+
auto radius = psqrt(pmul(pn,
|
|
181
|
+
psub(pexp(pmul(plog(u1), pset1<Packet>(-2 / n))), pset1<Packet>(1))
|
|
182
|
+
));
|
|
183
|
+
auto theta = pmul(pset1<Packet>(2 * constant::pi), u2);
|
|
184
|
+
Packet sintheta, costheta;
|
|
185
|
+
|
|
186
|
+
//psincos(theta, sintheta, costheta);
|
|
187
|
+
return pmul(radius, psin(theta));
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
template<typename Scalar, typename Urng>
|
|
192
|
+
struct functor_traits<scalar_student_t_dist_op<Scalar, Urng> >
|
|
193
|
+
{
|
|
194
|
+
enum { Cost = HugeCost, PacketAccess = packet_traits<Scalar>::Vectorizable, IsRepeatable = false };
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
template<typename Scalar, typename Rng>
|
|
198
|
+
struct scalar_exp_dist_op : public scalar_uniform_real_op<Scalar, Rng>
|
|
199
|
+
{
|
|
200
|
+
static_assert(std::is_floating_point<Scalar>::value, "expDist needs floating point types.");
|
|
201
|
+
|
|
202
|
+
Scalar lambda = 1;
|
|
203
|
+
|
|
204
|
+
scalar_exp_dist_op(const Rng& _rng, Scalar _lambda = 1)
|
|
205
|
+
: scalar_uniform_real_op<Scalar, Rng>{ _rng }, lambda{ _lambda }
|
|
206
|
+
{
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() () const
|
|
210
|
+
{
|
|
211
|
+
return -std::log(1 - scalar_uniform_real_op<Scalar, Rng>::operator()()) / lambda;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
template<typename Packet>
|
|
215
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp() const
|
|
216
|
+
{
|
|
217
|
+
return pnegate(pdiv(plog(
|
|
218
|
+
psub(pset1<Packet>(1), scalar_uniform_real_op<Scalar, Rng>::template packetOp<Packet>())
|
|
219
|
+
), pset1<Packet>(lambda)));
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
template<typename Scalar, typename Urng>
|
|
224
|
+
struct functor_traits<scalar_exp_dist_op<Scalar, Urng> >
|
|
225
|
+
{
|
|
226
|
+
enum { Cost = HugeCost, PacketAccess = packet_traits<Scalar>::Vectorizable, IsRepeatable = false };
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
template<typename Scalar, typename Rng>
|
|
230
|
+
struct scalar_gamma_dist_op : public scalar_exp_dist_op<Scalar, Rng>
|
|
231
|
+
{
|
|
232
|
+
static_assert(std::is_floating_point<Scalar>::value, "gammaDist needs floating point types.");
|
|
233
|
+
|
|
234
|
+
Scalar alpha, beta, px, sqrt;
|
|
235
|
+
|
|
236
|
+
scalar_gamma_dist_op(const Rng& _rng, Scalar _alpha = 1, Scalar _beta = 1)
|
|
237
|
+
: scalar_exp_dist_op<Scalar, Rng>{ _rng }, alpha{ _alpha }, beta{ _beta }
|
|
238
|
+
{
|
|
239
|
+
px = constant::e / (alpha + constant::e);
|
|
240
|
+
sqrt = std::sqrt(2 * alpha - 1);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() () const
|
|
244
|
+
{
|
|
245
|
+
using ur_base = scalar_uniform_real_op<Scalar, Rng>;
|
|
246
|
+
if (alpha < 1)
|
|
247
|
+
{
|
|
248
|
+
Scalar ux, vx, xx, qx;
|
|
249
|
+
while (1)
|
|
250
|
+
{
|
|
251
|
+
ux = ur_base::operator()();
|
|
252
|
+
vx = this->nzur_scalar();
|
|
253
|
+
|
|
254
|
+
if (ux < px)
|
|
255
|
+
{
|
|
256
|
+
xx = std::pow(vx, 1 / alpha);
|
|
257
|
+
qx = std::exp(-xx);
|
|
258
|
+
}
|
|
259
|
+
else
|
|
260
|
+
{
|
|
261
|
+
xx = 1 - std::log(vx);
|
|
262
|
+
qx = std::pow(xx, alpha - 1);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
if (ur_base::operator()() < qx)
|
|
266
|
+
{
|
|
267
|
+
return beta * xx;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
if (alpha == 1)
|
|
272
|
+
{
|
|
273
|
+
return beta * scalar_exp_dist_op<Scalar, Rng>::operator()();
|
|
274
|
+
}
|
|
275
|
+
int count;
|
|
276
|
+
if ((count = alpha) == alpha && count < 20)
|
|
277
|
+
{
|
|
278
|
+
Scalar yx;
|
|
279
|
+
yx = this->nzur_scalar();
|
|
280
|
+
while (--count)
|
|
281
|
+
{
|
|
282
|
+
yx *= this->nzur_scalar();
|
|
283
|
+
}
|
|
284
|
+
return -beta * std::log(yx);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
while (1)
|
|
288
|
+
{
|
|
289
|
+
Scalar yx, xx;
|
|
290
|
+
yx = std::tan(constant::pi * ur_base::operator()());
|
|
291
|
+
xx = sqrt * yx + alpha - 1;
|
|
292
|
+
if (xx <= 0) continue;
|
|
293
|
+
if (ur_base::operator()() <= (1 + yx * yx)
|
|
294
|
+
* std::exp((alpha - 1) * std::log(xx / (alpha - 1)) - sqrt * yx))
|
|
295
|
+
{
|
|
296
|
+
return beta * xx;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
template<typename Packet>
|
|
302
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp() const
|
|
303
|
+
{
|
|
304
|
+
using RUtils = RandUtils<Packet, Rng>;
|
|
305
|
+
auto& cm = Rand::detail::CompressMask<sizeof(Packet)>::get_inst();
|
|
306
|
+
|
|
307
|
+
RUtils ru;
|
|
308
|
+
thread_local Packet cache_rest;
|
|
309
|
+
thread_local int cache_rest_cnt;
|
|
310
|
+
thread_local const scalar_gamma_dist_op* cache_ptr = nullptr;
|
|
311
|
+
if (cache_ptr != this)
|
|
312
|
+
{
|
|
313
|
+
cache_ptr = this;
|
|
314
|
+
cache_rest = pset1<Packet>(0);
|
|
315
|
+
cache_rest_cnt = 0;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
if (alpha < 1)
|
|
319
|
+
{
|
|
320
|
+
while (1)
|
|
321
|
+
{
|
|
322
|
+
Packet ux = ru.uniform_real(this->rng);
|
|
323
|
+
Packet vx = ru.nonzero_uniform_real(this->rng);
|
|
324
|
+
|
|
325
|
+
Packet xx = pexp(pmul(pset1<Packet>(1 / alpha), plog(vx)));
|
|
326
|
+
Packet qx = pexp(pnegate(xx));
|
|
327
|
+
|
|
328
|
+
Packet xx2 = psub(pset1<Packet>(1), plog(vx));
|
|
329
|
+
Packet qx2 = pexp(pmul(plog(xx2), pset1<Packet>(alpha - 1)));
|
|
330
|
+
|
|
331
|
+
auto c = pcmplt(ux, pset1<Packet>(px));
|
|
332
|
+
xx = pblendv(c, xx, xx2);
|
|
333
|
+
qx = pblendv(c, qx, qx2);
|
|
334
|
+
|
|
335
|
+
ux = ru.uniform_real(this->rng);
|
|
336
|
+
Packet cands = pmul(pset1<Packet>(beta), xx);
|
|
337
|
+
bool full = false;
|
|
338
|
+
cache_rest_cnt = cm.compress_append(cands, pcmplt(ux, qx),
|
|
339
|
+
cache_rest, cache_rest_cnt, full);
|
|
340
|
+
if (full) return cands;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
if (alpha == 1)
|
|
344
|
+
{
|
|
345
|
+
return pmul(pset1<Packet>(beta),
|
|
346
|
+
scalar_exp_dist_op<Scalar, Rng>::template packetOp<Packet>()
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
int count;
|
|
350
|
+
if ((count = alpha) == alpha && count < 20)
|
|
351
|
+
{
|
|
352
|
+
RUtils ru;
|
|
353
|
+
Packet ux, yx;
|
|
354
|
+
yx = ru.nonzero_uniform_real(this->rng);
|
|
355
|
+
while (--count)
|
|
356
|
+
{
|
|
357
|
+
yx = pmul(yx, ru.nonzero_uniform_real(this->rng));
|
|
358
|
+
}
|
|
359
|
+
return pnegate(pmul(pset1<Packet>(beta), plog(yx)));
|
|
360
|
+
}
|
|
361
|
+
else
|
|
362
|
+
{
|
|
363
|
+
while (1)
|
|
364
|
+
{
|
|
365
|
+
Packet alpha_1 = pset1<Packet>(alpha - 1);
|
|
366
|
+
Packet ys, yc;
|
|
367
|
+
psincos(pmul(pset1<Packet>(constant::pi), ru.uniform_real(this->rng)), ys, yc);
|
|
368
|
+
Packet yx = pdiv(ys, yc);
|
|
369
|
+
Packet xx = padd(pmul(pset1<Packet>(sqrt), yx), alpha_1);
|
|
370
|
+
auto c = pcmplt(pset1<Packet>(0), xx);
|
|
371
|
+
Packet ux = ru.uniform_real(this->rng);
|
|
372
|
+
Packet ub = pmul(padd(pmul(yx, yx), pset1<Packet>(1)),
|
|
373
|
+
pexp(psub(
|
|
374
|
+
pmul(alpha_1, plog(pdiv(xx, alpha_1))),
|
|
375
|
+
pmul(yx, pset1<Packet>(sqrt))
|
|
376
|
+
))
|
|
377
|
+
);
|
|
378
|
+
c = pand(c, pcmple(ux, ub));
|
|
379
|
+
Packet cands = pmul(pset1<Packet>(beta), xx);
|
|
380
|
+
bool full = false;
|
|
381
|
+
cache_rest_cnt = cm.compress_append(cands, c,
|
|
382
|
+
cache_rest, cache_rest_cnt, full);
|
|
383
|
+
if (full) return cands;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
template<typename Scalar, typename Urng>
|
|
390
|
+
struct functor_traits<scalar_gamma_dist_op<Scalar, Urng> >
|
|
391
|
+
{
|
|
392
|
+
enum { Cost = HugeCost, PacketAccess = packet_traits<Scalar>::Vectorizable, IsRepeatable = false };
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
template<typename Scalar, typename Rng>
|
|
396
|
+
struct scalar_weibull_dist_op : public scalar_uniform_real_op<Scalar, Rng>
|
|
397
|
+
{
|
|
398
|
+
static_assert(std::is_floating_point<Scalar>::value, "weilbullDist needs floating point types.");
|
|
399
|
+
|
|
400
|
+
Scalar a = 1, b = 1;
|
|
401
|
+
|
|
402
|
+
scalar_weibull_dist_op(const Rng& _rng, Scalar _a = 1, Scalar _b = 1)
|
|
403
|
+
: scalar_uniform_real_op<Scalar, Rng>{ _rng }, a{ _a }, b{ _b }
|
|
404
|
+
{
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() () const
|
|
408
|
+
{
|
|
409
|
+
return std::pow(-std::log(1 - scalar_uniform_real_op<Scalar, Rng>::operator()()), 1 / a) * b;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
template<typename Packet>
|
|
413
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp() const
|
|
414
|
+
{
|
|
415
|
+
return pmul(pexp(pmul(plog(pnegate(plog(
|
|
416
|
+
psub(pset1<Packet>(1), scalar_uniform_real_op<Scalar, Rng>::template packetOp<Packet>())
|
|
417
|
+
))), pset1<Packet>(1 / a))), pset1<Packet>(b));
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
|
|
421
|
+
template<typename Scalar, typename Urng>
|
|
422
|
+
struct functor_traits<scalar_weibull_dist_op<Scalar, Urng> >
|
|
423
|
+
{
|
|
424
|
+
enum { Cost = HugeCost, PacketAccess = packet_traits<Scalar>::Vectorizable, IsRepeatable = false };
|
|
425
|
+
};
|
|
426
|
+
|
|
427
|
+
template<typename Scalar, typename Rng>
|
|
428
|
+
struct scalar_extreme_value_dist_op : public scalar_uniform_real_op<Scalar, Rng>
|
|
429
|
+
{
|
|
430
|
+
static_assert(std::is_floating_point<Scalar>::value, "extremeValueDist needs floating point types.");
|
|
431
|
+
|
|
432
|
+
Scalar a = 0, b = 1;
|
|
433
|
+
|
|
434
|
+
scalar_extreme_value_dist_op(const Rng& _rng, Scalar _a = 0, Scalar _b = 1)
|
|
435
|
+
: scalar_uniform_real_op<Scalar, Rng>{ _rng }, a{ _a }, b{ _b }
|
|
436
|
+
{
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() () const
|
|
440
|
+
{
|
|
441
|
+
return (a - b * std::log(-std::log(this->nzur_scalar())));
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
template<typename Packet>
|
|
445
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp() const
|
|
446
|
+
{
|
|
447
|
+
using RUtils = RandUtils<Packet, Rng>;
|
|
448
|
+
return psub(pset1<Packet>(a),
|
|
449
|
+
pmul(plog(pnegate(plog(RUtils{}.nonzero_uniform_real(this->rng)))), pset1<Packet>(b))
|
|
450
|
+
);
|
|
451
|
+
}
|
|
452
|
+
};
|
|
453
|
+
|
|
454
|
+
template<typename Scalar, typename Urng>
|
|
455
|
+
struct functor_traits<scalar_extreme_value_dist_op<Scalar, Urng> >
|
|
456
|
+
{
|
|
457
|
+
enum { Cost = HugeCost, PacketAccess = packet_traits<Scalar>::Vectorizable, IsRepeatable = false };
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
template<typename Scalar, typename Rng>
|
|
461
|
+
struct scalar_chi_squared_dist_op : public scalar_gamma_dist_op<Scalar, Rng>
|
|
462
|
+
{
|
|
463
|
+
static_assert(std::is_floating_point<Scalar>::value, "chiSquaredDist needs floating point types.");
|
|
464
|
+
|
|
465
|
+
scalar_chi_squared_dist_op(const Rng& _rng, Scalar n = 1)
|
|
466
|
+
: scalar_gamma_dist_op<Scalar, Rng>{ _rng, n * Scalar(0.5), 2 }
|
|
467
|
+
{
|
|
468
|
+
}
|
|
469
|
+
};
|
|
470
|
+
|
|
471
|
+
template<typename Scalar, typename Urng>
|
|
472
|
+
struct functor_traits<scalar_chi_squared_dist_op<Scalar, Urng> >
|
|
473
|
+
{
|
|
474
|
+
enum { Cost = HugeCost, PacketAccess = packet_traits<Scalar>::Vectorizable, IsRepeatable = false };
|
|
475
|
+
};
|
|
476
|
+
|
|
477
|
+
template<typename Scalar, typename Rng>
|
|
478
|
+
struct scalar_cauchy_dist_op : public scalar_uniform_real_op<Scalar, Rng>
|
|
479
|
+
{
|
|
480
|
+
static_assert(std::is_floating_point<Scalar>::value, "cauchyDist needs floating point types.");
|
|
481
|
+
|
|
482
|
+
Scalar a = 0, b = 1;
|
|
483
|
+
|
|
484
|
+
scalar_cauchy_dist_op(const Rng& _rng, Scalar _a = 0, Scalar _b = 1)
|
|
485
|
+
: scalar_uniform_real_op<Scalar, Rng>{ _rng }, a{ _a }, b{ _b }
|
|
486
|
+
{
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() () const
|
|
490
|
+
{
|
|
491
|
+
return a + b * std::tan(constant::pi * (scalar_uniform_real_op<Scalar, Rng>::operator()() - 0.5));
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
template<typename Packet>
|
|
495
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp() const
|
|
496
|
+
{
|
|
497
|
+
Packet s, c;
|
|
498
|
+
psincos(pmul(pset1<Packet>(constant::pi),
|
|
499
|
+
psub(scalar_uniform_real_op<Scalar, Rng>::template packetOp<Packet>(), pset1<Packet>(0.5))
|
|
500
|
+
), s, c);
|
|
501
|
+
return padd(pset1<Packet>(a),
|
|
502
|
+
pmul(pset1<Packet>(b), pdiv(s, c))
|
|
503
|
+
);
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
|
|
507
|
+
template<typename Scalar, typename Urng>
|
|
508
|
+
struct functor_traits<scalar_cauchy_dist_op<Scalar, Urng> >
|
|
509
|
+
{
|
|
510
|
+
enum { Cost = HugeCost, PacketAccess = packet_traits<Scalar>::Vectorizable, IsRepeatable = false };
|
|
511
|
+
};
|
|
512
|
+
|
|
513
|
+
template<typename Scalar, typename Rng>
|
|
514
|
+
struct scalar_beta_dist_op : public scalar_uniform_real_op<Scalar, Rng>
|
|
515
|
+
{
|
|
516
|
+
static_assert(std::is_floating_point<Scalar>::value, "betaDist needs floating point types.");
|
|
517
|
+
using ur_base = scalar_uniform_real_op<Scalar, Rng>;
|
|
518
|
+
|
|
519
|
+
Scalar a, b;
|
|
520
|
+
scalar_gamma_dist_op<Scalar, Rng> gd1, gd2;
|
|
521
|
+
|
|
522
|
+
scalar_beta_dist_op(const Rng& _rng, Scalar _a = 1, Scalar _b = 1)
|
|
523
|
+
: ur_base{ _rng }, a{ _a }, b{ _b },
|
|
524
|
+
gd1{ _rng, _a }, gd2{ _rng, _b }
|
|
525
|
+
{
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() () const
|
|
529
|
+
{
|
|
530
|
+
if (a < 1 && b < 1)
|
|
531
|
+
{
|
|
532
|
+
Scalar x, p1, p2;
|
|
533
|
+
while(1)
|
|
534
|
+
{
|
|
535
|
+
p1 = std::pow(ur_base::operator()(), 1 / a);
|
|
536
|
+
p2 = std::pow(ur_base::operator()(), 1 / b);
|
|
537
|
+
x = p1 + p2;
|
|
538
|
+
if (x <= 1) break;
|
|
539
|
+
}
|
|
540
|
+
return p1 / x;
|
|
541
|
+
}
|
|
542
|
+
else
|
|
543
|
+
{
|
|
544
|
+
Scalar p1 = gd1(), p2 = gd2();
|
|
545
|
+
return p1 / (p1 + p2);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
template<typename Packet>
|
|
550
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp() const
|
|
551
|
+
{
|
|
552
|
+
if (a < 1 && b < 1)
|
|
553
|
+
{
|
|
554
|
+
auto& cm = Rand::detail::CompressMask<sizeof(Packet)>::get_inst();
|
|
555
|
+
|
|
556
|
+
thread_local Packet cache_rest;
|
|
557
|
+
thread_local int cache_rest_cnt;
|
|
558
|
+
thread_local const scalar_beta_dist_op* cache_ptr = nullptr;
|
|
559
|
+
if (cache_ptr != this)
|
|
560
|
+
{
|
|
561
|
+
cache_ptr = this;
|
|
562
|
+
cache_rest = pset1<Packet>(0);
|
|
563
|
+
cache_rest_cnt = 0;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
Packet x, p1, p2;
|
|
567
|
+
while (1)
|
|
568
|
+
{
|
|
569
|
+
p1 = pexp(pmul(plog(ur_base::template packetOp<Packet>()), pset1<Packet>(1 / a)));
|
|
570
|
+
p2 = pexp(pmul(plog(ur_base::template packetOp<Packet>()), pset1<Packet>(1 / b)));
|
|
571
|
+
x = padd(p1, p2);
|
|
572
|
+
Packet cands = pdiv(p1, x);
|
|
573
|
+
bool full = false;
|
|
574
|
+
cache_rest_cnt = cm.compress_append(cands, pcmple(x, pset1<Packet>(1)),
|
|
575
|
+
cache_rest, cache_rest_cnt, full);
|
|
576
|
+
if (full) return cands;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
else
|
|
580
|
+
{
|
|
581
|
+
auto p1 = gd1.template packetOp<Packet>(),
|
|
582
|
+
p2 = gd2.template packetOp<Packet>();
|
|
583
|
+
return pdiv(p1, padd(p1, p2));
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
};
|
|
587
|
+
|
|
588
|
+
template<typename Scalar, typename Urng>
|
|
589
|
+
struct functor_traits<scalar_beta_dist_op<Scalar, Urng> >
|
|
590
|
+
{
|
|
591
|
+
enum { Cost = HugeCost, PacketAccess = packet_traits<Scalar>::Vectorizable, IsRepeatable = false };
|
|
592
|
+
};
|
|
593
|
+
|
|
594
|
+
template<typename Scalar, typename Rng>
|
|
595
|
+
struct scalar_fisher_f_dist_op : public scalar_beta_dist_op<Scalar, Rng>
|
|
596
|
+
{
|
|
597
|
+
static_assert(std::is_floating_point<Scalar>::value, "chiSquaredDist needs floating point types.");
|
|
598
|
+
|
|
599
|
+
scalar_fisher_f_dist_op(const Rng& _rng, Scalar m = 1, Scalar n = 1)
|
|
600
|
+
: scalar_beta_dist_op<Scalar, Rng>{ _rng, m * Scalar(0.5), n * Scalar(0.5) }
|
|
601
|
+
{
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() () const
|
|
605
|
+
{
|
|
606
|
+
auto x = scalar_beta_dist_op<Scalar, Rng>::operator()();
|
|
607
|
+
return this->b / this->a * x / (1 - x);
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
template<typename Packet>
|
|
611
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp() const
|
|
612
|
+
{
|
|
613
|
+
auto x = scalar_beta_dist_op<Scalar, Rng>::template packetOp<Packet>();
|
|
614
|
+
return pdiv(pmul(pset1<Packet>(this->b / this->a), x), psub(pset1<Packet>(1), x));
|
|
615
|
+
}
|
|
616
|
+
};
|
|
617
|
+
|
|
618
|
+
template<typename Scalar, typename Urng>
|
|
619
|
+
struct functor_traits<scalar_fisher_f_dist_op<Scalar, Urng> >
|
|
620
|
+
{
|
|
621
|
+
enum { Cost = HugeCost, PacketAccess = packet_traits<Scalar>::Vectorizable, IsRepeatable = false };
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
#endif
|