├── .gitignore ├── LICENSE.md ├── README.md ├── cpp ├── Eigen │ ├── Array │ ├── CMakeLists.txt │ ├── Cholesky │ ├── CholmodSupport │ ├── Core │ ├── Dense │ ├── Eigen │ ├── Eigen2Support │ ├── Eigenvalues │ ├── Geometry │ ├── Householder │ ├── IterativeLinearSolvers │ ├── Jacobi │ ├── LU │ ├── LeastSquares │ ├── MetisSupport │ ├── OrderingMethods │ ├── PaStiXSupport │ ├── PardisoSupport │ ├── QR │ ├── QtAlignedMalloc │ ├── SPQRSupport │ ├── SVD │ ├── Sparse │ ├── SparseCholesky │ ├── SparseCore │ ├── SparseLU │ ├── SparseQR │ ├── StdDeque │ ├── StdList │ ├── StdVector │ ├── SuperLUSupport │ ├── UmfPackSupport │ └── src │ │ ├── CMakeLists.txt │ │ ├── Cholesky │ │ ├── CMakeLists.txt │ │ ├── LDLT.h │ │ ├── LLT.h │ │ └── LLT_MKL.h │ │ ├── CholmodSupport │ │ ├── CMakeLists.txt │ │ └── CholmodSupport.h │ │ ├── Core │ │ ├── Array.h │ │ ├── ArrayBase.h │ │ ├── ArrayWrapper.h │ │ ├── Assign.h │ │ ├── Assign_MKL.h │ │ ├── BandMatrix.h │ │ ├── Block.h │ │ ├── BooleanRedux.h │ │ ├── CMakeLists.txt │ │ ├── CommaInitializer.h │ │ ├── CoreIterators.h │ │ ├── CwiseBinaryOp.h │ │ ├── CwiseNullaryOp.h │ │ ├── CwiseUnaryOp.h │ │ ├── CwiseUnaryView.h │ │ ├── DenseBase.h │ │ ├── DenseCoeffsBase.h │ │ ├── DenseStorage.h │ │ ├── Diagonal.h │ │ ├── DiagonalMatrix.h │ │ ├── DiagonalProduct.h │ │ ├── Dot.h │ │ ├── EigenBase.h │ │ ├── Flagged.h │ │ ├── ForceAlignedAccess.h │ │ ├── Functors.h │ │ ├── Fuzzy.h │ │ ├── GeneralProduct.h │ │ ├── GenericPacketMath.h │ │ ├── GlobalFunctions.h │ │ ├── IO.h │ │ ├── Map.h │ │ ├── MapBase.h │ │ ├── MathFunctions.h │ │ ├── Matrix.h │ │ ├── MatrixBase.h │ │ ├── NestByValue.h │ │ ├── NoAlias.h │ │ ├── NumTraits.h │ │ ├── PermutationMatrix.h │ │ ├── PlainObjectBase.h │ │ ├── ProductBase.h │ │ ├── Random.h │ │ ├── Redux.h │ │ ├── Ref.h │ │ ├── Replicate.h │ │ ├── ReturnByValue.h │ │ ├── Reverse.h │ │ ├── Select.h │ │ ├── SelfAdjointView.h │ │ ├── SelfCwiseBinaryOp.h │ │ ├── SolveTriangular.h │ │ ├── StableNorm.h │ │ ├── Stride.h │ │ ├── Swap.h │ │ ├── Transpose.h │ │ ├── Transpositions.h │ │ ├── TriangularMatrix.h │ │ ├── VectorBlock.h │ │ ├── VectorwiseOp.h │ │ ├── Visitor.h │ │ ├── arch │ │ │ ├── AltiVec │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── Complex.h │ │ │ │ └── PacketMath.h │ │ │ ├── CMakeLists.txt │ │ │ ├── Default │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── Settings.h │ │ │ ├── NEON │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── Complex.h │ │ │ │ └── PacketMath.h │ │ │ └── SSE │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── Complex.h │ │ │ │ ├── MathFunctions.h │ │ │ │ └── PacketMath.h │ │ ├── products │ │ │ ├── CMakeLists.txt │ │ │ ├── CoeffBasedProduct.h │ │ │ ├── GeneralBlockPanelKernel.h │ │ │ ├── GeneralMatrixMatrix.h │ │ │ ├── GeneralMatrixMatrixTriangular.h │ │ │ ├── GeneralMatrixMatrixTriangular_MKL.h │ │ │ ├── GeneralMatrixMatrix_MKL.h │ │ │ ├── GeneralMatrixVector.h │ │ │ ├── GeneralMatrixVector_MKL.h │ │ │ ├── Parallelizer.h │ │ │ ├── SelfadjointMatrixMatrix.h │ │ │ ├── SelfadjointMatrixMatrix_MKL.h │ │ │ ├── SelfadjointMatrixVector.h │ │ │ ├── SelfadjointMatrixVector_MKL.h │ │ │ ├── SelfadjointProduct.h │ │ │ ├── SelfadjointRank2Update.h │ │ │ ├── TriangularMatrixMatrix.h │ │ │ ├── TriangularMatrixMatrix_MKL.h │ │ │ ├── TriangularMatrixVector.h │ │ │ ├── TriangularMatrixVector_MKL.h │ │ │ ├── TriangularSolverMatrix.h │ │ │ ├── TriangularSolverMatrix_MKL.h │ │ │ └── TriangularSolverVector.h │ │ └── util │ │ │ ├── BlasUtil.h │ │ │ ├── CMakeLists.txt │ │ │ ├── Constants.h │ │ │ ├── DisableStupidWarnings.h │ │ │ ├── ForwardDeclarations.h │ │ │ ├── MKL_support.h │ │ │ ├── Macros.h │ │ │ ├── Memory.h │ │ │ ├── Meta.h │ │ │ ├── NonMPL2.h │ │ │ ├── ReenableStupidWarnings.h │ │ │ ├── StaticAssert.h │ │ │ └── XprHelper.h │ │ ├── Eigen2Support │ │ ├── Block.h │ │ ├── CMakeLists.txt │ │ ├── Cwise.h │ │ ├── CwiseOperators.h │ │ ├── Geometry │ │ │ ├── AlignedBox.h │ │ │ ├── All.h │ │ │ ├── AngleAxis.h │ │ │ ├── CMakeLists.txt │ │ │ ├── Hyperplane.h │ │ │ ├── ParametrizedLine.h │ │ │ ├── Quaternion.h │ │ │ ├── Rotation2D.h │ │ │ ├── RotationBase.h │ │ │ ├── Scaling.h │ │ │ ├── Transform.h │ │ │ └── Translation.h │ │ ├── LU.h │ │ ├── Lazy.h │ │ ├── LeastSquares.h │ │ ├── Macros.h │ │ ├── MathFunctions.h │ │ ├── Memory.h │ │ ├── Meta.h │ │ ├── Minor.h │ │ ├── QR.h │ │ ├── SVD.h │ │ ├── TriangularSolver.h │ │ └── VectorBlock.h │ │ ├── Eigenvalues │ │ ├── CMakeLists.txt │ │ ├── ComplexEigenSolver.h │ │ ├── ComplexSchur.h │ │ ├── ComplexSchur_MKL.h │ │ ├── EigenSolver.h │ │ ├── GeneralizedEigenSolver.h │ │ ├── GeneralizedSelfAdjointEigenSolver.h │ │ ├── HessenbergDecomposition.h │ │ ├── MatrixBaseEigenvalues.h │ │ ├── RealQZ.h │ │ ├── RealSchur.h │ │ ├── RealSchur_MKL.h │ │ ├── SelfAdjointEigenSolver.h │ │ ├── SelfAdjointEigenSolver_MKL.h │ │ └── Tridiagonalization.h │ │ ├── Geometry │ │ ├── AlignedBox.h │ │ ├── AngleAxis.h │ │ ├── CMakeLists.txt │ │ ├── EulerAngles.h │ │ ├── Homogeneous.h │ │ ├── Hyperplane.h │ │ ├── OrthoMethods.h │ │ ├── ParametrizedLine.h │ │ ├── Quaternion.h │ │ ├── Rotation2D.h │ │ ├── RotationBase.h │ │ ├── Scaling.h │ │ ├── Transform.h │ │ ├── Translation.h │ │ ├── Umeyama.h │ │ └── arch │ │ │ ├── CMakeLists.txt │ │ │ └── Geometry_SSE.h │ │ ├── Householder │ │ ├── BlockHouseholder.h │ │ ├── CMakeLists.txt │ │ ├── Householder.h │ │ └── HouseholderSequence.h │ │ ├── IterativeLinearSolvers │ │ ├── BasicPreconditioners.h │ │ ├── BiCGSTAB.h │ │ ├── CMakeLists.txt │ │ ├── ConjugateGradient.h │ │ ├── IncompleteLUT.h │ │ └── IterativeSolverBase.h │ │ ├── Jacobi │ │ ├── CMakeLists.txt │ │ └── Jacobi.h │ │ ├── LU │ │ ├── CMakeLists.txt │ │ ├── Determinant.h │ │ ├── FullPivLU.h │ │ ├── Inverse.h │ │ ├── PartialPivLU.h │ │ ├── PartialPivLU_MKL.h │ │ └── arch │ │ │ ├── CMakeLists.txt │ │ │ └── Inverse_SSE.h │ │ ├── MetisSupport │ │ ├── CMakeLists.txt │ │ └── MetisSupport.h │ │ ├── OrderingMethods │ │ ├── Amd.h │ │ ├── CMakeLists.txt │ │ ├── Eigen_Colamd.h │ │ └── Ordering.h │ │ ├── PaStiXSupport │ │ ├── CMakeLists.txt │ │ └── PaStiXSupport.h │ │ ├── PardisoSupport │ │ ├── CMakeLists.txt │ │ └── PardisoSupport.h │ │ ├── QR │ │ ├── CMakeLists.txt │ │ ├── ColPivHouseholderQR.h │ │ ├── ColPivHouseholderQR_MKL.h │ │ ├── FullPivHouseholderQR.h │ │ ├── HouseholderQR.h │ │ └── HouseholderQR_MKL.h │ │ ├── SPQRSupport │ │ ├── CMakeLists.txt │ │ └── SuiteSparseQRSupport.h │ │ ├── SVD │ │ ├── CMakeLists.txt │ │ ├── JacobiSVD.h │ │ ├── JacobiSVD_MKL.h │ │ └── UpperBidiagonalization.h │ │ ├── SparseCholesky │ │ ├── CMakeLists.txt │ │ ├── SimplicialCholesky.h │ │ └── SimplicialCholesky_impl.h │ │ ├── SparseCore │ │ ├── AmbiVector.h │ │ ├── CMakeLists.txt │ │ ├── CompressedStorage.h │ │ ├── ConservativeSparseSparseProduct.h │ │ ├── MappedSparseMatrix.h │ │ ├── SparseBlock.h │ │ ├── SparseColEtree.h │ │ ├── SparseCwiseBinaryOp.h │ │ ├── SparseCwiseUnaryOp.h │ │ ├── SparseDenseProduct.h │ │ ├── SparseDiagonalProduct.h │ │ ├── SparseDot.h │ │ ├── SparseFuzzy.h │ │ ├── SparseMatrix.h │ │ ├── SparseMatrixBase.h │ │ ├── SparsePermutation.h │ │ ├── SparseProduct.h │ │ ├── SparseRedux.h │ │ ├── SparseSelfAdjointView.h │ │ ├── SparseSparseProductWithPruning.h │ │ ├── SparseTranspose.h │ │ ├── SparseTriangularView.h │ │ ├── SparseUtil.h │ │ ├── SparseVector.h │ │ ├── SparseView.h │ │ └── TriangularSolver.h │ │ ├── SparseLU │ │ ├── CMakeLists.txt │ │ ├── SparseLU.h │ │ ├── SparseLUImpl.h │ │ ├── SparseLU_Memory.h │ │ ├── SparseLU_Structs.h │ │ ├── SparseLU_SupernodalMatrix.h │ │ ├── SparseLU_Utils.h │ │ ├── SparseLU_column_bmod.h │ │ ├── SparseLU_column_dfs.h │ │ ├── SparseLU_copy_to_ucol.h │ │ ├── SparseLU_gemm_kernel.h │ │ ├── SparseLU_heap_relax_snode.h │ │ ├── SparseLU_kernel_bmod.h │ │ ├── SparseLU_panel_bmod.h │ │ ├── SparseLU_panel_dfs.h │ │ ├── SparseLU_pivotL.h │ │ ├── SparseLU_pruneL.h │ │ └── SparseLU_relax_snode.h │ │ ├── SparseQR │ │ ├── CMakeLists.txt │ │ └── SparseQR.h │ │ ├── StlSupport │ │ ├── CMakeLists.txt │ │ ├── StdDeque.h │ │ ├── StdList.h │ │ ├── StdVector.h │ │ └── details.h │ │ ├── SuperLUSupport │ │ ├── CMakeLists.txt │ │ └── SuperLUSupport.h │ │ ├── UmfPackSupport │ │ ├── CMakeLists.txt │ │ └── UmfPackSupport.h │ │ ├── misc │ │ ├── CMakeLists.txt │ │ ├── Image.h │ │ ├── Kernel.h │ │ ├── Solve.h │ │ ├── SparseSolve.h │ │ └── blas.h │ │ └── plugins │ │ ├── ArrayCwiseBinaryOps.h │ │ ├── ArrayCwiseUnaryOps.h │ │ ├── BlockMethods.h │ │ ├── CMakeLists.txt │ │ ├── CommonCwiseBinaryOps.h │ │ ├── CommonCwiseUnaryOps.h │ │ ├── MatrixCwiseBinaryOps.h │ │ └── MatrixCwiseUnaryOps.h └── joint_min.cpp └── matlab ├── Bowl.m ├── EI_fun.m ├── EntropySearch.m ├── ExampleSetup.m ├── FindGlobalGPMinimum.m ├── GP_innovation_local.m ├── GP_moments.m ├── GP_noise_var.m ├── GaussProcess.m ├── LogLoss.m ├── PI_fun.m ├── PhysicalExperiment.m ├── Rosenbrock.m ├── SEGammaHyperPosterior.m ├── SampleBeliefLocations.m ├── Slice_ShrinkRank.m ├── Slice_ShrinkRank_nolog.m ├── compile_utilities.m ├── covRQard_dx_MD.m ├── covSEard_dx_MD.m ├── dH_MC_local.m ├── ext ├── README.md ├── gpml │ ├── Copyright │ ├── README │ ├── cov │ │ ├── apx.m │ │ ├── apxGrid.m │ │ ├── apxSparse.m │ │ ├── covADD.m │ │ ├── covConst.m │ │ ├── covCos.m │ │ ├── covDiscrete.m │ │ ├── covDot.m │ │ ├── covEye.m │ │ ├── covGE.m │ │ ├── covGabor.m │ │ ├── covGaborard.m │ │ ├── covGaboriso.m │ │ ├── covLIN.m │ │ ├── covLINard.m │ │ ├── covLINiso.m │ │ ├── covLINone.m │ │ ├── covMaha.m │ │ ├── covMask.m │ │ ├── covMatern.m │ │ ├── covMaternard.m │ │ ├── covMaterniso.m │ │ ├── covNNone.m │ │ ├── covNoise.m │ │ ├── covOne.m │ │ ├── covPER.m │ │ ├── covPERard.m │ │ ├── covPERiso.m │ │ ├── covPP.m │ │ ├── covPPard.m │ │ ├── covPPiso.m │ │ ├── covPeriodic.m │ │ ├── covPeriodicNoDC.m │ │ ├── covPoly.m │ │ ├── covPref.m │ │ ├── covProd.m │ │ ├── covRQ.m │ │ ├── covRQard.m │ │ ├── covRQiso.m │ │ ├── covSE.m │ │ ├── covSEard.m │ │ ├── covSEiso.m │ │ ├── covSEisoU.m │ │ ├── covSEproj.m │ │ ├── covSEvlen.m │ │ ├── covSM.m │ │ ├── covScale.m │ │ ├── covSum.m │ │ └── covZero.m │ ├── covFunctions.m │ ├── doc │ │ ├── README │ │ ├── changelog │ │ ├── checkmark.png │ │ ├── demoClassification.m │ │ ├── demoGrid1d.m │ │ ├── demoGrid2d.m │ │ ├── demoMinimize.m │ │ ├── demoRegression.m │ │ ├── demoSparse.m │ │ ├── f0.gif │ │ ├── f1.gif │ │ ├── f2.gif │ │ ├── f3.gif │ │ ├── f4.gif │ │ ├── f5.gif │ │ ├── f6.gif │ │ ├── f7.gif │ │ ├── f8.gif │ │ ├── f9.png │ │ ├── gpml_randn.m │ │ ├── index.html │ │ ├── manual.pdf │ │ ├── style.css │ │ ├── usageClassification.m │ │ ├── usageCov.m │ │ ├── usageLik.m │ │ ├── usageMean.m │ │ ├── usagePrior.m │ │ ├── usageRegression.m │ │ └── usageSampling.m │ ├── gp.m │ ├── inf │ │ ├── infEP.m │ │ ├── infFITC_EP.m │ │ ├── infGaussLik.m │ │ ├── infGrid.m │ │ ├── infKL.m │ │ ├── infLOO.m │ │ ├── infLaplace.m │ │ ├── infMCMC.m │ │ ├── infPrior.m │ │ └── infVB.m │ ├── infMethods.m │ ├── lik │ │ ├── likBeta.m │ │ ├── likErf.m │ │ ├── likExp.m │ │ ├── likGamma.m │ │ ├── likGauss.m │ │ ├── likGaussWarp.m │ │ ├── likGumbel.m │ │ ├── likInvGauss.m │ │ ├── likLaplace.m │ │ ├── likLogistic.m │ │ ├── likMix.m │ │ ├── likNegBinom.m │ │ ├── likPoisson.m │ │ ├── likSech2.m │ │ ├── likT.m │ │ ├── likUni.m │ │ └── likWeibull.m │ ├── likFunctions.m │ ├── mean │ │ ├── meanConst.m │ │ ├── meanDiscrete.m │ │ ├── meanGP.m │ │ ├── meanGPexact.m │ │ ├── meanLinear.m │ │ ├── meanMask.m │ │ ├── meanNN.m │ │ ├── meanOne.m │ │ ├── meanPoly.m │ │ ├── meanPow.m │ │ ├── meanPref.m │ │ ├── meanProd.m │ │ ├── meanScale.m │ │ ├── meanSum.m │ │ ├── meanWSPC.m │ │ ├── meanWarp.m │ │ └── meanZero.m │ ├── meanFunctions.m │ ├── prior │ │ ├── priorClamped.m │ │ ├── priorClampedMulti.m │ │ ├── priorDelta.m │ │ ├── priorDeltaMulti.m │ │ ├── priorEqualMulti.m │ │ ├── priorGamma.m │ │ ├── priorGauss.m │ │ ├── priorGaussMulti.m │ │ ├── priorInvGauss.m │ │ ├── priorLaplace.m │ │ ├── priorLaplaceMulti.m │ │ ├── priorLogNormal.m │ │ ├── priorMix.m │ │ ├── priorSameMulti.m │ │ ├── priorSmoothBox1.m │ │ ├── priorSmoothBox2.m │ │ ├── priorT.m │ │ ├── priorTMulti.m │ │ ├── priorTransform.m │ │ └── priorWeibull.m │ ├── priorDistributions.m │ ├── startup.m │ └── util │ │ ├── any2vec.m │ │ ├── binaryEPGP.m │ │ ├── binaryGP.m │ │ ├── binaryLaplaceGP.m │ │ ├── brentmin.m │ │ ├── covFITC.m │ │ ├── covGrid.m │ │ ├── digamma.m │ │ ├── elsympol.m │ │ ├── gauher.m │ │ ├── glm_invlink_exp.m │ │ ├── glm_invlink_expexp.m │ │ ├── glm_invlink_logistic.m │ │ ├── glm_invlink_logistic2.m │ │ ├── glm_invlink_logit.m │ │ ├── gpr.m │ │ ├── infExact.m │ │ ├── infFITC.m │ │ ├── infFITC_Laplace.m │ │ ├── lbfgsb.m │ │ ├── lbfgsb │ │ ├── LICENSE │ │ ├── Makefile │ │ ├── README │ │ ├── array.h │ │ ├── arrayofmatrices.cpp │ │ ├── arrayofmatrices.h │ │ ├── blas.f │ │ ├── lbfgsb.cpp │ │ ├── linpack.f │ │ ├── matlabexception.cpp │ │ ├── matlabexception.h │ │ ├── matlabmatrix.cpp │ │ ├── matlabmatrix.h │ │ ├── matlabprogram.cpp │ │ ├── matlabprogram.h │ │ ├── matlabscalar.cpp │ │ ├── matlabscalar.h │ │ ├── matlabstring.cpp │ │ ├── matlabstring.h │ │ ├── program.cpp │ │ ├── program.h │ │ ├── solver_2_4.f │ │ ├── solver_3_0.f │ │ └── timer.f │ │ ├── lik_epquad.m │ │ ├── logphi.m │ │ ├── logsumexp2.m │ │ ├── make.m │ │ ├── minfunc │ │ ├── ArmijoBacktrack.m │ │ ├── License │ │ ├── WolfeLineSearch.m │ │ ├── compiled │ │ │ ├── lbfgsAddC.mexa64 │ │ │ ├── lbfgsAddC.mexglx │ │ │ ├── lbfgsAddC.mexmaci64 │ │ │ ├── lbfgsAddC.mexw64 │ │ │ ├── lbfgsC.mexa64 │ │ │ ├── lbfgsC.mexglx │ │ │ ├── lbfgsC.mexmac │ │ │ ├── lbfgsC.mexmaci │ │ │ ├── lbfgsC.mexmaci64 │ │ │ ├── lbfgsC.mexw32 │ │ │ ├── lbfgsC.mexw64 │ │ │ ├── lbfgsProdC.mexa64 │ │ │ ├── lbfgsProdC.mexglx │ │ │ ├── lbfgsProdC.mexmaci64 │ │ │ ├── lbfgsProdC.mexw64 │ │ │ ├── mcholC.mexa64 │ │ │ ├── mcholC.mexglx │ │ │ ├── mcholC.mexmac │ │ │ ├── mcholC.mexmaci64 │ │ │ ├── mcholC.mexw32 │ │ │ └── mcholC.mexw64 │ │ ├── conjGrad.m │ │ ├── dampedUpdate.m │ │ ├── isLegal.m │ │ ├── lbfgs.m │ │ ├── lbfgsAdd.m │ │ ├── lbfgsProd.m │ │ ├── lbfgsUpdate.m │ │ ├── mchol.m │ │ ├── mcholinc.m │ │ ├── mex │ │ │ ├── lbfgsAddC.c │ │ │ ├── lbfgsC.c │ │ │ ├── lbfgsProdC.c │ │ │ ├── mcholC.c │ │ │ ├── mexAll_matlab.m │ │ │ └── mexAll_octave.m │ │ ├── minFunc.m │ │ ├── minFunc_processInputOptions.m │ │ ├── polyinterp.m │ │ ├── precondDiag.m │ │ ├── precondTriu.m │ │ ├── precondTriuDiag.m │ │ └── taylorModel.m │ │ ├── minimize.m │ │ ├── minimize_lbfgsb.m │ │ ├── minimize_lbfgsb_gradfun.m │ │ ├── minimize_lbfgsb_objfun.m │ │ ├── minimize_minfunc.m │ │ ├── solve_chol.c │ │ ├── solve_chol.m │ │ ├── sq_dist.m │ │ ├── vec2any.m │ │ └── vfe_xu_opt.m ├── logsumexp │ └── logsumexp.m └── tprod │ ├── ddtprod.c │ ├── dstprod.c │ ├── etprod.m │ ├── license.txt │ ├── makefile │ ├── mxInfo.c │ ├── mxInfo.h │ ├── mxInfo_mex.c │ ├── mxInfo_mex.h │ ├── mxUtils.c │ ├── mxUtils.h │ ├── orderTests.m │ ├── readme │ ├── sdtprod.c │ ├── sstprod.c │ ├── tprod.c │ ├── tprod.def │ ├── tprod.h │ ├── tprod.m │ ├── tprod_mex.c │ ├── tprod_testcases.c │ ├── tprod_testcases.m │ └── tprod_util.c ├── k_matrix.m ├── k_matrix_full.m ├── logdet.m ├── lt_factor.m ├── min_factor.m ├── minimize.m ├── poly_mat.m ├── util └── joint_min.m └── y_vector.m /.gitignore: -------------------------------------------------------------------------------- 1 | .gitignore~ 2 | *.*~ 3 | *.swp 4 | *.orig 5 | build/ 6 | temp/ 7 | *.kdev* 8 | *.kate-swp 9 | nbproject 10 | *.mexa64 11 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | % Copyright (c) 2011-2012, Philipp Hennig & Christian J. Schuler 2 | % Copyright (c) 2017, Max Planck Society 3 | % Version 1.1, March 2017 4 | % 5 | % Permission is hereby granted, free of charge, to any person OBTAINING A COPY 6 | % OF THIS SOFTWARE AND ASSOCIATED DOCUMENTATION FILES (THE "SOFTWARE"), TO DEAL 7 | % IN THE SOFTWARE WITHOUT RESTRICTION, INCLUDING WITHOUT LIMITATION THE RIGHTS 8 | % to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | % copies of the Software, and to permit persons to whom the Software is 10 | % furnished to do so, subject to the following conditions: 11 | % 12 | % The above copyright notice and this permission notice shall be included in 13 | % all copies or substantial portions of the Software. 14 | % 15 | % THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | % IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | % FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | % AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | % LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | % OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | % SOFTWARE. 22 | -------------------------------------------------------------------------------- /cpp/Eigen/Array: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_ARRAY_MODULE_H 2 | #define EIGEN_ARRAY_MODULE_H 3 | 4 | // include Core first to handle Eigen2 support macros 5 | #include "Core" 6 | 7 | #ifndef EIGEN2_SUPPORT 8 | #error The Eigen/Array header does no longer exist in Eigen3. All that functionality has moved to Eigen/Core. 9 | #endif 10 | 11 | #endif // EIGEN_ARRAY_MODULE_H 12 | -------------------------------------------------------------------------------- /cpp/Eigen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(RegexUtils) 2 | test_escape_string_as_regex() 3 | 4 | file(GLOB Eigen_directory_files "*") 5 | 6 | escape_string_as_regex(ESCAPED_CMAKE_CURRENT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") 7 | 8 | foreach(f ${Eigen_directory_files}) 9 | if(NOT f MATCHES "\\.txt" AND NOT f MATCHES "${ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/[.].+" AND NOT f MATCHES "${ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/src") 10 | list(APPEND Eigen_directory_files_to_install ${f}) 11 | endif() 12 | endforeach(f ${Eigen_directory_files}) 13 | 14 | install(FILES 15 | ${Eigen_directory_files_to_install} 16 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen COMPONENT Devel 17 | ) 18 | 19 | add_subdirectory(src) 20 | -------------------------------------------------------------------------------- /cpp/Eigen/Cholesky: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_CHOLESKY_MODULE_H 2 | #define EIGEN_CHOLESKY_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | /** \defgroup Cholesky_Module Cholesky module 9 | * 10 | * 11 | * 12 | * This module provides two variants of the Cholesky decomposition for selfadjoint (hermitian) matrices. 13 | * Those decompositions are accessible via the following MatrixBase methods: 14 | * - MatrixBase::llt(), 15 | * - MatrixBase::ldlt() 16 | * 17 | * \code 18 | * #include 19 | * \endcode 20 | */ 21 | 22 | #include "src/misc/Solve.h" 23 | #include "src/Cholesky/LLT.h" 24 | #include "src/Cholesky/LDLT.h" 25 | #ifdef EIGEN_USE_LAPACKE 26 | #include "src/Cholesky/LLT_MKL.h" 27 | #endif 28 | 29 | #include "src/Core/util/ReenableStupidWarnings.h" 30 | 31 | #endif // EIGEN_CHOLESKY_MODULE_H 32 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 33 | -------------------------------------------------------------------------------- /cpp/Eigen/CholmodSupport: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_CHOLMODSUPPORT_MODULE_H 2 | #define EIGEN_CHOLMODSUPPORT_MODULE_H 3 | 4 | #include "SparseCore" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | extern "C" { 9 | #include 10 | } 11 | 12 | /** \ingroup Support_modules 13 | * \defgroup CholmodSupport_Module CholmodSupport module 14 | * 15 | * This module provides an interface to the Cholmod library which is part of the suitesparse package. 16 | * It provides the two following main factorization classes: 17 | * - class CholmodSupernodalLLT: a supernodal LLT Cholesky factorization. 18 | * - class CholmodDecomposiiton: a general L(D)LT Cholesky factorization with automatic or explicit runtime selection of the underlying factorization method (supernodal or simplicial). 19 | * 20 | * For the sake of completeness, this module also propose the two following classes: 21 | * - class CholmodSimplicialLLT 22 | * - class CholmodSimplicialLDLT 23 | * Note that these classes does not bring any particular advantage compared to the built-in 24 | * SimplicialLLT and SimplicialLDLT factorization classes. 25 | * 26 | * \code 27 | * #include 28 | * \endcode 29 | * 30 | * In order to use this module, the cholmod headers must be accessible from the include paths, and your binary must be linked to the cholmod library and its dependencies. 31 | * The dependencies depend on how cholmod has been compiled. 32 | * For a cmake based project, you can use our FindCholmod.cmake module to help you in this task. 33 | * 34 | */ 35 | 36 | #include "src/misc/Solve.h" 37 | #include "src/misc/SparseSolve.h" 38 | 39 | #include "src/CholmodSupport/CholmodSupport.h" 40 | 41 | 42 | #include "src/Core/util/ReenableStupidWarnings.h" 43 | 44 | #endif // EIGEN_CHOLMODSUPPORT_MODULE_H 45 | 46 | -------------------------------------------------------------------------------- /cpp/Eigen/Dense: -------------------------------------------------------------------------------- 1 | #include "Core" 2 | #include "LU" 3 | #include "Cholesky" 4 | #include "QR" 5 | #include "SVD" 6 | #include "Geometry" 7 | #include "Eigenvalues" 8 | -------------------------------------------------------------------------------- /cpp/Eigen/Eigen: -------------------------------------------------------------------------------- 1 | #include "Dense" 2 | //#include "Sparse" 3 | -------------------------------------------------------------------------------- /cpp/Eigen/Eigenvalues: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_EIGENVALUES_MODULE_H 2 | #define EIGEN_EIGENVALUES_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | #include "Cholesky" 9 | #include "Jacobi" 10 | #include "Householder" 11 | #include "LU" 12 | #include "Geometry" 13 | 14 | /** \defgroup Eigenvalues_Module Eigenvalues module 15 | * 16 | * 17 | * 18 | * This module mainly provides various eigenvalue solvers. 19 | * This module also provides some MatrixBase methods, including: 20 | * - MatrixBase::eigenvalues(), 21 | * - MatrixBase::operatorNorm() 22 | * 23 | * \code 24 | * #include 25 | * \endcode 26 | */ 27 | 28 | #include "src/Eigenvalues/Tridiagonalization.h" 29 | #include "src/Eigenvalues/RealSchur.h" 30 | #include "src/Eigenvalues/EigenSolver.h" 31 | #include "src/Eigenvalues/SelfAdjointEigenSolver.h" 32 | #include "src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h" 33 | #include "src/Eigenvalues/HessenbergDecomposition.h" 34 | #include "src/Eigenvalues/ComplexSchur.h" 35 | #include "src/Eigenvalues/ComplexEigenSolver.h" 36 | #include "src/Eigenvalues/RealQZ.h" 37 | #include "src/Eigenvalues/GeneralizedEigenSolver.h" 38 | #include "src/Eigenvalues/MatrixBaseEigenvalues.h" 39 | #ifdef EIGEN_USE_LAPACKE 40 | #include "src/Eigenvalues/RealSchur_MKL.h" 41 | #include "src/Eigenvalues/ComplexSchur_MKL.h" 42 | #include "src/Eigenvalues/SelfAdjointEigenSolver_MKL.h" 43 | #endif 44 | 45 | #include "src/Core/util/ReenableStupidWarnings.h" 46 | 47 | #endif // EIGEN_EIGENVALUES_MODULE_H 48 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 49 | -------------------------------------------------------------------------------- /cpp/Eigen/Geometry: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_GEOMETRY_MODULE_H 2 | #define EIGEN_GEOMETRY_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | #include "SVD" 9 | #include "LU" 10 | #include 11 | 12 | #ifndef M_PI 13 | #define M_PI 3.14159265358979323846 14 | #endif 15 | 16 | /** \defgroup Geometry_Module Geometry module 17 | * 18 | * 19 | * 20 | * This module provides support for: 21 | * - fixed-size homogeneous transformations 22 | * - translation, scaling, 2D and 3D rotations 23 | * - quaternions 24 | * - \ref MatrixBase::cross() "cross product" 25 | * - \ref MatrixBase::unitOrthogonal() "orthognal vector generation" 26 | * - some linear components: parametrized-lines and hyperplanes 27 | * 28 | * \code 29 | * #include 30 | * \endcode 31 | */ 32 | 33 | #include "src/Geometry/OrthoMethods.h" 34 | #include "src/Geometry/EulerAngles.h" 35 | 36 | #if EIGEN2_SUPPORT_STAGE > STAGE20_RESOLVE_API_CONFLICTS 37 | #include "src/Geometry/Homogeneous.h" 38 | #include "src/Geometry/RotationBase.h" 39 | #include "src/Geometry/Rotation2D.h" 40 | #include "src/Geometry/Quaternion.h" 41 | #include "src/Geometry/AngleAxis.h" 42 | #include "src/Geometry/Transform.h" 43 | #include "src/Geometry/Translation.h" 44 | #include "src/Geometry/Scaling.h" 45 | #include "src/Geometry/Hyperplane.h" 46 | #include "src/Geometry/ParametrizedLine.h" 47 | #include "src/Geometry/AlignedBox.h" 48 | #include "src/Geometry/Umeyama.h" 49 | 50 | #if defined EIGEN_VECTORIZE_SSE 51 | #include "src/Geometry/arch/Geometry_SSE.h" 52 | #endif 53 | #endif 54 | 55 | #ifdef EIGEN2_SUPPORT 56 | #include "src/Eigen2Support/Geometry/All.h" 57 | #endif 58 | 59 | #include "src/Core/util/ReenableStupidWarnings.h" 60 | 61 | #endif // EIGEN_GEOMETRY_MODULE_H 62 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 63 | 64 | -------------------------------------------------------------------------------- /cpp/Eigen/Householder: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_HOUSEHOLDER_MODULE_H 2 | #define EIGEN_HOUSEHOLDER_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | /** \defgroup Householder_Module Householder module 9 | * This module provides Householder transformations. 10 | * 11 | * \code 12 | * #include 13 | * \endcode 14 | */ 15 | 16 | #include "src/Householder/Householder.h" 17 | #include "src/Householder/HouseholderSequence.h" 18 | #include "src/Householder/BlockHouseholder.h" 19 | 20 | #include "src/Core/util/ReenableStupidWarnings.h" 21 | 22 | #endif // EIGEN_HOUSEHOLDER_MODULE_H 23 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 24 | -------------------------------------------------------------------------------- /cpp/Eigen/IterativeLinearSolvers: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_ITERATIVELINEARSOLVERS_MODULE_H 2 | #define EIGEN_ITERATIVELINEARSOLVERS_MODULE_H 3 | 4 | #include "SparseCore" 5 | #include "OrderingMethods" 6 | 7 | #include "src/Core/util/DisableStupidWarnings.h" 8 | 9 | /** 10 | * \defgroup IterativeLinearSolvers_Module IterativeLinearSolvers module 11 | * 12 | * This module currently provides iterative methods to solve problems of the form \c A \c x = \c b, where \c A is a squared matrix, usually very large and sparse. 13 | * Those solvers are accessible via the following classes: 14 | * - ConjugateGradient for selfadjoint (hermitian) matrices, 15 | * - BiCGSTAB for general square matrices. 16 | * 17 | * These iterative solvers are associated with some preconditioners: 18 | * - IdentityPreconditioner - not really useful 19 | * - DiagonalPreconditioner - also called JAcobi preconditioner, work very well on diagonal dominant matrices. 20 | * - IncompleteILUT - incomplete LU factorization with dual thresholding 21 | * 22 | * Such problems can also be solved using the direct sparse decomposition modules: SparseCholesky, CholmodSupport, UmfPackSupport, SuperLUSupport. 23 | * 24 | * \code 25 | * #include 26 | * \endcode 27 | */ 28 | 29 | #include "src/misc/Solve.h" 30 | #include "src/misc/SparseSolve.h" 31 | 32 | #include "src/IterativeLinearSolvers/IterativeSolverBase.h" 33 | #include "src/IterativeLinearSolvers/BasicPreconditioners.h" 34 | #include "src/IterativeLinearSolvers/ConjugateGradient.h" 35 | #include "src/IterativeLinearSolvers/BiCGSTAB.h" 36 | #include "src/IterativeLinearSolvers/IncompleteLUT.h" 37 | 38 | #include "src/Core/util/ReenableStupidWarnings.h" 39 | 40 | #endif // EIGEN_ITERATIVELINEARSOLVERS_MODULE_H 41 | -------------------------------------------------------------------------------- /cpp/Eigen/Jacobi: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_JACOBI_MODULE_H 2 | #define EIGEN_JACOBI_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | /** \defgroup Jacobi_Module Jacobi module 9 | * This module provides Jacobi and Givens rotations. 10 | * 11 | * \code 12 | * #include 13 | * \endcode 14 | * 15 | * In addition to listed classes, it defines the two following MatrixBase methods to apply a Jacobi or Givens rotation: 16 | * - MatrixBase::applyOnTheLeft() 17 | * - MatrixBase::applyOnTheRight(). 18 | */ 19 | 20 | #include "src/Jacobi/Jacobi.h" 21 | 22 | #include "src/Core/util/ReenableStupidWarnings.h" 23 | 24 | #endif // EIGEN_JACOBI_MODULE_H 25 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 26 | 27 | -------------------------------------------------------------------------------- /cpp/Eigen/LU: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_LU_MODULE_H 2 | #define EIGEN_LU_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | /** \defgroup LU_Module LU module 9 | * This module includes %LU decomposition and related notions such as matrix inversion and determinant. 10 | * This module defines the following MatrixBase methods: 11 | * - MatrixBase::inverse() 12 | * - MatrixBase::determinant() 13 | * 14 | * \code 15 | * #include 16 | * \endcode 17 | */ 18 | 19 | #include "src/misc/Solve.h" 20 | #include "src/misc/Kernel.h" 21 | #include "src/misc/Image.h" 22 | #include "src/LU/FullPivLU.h" 23 | #include "src/LU/PartialPivLU.h" 24 | #ifdef EIGEN_USE_LAPACKE 25 | #include "src/LU/PartialPivLU_MKL.h" 26 | #endif 27 | #include "src/LU/Determinant.h" 28 | #include "src/LU/Inverse.h" 29 | 30 | #if defined EIGEN_VECTORIZE_SSE 31 | #include "src/LU/arch/Inverse_SSE.h" 32 | #endif 33 | 34 | #ifdef EIGEN2_SUPPORT 35 | #include "src/Eigen2Support/LU.h" 36 | #endif 37 | 38 | #include "src/Core/util/ReenableStupidWarnings.h" 39 | 40 | #endif // EIGEN_LU_MODULE_H 41 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 42 | -------------------------------------------------------------------------------- /cpp/Eigen/LeastSquares: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_REGRESSION_MODULE_H 2 | #define EIGEN_REGRESSION_MODULE_H 3 | 4 | #ifndef EIGEN2_SUPPORT 5 | #error LeastSquares is only available in Eigen2 support mode (define EIGEN2_SUPPORT) 6 | #endif 7 | 8 | // exclude from normal eigen3-only documentation 9 | #ifdef EIGEN2_SUPPORT 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | #include "Eigenvalues" 16 | #include "Geometry" 17 | 18 | /** \defgroup LeastSquares_Module LeastSquares module 19 | * This module provides linear regression and related features. 20 | * 21 | * \code 22 | * #include 23 | * \endcode 24 | */ 25 | 26 | #include "src/Eigen2Support/LeastSquares.h" 27 | 28 | #include "src/Core/util/ReenableStupidWarnings.h" 29 | 30 | #endif // EIGEN2_SUPPORT 31 | 32 | #endif // EIGEN_REGRESSION_MODULE_H 33 | -------------------------------------------------------------------------------- /cpp/Eigen/MetisSupport: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_METISSUPPORT_MODULE_H 2 | #define EIGEN_METISSUPPORT_MODULE_H 3 | 4 | #include "SparseCore" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | extern "C" { 9 | #include 10 | } 11 | 12 | 13 | /** \ingroup Support_modules 14 | * \defgroup MetisSupport_Module MetisSupport module 15 | * 16 | * \code 17 | * #include 18 | * \endcode 19 | * This module defines an interface to the METIS reordering package (http://glaros.dtc.umn.edu/gkhome/views/metis). 20 | * It can be used just as any other built-in method as explained in \link OrderingMethods_Module here. \endlink 21 | */ 22 | 23 | 24 | #include "src/MetisSupport/MetisSupport.h" 25 | 26 | #include "src/Core/util/ReenableStupidWarnings.h" 27 | 28 | #endif // EIGEN_METISSUPPORT_MODULE_H 29 | -------------------------------------------------------------------------------- /cpp/Eigen/PaStiXSupport: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_PASTIXSUPPORT_MODULE_H 2 | #define EIGEN_PASTIXSUPPORT_MODULE_H 3 | 4 | #include "SparseCore" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | #include 9 | extern "C" { 10 | #include 11 | #include 12 | } 13 | 14 | #ifdef complex 15 | #undef complex 16 | #endif 17 | 18 | /** \ingroup Support_modules 19 | * \defgroup PaStiXSupport_Module PaStiXSupport module 20 | * 21 | * This module provides an interface to the PaSTiX library. 22 | * PaSTiX is a general \b supernodal, \b parallel and \b opensource sparse solver. 23 | * It provides the two following main factorization classes: 24 | * - class PastixLLT : a supernodal, parallel LLt Cholesky factorization. 25 | * - class PastixLDLT: a supernodal, parallel LDLt Cholesky factorization. 26 | * - class PastixLU : a supernodal, parallel LU factorization (optimized for a symmetric pattern). 27 | * 28 | * \code 29 | * #include 30 | * \endcode 31 | * 32 | * In order to use this module, the PaSTiX headers must be accessible from the include paths, and your binary must be linked to the PaSTiX library and its dependencies. 33 | * The dependencies depend on how PaSTiX has been compiled. 34 | * For a cmake based project, you can use our FindPaSTiX.cmake module to help you in this task. 35 | * 36 | */ 37 | 38 | #include "src/misc/Solve.h" 39 | #include "src/misc/SparseSolve.h" 40 | 41 | #include "src/PaStiXSupport/PaStiXSupport.h" 42 | 43 | 44 | #include "src/Core/util/ReenableStupidWarnings.h" 45 | 46 | #endif // EIGEN_PASTIXSUPPORT_MODULE_H 47 | -------------------------------------------------------------------------------- /cpp/Eigen/PardisoSupport: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_PARDISOSUPPORT_MODULE_H 2 | #define EIGEN_PARDISOSUPPORT_MODULE_H 3 | 4 | #include "SparseCore" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | #include 9 | 10 | #include 11 | 12 | /** \ingroup Support_modules 13 | * \defgroup PardisoSupport_Module PardisoSupport module 14 | * 15 | * This module brings support for the Intel(R) MKL PARDISO direct sparse solvers. 16 | * 17 | * \code 18 | * #include 19 | * \endcode 20 | * 21 | * In order to use this module, the MKL headers must be accessible from the include paths, and your binary must be linked to the MKL library and its dependencies. 22 | * See this \ref TopicUsingIntelMKL "page" for more information on MKL-Eigen integration. 23 | * 24 | */ 25 | 26 | #include "src/PardisoSupport/PardisoSupport.h" 27 | 28 | #include "src/Core/util/ReenableStupidWarnings.h" 29 | 30 | #endif // EIGEN_PARDISOSUPPORT_MODULE_H 31 | -------------------------------------------------------------------------------- /cpp/Eigen/QR: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_QR_MODULE_H 2 | #define EIGEN_QR_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | #include "Cholesky" 9 | #include "Jacobi" 10 | #include "Householder" 11 | 12 | /** \defgroup QR_Module QR module 13 | * 14 | * 15 | * 16 | * This module provides various QR decompositions 17 | * This module also provides some MatrixBase methods, including: 18 | * - MatrixBase::qr(), 19 | * 20 | * \code 21 | * #include 22 | * \endcode 23 | */ 24 | 25 | #include "src/misc/Solve.h" 26 | #include "src/QR/HouseholderQR.h" 27 | #include "src/QR/FullPivHouseholderQR.h" 28 | #include "src/QR/ColPivHouseholderQR.h" 29 | #ifdef EIGEN_USE_LAPACKE 30 | #include "src/QR/HouseholderQR_MKL.h" 31 | #include "src/QR/ColPivHouseholderQR_MKL.h" 32 | #endif 33 | 34 | #ifdef EIGEN2_SUPPORT 35 | #include "src/Eigen2Support/QR.h" 36 | #endif 37 | 38 | #include "src/Core/util/ReenableStupidWarnings.h" 39 | 40 | #ifdef EIGEN2_SUPPORT 41 | #include "Eigenvalues" 42 | #endif 43 | 44 | #endif // EIGEN_QR_MODULE_H 45 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 46 | -------------------------------------------------------------------------------- /cpp/Eigen/QtAlignedMalloc: -------------------------------------------------------------------------------- 1 | 2 | #ifndef EIGEN_QTMALLOC_MODULE_H 3 | #define EIGEN_QTMALLOC_MODULE_H 4 | 5 | #include "Core" 6 | 7 | #if (!EIGEN_MALLOC_ALREADY_ALIGNED) 8 | 9 | #include "src/Core/util/DisableStupidWarnings.h" 10 | 11 | void *qMalloc(size_t size) 12 | { 13 | return Eigen::internal::aligned_malloc(size); 14 | } 15 | 16 | void qFree(void *ptr) 17 | { 18 | Eigen::internal::aligned_free(ptr); 19 | } 20 | 21 | void *qRealloc(void *ptr, size_t size) 22 | { 23 | void* newPtr = Eigen::internal::aligned_malloc(size); 24 | memcpy(newPtr, ptr, size); 25 | Eigen::internal::aligned_free(ptr); 26 | return newPtr; 27 | } 28 | 29 | #include "src/Core/util/ReenableStupidWarnings.h" 30 | 31 | #endif 32 | 33 | #endif // EIGEN_QTMALLOC_MODULE_H 34 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 35 | -------------------------------------------------------------------------------- /cpp/Eigen/SPQRSupport: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_SPQRSUPPORT_MODULE_H 2 | #define EIGEN_SPQRSUPPORT_MODULE_H 3 | 4 | #include "SparseCore" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | #include "SuiteSparseQR.hpp" 9 | 10 | /** \ingroup Support_modules 11 | * \defgroup SPQRSupport_Module SuiteSparseQR module 12 | * 13 | * This module provides an interface to the SPQR library, which is part of the suitesparse package. 14 | * 15 | * \code 16 | * #include 17 | * \endcode 18 | * 19 | * In order to use this module, the SPQR headers must be accessible from the include paths, and your binary must be linked to the SPQR library and its dependencies (Cholmod, AMD, COLAMD,...). 20 | * For a cmake based project, you can use our FindSPQR.cmake and FindCholmod.Cmake modules 21 | * 22 | */ 23 | 24 | #include "src/misc/Solve.h" 25 | #include "src/misc/SparseSolve.h" 26 | #include "src/CholmodSupport/CholmodSupport.h" 27 | #include "src/SPQRSupport/SuiteSparseQRSupport.h" 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /cpp/Eigen/SVD: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_SVD_MODULE_H 2 | #define EIGEN_SVD_MODULE_H 3 | 4 | #include "QR" 5 | #include "Householder" 6 | #include "Jacobi" 7 | 8 | #include "src/Core/util/DisableStupidWarnings.h" 9 | 10 | /** \defgroup SVD_Module SVD module 11 | * 12 | * 13 | * 14 | * This module provides SVD decomposition for matrices (both real and complex). 15 | * This decomposition is accessible via the following MatrixBase method: 16 | * - MatrixBase::jacobiSvd() 17 | * 18 | * \code 19 | * #include 20 | * \endcode 21 | */ 22 | 23 | #include "src/misc/Solve.h" 24 | #include "src/SVD/JacobiSVD.h" 25 | #if defined(EIGEN_USE_LAPACKE) && !defined(EIGEN_USE_LAPACKE_STRICT) 26 | #include "src/SVD/JacobiSVD_MKL.h" 27 | #endif 28 | #include "src/SVD/UpperBidiagonalization.h" 29 | 30 | #ifdef EIGEN2_SUPPORT 31 | #include "src/Eigen2Support/SVD.h" 32 | #endif 33 | 34 | #include "src/Core/util/ReenableStupidWarnings.h" 35 | 36 | #endif // EIGEN_SVD_MODULE_H 37 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 38 | -------------------------------------------------------------------------------- /cpp/Eigen/Sparse: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_SPARSE_MODULE_H 2 | #define EIGEN_SPARSE_MODULE_H 3 | 4 | /** \defgroup Sparse_Module Sparse meta-module 5 | * 6 | * Meta-module including all related modules: 7 | * - \ref SparseCore_Module 8 | * - \ref OrderingMethods_Module 9 | * - \ref SparseCholesky_Module 10 | * - \ref SparseLU_Module 11 | * - \ref SparseQR_Module 12 | * - \ref IterativeLinearSolvers_Module 13 | * 14 | * \code 15 | * #include 16 | * \endcode 17 | */ 18 | 19 | #include "SparseCore" 20 | #include "OrderingMethods" 21 | #include "SparseCholesky" 22 | #include "SparseLU" 23 | #include "SparseQR" 24 | #include "IterativeLinearSolvers" 25 | 26 | #endif // EIGEN_SPARSE_MODULE_H 27 | 28 | -------------------------------------------------------------------------------- /cpp/Eigen/SparseCholesky: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2013 Gael Guennebaud 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_SPARSECHOLESKY_MODULE_H 11 | #define EIGEN_SPARSECHOLESKY_MODULE_H 12 | 13 | #include "SparseCore" 14 | #include "OrderingMethods" 15 | 16 | #include "src/Core/util/DisableStupidWarnings.h" 17 | 18 | /** 19 | * \defgroup SparseCholesky_Module SparseCholesky module 20 | * 21 | * This module currently provides two variants of the direct sparse Cholesky decomposition for selfadjoint (hermitian) matrices. 22 | * Those decompositions are accessible via the following classes: 23 | * - SimplicialLLt, 24 | * - SimplicialLDLt 25 | * 26 | * Such problems can also be solved using the ConjugateGradient solver from the IterativeLinearSolvers module. 27 | * 28 | * \code 29 | * #include 30 | * \endcode 31 | */ 32 | 33 | #ifdef EIGEN_MPL2_ONLY 34 | #error The SparseCholesky module has nothing to offer in MPL2 only mode 35 | #endif 36 | 37 | #include "src/misc/Solve.h" 38 | #include "src/misc/SparseSolve.h" 39 | #include "src/SparseCholesky/SimplicialCholesky.h" 40 | 41 | #ifndef EIGEN_MPL2_ONLY 42 | #include "src/SparseCholesky/SimplicialCholesky_impl.h" 43 | #endif 44 | 45 | #include "src/Core/util/ReenableStupidWarnings.h" 46 | 47 | #endif // EIGEN_SPARSECHOLESKY_MODULE_H 48 | -------------------------------------------------------------------------------- /cpp/Eigen/SparseCore: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_SPARSECORE_MODULE_H 2 | #define EIGEN_SPARSECORE_MODULE_H 3 | 4 | #include "Core" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | /** 15 | * \defgroup SparseCore_Module SparseCore module 16 | * 17 | * This module provides a sparse matrix representation, and basic associatd matrix manipulations 18 | * and operations. 19 | * 20 | * See the \ref TutorialSparse "Sparse tutorial" 21 | * 22 | * \code 23 | * #include 24 | * \endcode 25 | * 26 | * This module depends on: Core. 27 | */ 28 | 29 | namespace Eigen { 30 | 31 | /** The type used to identify a general sparse storage. */ 32 | struct Sparse {}; 33 | 34 | } 35 | 36 | #include "src/SparseCore/SparseUtil.h" 37 | #include "src/SparseCore/SparseMatrixBase.h" 38 | #include "src/SparseCore/CompressedStorage.h" 39 | #include "src/SparseCore/AmbiVector.h" 40 | #include "src/SparseCore/SparseMatrix.h" 41 | #include "src/SparseCore/MappedSparseMatrix.h" 42 | #include "src/SparseCore/SparseVector.h" 43 | #include "src/SparseCore/SparseBlock.h" 44 | #include "src/SparseCore/SparseTranspose.h" 45 | #include "src/SparseCore/SparseCwiseUnaryOp.h" 46 | #include "src/SparseCore/SparseCwiseBinaryOp.h" 47 | #include "src/SparseCore/SparseDot.h" 48 | #include "src/SparseCore/SparsePermutation.h" 49 | #include "src/SparseCore/SparseRedux.h" 50 | #include "src/SparseCore/SparseFuzzy.h" 51 | #include "src/SparseCore/ConservativeSparseSparseProduct.h" 52 | #include "src/SparseCore/SparseSparseProductWithPruning.h" 53 | #include "src/SparseCore/SparseProduct.h" 54 | #include "src/SparseCore/SparseDenseProduct.h" 55 | #include "src/SparseCore/SparseDiagonalProduct.h" 56 | #include "src/SparseCore/SparseTriangularView.h" 57 | #include "src/SparseCore/SparseSelfAdjointView.h" 58 | #include "src/SparseCore/TriangularSolver.h" 59 | #include "src/SparseCore/SparseView.h" 60 | 61 | #include "src/Core/util/ReenableStupidWarnings.h" 62 | 63 | #endif // EIGEN_SPARSECORE_MODULE_H 64 | 65 | -------------------------------------------------------------------------------- /cpp/Eigen/SparseLU: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2012 Désiré Nuentsa-Wakam 5 | // Copyright (C) 2012 Gael Guennebaud 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_SPARSELU_MODULE_H 12 | #define EIGEN_SPARSELU_MODULE_H 13 | 14 | #include "SparseCore" 15 | 16 | /** 17 | * \defgroup SparseLU_Module SparseLU module 18 | * This module defines a supernodal factorization of general sparse matrices. 19 | * The code is fully optimized for supernode-panel updates with specialized kernels. 20 | * Please, see the documentation of the SparseLU class for more details. 21 | */ 22 | 23 | #include "src/misc/Solve.h" 24 | #include "src/misc/SparseSolve.h" 25 | 26 | // Ordering interface 27 | #include "OrderingMethods" 28 | 29 | #include "src/SparseLU/SparseLU_gemm_kernel.h" 30 | 31 | #include "src/SparseLU/SparseLU_Structs.h" 32 | #include "src/SparseLU/SparseLU_SupernodalMatrix.h" 33 | #include "src/SparseLU/SparseLUImpl.h" 34 | #include "src/SparseCore/SparseColEtree.h" 35 | #include "src/SparseLU/SparseLU_Memory.h" 36 | #include "src/SparseLU/SparseLU_heap_relax_snode.h" 37 | #include "src/SparseLU/SparseLU_relax_snode.h" 38 | #include "src/SparseLU/SparseLU_pivotL.h" 39 | #include "src/SparseLU/SparseLU_panel_dfs.h" 40 | #include "src/SparseLU/SparseLU_kernel_bmod.h" 41 | #include "src/SparseLU/SparseLU_panel_bmod.h" 42 | #include "src/SparseLU/SparseLU_column_dfs.h" 43 | #include "src/SparseLU/SparseLU_column_bmod.h" 44 | #include "src/SparseLU/SparseLU_copy_to_ucol.h" 45 | #include "src/SparseLU/SparseLU_pruneL.h" 46 | #include "src/SparseLU/SparseLU_Utils.h" 47 | #include "src/SparseLU/SparseLU.h" 48 | 49 | #endif // EIGEN_SPARSELU_MODULE_H 50 | -------------------------------------------------------------------------------- /cpp/Eigen/SparseQR: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_SPARSEQR_MODULE_H 2 | #define EIGEN_SPARSEQR_MODULE_H 3 | 4 | #include "SparseCore" 5 | #include "OrderingMethods" 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | /** \defgroup SparseQR_Module SparseQR module 9 | * \brief Provides QR decomposition for sparse matrices 10 | * 11 | * This module provides a simplicial version of the left-looking Sparse QR decomposition. 12 | * The columns of the input matrix should be reordered to limit the fill-in during the 13 | * decomposition. Built-in methods (COLAMD, AMD) or external methods (METIS) can be used to this end. 14 | * See the \link OrderingMethods_Module OrderingMethods\endlink module for the list 15 | * of built-in and external ordering methods. 16 | * 17 | * \code 18 | * #include 19 | * \endcode 20 | * 21 | * 22 | */ 23 | 24 | #include "src/misc/Solve.h" 25 | #include "src/misc/SparseSolve.h" 26 | 27 | #include "OrderingMethods" 28 | #include "src/SparseCore/SparseColEtree.h" 29 | #include "src/SparseQR/SparseQR.h" 30 | 31 | #include "src/Core/util/ReenableStupidWarnings.h" 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /cpp/Eigen/StdDeque: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Gael Guennebaud 5 | // Copyright (C) 2009 Hauke Heibel 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_STDDEQUE_MODULE_H 12 | #define EIGEN_STDDEQUE_MODULE_H 13 | 14 | #include "Core" 15 | #include 16 | 17 | #if (defined(_MSC_VER) && defined(_WIN64)) /* MSVC auto aligns in 64 bit builds */ 18 | 19 | #define EIGEN_DEFINE_STL_DEQUE_SPECIALIZATION(...) 20 | 21 | #else 22 | 23 | #include "src/StlSupport/StdDeque.h" 24 | 25 | #endif 26 | 27 | #endif // EIGEN_STDDEQUE_MODULE_H 28 | -------------------------------------------------------------------------------- /cpp/Eigen/StdList: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Hauke Heibel 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_STDLIST_MODULE_H 11 | #define EIGEN_STDLIST_MODULE_H 12 | 13 | #include "Core" 14 | #include 15 | 16 | #if (defined(_MSC_VER) && defined(_WIN64)) /* MSVC auto aligns in 64 bit builds */ 17 | 18 | #define EIGEN_DEFINE_STL_LIST_SPECIALIZATION(...) 19 | 20 | #else 21 | 22 | #include "src/StlSupport/StdList.h" 23 | 24 | #endif 25 | 26 | #endif // EIGEN_STDLIST_MODULE_H 27 | -------------------------------------------------------------------------------- /cpp/Eigen/StdVector: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Gael Guennebaud 5 | // Copyright (C) 2009 Hauke Heibel 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_STDVECTOR_MODULE_H 12 | #define EIGEN_STDVECTOR_MODULE_H 13 | 14 | #include "Core" 15 | #include 16 | 17 | #if (defined(_MSC_VER) && defined(_WIN64)) /* MSVC auto aligns in 64 bit builds */ 18 | 19 | #define EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(...) 20 | 21 | #else 22 | 23 | #include "src/StlSupport/StdVector.h" 24 | 25 | #endif 26 | 27 | #endif // EIGEN_STDVECTOR_MODULE_H 28 | -------------------------------------------------------------------------------- /cpp/Eigen/UmfPackSupport: -------------------------------------------------------------------------------- 1 | #ifndef EIGEN_UMFPACKSUPPORT_MODULE_H 2 | #define EIGEN_UMFPACKSUPPORT_MODULE_H 3 | 4 | #include "SparseCore" 5 | 6 | #include "src/Core/util/DisableStupidWarnings.h" 7 | 8 | extern "C" { 9 | #include 10 | } 11 | 12 | /** \ingroup Support_modules 13 | * \defgroup UmfPackSupport_Module UmfPackSupport module 14 | * 15 | * This module provides an interface to the UmfPack library which is part of the suitesparse package. 16 | * It provides the following factorization class: 17 | * - class UmfPackLU: a multifrontal sequential LU factorization. 18 | * 19 | * \code 20 | * #include 21 | * \endcode 22 | * 23 | * In order to use this module, the umfpack headers must be accessible from the include paths, and your binary must be linked to the umfpack library and its dependencies. 24 | * The dependencies depend on how umfpack has been compiled. 25 | * For a cmake based project, you can use our FindUmfPack.cmake module to help you in this task. 26 | * 27 | */ 28 | 29 | #include "src/misc/Solve.h" 30 | #include "src/misc/SparseSolve.h" 31 | 32 | #include "src/UmfPackSupport/UmfPackSupport.h" 33 | 34 | #include "src/Core/util/ReenableStupidWarnings.h" 35 | 36 | #endif // EIGEN_UMFPACKSUPPORT_MODULE_H 37 | -------------------------------------------------------------------------------- /cpp/Eigen/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB Eigen_src_subdirectories "*") 2 | escape_string_as_regex(ESCAPED_CMAKE_CURRENT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") 3 | foreach(f ${Eigen_src_subdirectories}) 4 | if(NOT f MATCHES "\\.txt" AND NOT f MATCHES "${ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/[.].+" ) 5 | add_subdirectory(${f}) 6 | endif() 7 | endforeach() 8 | -------------------------------------------------------------------------------- /cpp/Eigen/src/Cholesky/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Cholesky_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Cholesky_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Cholesky COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /cpp/Eigen/src/CholmodSupport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_CholmodSupport_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_CholmodSupport_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/CholmodSupport COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /cpp/Eigen/src/Core/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Core_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Core_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core COMPONENT Devel 6 | ) 7 | 8 | ADD_SUBDIRECTORY(products) 9 | ADD_SUBDIRECTORY(util) 10 | ADD_SUBDIRECTORY(arch) 11 | -------------------------------------------------------------------------------- /cpp/Eigen/src/Core/arch/AltiVec/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Core_arch_AltiVec_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Core_arch_AltiVec_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core/arch/AltiVec COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /cpp/Eigen/src/Core/arch/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_SUBDIRECTORY(SSE) 2 | ADD_SUBDIRECTORY(AltiVec) 3 | ADD_SUBDIRECTORY(NEON) 4 | ADD_SUBDIRECTORY(Default) 5 | -------------------------------------------------------------------------------- /cpp/Eigen/src/Core/arch/Default/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Core_arch_Default_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Core_arch_Default_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core/arch/Default COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /cpp/Eigen/src/Core/arch/Default/Settings.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008-2010 Gael Guennebaud 5 | // Copyright (C) 2006-2008 Benoit Jacob 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | 12 | /* All the parameters defined in this file can be specialized in the 13 | * architecture specific files, and/or by the user. 14 | * More to come... */ 15 | 16 | #ifndef EIGEN_DEFAULT_SETTINGS_H 17 | #define EIGEN_DEFAULT_SETTINGS_H 18 | 19 | /** Defines the maximal loop size to enable meta unrolling of loops. 20 | * Note that the value here is expressed in Eigen's own notion of "number of FLOPS", 21 | * it does not correspond to the number of iterations or the number of instructions 22 | */ 23 | #ifndef EIGEN_UNROLLING_LIMIT 24 | #define EIGEN_UNROLLING_LIMIT 100 25 | #endif 26 | 27 | /** Defines the threshold between a "small" and a "large" matrix. 28 | * This threshold is mainly used to select the proper product implementation. 29 | */ 30 | #ifndef EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 31 | #define EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 8 32 | #endif 33 | 34 | /** Defines the maximal width of the blocks used in the triangular product and solver 35 | * for vectors (level 2 blas xTRMV and xTRSV). The default is 8. 36 | */ 37 | #ifndef EIGEN_TUNE_TRIANGULAR_PANEL_WIDTH 38 | #define EIGEN_TUNE_TRIANGULAR_PANEL_WIDTH 8 39 | #endif 40 | 41 | 42 | /** Defines the default number of registers available for that architecture. 43 | * Currently it must be 8 or 16. Other values will fail. 44 | */ 45 | #ifndef EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS 46 | #define EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS 8 47 | #endif 48 | 49 | #endif // EIGEN_DEFAULT_SETTINGS_H 50 | -------------------------------------------------------------------------------- /cpp/Eigen/src/Core/arch/NEON/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Core_arch_NEON_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Core_arch_NEON_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core/arch/NEON COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /cpp/Eigen/src/Core/arch/SSE/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Core_arch_SSE_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Core_arch_SSE_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core/arch/SSE COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /cpp/Eigen/src/Core/products/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Core_Product_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Core_Product_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core/products COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /cpp/Eigen/src/Core/util/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Core_util_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Core_util_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core/util COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /cpp/Eigen/src/Core/util/NonMPL2.h: -------------------------------------------------------------------------------- 1 | #ifdef EIGEN_MPL2_ONLY 2 | #error Including non-MPL2 code in EIGEN_MPL2_ONLY mode 3 | #endif 4 | -------------------------------------------------------------------------------- /cpp/Eigen/src/Core/util/ReenableStupidWarnings.h: -------------------------------------------------------------------------------- 1 | #ifdef EIGEN_WARNINGS_DISABLED 2 | #undef EIGEN_WARNINGS_DISABLED 3 | 4 | #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS 5 | #ifdef _MSC_VER 6 | #pragma warning( pop ) 7 | #elif defined __INTEL_COMPILER 8 | #pragma warning pop 9 | #elif defined __clang__ 10 | #pragma clang diagnostic pop 11 | #endif 12 | #endif 13 | 14 | #endif // EIGEN_WARNINGS_DISABLED 15 | -------------------------------------------------------------------------------- /cpp/Eigen/src/Eigen2Support/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Eigen2Support_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Eigen2Support_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Eigen2Support COMPONENT Devel 6 | ) 7 | 8 | ADD_SUBDIRECTORY(Geometry) -------------------------------------------------------------------------------- /cpp/Eigen/src/Eigen2Support/Geometry/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Eigen2Support_Geometry_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Eigen2Support_Geometry_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Eigen2Support/Geometry 6 | ) 7 | -------------------------------------------------------------------------------- /cpp/Eigen/src/Eigen2Support/Macros.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2011 Benoit Jacob 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 EIGEN2_MACROS_H 11 | #define EIGEN2_MACROS_H 12 | 13 | #define ei_assert eigen_assert 14 | #define ei_internal_assert eigen_internal_assert 15 | 16 | #define EIGEN_ALIGN_128 EIGEN_ALIGN16 17 | 18 | #define EIGEN_ARCH_WANTS_ALIGNMENT EIGEN_ALIGN_STATICALLY 19 | 20 | #endif // EIGEN2_MACROS_H 21 | -------------------------------------------------------------------------------- /cpp/Eigen/src/Eigen2Support/Memory.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2011 Benoit Jacob 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 EIGEN2_MEMORY_H 11 | #define EIGEN2_MEMORY_H 12 | 13 | namespace Eigen { 14 | 15 | inline void* ei_aligned_malloc(size_t size) { return internal::aligned_malloc(size); } 16 | inline void ei_aligned_free(void *ptr) { internal::aligned_free(ptr); } 17 | inline void* ei_aligned_realloc(void *ptr, size_t new_size, size_t old_size) { return internal::aligned_realloc(ptr, new_size, old_size); } 18 | inline void* ei_handmade_aligned_malloc(size_t size) { return internal::handmade_aligned_malloc(size); } 19 | inline void ei_handmade_aligned_free(void *ptr) { internal::handmade_aligned_free(ptr); } 20 | 21 | template inline void* ei_conditional_aligned_malloc(size_t size) 22 | { 23 | return internal::conditional_aligned_malloc(size); 24 | } 25 | template inline void ei_conditional_aligned_free(void *ptr) 26 | { 27 | internal::conditional_aligned_free(ptr); 28 | } 29 | template inline void* ei_conditional_aligned_realloc(void* ptr, size_t new_size, size_t old_size) 30 | { 31 | return internal::conditional_aligned_realloc(ptr, new_size, old_size); 32 | } 33 | 34 | template inline T* ei_aligned_new(size_t size) 35 | { 36 | return internal::aligned_new(size); 37 | } 38 | template inline void ei_aligned_delete(T *ptr, size_t size) 39 | { 40 | return internal::aligned_delete(ptr, size); 41 | } 42 | 43 | } // end namespace Eigen 44 | 45 | #endif // EIGEN2_MACROS_H 46 | -------------------------------------------------------------------------------- /cpp/Eigen/src/Eigen2Support/QR.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Gael Guennebaud 5 | // Copyright (C) 2011 Benoit Jacob 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN2_QR_H 12 | #define EIGEN2_QR_H 13 | 14 | namespace Eigen { 15 | 16 | template 17 | class QR : public HouseholderQR 18 | { 19 | public: 20 | 21 | typedef HouseholderQR Base; 22 | typedef Block MatrixRBlockType; 23 | 24 | QR() : Base() {} 25 | 26 | template 27 | explicit QR(const T& t) : Base(t) {} 28 | 29 | template 30 | bool solve(const MatrixBase& b, ResultType *result) const 31 | { 32 | *result = static_cast(this)->solve(b); 33 | return true; 34 | } 35 | 36 | MatrixType matrixQ(void) const { 37 | MatrixType ret = MatrixType::Identity(this->rows(), this->cols()); 38 | ret = this->householderQ() * ret; 39 | return ret; 40 | } 41 | 42 | bool isFullRank() const { 43 | return true; 44 | } 45 | 46 | const TriangularView 47 | matrixR(void) const 48 | { 49 | int cols = this->cols(); 50 | return MatrixRBlockType(this->matrixQR(), 0, 0, cols, cols).template triangularView(); 51 | } 52 | }; 53 | 54 | /** \return the QR decomposition of \c *this. 55 | * 56 | * \sa class QR 57 | */ 58 | template 59 | const QR::PlainObject> 60 | MatrixBase::qr() const 61 | { 62 | return QR(eval()); 63 | } 64 | 65 | } // end namespace Eigen 66 | 67 | #endif // EIGEN2_QR_H 68 | -------------------------------------------------------------------------------- /cpp/Eigen/src/Eigen2Support/TriangularSolver.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2010 Gael Guennebaud 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_TRIANGULAR_SOLVER2_H 11 | #define EIGEN_TRIANGULAR_SOLVER2_H 12 | 13 | namespace Eigen { 14 | 15 | const unsigned int UnitDiagBit = UnitDiag; 16 | const unsigned int SelfAdjointBit = SelfAdjoint; 17 | const unsigned int UpperTriangularBit = Upper; 18 | const unsigned int LowerTriangularBit = Lower; 19 | 20 | const unsigned int UpperTriangular = Upper; 21 | const unsigned int LowerTriangular = Lower; 22 | const unsigned int UnitUpperTriangular = UnitUpper; 23 | const unsigned int UnitLowerTriangular = UnitLower; 24 | 25 | template 26 | template 27 | typename ExpressionType::PlainObject 28 | Flagged::solveTriangular(const MatrixBase& other) const 29 | { 30 | return m_matrix.template triangularView().solve(other.derived()); 31 | } 32 | 33 | template 34 | template 35 | void Flagged::solveTriangularInPlace(const MatrixBase& other) const 36 | { 37 | m_matrix.template triangularView().solveInPlace(other.derived()); 38 | } 39 | 40 | } // end namespace Eigen 41 | 42 | #endif // EIGEN_TRIANGULAR_SOLVER2_H 43 | -------------------------------------------------------------------------------- /cpp/Eigen/src/Eigenvalues/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_EIGENVALUES_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_EIGENVALUES_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Eigenvalues COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /cpp/Eigen/src/Geometry/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Geometry_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Geometry_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Geometry COMPONENT Devel 6 | ) 7 | 8 | ADD_SUBDIRECTORY(arch) 9 | -------------------------------------------------------------------------------- /cpp/Eigen/src/Geometry/arch/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Geometry_arch_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Geometry_arch_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Geometry/arch COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /cpp/Eigen/src/Householder/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Householder_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Householder_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Householder COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /cpp/Eigen/src/IterativeLinearSolvers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_IterativeLinearSolvers_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_IterativeLinearSolvers_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/IterativeLinearSolvers COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /cpp/Eigen/src/Jacobi/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_Jacobi_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_Jacobi_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Jacobi COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /cpp/Eigen/src/LU/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_LU_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_LU_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/LU COMPONENT Devel 6 | ) 7 | 8 | ADD_SUBDIRECTORY(arch) 9 | -------------------------------------------------------------------------------- /cpp/Eigen/src/LU/arch/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_LU_arch_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_LU_arch_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/LU/arch COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /cpp/Eigen/src/MetisSupport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_MetisSupport_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_MetisSupport_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/MetisSupport COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /cpp/Eigen/src/OrderingMethods/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_OrderingMethods_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_OrderingMethods_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/OrderingMethods COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /cpp/Eigen/src/PaStiXSupport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_PastixSupport_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_PastixSupport_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/PaStiXSupport COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /cpp/Eigen/src/PardisoSupport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_PardisoSupport_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_PardisoSupport_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/PardisoSupport COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /cpp/Eigen/src/QR/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_QR_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_QR_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/QR COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /cpp/Eigen/src/SPQRSupport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_SPQRSupport_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_SPQRSupport_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/SPQRSupport/ COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /cpp/Eigen/src/SVD/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_SVD_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_SVD_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/SVD COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /cpp/Eigen/src/SparseCholesky/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_SparseCholesky_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_SparseCholesky_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/SparseCholesky COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /cpp/Eigen/src/SparseCore/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_SparseCore_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_SparseCore_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/SparseCore COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /cpp/Eigen/src/SparseCore/SparseFuzzy.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Gael Guennebaud 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_SPARSE_FUZZY_H 11 | #define EIGEN_SPARSE_FUZZY_H 12 | 13 | // template 14 | // template 15 | // bool SparseMatrixBase::isApprox( 16 | // const OtherDerived& other, 17 | // typename NumTraits::Real prec 18 | // ) const 19 | // { 20 | // const typename internal::nested::type nested(derived()); 21 | // const typename internal::nested::type otherNested(other.derived()); 22 | // return (nested - otherNested).cwise().abs2().sum() 23 | // <= prec * prec * (std::min)(nested.cwise().abs2().sum(), otherNested.cwise().abs2().sum()); 24 | // } 25 | 26 | #endif // EIGEN_SPARSE_FUZZY_H 27 | -------------------------------------------------------------------------------- /cpp/Eigen/src/SparseCore/SparseRedux.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Gael Guennebaud 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_SPARSEREDUX_H 11 | #define EIGEN_SPARSEREDUX_H 12 | 13 | namespace Eigen { 14 | 15 | template 16 | typename internal::traits::Scalar 17 | SparseMatrixBase::sum() const 18 | { 19 | eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); 20 | Scalar res(0); 21 | for (Index j=0; j 28 | typename internal::traits >::Scalar 29 | SparseMatrix<_Scalar,_Options,_Index>::sum() const 30 | { 31 | eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); 32 | return Matrix::Map(&m_data.value(0), m_data.size()).sum(); 33 | } 34 | 35 | template 36 | typename internal::traits >::Scalar 37 | SparseVector<_Scalar,_Options,_Index>::sum() const 38 | { 39 | eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); 40 | return Matrix::Map(&m_data.value(0), m_data.size()).sum(); 41 | } 42 | 43 | } // end namespace Eigen 44 | 45 | #endif // EIGEN_SPARSEREDUX_H 46 | -------------------------------------------------------------------------------- /cpp/Eigen/src/SparseLU/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_SparseLU_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_SparseLU_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/SparseLU COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /cpp/Eigen/src/SparseQR/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_SparseQR_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_SparseQR_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/SparseQR/ COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /cpp/Eigen/src/StlSupport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_StlSupport_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_StlSupport_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/StlSupport COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /cpp/Eigen/src/SuperLUSupport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_SuperLUSupport_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_SuperLUSupport_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/SuperLUSupport COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /cpp/Eigen/src/UmfPackSupport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_UmfPackSupport_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_UmfPackSupport_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/UmfPackSupport COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /cpp/Eigen/src/misc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_misc_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_misc_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/misc COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /cpp/Eigen/src/plugins/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_plugins_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_plugins_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/plugins COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /matlab/Bowl.m: -------------------------------------------------------------------------------- 1 | function f = Bowl(x) 2 | a = 1; 3 | b = 2; 4 | f = a.*x(:,1).^2+b.*x(:,2).^2; -------------------------------------------------------------------------------- /matlab/FindGlobalGPMinimum.m: -------------------------------------------------------------------------------- 1 | function [x,f] = FindGlobalGPMinimum(BestGuesses,GP,xmin,xmax) 2 | 3 | [N,D] = size(BestGuesses); 4 | 5 | X = zeros(N+10,D); 6 | F = zeros(N+10,1); 7 | alpha = (GP.cK \ (GP.cK' \ GP.y)); 8 | 9 | for i = 1 : size(BestGuesses,1) 10 | [X(i,:),F(i)] = fmincon(@(x)GPmeanderiv(x,GP,alpha),BestGuesses(i,:),[],[],[],[],xmin,xmax,[], ... 11 | optimset('MaxFunEvals',100,'TolX',eps,'Display','off','GradObj','on')); 12 | 13 | %[X(i,:),F(i)] = fminbnd(@(x)GPmeanderiv(x,GP,alpha),xmin,xmax, ... 14 | % optimset('MaxFunEvals',100,'TolX',eps,'Display','off')); 15 | end 16 | for i = size(BestGuesses,1) + 1: size(BestGuesses,1) + 10 17 | start = xmin + (xmax-xmin) .* rand(1,D); 18 | [X(i,:),F(i)] = fmincon(@(x)GPmeanderiv(x,GP,alpha),start,[],[],[],[],xmin,xmax,[], ... 19 | optimset('MaxFunEvals',100,'TolX',eps,'Display','off','GradObj','on')); 20 | end 21 | 22 | [f,xi] = min(F); 23 | x = X(xi,:); 24 | end 25 | 26 | function [f,df] = GPmeanderiv(x,GP,alpha) 27 | 28 | kx = feval(GP.covfunc{:},GP.hyp.cov,x,GP.x); 29 | dkx = feval(GP.covfunc_dx{:},GP.hyp.cov,x,GP.x); 30 | 31 | f = kx * alpha; 32 | df = zeros(size(x,2),1); 33 | for d = 1:size(x,2) 34 | df(d) = dkx(:,:,d) * alpha; 35 | end 36 | 37 | end -------------------------------------------------------------------------------- /matlab/GP_moments.m: -------------------------------------------------------------------------------- 1 | function [Mx,Vx,Mz,Vz,Vxz] = GP_moments(GP,x,z) 2 | %UNTITLED Summary of this function goes here 3 | % Detailed explanation goes here 4 | 5 | if ~isfield(GP,'poly') 6 | GP.poly = -1; 7 | end 8 | 9 | kx = k_matrix_full(GP,GP.x,x); 10 | if GP.poly >= 0 && ~isempty(GP.x) % special case for no data. 11 | GP.H = poly_mat(GP.x,GP.poly,GP.deriv); 12 | cKH = (GP.cK' \ GP.H'); 13 | GP.cHKH = chol(cKH' * cKH + 1.0e-4 * eye(GP.poly + 1)); 14 | Rx = poly_mat(x,GP.poly,GP.deriv) - GP.H * (GP.cK \ (GP.cK' \ kx')); 15 | else 16 | Rx = []; 17 | end 18 | 19 | Mx = GP_mean(GP,x,kx,Rx); 20 | if nargout > 1 21 | Vx = GP_var(GP,x,kx,Rx); 22 | end 23 | 24 | if nargin > 2 25 | kz = k_matrix_full(GP,GP.x,z); 26 | if GP.poly >= 0 && ~isempty(GP.x) 27 | Rz = poly_mat(z,GP.poly,GP.deriv) - GP.H * (GP.cK \ (GP.cK' \ kz')); 28 | else 29 | Rz = []; 30 | end 31 | 32 | Mz = GP_mean(GP,z,kz,Rz); 33 | Vz = GP_var(GP,z,kz,Rz); 34 | Vxz = GP_var(GP,x,kx,Rx,z,kz,Rz); 35 | end 36 | 37 | end 38 | 39 | function M = GP_mean(GP,x,k,R) 40 | 41 | if isempty(GP.x) 42 | if GP.deriv 43 | M = zeros(size(x,1) .* 2,1); 44 | else 45 | M = zeros(size(x,1),1); 46 | end 47 | else 48 | Ky = GP.cK \ (GP.cK' \ y_vector(GP)); 49 | M = k * Ky; 50 | if ~isempty(R) 51 | M = M + R' * (GP.cHKH \ (GP.cHKH' \ (GP.H * Ky))); 52 | end 53 | end 54 | 55 | end 56 | 57 | function V = GP_var(GP,x,kx,Rx,z,kz,Rz) 58 | 59 | if nargin < 5 60 | z = x; 61 | kz = kx; 62 | Rz = Rx; 63 | end 64 | kk = k_matrix_full(GP,x,z); 65 | 66 | if isempty(GP.x) 67 | V = kk; 68 | else 69 | V = kk - kz * (GP.cK \ (GP.cK' \ kx')); 70 | if ~isempty(Rx) 71 | V = V + Rz' * (GP.cHKH \ (GP.cHKH' \ Rx)); 72 | end 73 | end 74 | 75 | end 76 | 77 | 78 | -------------------------------------------------------------------------------- /matlab/GP_noise_var.m: -------------------------------------------------------------------------------- 1 | function noise_var = GP_noise_var(GP,y) 2 | %UNTITLED Summary of this function goes here 3 | % Detailed explanation goes here 4 | if ~isfield(GP,'log') 5 | GP.log = 0; 6 | end 7 | 8 | if GP.log 9 | noise_var = exp(2*GP.hyp.lik)*ones(numel(y),1) ./ exp(2*y); 10 | else 11 | noise_var = exp(2*GP.hyp.lik)*ones(numel(y),1); 12 | end 13 | 14 | if GP.deriv 15 | noise_var = [noise_var; noise_var]; 16 | end 17 | 18 | 19 | end 20 | 21 | -------------------------------------------------------------------------------- /matlab/GaussProcess.m: -------------------------------------------------------------------------------- 1 | function f = GaussProcess(x) 2 | rng(2017) % fix random number generator to get consistent function values 3 | 4 | l = 1; 5 | covSE1 = @(a,b) exp(-0.5*bsxfun(@minus,a(1,:),b(1,:)').^2./l^2); 6 | covSE2 = @(a,b) exp(-0.5*bsxfun(@minus,a(2,:),b(2,:)').^2./l^2); 7 | 8 | cov = @(a,b) covSE1(a,b) .* covSE2(a,b); 9 | 10 | % define a grid for the function evaluation 11 | r = 25; 12 | xl = linspace(-2, 2, r); 13 | yl = linspace(-2, 2, r); 14 | [X, Y] = meshgrid(xl, yl); 15 | V = [X(:), Y(:)]; 16 | 17 | % evaluate the GP on a grid 18 | Zm = chol(cov(V',V')+1e-3*eye(size(V,1)))'*randn(size(V,1),1); 19 | Zm = reshape(Zm, size(X)); 20 | 21 | % function evaluation by interpolation 22 | f = interp2(X,Y,Zm,x(:,1),x(:,2)); -------------------------------------------------------------------------------- /matlab/LogLoss.m: -------------------------------------------------------------------------------- 1 | function dHp = LogLoss(logP,lmb,lPred,~,~,~) 2 | 3 | H = - sum(exp(logP) .* (logP + lmb)); % current Entropy 4 | dHp = -sum(exp(lPred) .* bsxfun(@plus,lPred,lmb),1) - H; % @minus? If you change it, change it above in H, too! -------------------------------------------------------------------------------- /matlab/PhysicalExperiment.m: -------------------------------------------------------------------------------- 1 | function f = PhysicalExperiment(x) 2 | 3 | display(['The optimizer proposes x = ']); 4 | display([num2str(x)]); 5 | display(['as the next location to test at. Please perform an experiment with this setting.']); 6 | f = input('please enter the resulting function value now (as a floating point number).\n'); -------------------------------------------------------------------------------- /matlab/Rosenbrock.m: -------------------------------------------------------------------------------- 1 | function f = Rosenbrock(x) 2 | a = 1; 3 | b = 100; 4 | f = (a-x(:,1)).^2+b.*(x(:,2)-x(:,1).^2).^2; -------------------------------------------------------------------------------- /matlab/SEGammaHyperPosterior.m: -------------------------------------------------------------------------------- 1 | function [logpost,dlogpost] = SEGammaHyperPosterior(hyp,x,y) 2 | 3 | if nargin > 1 % data available: evaluate log likelihood 4 | [lik,dlik] = gp(hyp,@infExact,[],@covSEard,@likGauss,x,y); 5 | else 6 | lik = 0; dlik.cov = []; dlik.lik = []; 7 | end 8 | 9 | % evaluate log prior 10 | log_ell = hyp.cov(1:end-1); 11 | log_the2 = 2 * hyp.cov(end); 12 | log_sig = hyp.lik; 13 | 14 | N = size(hyp.cov,1) - 1; 15 | a = 0.05 * ones(N,1); % hyperhyp.cov.a_ell; 16 | b = 100 * ones(N,1); % hyperhyp.cov.b_ell; 17 | c = 0.01; % hyperhyp.cov.a_theta; 18 | d = 100; % hyperhyp.cov.b_theta; 19 | s = 0.05; % hyperhyp.lik.s; 20 | m = 1; % hyperhyp.lik.m; 21 | 22 | % hyperprior 23 | logprior = sum(log_ell .* a - exp(log_ell) ./ b) ... % gamma prior over length scales 24 | + log_the2 .* c - exp(log_the2) ./ d ... % gamma prior over signal variance 25 | + log_sig .* s - exp(log_sig) ./ m; % gamma prior over noise stddev 26 | 27 | % gradient 28 | dlogprior = [a - exp(log_ell) ./ b; ... 29 | 2 * c - 2 * exp(log_the2) ./ d; ... 30 | s - exp(log_sig) ./ m]; 31 | 32 | % log posterior is log lik + log prior 33 | logpost = lik - logprior; 34 | 35 | dlogpost.cov = dlik.cov - dlogprior(1:end-1); 36 | dlogpost.lik = dlik.lik - dlogprior(end); 37 | dlogpost.mean = []; 38 | 39 | 40 | %% unit test: 41 | % N = 3; 42 | % x.cov = randn(N+1,1); 43 | % x.lik = randn(); 44 | % e = 1.0e-6; dt = zeros(N+1,1); 45 | % [f,df] = SEGammaPrior(x); 46 | % for i = 1:N+1 47 | % y = x; y.cov(i) = y.cov(i) + e; f1 = SEGammaPrior(y); 48 | % y = x; y.cov(i) = y.cov(i) - e; f2 = SEGammaPrior(y); 49 | % dt(i) = (f1 - f2) / (2*e); 50 | % end 51 | % y = x; y.lik = y.lik + e; f1 = SEGammaPrior(y); 52 | % y = x; y.lik = y.lik - e; f2 = SEGammaPrior(y); 53 | % dt(N+2) = (f1 - f2) / (2*e); 54 | % [df dt] -------------------------------------------------------------------------------- /matlab/Slice_ShrinkRank.m: -------------------------------------------------------------------------------- 1 | function xx = Slice_ShrinkRank(xx,logP,s0,transpose) 2 | % multivariate slice sampling with shrinking rank covariance adaptation. 3 | % Implemented after Thompson and Neal, November 2010 4 | % 5 | % The algorithm has three inputs: 6 | % xx -- the last sample of the Markov Chain 7 | % logP -- function returning [logP*,dlogP*/dx], the log probability and 8 | % its first derivative. 9 | % s0 -- initial proposal width, the one free parameter. 10 | % Set it to the width of the prior. 11 | % 12 | % Philipp Hennig, August 2011 13 | 14 | if transpose; xx = xx'; end 15 | 16 | D = size(xx,1); 17 | [logf,~] = logP(xx'); 18 | logy = log(rand()) + logf; 19 | 20 | theta= 0.95; 21 | 22 | k = 0; 23 | s = s0; 24 | c = zeros(D,0); 25 | J = []; 26 | 27 | while true 28 | k = k + 1; 29 | c(:,k) = ProjNullSpace(J,xx + s(k) * randn(D,1)); 30 | sx = 1 ./ (sum(1./s)); 31 | mx = sx * sum(bsxfun(@times,1./s,bsxfun(@minus,c,xx)),2); 32 | xk = xx + ProjNullSpace(J,mx + sx .* randn(D,1)); 33 | 34 | [logfk,dlogfk] = logP(xk'); 35 | if logfk > logy % accept 36 | if transpose; xx = xk'; else xx = xk; end 37 | break 38 | else % shrink 39 | g = ProjNullSpace(J,dlogfk); 40 | if size(J,2) < D - 1 && g' * dlogfk > 0.5 * norm(g) * norm(dlogfk) 41 | J = [J, g ./ norm(g)]; %#ok 42 | s(k+1) = s(k); 43 | else 44 | s(k+1) = theta .* s(k); % max(theta .* s(k),s0/1000); 45 | if s(k+1) < eps 46 | warning 'contracted down to zero step size. collapsed posterior?' 47 | if transpose; xx = xx'; return; else return; 48 | end 49 | end 50 | end 51 | end 52 | end 53 | end 54 | 55 | function p = ProjNullSpace(J,v) 56 | if size(J,2) > 0 57 | p = v - J * J' * v; 58 | else 59 | p = v; 60 | end 61 | end 62 | -------------------------------------------------------------------------------- /matlab/compile_utilities.m: -------------------------------------------------------------------------------- 1 | % compiling the mex files of some utilities 2 | % 3 | % (C) 2017 Max-Planck-Institute for Intelligent Systems 4 | % 5 | % Author: Edgar D. Klenske, 2017 6 | 7 | % compile utilities 8 | mex -I../cpp/ ../cpp/joint_min.cpp -------------------------------------------------------------------------------- /matlab/covSEard_dx_MD.m: -------------------------------------------------------------------------------- 1 | function K = covSEard_dx_MD(hyp, x, z) 2 | % Squared Exponential covariance function with Automatic Relevance Detemination 3 | % (ARD) distance measure. The covariance function is parameterized as: 4 | % 5 | % k(x^p,x^q) = sf2 * exp(-(x^p - x^q)'*inv(P)*(x^p - x^q)/2) 6 | % 7 | % where the P matrix is diagonal with ARD parameters ell_1^2,...,ell_D^2, where 8 | % D is the dimension of the input space and sf2 is the signal variance. The 9 | % hyperparameters are: 10 | % 11 | % hyp = [ log(ell_1) 12 | % log(ell_2) 13 | % . 14 | % log(ell_D) 15 | % log(sqrt(sf2)) ] 16 | % 17 | % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch, 2010-09-10. 18 | % 19 | % See also COVFUNCTIONS.M. 20 | 21 | if nargin<2, K = '(D+1)'; return; end % report number of parameters 22 | if nargin<3, z = []; end % make sure, z exists 23 | xeqz = numel(z)==0; dg = strcmp(z,'diag') && numel(z)>0; % determine mode 24 | 25 | [n,D] = size(x); 26 | ell = exp(hyp(1:D)); % characteristic length scale 27 | sf2 = exp(2*hyp(D+1)); % signal variance 28 | 29 | % precompute squared distances 30 | if dg % vector kxx 31 | K = zeros(size(x,1),1); 32 | else 33 | if xeqz % symmetric matrix Kxx 34 | K = sq_dist(diag(1./ell)*x'); 35 | else % cross covariances Kxz 36 | K = sq_dist(diag(1./ell)*x',diag(1./ell)*z'); 37 | end 38 | end 39 | K0 = sf2*exp(-K/2); 40 | 41 | if xeqz 42 | p = reshape(x',[1,size(x,2),size(x,1)]); 43 | else 44 | p = reshape(z',[1,size(z,2),size(z,1)]); 45 | end 46 | D_idj = bsxfun(@minus,x,p); 47 | T_idj = bsxfun(@rdivide,D_idj,reshape(ell.^2,[1,D,1])); 48 | K = -bsxfun(@times,T_idj,reshape(K0,[size(K0,1),1,size(K0,2)])); 49 | K = permute(K,[1,3,2]); -------------------------------------------------------------------------------- /matlab/ext/README.md: -------------------------------------------------------------------------------- 1 | External Matlab Dependencies 2 | ============================ 3 | 4 | This folder contains the external Matlab dependencies. These files are provided for convenience only, the copyright belongs to the original authors, which are listed in the source files. 5 | -------------------------------------------------------------------------------- /matlab/ext/gpml/Copyright: -------------------------------------------------------------------------------- 1 | GAUSSIAN PROCESS REGRESSION AND CLASSIFICATION Toolbox version 4.0 2 | for GNU Octave 3.2.x and Matlab 7.x 3 | 4 | The code is released under the FreeBSD License. 5 | 6 | Copyright (c) 2005-2016 Carl Edward Rasmussen & Hannes Nickisch. All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY CARL EDWARD RASMUSSEN & HANNES NICKISCH ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARL EDWARD RASMUSSEN & HANNES NICKISCH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 15 | 16 | The views and conclusions contained in the software and documentation are those of the authors and should not be interpreted as representing official policies, either expressed or implied, of Carl Edward Rasmussen & Hannes Nickisch. 17 | 18 | The code and associated documentation is available from http://gaussianprocess.org/gpml/code. -------------------------------------------------------------------------------- /matlab/ext/gpml/cov/covConst.m: -------------------------------------------------------------------------------- 1 | function varargout = covConst(varargin) 2 | 3 | % Wrapper for unit constant covariance function covOne.m. 4 | % 5 | % Covariance function for a constant function. The covariance function is 6 | % parameterized as: 7 | % 8 | % k(x,z) = sf^2 9 | % 10 | % The scalar hyperparameter is: 11 | % 12 | % hyp = [ log(sf) ] 13 | % 14 | % For more help on design of covariance functions, try "help covFunctions". 15 | % 16 | % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch, 2016-04-19. 17 | % 18 | % See also covOne.m. 19 | 20 | varargout = cell(max(nargout,1),1); 21 | [varargout{:}] = covScale({'covOne'},varargin{:}); -------------------------------------------------------------------------------- /matlab/ext/gpml/cov/covCos.m: -------------------------------------------------------------------------------- 1 | function [K,dK] = covCos(hyp, x, z) 2 | 3 | % Stationary covariance function for a sinusoid with period p in 1d: 4 | % 5 | % k(x,z) = sf^2*cos(2*pi*(x-z)/p) 6 | % 7 | % where the hyperparameters are: 8 | % 9 | % hyp = [ log(p) 10 | % log(sf) ] 11 | % 12 | % Note that covPeriodicNoDC converges to covCos as ell goes to infinity. 13 | % 14 | % Copyright (c) by James Robert Lloyd and Hannes Nickisch, 2016-04-24. 15 | % 16 | % See also COVFUNCTIONS.M, COVPERIODICNODC.M. 17 | 18 | if nargin<2, K = '2'; return; end % report number of parameters 19 | if nargin<3, z = []; end % make sure, z exists 20 | xeqz = isempty(z); dg = strcmp(z,'diag'); % determine mode 21 | 22 | [n,D] = size(x); 23 | if D>1, error('Covariance is defined for 1d data only.'), end 24 | p = exp(hyp(1)); 25 | sf2 = exp(2*hyp(2)); 26 | 27 | % precompute deviations and exploit symmetry of cos 28 | if dg % vector txx 29 | T = zeros(size(x,1),1); 30 | else 31 | if xeqz % symmetric matrix Txx 32 | T = 2*pi/p*bsxfun(@plus,x,-x'); 33 | else % cross covariances Txz 34 | T = 2*pi/p*bsxfun(@plus,x,-z'); 35 | end 36 | end 37 | 38 | K = sf2*cos(T); % covariances 39 | if nargout > 1 40 | dK = @(Q) dirder(Q,K,T,x,p,sf2,dg,xeqz); 41 | end 42 | 43 | function [dhyp,dx] = dirder(Q,K,T,x,p,sf2,dg,xeqz) 44 | dhyp = [sf2*(sin(T(:)).*T(:))'*Q(:); 2*Q(:)'*K(:)]; 45 | if nargout > 1 46 | R = -sf2*pi/p * Q .* sin(T); 47 | if dg 48 | dx = zeros(size(x)); 49 | else 50 | if xeqz 51 | dx = 2*(sum(R,2)-sum(R,1)'); 52 | else 53 | dx = 2*sum(R,2); 54 | end 55 | end 56 | end -------------------------------------------------------------------------------- /matlab/ext/gpml/cov/covEye.m: -------------------------------------------------------------------------------- 1 | function [K,dK] = covEye(hyp, x, z) 2 | 3 | % Independent covariance function, i.e. "white noise", with unit variance. 4 | % The covariance function is specified as: 5 | % 6 | % k(x^p,x^q) = \delta(p,q) 7 | % 8 | % \delta(p,q) is a Kronecker delta function which is 1 iff p=q and zero 9 | % otherwise in mode 1). 10 | % In cross covariance mode 2) two data points x_p and z_q are considered equal 11 | % if their difference norm |x_p-z_q| is less than eps, the machine precision. 12 | % The hyperparameters are: 13 | % 14 | % hyp = [ ] 15 | % 16 | % For more help on design of covariance functions, try "help covFunctions". 17 | % 18 | % Copyright (c) by Hannes Nickisch, 2016-04-18. 19 | % 20 | % See also COVFUNCTIONS.M. 21 | 22 | tol = eps; % threshold on the norm when two vectors are considered to be equal 23 | if nargin<2, K = '0'; return; end % report number of parameters 24 | if nargin<3, z = []; end % make sure, z exists 25 | dg = strcmp(z,'diag'); % determine mode 26 | 27 | n = size(x,1); 28 | 29 | if dg % vector kxx 30 | K = ones(n,1); 31 | else 32 | if isempty(z) % symmetric matrix Kxx 33 | K = eye(n); 34 | else % cross covariances Kxz 35 | K = double(sq_dist(x',z') 1 40 | dK = @(Q) dirder(Q,x); % directional hyper derivative 41 | end 42 | 43 | function [dhyp,dx] = dirder(Q,x) 44 | dhyp = zeros(0,1); if nargout > 1, dx = zeros(size(x)); end -------------------------------------------------------------------------------- /matlab/ext/gpml/cov/covGE.m: -------------------------------------------------------------------------------- 1 | function [K,dK] = covGE(mode, par, hyp, varargin) 2 | 3 | % Gamma Exponential covariance function. 4 | % The covariance function is parameterized as: 5 | % 6 | % k(x,z) = exp(-r^gamma), r = maha(x,z) 7 | % 8 | % where maha(x,z) is a Mahalanobis distance and gamma is the shape parameter 9 | % for the GE covariance. The hyperparameters are: 10 | % 11 | % hyp = [ hyp_maha 12 | % log(gamma/(2-gamma)) ] 13 | % 14 | % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch, 2016-04-27. 15 | % 16 | % See also COVFUNCTIONS.M. 17 | 18 | if nargin<1, mode = 'eye'; end, if nargin <2, par = []; end % default values 19 | if nargin<4, K = [covMaha(mode,par),'+1']; return, end 20 | 21 | gamma = 2/(1+exp(-hyp(end))); 22 | k = @(d2) exp(-d2.^(gamma/2)); 23 | dk = @(d2,k) -gamma/2*set_zero(k.*d2.^(gamma/2-1),d2==0); 24 | 25 | if nargout==2 26 | [K,dKmaha,D2] = covMaha(mode,par,k,dk,hyp(1:end-1),varargin{:}); 27 | dK = @(Q) dirder(Q,K,D2,dKmaha,gamma); 28 | else 29 | K = covMaha(mode,par,k,dk,hyp(1:end-1),varargin{:}); 30 | end 31 | 32 | function [dhyp,dx] = dirder(Q,K,D2,dKmaha,gamma) 33 | if nargout==1 34 | dhyp = dKmaha(Q); 35 | else 36 | [dhyp,dx] = dKmaha(Q); 37 | end 38 | Q = Q.*K; B = (gamma-2)*gamma/4 * D2.^(gamma/2) .* set_zero(log(D2),D2==0); 39 | dhyp = [dhyp; Q(:)'*B(:)]; 40 | 41 | function A = set_zero(A,I), A(I) = 0; -------------------------------------------------------------------------------- /matlab/ext/gpml/cov/covGaborard.m: -------------------------------------------------------------------------------- 1 | function varargout = covGaborard(varargin) 2 | 3 | % Wrapper for Gabor covariance function covGabor.m. 4 | % 5 | % Gabor covariance function with length scales ell and periods p. The covariance 6 | % function is parameterized as: 7 | % 8 | % k(x,z) = h(x-z), h(t) = exp(-sum(t.^2./(2*ell.^2)))*cos(2*pi*sum(t./p)). 9 | % 10 | % The hyperparameters are: 11 | % 12 | % hyp = [ log(ell_1) 13 | % log(ell_2) 14 | % .. 15 | % log(ell_D) 16 | % log(p_1) 17 | % log(p_2) 18 | % .. 19 | % log(p_D) ] 20 | % 21 | % For more help on design of covariance functions, try "help covFunctions". 22 | % 23 | % Note that covSM implements a weighted sum of Gabor covariance functions, but 24 | % using an alternative (spectral) parameterization. 25 | % 26 | % Copyright (c) by Hannes Nickisch, 2016-04-25. 27 | % 28 | % See also COVFUNCTIONS.M, COVGABOR.M, COVSM.M. 29 | 30 | varargout = cell(max(1,nargout),1); 31 | [varargout{:}] = covGabor('ard',varargin{:}); -------------------------------------------------------------------------------- /matlab/ext/gpml/cov/covGaboriso.m: -------------------------------------------------------------------------------- 1 | function varargout = covGaboriso(varargin) 2 | 3 | % Wrapper for Gabor covariance function covGabor.m. 4 | % 5 | % Gabor covariance function with length scale ell and period p. The 6 | % covariance function is parameterized as: 7 | % 8 | % k(x,z) = h(x-z) with h(t) = exp(-t'*t/(2*ell^2))*cos(2*pi*sum(t)/p). 9 | % 10 | % The hyperparameters are: 11 | % 12 | % hyp = [ log(ell) 13 | % log(p) ] 14 | % 15 | % Note that covSM implements a weighted sum of Gabor covariance functions, but 16 | % using an alternative (spectral) parameterization. 17 | % 18 | % For more help on design of covariance functions, try "help covFunctions". 19 | % 20 | % Copyright (c) by Hannes Nickisch, 2016-04-25. 21 | % 22 | % See also COVFUNCTIONS.M, COVGABOR.M, COVSM.M. 23 | 24 | varargout = cell(max(1,nargout),1); 25 | [varargout{:}] = covGabor('iso',varargin{:}); -------------------------------------------------------------------------------- /matlab/ext/gpml/cov/covLIN.m: -------------------------------------------------------------------------------- 1 | function [K,dK] = covLIN(mode,hyp,x,z) 2 | 3 | % Linear covariance function. 4 | % The covariance function is parameterized as: 5 | % 6 | % k(x,z) = dot(x,z) 7 | % 8 | % where dot(x,z) is a dot product. The hyperparameters are: 9 | % 10 | % hyp = [ hyp_maha ] 11 | % 12 | % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch, 2016-04-26. 13 | % 14 | % See also covDot.m. 15 | 16 | if nargin<1, mode = 'eye'; end, narg = nargin; % default mode 17 | if ~ischar(mode) % compatible to old version 18 | if nargin>2, z = x; end 19 | if nargin>1, x = hyp; end 20 | if nargin>0, hyp = mode; end 21 | mode = 'eye'; narg = narg+1; 22 | end 23 | if narg<3, K = covDot(mode); return, end 24 | if narg<4, z = []; end % make sure, z exists 25 | 26 | k = @(s) s; dk = @(s) ones(size(s)); 27 | 28 | if nargout > 1 29 | [K,dK] = covDot(mode,k,dk,hyp,x,z); 30 | else 31 | K = covDot(mode,k,dk,hyp,x,z); 32 | end -------------------------------------------------------------------------------- /matlab/ext/gpml/cov/covLINard.m: -------------------------------------------------------------------------------- 1 | function varargout = covLINard(varargin) 2 | 3 | % Wrapper for Linear covariance function covLin.m. 4 | % 5 | % Linear covariance function with Automatic Relevance Determination (ARD). The 6 | % covariance function is parameterized as: 7 | % 8 | % k(x,z) = x'*inv(P)*z 9 | % 10 | % where the P matrix is diagonal with ARD parameters ell_1^2,...,ell_D^2, where 11 | % D is the dimension of the input space. The hyperparameters are: 12 | % 13 | % hyp = [ log(ell_1) 14 | % log(ell_2) 15 | % .. 16 | % log(ell_D) ] 17 | % 18 | % Note that there is no bias term; use covConst to add a bias. 19 | % 20 | % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch, 2016-04-26. 21 | % 22 | % See also covLin.m. 23 | 24 | varargout = cell(max(1,nargout),1); 25 | [varargout{:}] = covLIN('ard',varargin{:}); -------------------------------------------------------------------------------- /matlab/ext/gpml/cov/covLINiso.m: -------------------------------------------------------------------------------- 1 | function varargout = covLINiso(varargin) 2 | 3 | % Wrapper for Linear covariance function covLin.m. 4 | % 5 | % Linear covariance function with Automatic Relevance Determination (ARD). The 6 | % covariance function is parameterized as: 7 | % 8 | % k(x,z) = x'*inv(P)*z 9 | % 10 | % where the P matrix is ell^2 times the unit matrix. The hyperparameters are: 11 | % 12 | % hyp = [ log(ell) ] 13 | % 14 | % Note that there is no bias term; use covConst to add a bias. 15 | % 16 | % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch, 2016-04-26. 17 | % 18 | % See also covLin.m. 19 | 20 | varargout = cell(max(1,nargout),1); 21 | [varargout{:}] = covLIN('iso',varargin{:}); -------------------------------------------------------------------------------- /matlab/ext/gpml/cov/covLINone.m: -------------------------------------------------------------------------------- 1 | function [K,dK] = covLINone(hyp, x, z) 2 | 3 | % Linear covariance function with a single hyperparameter. The covariance 4 | % function is parameterized as: 5 | % 6 | % k(x,z) = (x'*z + 1)/t^2; 7 | % 8 | % where the P matrix is t2 times the unit matrix. The second term plays the 9 | % role of the bias. The hyperparameter is: 10 | % 11 | % hyp = [ log(t) ] 12 | % 13 | % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch, 2016-04-23. 14 | % 15 | % See also COVFUNCTIONS.M. 16 | 17 | if nargin<2, K = '1'; return; end % report number of parameters 18 | if nargin<3, z = []; end % make sure, z exists 19 | xeqz = isempty(z); dg = strcmp(z,'diag'); % determine mode 20 | 21 | it2 = exp(-2*hyp); % t2 inverse 22 | 23 | % precompute inner products 24 | if dg % vector kxx 25 | K = sum(x.*x,2); 26 | else 27 | if xeqz % symmetric matrix Kxx 28 | K = x*x'; 29 | else % cross covariances Kxz 30 | K = x*z'; 31 | end 32 | end 33 | K = it2*(K+1); % covariances 34 | if nargout > 1, dK = @(Q) dirder(Q,K,x,z,it2,xeqz,dg); end % dir derivative 35 | 36 | function [dhyp,dx] = dirder(Q,K,x,z,it2,xeqz,dg) 37 | dhyp = -2*Q(:)'*K(:); 38 | if nargout>1 39 | if dg 40 | dx = zeros(size(x)); 41 | else 42 | if xeqz 43 | dx = it2*(Q*x+Q'*x); 44 | else 45 | dx = it2*Q*z; 46 | end 47 | end 48 | end -------------------------------------------------------------------------------- /matlab/ext/gpml/cov/covMask.m: -------------------------------------------------------------------------------- 1 | function [K,dK] = covMask(cov, hyp, x, z) 2 | 3 | % Apply a covariance function to a subset of the dimensions only. The subset can 4 | % either be specified by a 0/1 mask by a boolean mask or by an index set. 5 | % 6 | % This function doesn't actually compute very much on its own, it merely does 7 | % some bookkeeping, and calls another covariance function to do the actual work. 8 | % 9 | % The function was suggested by Iain Murray, 2010-02-18 and is based on an 10 | % earlier implementation of his dating back to 2009-06-16. 11 | % 12 | % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch, 2016-04-17. 13 | % 14 | % See also COVFUNCTIONS.M. 15 | 16 | mask = fix(cov{1}(:)); % either a binary mask or an index set 17 | cov = cov(2); % covariance function to be masked 18 | if iscell(cov{:}), cov = cov{:}; end % properly unwrap nested cell arrays 19 | nh_string = feval(cov{:}); % number of hyperparameters of the full covariance 20 | 21 | if max(mask)<2 && length(mask)>1, mask = find(mask); end % convert 1/0->index 22 | D = length(mask); % masked dimension 23 | if nargin<3, K = num2str(eval(nh_string)); return, end % number of parameters 24 | if nargin<4, z = []; end % make sure, z exists 25 | xeqz = isempty(z); dg = strcmp(z,'diag'); % determine mode 26 | 27 | if eval(nh_string)~=length(hyp) % check hyperparameters 28 | error('number of hyperparameters does not match size of masked data') 29 | end 30 | 31 | xm = x(:,mask); if ~dg && ~xeqz, zm = z(:,mask); else zm = z; end 32 | if nargout>1 33 | [K,dK] = feval(cov{:}, hyp, xm, zm); 34 | dK = @(Q) dirder(Q,dK,x,mask); 35 | else 36 | K = feval(cov{:}, hyp, xm, zm); 37 | end 38 | 39 | function [dhyp,dx] = dirder(Q,dK,x,mask) 40 | if nargout>1 41 | [dhyp,dxm] = dK(Q); n = size(x,1); 42 | subs = [repmat((1:n)',length(mask),1), reshape(repmat(mask(:)',n,1),[],1)]; 43 | dx = accumarray(subs,dxm(:),size(x)); 44 | else 45 | dhyp = dK(Q); 46 | end -------------------------------------------------------------------------------- /matlab/ext/gpml/cov/covMatern.m: -------------------------------------------------------------------------------- 1 | function varargout = covMatern(mode, par, d, varargin) 2 | 3 | % Matern covariance function with nu = d/2 and isotropic distance measure. For 4 | % d=1 the function is also known as the exponential covariance function or the 5 | % Ornstein-Uhlenbeck covariance in 1d. The covariance function is: 6 | % 7 | % k(x,z) = f( sqrt(d)*r ) * exp(-sqrt(d)*r) 8 | % 9 | % with f(t)=1 for d=1, f(t)=1+t for d=3 and f(t)=1+t+t^2/3 for d=5. 10 | % Here r is the Mahalanobis distance sqrt(maha(x,z)). The function takes a 11 | % "mode" parameter, which specifies precisely the Mahalanobis distance used, see 12 | % covMaha. The function returns either the number of hyperparameters (with less 13 | % than 3 input argments) or it returns a covariance matrix and (optionally) a 14 | % derivative function. 15 | % 16 | % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch, 2016-05-23. 17 | % 18 | % See also covMaha.m. 19 | 20 | if nargin < 1, error('Mode cannot be empty.'); end % no default 21 | if nargin < 2, par = []; end % default 22 | varargout = cell(max(1, nargout), 1); % allocate mem for output 23 | if nargin < 5, varargout{1} = covMaha(mode,par); return, end 24 | 25 | if all(d~=[1,3,5]), error('only 1, 3 and 5 allowed for d'), end % degree 26 | switch d 27 | case 1, f = @(t) 1; df = @(t) 1./t; % df(t) = (f(t)-f'(t))/t 28 | case 3, f = @(t) 1 + t; df = @(t) 1; 29 | case 5, f = @(t) 1 + t.*(1+t/3); df = @(t) (1+t)/3; 30 | end 31 | m = @(t,f) f(t).*exp(-t); dm = @(t,f) df(t).*exp(-t); 32 | 33 | k = @(d2) m(sqrt(d*d2),f); 34 | if d==1 35 | dk = @(d2,k) set_zero( -dm(sqrt( d2),f)/2, d2==0 ); % fix limit case d2->0 36 | else 37 | dk = @(d2,k) -dm(sqrt(d*d2),f)*d/2; 38 | end 39 | 40 | [varargout{:}] = covMaha(mode, par, k, dk, varargin{:}); 41 | function A = set_zero(A,I), A(I) = 0; -------------------------------------------------------------------------------- /matlab/ext/gpml/cov/covMaternard.m: -------------------------------------------------------------------------------- 1 | function varargout = covMaternard(d,varargin) 2 | 3 | % Wrapper for Matern covariance function covMatern.m. 4 | % 5 | % Matern covariance function with nu = d/2 and with Automatic Relevance 6 | % Determination (ARD) distance measure. For d=1 the function is also known as 7 | % the exponential covariance function or the Ornstein-Uhlenbeck covariance 8 | % in 1d. The covariance function is: 9 | % 10 | % k(x,z) = f( sqrt(d)*r ) * exp(-sqrt(d)*r) 11 | % 12 | % with f(t)=1 for d=1, f(t)=1+t for d=3 and f(t)=1+t+t^2/3 for d=5. 13 | % Here r is the distance sqrt((x-z)'*inv(P)*(x-z)), where the P matrix 14 | % is diagonal with ARD parameters ell_1^2,...,ell_D^2, where D is the dimension 15 | % of the input space and sf2 is the signal variance. The hyperparameters are: 16 | % 17 | % hyp = [ log(ell_1) 18 | % log(ell_2) 19 | % .. 20 | % log(ell_D) 21 | % log(sf) ] 22 | % 23 | % Copyright (c) by Hannes Nickisch, 2016-04-17. 24 | % 25 | % See also COVFUNCTIONS.M. 26 | 27 | varargout = cell(max(1,nargout),1); 28 | [varargout{:}] = covScale({'covMatern','ard',[],d},varargin{:}); -------------------------------------------------------------------------------- /matlab/ext/gpml/cov/covMaterniso.m: -------------------------------------------------------------------------------- 1 | function varargout = covMaterniso(d,varargin) 2 | 3 | % Wrapper for Matern covariance function covMatern.m. 4 | % 5 | % Matern covariance function with nu = d/2 and isotropic distance measure. For 6 | % d=1 the function is also known as the exponential covariance function or the 7 | % Ornstein-Uhlenbeck covariance in 1d. The covariance function is: 8 | % 9 | % k(x,z) = sf^2 * f( sqrt(d)*r ) * exp(-sqrt(d)*r) 10 | % 11 | % with f(t)=1 for d=1, f(t)=1+t for d=3 and f(t)=1+t+t^2/3 for d=5. 12 | % Here r is the distance sqrt((x-z)'*inv(P)*(x-z)), P is ell times 13 | % the unit matrix and sf2 is the signal variance. The hyperparameters are: 14 | % 15 | % hyp = [ log(ell) 16 | % log(sf) ] 17 | % 18 | % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch, 2016-04-27. 19 | % 20 | % See also COVFUNCTIONS.M. 21 | 22 | varargout = cell(max(1,nargout),1); 23 | [varargout{:}] = covScale({'covMatern','iso',[],d},varargin{:}); -------------------------------------------------------------------------------- /matlab/ext/gpml/cov/covNoise.m: -------------------------------------------------------------------------------- 1 | function varargout = covNoise(varargin) 2 | 3 | % Wrapper for unit "white noise" covariance function covEye.m. 4 | % 5 | % Independent covariance function, i.e. "white noise". 6 | % The covariance function is specified as: 7 | % 8 | % k(x^p,x^q) = sf^2 * \delta(p,q) 9 | % 10 | % \delta(p,q) is a Kronecker delta function which is 1 iff p=q and zero 11 | % otherwise in mode 1). 12 | % In cross covariance mode 2) two data points x_p and z_q are considered equal 13 | % if their difference norm |x_p-z_q| is less than eps, the machine precision. 14 | % The hyperparameters are: 15 | % 16 | % hyp = [ log(sf) ] 17 | % 18 | % For more help on design of covariance functions, try "help covFunctions". 19 | % 20 | % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch, 2016-04-19. 21 | % 22 | % See also covEye.m. 23 | 24 | varargout = cell(max(nargout,1),1); 25 | [varargout{:}] = covScale({'covEye'},varargin{:}); -------------------------------------------------------------------------------- /matlab/ext/gpml/cov/covOne.m: -------------------------------------------------------------------------------- 1 | function [K,dK] = covOne(hyp, x, z) 2 | 3 | % Constant (degenerate) covariance function, with unit variance. 4 | % The covariance function is specified as: 5 | % 6 | % k(x,z) = 1 7 | % 8 | % hyp = [ ] 9 | % 10 | % For more help on design of covariance functions, try "help covFunctions". 11 | % 12 | % Copyright (c) by Hannes Nickisch, 2016-04-17. 13 | % 14 | % See also COVFUNCTIONS.M. 15 | 16 | if nargin<2, K = '0'; return; end % report number of parameters 17 | if nargin<3, z = []; end % make sure, z exists 18 | dg = strcmp(z,'diag'); % determine mode 19 | 20 | n = size(x,1); 21 | 22 | if dg % vector kxx 23 | K = ones(n,1); 24 | else 25 | if isempty(z) % symmetric matrix Kxx 26 | K = ones(n,n); 27 | else % cross covariances Kxz 28 | K = ones(n,size(z,1)); 29 | end 30 | end 31 | 32 | if nargout > 1 33 | dK = @(Q) dirder(Q,K,x); % directional hyper derivative 34 | end 35 | 36 | function [dhyp,dx] = dirder(Q,K,x) 37 | dhyp = zeros(0,1); if nargout > 1, dx = zeros(size(x)); end 38 | -------------------------------------------------------------------------------- /matlab/ext/gpml/cov/covPERard.m: -------------------------------------------------------------------------------- 1 | function varargout = covPERard(varargin) 2 | 3 | % Wrapper for PERiodic covariance function covPER.m. 4 | % 5 | % Periodic covariance function from an arbitrary covariance function k0 via 6 | % embedding IR^D into IC^D. 7 | % The covariance function is parameterized as: 8 | % 9 | % k(x,z) = k0(u(x),u(z)), u(x) = [sin(pi*x./p); cos(pi*x./p)] 10 | % 11 | % where the period p belongs to covPERiso and hyp0 belong to k0: 12 | % 13 | % hyp = [ log(p_1) 14 | % log(p_2) 15 | % . 16 | % log(p_D) 17 | % hyp0 ] 18 | % 19 | % Note that for k0 = covSEard and D = 1, a faster alternative is covPeriodic. 20 | % 21 | % Copyright (c) by Hannes Nickisch, 2016-04-25. 22 | % 23 | % See also COVFUNCTIONS.M. 24 | 25 | varargout = cell(max(1,nargout),1); 26 | [varargout{:}] = covPER('ard',varargin{:}); -------------------------------------------------------------------------------- /matlab/ext/gpml/cov/covPERiso.m: -------------------------------------------------------------------------------- 1 | function varargout = covPERiso(varargin) 2 | 3 | % Wrapper for PERiodic covariance function covPER.m. 4 | % 5 | % Periodic covariance function from an arbitrary covariance function k0 via 6 | % embedding IR^D into IC^D. 7 | % The covariance function is parameterized as: 8 | % 9 | % k(x,z) = k0(u(x),u(z)), u(x) = [sin(pi*x/p); cos(pi*x/p)] 10 | % 11 | % where the period p belongs to covPERiso and hyp0 belongs to k0: 12 | % 13 | % hyp = [ log(p) 14 | % hyp0 ] 15 | % 16 | % Note that for k0 = covSEiso and D = 1, a faster alternative is covPeriodic. 17 | % 18 | % Copyright (c) by Hannes Nickisch, 2016-04-25. 19 | % 20 | % See also COVFUNCTIONS.M. 21 | 22 | varargout = cell(max(1,nargout),1); 23 | [varargout{:}] = covPER('iso',varargin{:}); -------------------------------------------------------------------------------- /matlab/ext/gpml/cov/covPP.m: -------------------------------------------------------------------------------- 1 | function varargout = covPP(mode, par, v, hyp, x, varargin) 2 | 3 | % Piecewise Polynomial covariance function with compact support, v = 0,1,2,3. 4 | % The covariance functions are 2v times contin. diff'ble and the corresponding 5 | % processes are hence v times mean-square diffble. The covariance function is: 6 | % 7 | % k(x,z) = max(1-r,0)^(j+v) * f(r,j) with j = floor(D/2)+v+1 8 | % 9 | % where r is the Mahalanobis distance sqrt(maha(x,z)). The hyperparameters are: 10 | % 11 | % hyp = [ hyp_maha ] 12 | % 13 | % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch, 2016-05-23. 14 | % 15 | % See also covMaha.m. 16 | 17 | if nargin < 1, error('Mode cannot be empty.'); end % no default 18 | if nargin < 2, par = []; end % default 19 | varargout = cell(max(1, nargout), 1); % allocate mem for output 20 | if nargin<5, varargout{1} = covMaha(mode,par); return, end 21 | 22 | [n,D] = size(x); 23 | if all(v~=[0,1,2,3]), error('only 0,1,2 and 3 allowed for v'), end % degree 24 | j = floor(D/2)+v+1; % exponent 25 | 26 | switch v 27 | case 0, f = @(r,j) 1; 28 | df = @(r,j) 0; 29 | case 1, f = @(r,j) 1 + (j+1)*r; 30 | df = @(r,j) (j+1); 31 | case 2, f = @(r,j) 1 + (j+2)*r + ( j^2+ 4*j+ 3)/ 3*r.^2; 32 | df = @(r,j) (j+2) + 2*( j^2+ 4*j+ 3)/ 3*r; 33 | case 3, f = @(r,j) 1 + (j+3)*r + (6*j^2+36*j+45)/15*r.^2 ... 34 | + (j^3+9*j^2+23*j+15)/15*r.^3; 35 | df = @(r,j) (j+3) + 2*(6*j^2+36*j+45)/15*r ... 36 | + (j^3+9*j^2+23*j+15)/ 5*r.^2; 37 | end 38 | cs = @(r,e) (r<1).*max(1-r,0).^e; 39 | pp = @(r,j,v,f) cs(r,j+v ).* f(r,j); 40 | dpp = @(r,j,v,f) r.*cs(r,j+v-1).*( f(r,j)*(j+v) - max(1-r,0).*df(r,j) ); 41 | 42 | k = @(d2) pp( sqrt(d2), j, v, f ); 43 | dk = @(d2,k) set_zero( -(1/2)*dpp( sqrt(d2), j, v, f )./d2 , d2==0); 44 | 45 | [varargout{:}] = covMaha(mode, par, k, dk, hyp, x, varargin{:}); 46 | function A = set_zero(A,I), A(I) = 0; -------------------------------------------------------------------------------- /matlab/ext/gpml/cov/covPPard.m: -------------------------------------------------------------------------------- 1 | function varargout = covPPard(v,varargin) 2 | 3 | % Wrapper for Piecewise Polyonomial covariance function covPP.m. 4 | % 5 | % Piecewise Polynomial covariance function with compact support, v = 0,1,2,3. 6 | % The covariance functions are 2v times contin. diff'ble and the corresponding 7 | % processes are hence v times mean-square diffble. The covariance function is: 8 | % 9 | % k(x,z) = s2f * max(1-r,0)^(j+v) * f(r,j) with j = floor(D/2)+v+1 10 | % 11 | % where r is the distance sqrt((x-z)'*inv(P)*(x-z)), and the P matrix 12 | % is diagonal with ARD parameters ell_1^2,...,ell_D^2, where D is the dimension 13 | % of the input space and sf2 is the signal variance. The hyperparameters are: 14 | % 15 | % hyp = [ log(ell_1) 16 | % log(ell_2) 17 | % .. 18 | % log(ell_D) 19 | % log(sf) ] 20 | % 21 | % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch, 2016-04-27. 22 | % 23 | % See also covPP.M. 24 | 25 | varargout = cell(max(1,nargout),1); 26 | [varargout{:}] = covScale({'covPP','ard',[],v},varargin{:}); -------------------------------------------------------------------------------- /matlab/ext/gpml/cov/covPPiso.m: -------------------------------------------------------------------------------- 1 | function varargout = covPPiso(v,varargin) 2 | 3 | % Wrapper for Piecewise Polyonomial covariance function covPP.m. 4 | % 5 | % Piecewise polynomial covariance function with compact support, v = 0,1,2,3. 6 | % The covariance functions are 2v times contin. diff'ble and the corresponding 7 | % processes are hence v times mean-square diffble. The covariance function is: 8 | % 9 | % k(x,z) = sf^2 * max(1-r,0)^(j+v) * f(r,j) with j = floor(D/2)+v+1 10 | % 11 | % where r is the distance sqrt((x-z)'*inv(P)*(x-z)), P is ell^2 times 12 | % the unit matrix and sf2 is the signal variance. The hyperparameters are: 13 | % 14 | % hyp = [ log(ell) 15 | % log(sf) ] 16 | % 17 | % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch, 2016-04-27. 18 | % 19 | % See also covPP.M. 20 | 21 | varargout = cell(max(1,nargout),1); 22 | [varargout{:}] = covScale({'covPP','iso',[],v},varargin{:}); -------------------------------------------------------------------------------- /matlab/ext/gpml/cov/covPeriodic.m: -------------------------------------------------------------------------------- 1 | function [K,dK] = covPeriodic(hyp, x, z) 2 | 3 | % Stationary covariance function for a smooth periodic function, with period p 4 | % in 1d (see covPERiso and covPERard for multivariate data): 5 | % 6 | % k(x,z) = sf^2 * exp( -2*sin^2( pi*(x-z)/p )/ell^2 ) 7 | % 8 | % where the hyperparameters are: 9 | % 10 | % hyp = [ log(ell) 11 | % log(p) 12 | % log(sf) ] 13 | % 14 | % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch, 2016-04-24. 15 | % 16 | % See also COVFUNCTIONS.M. 17 | 18 | if nargin<2, K = '3'; return; end % report number of parameters 19 | if nargin<3, z = []; end % make sure, z exists 20 | xeqz = isempty(z); dg = strcmp(z,'diag'); % determine mode 21 | 22 | [n,D] = size(x); 23 | if D>1, error('Covariance is defined for 1d data only.'), end 24 | ell = exp(hyp(1)); p = exp(hyp(2)); sf2 = exp(2*hyp(3)); % extract hyperparams 25 | 26 | % precompute deviations and exploit symmetry of sin^2 27 | if dg % vector txx 28 | T = zeros(size(x,1),1); 29 | else 30 | if xeqz % symmetric matrix Txx 31 | T = pi/p*bsxfun(@plus,x,-x'); 32 | else % cross covariances Txz 33 | T = pi/p*bsxfun(@plus,x,-z'); 34 | end 35 | end 36 | 37 | S2 = (sin(T)/ell).^2; 38 | K = sf2*exp( -2*S2 ); % covariances 39 | 40 | if nargout>1 41 | dK = @(Q) dirder(Q,K,S2,T,ell,xeqz,x,z,p); % directional hyper derivative 42 | end 43 | 44 | function [dhyp,dx] = dirder(Q,K,S2,T,ell,xeqz,x,z,p) 45 | Q = K.*Q; P = sin(2*T).*Q; 46 | dhyp = [4*(S2(:)'*Q(:)); 2/ell^2*(P(:)'*T(:)); 2*sum(Q(:))]; 47 | if nargout > 1 48 | R = P./T; R(T==0) = 0; 49 | q2 = sum(R,2); q1 = sum(R,1)'; 50 | if xeqz 51 | y = bsxfun(@times,q1+q2,x) - (R+R')*x; 52 | else 53 | Rz = R*z; y = bsxfun(@times,q2,x) - Rz; 54 | end 55 | dx = -2*pi^2/(ell*p)^2 * y; 56 | end -------------------------------------------------------------------------------- /matlab/ext/gpml/cov/covPoly.m: -------------------------------------------------------------------------------- 1 | function [K,dK] = covPoly(mode, d, hyp, x, z) 2 | 3 | % Polynomial covariance function. The covariance function is parameterized as: 4 | % 5 | % k(x,z) = sf^2 * ( c + s )^d , where s = x*inv(P)*z is the dot product 6 | % 7 | % The hyperparameters are: 8 | % 9 | % hyp = [ hyp_dot 10 | % log(c) 11 | % log(sf) ] 12 | % 13 | % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch, 2016-04-23. 14 | % 15 | % See also covDot.m. 16 | 17 | if nargin<1, mode = 'eye'; end % default mode 18 | if ~ischar(mode) % compatible to old version 19 | if nargin>3, z = x; end 20 | if nargin>2, x = hyp; end 21 | if nargin>1, hyp = d; end 22 | if nargin>0, d = mode; end 23 | mode = 'eye'; narg = nargin+1; 24 | else 25 | narg = nargin; 26 | end 27 | 28 | if narg<4, K = [covDot(mode),'+2']; return, end % report number of parameters 29 | if narg<5, z = []; end % make sure, z exists 30 | [n,D] = size(x); % dimensions 31 | ne = eval(covDot(mode)); 32 | c = exp(hyp(ne+1)); % inhomogeneous offset 33 | sf2 = exp(2*hyp(ne+2)); % signal variance 34 | if d~=max(1,fix(d)), error('only nonzero integers allowed for d'), end % degree 35 | 36 | k = @(s) (c+s).^d; dk = @(s) d*(c+s).^(d-1); 37 | 38 | if nargout > 1 39 | [K,dK0] = covScale({'covDot',mode,k,dk},hyp([1:ne,ne+2]),x,z); 40 | S = covDot(mode,@(s)s,[],hyp(1:ne),x,z); 41 | dK = @(Q) dirder(Q,S,dK0,c,d,sf2,ne); 42 | else 43 | K = covScale({'covDot',mode,k,dk},hyp([1:ne,ne+2]),x,z); 44 | end 45 | 46 | function [dhyp,dx] = dirder(Q,S,dK0,c,d,sf2,ne) 47 | if nargout > 1, [dhyp,dx] = dK0(Q); else dhyp = dK0(Q); end 48 | dhyp = [dhyp(1:ne); c*d*sf2*(Q(:)'*(c+S(:)).^(d-1)); dhyp(ne+1)]; % insert c -------------------------------------------------------------------------------- /matlab/ext/gpml/cov/covRQ.m: -------------------------------------------------------------------------------- 1 | function [K,dK] = covRQ(mode, par, hyp, varargin) 2 | 3 | % Rational Quadratic covariance function. 4 | % The covariance function is parameterized as: 5 | % 6 | % k(x,z) = [1 + maha(x,z)/(2*alpha)]^(-alpha) 7 | % 8 | % where maha(x,z) is a Mahalanobis distance and alpha is the shape parameter 9 | % for the RQ covariance. The hyperparameters are: 10 | % 11 | % hyp = [ hyp_maha 12 | % log(alpha) ] 13 | % 14 | % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch, 2016-05-23. 15 | % 16 | % See also COVFUNCTIONS.M. 17 | 18 | if nargin < 1, error('Mode cannot be empty.'); end % no default 19 | if nargin < 2, par = []; end % default 20 | if nargin<4, K = [covMaha(mode,par),'+1']; return, end 21 | 22 | alpha = exp(hyp(end)); 23 | k = @(d2) (1+0.5*d2/alpha).^(-alpha); dk = @(d2,k) -k./(2+d2/alpha); 24 | 25 | if nargout==2 26 | [K,dKmaha,D2] = covMaha(mode,par,k,dk,hyp(1:end-1),varargin{:}); 27 | dK = @(Q) dirder(Q,K,D2,dKmaha,alpha); 28 | else 29 | K = covMaha(mode,par,k,dk,hyp(1:end-1),varargin{:}); 30 | end 31 | 32 | function [dhyp,dx] = dirder(Q,K,D2,dKmaha,alpha) 33 | if nargout==1 34 | dhyp = dKmaha(Q); 35 | else 36 | [dhyp,dx] = dKmaha(Q); 37 | end 38 | Q = Q.*K; B = 1+0.5*D2/alpha; 39 | dhyp = [dhyp; sum(sum( Q.*(0.5*D2./B-alpha*log(B)) ))]; -------------------------------------------------------------------------------- /matlab/ext/gpml/cov/covRQard.m: -------------------------------------------------------------------------------- 1 | function varargout = covRQard(varargin) 2 | 3 | % Wrapper for Rational Quadratic covariance function covRQ.m. 4 | % 5 | % Rational Quadratic covariance function with Automatic Relevance Determination 6 | % (ARD) distance measure. The covariance function is parameterized as: 7 | % 8 | % k(x,z) = sf^2 * [1 + (x-z)'*inv(P)*(x-z)/(2*alpha)]^(-alpha) 9 | % 10 | % where the P matrix is diagonal with ARD parameters ell_1^2,...,ell_D^2, where 11 | % D is the dimension of the input space, sf2 is the signal variance and alpha 12 | % is the shape parameter for the RQ covariance. The hyperparameters are: 13 | % 14 | % hyp = [ log(ell_1) 15 | % log(ell_2) 16 | % .. 17 | % log(ell_D) 18 | % log(sf) 19 | % log(alpha) ] 20 | % 21 | % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch, 2016-10-01. 22 | % 23 | % See also covRQ.M. 24 | 25 | varargout = cell(max(1,nargout),1); 26 | if nargin>0 % restore old hyper parameter order 27 | hyp = varargin{1}; 28 | if numel(hyp)>2, varargin{1} = hyp([1:end-2,end,end-1]); end 29 | end 30 | [varargout{:}] = covScale({'covRQ','ard',[]},varargin{:}); 31 | if nargout>1 % restore old hyper parameter order 32 | o2 = varargout{2}; varargout{2} = @(Q) dirder(Q,o2); 33 | end 34 | 35 | function [dKdhyp,dKdx] = dirder(Q,dK) 36 | if nargout>1, [dKdhyp,dKdx] = dK(Q); else dKdhyp = dK(Q); end 37 | dKdhyp = dKdhyp([1:end-2,end,end-1]); -------------------------------------------------------------------------------- /matlab/ext/gpml/cov/covRQiso.m: -------------------------------------------------------------------------------- 1 | function varargout = covRQiso(varargin) 2 | 3 | % Wrapper for Rational Quadratic covariance function covRQ.m. 4 | % 5 | % Rational Quadratic covariance function with isotropic distance measure. The 6 | % covariance function is parameterized as: 7 | % 8 | % k(x,z) = sf^2 * [1 + (x-z)'*inv(P)*(x-z)/(2*alpha)]^(-alpha) 9 | % 10 | % where the P matrix is ell^2 times the unit matrix, sf2 is the signal 11 | % variance and alpha is the shape parameter for the RQ covariance. The 12 | % hyperparameters are: 13 | % 14 | % hyp = [ log(ell) 15 | % log(sf) 16 | % log(alpha) ] 17 | % 18 | % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch, 2016-10-01. 19 | % 20 | % See also covRQ.m. 21 | 22 | varargout = cell(max(1,nargout),1); 23 | if nargin>0 % restore old hyper parameter order 24 | hyp = varargin{1}; 25 | if numel(hyp)>2, varargin{1} = hyp([1:end-2,end,end-1]); end 26 | end 27 | [varargout{:}] = covScale({'covRQ','iso',[]},varargin{:}); 28 | if nargout>1 % restore old hyper parameter order 29 | o2 = varargout{2}; varargout{2} = @(Q) dirder(Q,o2); 30 | end 31 | 32 | function [dKdhyp,dKdx] = dirder(Q,dK) 33 | if nargout>1, [dKdhyp,dKdx] = dK(Q); else dKdhyp = dK(Q); end 34 | dKdhyp = dKdhyp([1:end-2,end,end-1]); -------------------------------------------------------------------------------- /matlab/ext/gpml/cov/covSE.m: -------------------------------------------------------------------------------- 1 | function varargout = covSE(mode, par, varargin) 2 | 3 | % Squared Exponential covariance function with unit amplitude. The covariance 4 | % function is: 5 | % 6 | % k(x,z) = exp(-maha(x,z)/2) 7 | % 8 | % where maha(x,z) is a squared Mahalanobis distance. The function takes a "mode" 9 | % parameter, which specifies precisely the Mahalanobis distance used, see 10 | % covMaha. The function returns either the number of hyperparameters (with less 11 | % than 3 input argments) or it returns a covariance matrix and (optionally) a 12 | % derivative function. 13 | % 14 | % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch, 2016-05-23. 15 | % 16 | % See also covMaha.m. 17 | 18 | if nargin < 1, error('Mode cannot be empty.'); end % no default 19 | if nargin < 2, par = []; end % default 20 | varargout = cell(max(1, nargout), 1); % allocate mem for output 21 | if nargin < 4, varargout{1} = covMaha(mode,par); return, end 22 | 23 | k = @(d2) exp(-d2/2); dk = @(d2,k) (-1/2)*k; % covariance and derivative 24 | [varargout{:}] = covMaha(mode, par, k, dk, varargin{:}); -------------------------------------------------------------------------------- /matlab/ext/gpml/cov/covSEard.m: -------------------------------------------------------------------------------- 1 | function varargout = covSEard(varargin) 2 | 3 | % Wrapper for Squared Exponential covariance function covSE.m. 4 | % 5 | % Squared Exponential covariance function with Automatic Relevance Detemination 6 | % (ARD) distance measure. The covariance function is parameterized as: 7 | % 8 | % k(x,z) = sf^2 * exp(-(x-z)'*inv(P)*(x-z)/2) 9 | % 10 | % where the P matrix is diagonal with ARD parameters ell_1^2,...,ell_D^2, where 11 | % D is the dimension of the input space and sf2 is the signal variance. The 12 | % hyperparameters are: 13 | % 14 | % hyp = [ log(ell_1) 15 | % log(ell_2) 16 | % . 17 | % log(ell_D) 18 | % log(sf) ] 19 | % 20 | % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch, 2016-04-27. 21 | % 22 | % See also covSE.m. 23 | 24 | varargout = cell(max(1,nargout),1); 25 | [varargout{:}] = covScale({'covSE','ard',[]},varargin{:}); -------------------------------------------------------------------------------- /matlab/ext/gpml/cov/covSEiso.m: -------------------------------------------------------------------------------- 1 | function varargout = covSEiso(varargin) 2 | 3 | % Wrapper for Squared Exponential covariance function covSE.m. 4 | % 5 | % Squared Exponential covariance function with isotropic distance measure. The 6 | % covariance function is parameterized as: 7 | % 8 | % k(x,z) = sf^2 * exp(-(x-z)'*inv(P)*(x-z)/2) 9 | % 10 | % where the P matrix is ell^2 times the unit matrix and sf^2 is the signal 11 | % variance. The hyperparameters are: 12 | % 13 | % hyp = [ log(ell) 14 | % log(sf) ] 15 | % 16 | % For more help on design of covariance functions, try "help covFunctions". 17 | % 18 | % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch, 2016-04-27. 19 | % 20 | % See also covSE.M. 21 | 22 | varargout = cell(max(1,nargout),1); 23 | [varargout{:}] = covScale({'covSE','iso',[]},varargin{:}); -------------------------------------------------------------------------------- /matlab/ext/gpml/cov/covSEisoU.m: -------------------------------------------------------------------------------- 1 | function varargout = covSEisoU(varargin) 2 | 3 | % Wrapper for Squared Exponential covariance function covSE.m. 4 | % 5 | % Squared Exponential covariance function with isotropic distance measure with 6 | % unit magnitude. The covariance function is parameterized as: 7 | % 8 | % k(x,z) = exp(-(x-z)'*inv(P)*(x-z)/2) 9 | % 10 | % where the P matrix is ell^2 times the unit matrix and sf2 is the signal 11 | % variance. The hyperparameters are: 12 | % 13 | % hyp = [ log(ell) ] 14 | % 15 | % For more help on design of covariance functions, try "help covFunctions". 16 | % 17 | % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch, 2016-04-27. 18 | % 19 | % See also covSE.m. 20 | 21 | varargout = cell(max(1,nargout),1); 22 | [varargout{:}] = covSE('iso',[],varargin{:}); -------------------------------------------------------------------------------- /matlab/ext/gpml/cov/covSEproj.m: -------------------------------------------------------------------------------- 1 | function varargout = covSEproj(d,varargin) 2 | 3 | % Wrapper for Squared Exponential covariance function covSE.m. 4 | % 5 | % Projected squared exponential covariance. The covariance function is 6 | % parameterized as: 7 | % 8 | % k(x,z) = sf^2 * exp(-(x-z)'*inv(P)*(x-z)/2) 9 | % 10 | % where the inv(P) matrix is L'*L with L of size (d,D) and sf^2 is the signal 11 | % variance. 12 | % 13 | % The hyperparameters are: 14 | % hyp = [ L_11; 15 | % L_21; 16 | % .. 17 | % L_d1; 18 | % .. 19 | % L_dD; 20 | % log(sf) ], 21 | % 22 | % Copyright (c) by Roman Garnett & Hannes Nickisch, 2016-04-27. 23 | % 24 | % See also COVFUNCTIONS.M. 25 | 26 | varargout = cell(max(1,nargout),1); 27 | [varargout{:}] = covScale({'covSE','proj',d},varargin{:}); -------------------------------------------------------------------------------- /matlab/ext/gpml/cov/covSEvlen.m: -------------------------------------------------------------------------------- 1 | function varargout = covSEvlen(llen,varargin) 2 | 3 | % Wrapper for Squared Exponential covariance function covSE.m. 4 | % 5 | % Squared Exponential covariance function with spatially varying lengthscale. 6 | % The covariance function is parameterized as: 7 | % 8 | % k(x,z) = sf^2 * sqrt(a/b)^D * exp(-(x-z)'*(x-z)/b) where 9 | % a = 2*len(x)*len(z) 10 | % b = len(x)^2 + len(z)^2 11 | % 12 | % where len is the spatially varying lengthscale (here specified in the log 13 | % domain), D is the dimension of the input data and sf^2 is the signal variance. 14 | % The log-lengthscale function llen is supposed to be a valid GPML mean function 15 | % with hyperparameters hyp_len. 16 | % 17 | % The hyperparameters of covSEvlen are: 18 | % 19 | % hyp = [ hyp_len 20 | % log(sf) ] 21 | % 22 | % The covariance function has been introduced by Mark N. Gibbs in his 1997 PhD 23 | % thesis and was later generalised by Paciorek&Schervish at NIPS 2004. 24 | % 25 | % Note that by setting len(x)=len(z)=ell for every input x and z, we 26 | % recover covSEiso. 27 | % 28 | % For more help on design of covariance functions, try "help covFunctions". 29 | % 30 | % Copyright (c) by Hannes Nickisch, 2016-05-04. 31 | % 32 | % See also COVSEISO.M, COVFUNCTIONS.M. 33 | 34 | varargout = cell(max(1,nargout),1); 35 | [varargout{:}] = covScale({'covSE','vlen',llen},varargin{:}); -------------------------------------------------------------------------------- /matlab/ext/gpml/cov/covZero.m: -------------------------------------------------------------------------------- 1 | function [K,dK] = covZero(hyp, x, z) 2 | 3 | % Constant (degenerate) covariance function, with zero variance. 4 | % The covariance function is specified as: 5 | % 6 | % k(x,z) = 0 7 | % 8 | % hyp = [ ] 9 | % 10 | % For more help on design of covariance functions, try "help covFunctions". 11 | % 12 | % Copyright (c) by Hannes Nickisch, 2016-04-17. 13 | % 14 | % See also COVFUNCTIONS.M. 15 | 16 | if nargin<2, K = '0'; return; end % report number of parameters 17 | if nargin<3, z = []; end % make sure, z exists 18 | dg = strcmp(z,'diag'); % determine mode 19 | 20 | n = size(x,1); 21 | 22 | if dg % vector kxx 23 | K = zeros(n,1); 24 | else 25 | if isempty(z) % symmetric matrix Kxx 26 | K = zeros(n,n); 27 | else % cross covariances Kxz 28 | K = zeros(n,size(z,1)); 29 | end 30 | end 31 | 32 | if nargout > 1 33 | dK = @(Q) dirder(Q,K,x); % directional hyper derivative 34 | end 35 | 36 | function [dhyp,dx] = dirder(Q,K,x) 37 | dhyp = zeros(0,1); if nargout > 1, dx = zeros(size(x)); end 38 | -------------------------------------------------------------------------------- /matlab/ext/gpml/doc/changelog: -------------------------------------------------------------------------------- 1 | GAUSSIAN PROCESS REGRESSION AND CLASSIFICATION Toolbox version 4.0 2 | for GNU Octave 3.2.x and Matlab 7.x 3 | 4 | Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch, 2016-10-19. 5 | 6 | Changes and small incremental fixes applied since the last major release. 7 | -------------------------------------------------------------------------------- /matlab/ext/gpml/doc/checkmark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MethodsOfMachineLearning/entropy-search/3f968b190670ab23e7a99fee6ef574bbc80c1656/matlab/ext/gpml/doc/checkmark.png -------------------------------------------------------------------------------- /matlab/ext/gpml/doc/demoMinimize.m: -------------------------------------------------------------------------------- 1 | clear all, close all, nit = 50; % tabular rasa, max number of fun/grad evals 2 | n = 300; x = 10*sort(rand(n,1)); % sample data 3 | sn = 0.2; y = sin(x)+sqrt(x) + randn(n,1)*sn; 4 | cov = {@covSEiso}; sf = 1; ell = 0.4; hyp0.cov = log([ell;sf]); % covariance 5 | mean = {@meanSum,{@meanLinear,@meanConst}}; hyp0.mean = [0.2;1]; % mean 6 | lik = 'likGauss'; hyp0.lik = log(sn); inf = 'infExact'; % likelihood/inference 7 | par = {inf, mean, cov, lik, x, y}; 8 | 9 | 10 | [x1 fx1 c1] = minimize( hyp0,@gp,-nit,par{:}); 11 | [x2 fx2 c2] = minimize_minfunc(hyp0,@gp,-nit,par{:}); 12 | try 13 | [x3 fx3 c3] = minimize_lbfgsb(hyp0,@gp,-nit,par{:}); 14 | catch 15 | x3 = hyp0; fx3 = gp(hyp0,par{:}); c3 = 0; 16 | end 17 | fprintf('nit=%02d: minimize: %1.2f\n',c1,fx1(end)) 18 | fprintf('nit=%02d: minimize_minfunc: %1.2f\n',c2,fx2(end)) 19 | fprintf('nit=%02d: minimize_lbfgsb: %1.2f\n',c3,fx3(end)) -------------------------------------------------------------------------------- /matlab/ext/gpml/doc/f0.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MethodsOfMachineLearning/entropy-search/3f968b190670ab23e7a99fee6ef574bbc80c1656/matlab/ext/gpml/doc/f0.gif -------------------------------------------------------------------------------- /matlab/ext/gpml/doc/f1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MethodsOfMachineLearning/entropy-search/3f968b190670ab23e7a99fee6ef574bbc80c1656/matlab/ext/gpml/doc/f1.gif -------------------------------------------------------------------------------- /matlab/ext/gpml/doc/f2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MethodsOfMachineLearning/entropy-search/3f968b190670ab23e7a99fee6ef574bbc80c1656/matlab/ext/gpml/doc/f2.gif -------------------------------------------------------------------------------- /matlab/ext/gpml/doc/f3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MethodsOfMachineLearning/entropy-search/3f968b190670ab23e7a99fee6ef574bbc80c1656/matlab/ext/gpml/doc/f3.gif -------------------------------------------------------------------------------- /matlab/ext/gpml/doc/f4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MethodsOfMachineLearning/entropy-search/3f968b190670ab23e7a99fee6ef574bbc80c1656/matlab/ext/gpml/doc/f4.gif -------------------------------------------------------------------------------- /matlab/ext/gpml/doc/f5.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MethodsOfMachineLearning/entropy-search/3f968b190670ab23e7a99fee6ef574bbc80c1656/matlab/ext/gpml/doc/f5.gif -------------------------------------------------------------------------------- /matlab/ext/gpml/doc/f6.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MethodsOfMachineLearning/entropy-search/3f968b190670ab23e7a99fee6ef574bbc80c1656/matlab/ext/gpml/doc/f6.gif -------------------------------------------------------------------------------- /matlab/ext/gpml/doc/f7.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MethodsOfMachineLearning/entropy-search/3f968b190670ab23e7a99fee6ef574bbc80c1656/matlab/ext/gpml/doc/f7.gif -------------------------------------------------------------------------------- /matlab/ext/gpml/doc/f8.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MethodsOfMachineLearning/entropy-search/3f968b190670ab23e7a99fee6ef574bbc80c1656/matlab/ext/gpml/doc/f8.gif -------------------------------------------------------------------------------- /matlab/ext/gpml/doc/f9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MethodsOfMachineLearning/entropy-search/3f968b190670ab23e7a99fee6ef574bbc80c1656/matlab/ext/gpml/doc/f9.png -------------------------------------------------------------------------------- /matlab/ext/gpml/doc/gpml_randn.m: -------------------------------------------------------------------------------- 1 | function x = gpml_randn(seed,varargin) 2 | 3 | % Generate pseudo-random numbers in a quick and dirty way. 4 | % The function makes sure, we obtain the same random numbers using Octave and 5 | % Matlab for the demo scripts. 6 | % 7 | % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch 2010-07-07. 8 | 9 | if nargin==2 10 | sz = varargin{1}; 11 | else 12 | sz = zeros(1,nargin-1); 13 | for i=1:nargin-1 14 | sz(i) = varargin{i}; 15 | end 16 | end 17 | 18 | n = prod(sz); N = ceil(n/2)*2; 19 | 20 | % minimal uniform random number generator for uniform deviates from [0,1] 21 | % by Park and Miller 22 | a = 7^5; m = 2^31-1; 23 | % using Schrage's algorithm 24 | q = fix(m/a); r = mod(m,a); % m = a*q+r 25 | u = zeros(N+1,1); u(1) = fix(seed*2^31); 26 | for i=2:N+1 27 | % Schrage's algorithm for mod(a*u(i),m) 28 | u(i) = a*mod(u(i-1),q) - r*fix(u(i-1)/q); 29 | if u(i)<0, u(i) = u(i)+m; end 30 | end 31 | u = u(2:N+1)/2^31; 32 | 33 | % Box-Muller transform: Numerical Recipies, 2nd Edition, $7.2.8 34 | % http://en.wikipedia.org/wiki/Box-Muller_transform 35 | w = sqrt(- 2*log(u(1:N/2))); % split into two groups 36 | x = [w.*cos(2*pi*u(N/2+1:N)); w.*sin(2*pi*u(N/2+1:N))]; 37 | x = reshape(x(1:n),sz); 38 | -------------------------------------------------------------------------------- /matlab/ext/gpml/doc/manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MethodsOfMachineLearning/entropy-search/3f968b190670ab23e7a99fee6ef574bbc80c1656/matlab/ext/gpml/doc/manual.pdf -------------------------------------------------------------------------------- /matlab/ext/gpml/doc/style.css: -------------------------------------------------------------------------------- 1 | body {font-family: sans-serif; font-size: 16px} 2 | table {font-size: inherit;} 3 | 4 | -------------------------------------------------------------------------------- /matlab/ext/gpml/inf/infGaussLik.m: -------------------------------------------------------------------------------- 1 | function [post nlZ dnlZ] = infGaussLik(hyp, mean, cov, lik, x, y, opt) 2 | 3 | % Exact inference for a GP with Gaussian likelihood. Compute a parametrization 4 | % of the posterior, the negative log marginal likelihood and its derivatives 5 | % w.r.t. the hyperparameters. See also "help infMethods". 6 | % 7 | % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch, 2016-10-28. 8 | % File automatically generated using noweb. 9 | % 10 | % See also INFMETHODS.M, APX.M. 11 | 12 | if nargin<7, opt = []; end % make sure parameter exists 13 | if iscell(lik), likstr = lik{1}; else likstr = lik; end 14 | if ~ischar(likstr), likstr = func2str(likstr); end 15 | if ~strcmp(likstr,'likGauss') % NOTE: no explicit call to likGauss 16 | error('Exact inference only possible with Gaussian likelihood'); 17 | end 18 | 19 | [n, D] = size(x); 20 | [m,dm] = feval(mean{:}, hyp.mean, x); % evaluate mean vector and deriv 21 | sn2 = exp(2*hyp.lik); W = ones(n,1)/sn2; % noise variance of likGauss 22 | K = apx(hyp,cov,x,opt); % set up covariance approximation 23 | [ldB2,solveKiW,dW,dhyp,post.L] = K.fun(W); % obtain functionality depending on W 24 | 25 | alpha = solveKiW(y-m); 26 | post.alpha = K.P(alpha); % return the posterior parameters 27 | post.sW = sqrt(W); % sqrt of noise precision vector 28 | if nargout>1 % do we want the marginal likelihood? 29 | nlZ = (y-m)'*alpha/2 + ldB2 + n*log(2*pi*sn2)/2; % -log marginal likelihood 30 | if nargout>2 % do we want derivatives? 31 | dnlZ = dhyp(alpha); dnlZ.mean = -dm(alpha); 32 | dnlZ.lik = -sn2*(alpha'*alpha) - 2*sum(dW)/sn2 + n; 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /matlab/ext/gpml/lik/likExp.m: -------------------------------------------------------------------------------- 1 | function [varargout] = likExp(link, hyp, varargin) 2 | 3 | % likExp - Exponential likelihood function for strictly positive data y. The 4 | % expression for the likelihood is 5 | % likExp(f) = exp(-y/mu) / mu with 6 | % mean=mu and variance=mu^2 where mu = g(f) is the intensity, f is a 7 | % Gaussian process, y is the strictly positive data. Hence, we have 8 | % llik(f) = log(likExp(f)) = -y/g(f) - log(g(f)). 9 | % 10 | % Internally, the function is in fact a wrapper around likGamma with hyper 11 | % parameter al=1. 12 | % 13 | % We provide two inverse link functions 'exp' and 'logistic': 14 | % g(f) = exp(f) and g(f) = log(1+exp(f))). 15 | % The link functions are located at util/glm_invlink_*.m. 16 | % Note that for the 'exp' intensity the likelihood lik(f) is log concave. 17 | % 18 | % The hyperparameters are: 19 | % 20 | % hyp = [ ] 21 | % 22 | % Several modes are provided, for computing likelihoods, derivatives and moments 23 | % respectively, see likFunctions.m for the details. In general, care is taken 24 | % to avoid numerical issues when the arguments are extreme. 25 | % 26 | % See also LIKFUNCTIONS.M, LIKGAMMA.M. 27 | % 28 | % Copyright (c) by Hannes Nickisch, 2013-10-29. 29 | 30 | if nargin<4, varargout = {'0'}; return; end % report number of hyperparameters 31 | varargout = cell(nargout, 1); % allocate the right number of output arguments 32 | for j=1:nargout, varargout{j} = []; end % derivative output 33 | if nargin<=6, [varargout{:}] = likGamma(link,0,varargin{:}); end % log(al) = 0 -------------------------------------------------------------------------------- /matlab/ext/gpml/mean/meanConst.m: -------------------------------------------------------------------------------- 1 | function [m,dm] = meanConst(hyp, x) 2 | 3 | % Constant mean function. The mean function is parameterized as: 4 | % 5 | % m(x) = c 6 | % 7 | % The hyperparameter is: 8 | % 9 | % hyp = [ c ] 10 | % 11 | % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch, 2016-04-15. 12 | % 13 | % See also MEANFUNCTIONS.M. 14 | 15 | if nargin<2, m = '1'; return; end % report number of hyperparameters 16 | if numel(hyp)~=1, error('Exactly one hyperparameter needed.'), end 17 | c = hyp; 18 | m = c*ones(size(x,1),1); % mean 19 | dm = @(q) sum(q); % directional derivative 20 | -------------------------------------------------------------------------------- /matlab/ext/gpml/mean/meanDiscrete.m: -------------------------------------------------------------------------------- 1 | function [m,dm] = meanDiscrete(s, hyp, x) 2 | 3 | % Mean function for discrete inputs x. Given a function defined on the 4 | % integers 1,2,3,..,s, the mean function is parametrized as: 5 | % 6 | % m(x) = mu_x, 7 | % 8 | % where mu is a fixed vector of length s. 9 | % 10 | % This implementation assumes that the inputs x are given as integers 11 | % between 1 and s, which simply index the provided vector. 12 | % 13 | % The hyperparameters are: 14 | % 15 | % hyp = [ mu_1 16 | % mu_2 17 | % .. 18 | % mu_s ] 19 | % 20 | % Copyright (c) by Roman Garnett and Hannes Nickisch, 2016-04-16. 21 | % 22 | % See also COVDISCRETE.M, MEANFUNCTIONS.M. 23 | 24 | if nargin==0, error('s must be specified.'), end % check for dimension 25 | if nargin<=2, m = num2str(s); return; end % report number of hyperparameters 26 | mu = hyp(:); m = mu(x(:)); % evaluate mean 27 | dm = @(q) dirder(q,s,x); 28 | 29 | function dmdhyp = dirder(q,s,x) 30 | dmdhyp = zeros(s,1); 31 | for i=1:s, dmdhyp(i) = sum(q(x==i)); end -------------------------------------------------------------------------------- /matlab/ext/gpml/mean/meanGP.m: -------------------------------------------------------------------------------- 1 | function [m,dm] = meanGP(hyp,inf,mean,cov,lik,x,y, hypz,z) 2 | 3 | % Mean function being the predictive mean of a GP model: 4 | % 5 | % m(z) = posterior mean of another GP at location z as given by 6 | % m(z) = gp(hyp,inf,mean,cov,lik,x,y, z) 7 | % 8 | % The hyperparameters are: 9 | % 10 | % hypz = [ ] 11 | % 12 | % Copyright (c) by Hannes Nickisch, 2016-04-16. 13 | % 14 | % See also MEANFUNCTIONS.M and MEANGPEXACT.M. 15 | 16 | if nargin<7, error('GP must be specified.'), end % check for dimension 17 | if nargin<9, m = '0'; return, end % report number of hyperparameters 18 | 19 | m = gp(hyp,inf,mean,cov,lik,x,y, z); % evaluate posterior mean 20 | dm = @(q) zeros(0,1); % directional derivative -------------------------------------------------------------------------------- /matlab/ext/gpml/mean/meanLinear.m: -------------------------------------------------------------------------------- 1 | function [m,dm] = meanLinear(hyp, x) 2 | 3 | % Linear mean function. The mean function is parameterized as: 4 | % 5 | % m(x) = sum_i c_i * x_i; 6 | % 7 | % The hyperparameter is: 8 | % 9 | % hyp = [ c_1 10 | % c_2 11 | % .. 12 | % c_D ] 13 | % 14 | % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch, 2016-04-15. 15 | % 16 | % See also MEANFUNCTIONS.M. 17 | 18 | if nargin<2, m = 'D'; return; end % report number of hyperparameters 19 | [n,D] = size(x); 20 | if any(size(hyp)~=[D,1]), error('Exactly D hyperparameters needed.'), end 21 | m = x*hyp(:); % evaluate mean 22 | dm = @(q) x'*q(:); % directional derivative 23 | -------------------------------------------------------------------------------- /matlab/ext/gpml/mean/meanMask.m: -------------------------------------------------------------------------------- 1 | function [m,dm] = meanMask(mask, mean, hyp, x) 2 | 3 | % Apply a mean function to a subset of the dimensions only. The subset can 4 | % either be specified by a 0/1 mask by a boolean mask or by an index set. 5 | % 6 | % This function doesn't actually compute very much on its own, it merely does 7 | % some bookkeeping, and calls another mean function to do the actual work. 8 | % 9 | % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch, 2016-04-16. 10 | % 11 | % See also MEANFUNCTIONS.M. 12 | 13 | nh_string = feval(mean{:}); % number of hyperparameters of the full mean 14 | 15 | if max(mask)<2 && length(mask)>1, mask = find(mask); end % convert 1/0->index 16 | D = length(mask); % masked dimension 17 | if nargin<4, m = num2str(eval(nh_string)); return; end % number of parameters 18 | 19 | if eval(nh_string)~=length(hyp) % check hyperparameters 20 | error('number of hyperparameters does not match size of masked data') 21 | end 22 | 23 | [m,dm] = feval(mean{:}, hyp, x(:,mask)); 24 | -------------------------------------------------------------------------------- /matlab/ext/gpml/mean/meanNN.m: -------------------------------------------------------------------------------- 1 | function [m,dm] = meanNN(c,v, hyp, x) 2 | 3 | % Nearest neighbor mean function. The mean function is parameterized as: 4 | % 5 | % m(z) = v_j, j = arg min_i d(ci,x) where d is the Euclidean distance and ci is 6 | % the ith cluster center. 7 | % 8 | % The hyperparameters are: 9 | % 10 | % hyp = [ ] 11 | % 12 | % Copyright (c) by Hannes Nickisch, 2016-04-16. 13 | % 14 | % See also MEANFUNCTIONS.M. 15 | 16 | if nargin<4, m = '0'; return; end % report number of hyperparameters 17 | if numel(hyp)~=0, error('No hyperparameters needed for this model.'), end 18 | 19 | [junk,j] = min(sq_dist(c',x')); m = v(j); m = m(:); % evaluate mean 20 | dm = @(q) zeros(0,1); % directional derivative 21 | -------------------------------------------------------------------------------- /matlab/ext/gpml/mean/meanOne.m: -------------------------------------------------------------------------------- 1 | function [m,dm] = meanOne(hyp, x) 2 | 3 | % One mean function. The mean function does not have any parameters. 4 | % 5 | % m(x) = 1 6 | % 7 | % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch, 2016-04-15. 8 | % 9 | % See also MEANFUNCTIONS.M. 10 | 11 | if nargin<2, m = '0'; return; end % report number of hyperparameters 12 | m = ones(size(x,1),1); % mean 13 | dm = @(q) zeros(0,1); % directional derivative 14 | -------------------------------------------------------------------------------- /matlab/ext/gpml/mean/meanPoly.m: -------------------------------------------------------------------------------- 1 | function [m,dm] = meanPoly(d, hyp, x) 2 | 3 | % meanPoly - compose a mean function as a polynomial. 4 | % 5 | % The degree d has to be a strictly positive integer. 6 | % 7 | % m(x) = sum_i=1..D sum_j=1..d a_ij * x_i^j 8 | % 9 | % The hyperparameter is: 10 | % 11 | % hyp = [ a_11 12 | % a_21 13 | % .. 14 | % a_D1 15 | % a_12 16 | % a_22 17 | % .. 18 | % a_Dd] 19 | % 20 | % This function doesn't actually compute very much on its own, it merely does 21 | % some bookkeeping, and calls other mean function to do the actual work. 22 | % 23 | % Copyright (c) by Hannes Nickisch 2016-04-15. 24 | % 25 | % See also MEANFUNCTIONS.M. 26 | 27 | d = max(abs(floor(d)),1); % positive integer degree 28 | if nargin<3, m = ['D*',int2str(d)]; return; end % report number of hyperparams 29 | 30 | [n,D] = size(x); 31 | a = reshape(hyp,D,d); 32 | 33 | m = zeros(n,1); % allocate memory 34 | for j=1:d, m = m + (x.^j)*a(:,j); end % evaluate mean 35 | dm = @(q) dirder(q,x,a); % directional derivative 36 | 37 | function dhyp = dirder(q,x,a) 38 | [D,d] = size(a); 39 | dhyp = zeros(D*d,1); for j=1:d, dhyp((j-1)*D+(1:D)) = (x.^j)'*q(:); end -------------------------------------------------------------------------------- /matlab/ext/gpml/mean/meanPow.m: -------------------------------------------------------------------------------- 1 | function [m,dm] = meanPow(d, mean, hyp, x) 2 | 3 | % meanPow - compose a mean function as the power of another mean function m0. 4 | % 5 | % m(x) = m_0(x) ^ d 6 | % 7 | % If the degree d is not a strictly positive integer, we use 8 | % m(x) = sign(m_0(x)) * abs(m_0(x)) ^ d 9 | % to stay within the reals 10 | % 11 | % The hyperparameter is: 12 | % 13 | % hyp = [ hyp_m0 ] 14 | % 15 | % This function doesn't actually compute very much on its own, it merely does 16 | % some bookkeeping, and calls other mean function to do the actual work. 17 | % 18 | % Copyright (c) by Carl Edward Rasmussen & Hannes Nickisch 2016-05-04. 19 | % 20 | % See also MEANFUNCTIONS.M. 21 | 22 | if nargin<4 % report number of parameters 23 | m = feval(mean{:}); return 24 | end 25 | 26 | [m0,dm0] = feval(mean{:},hyp,x); % evaluate m0 27 | if d>0 && ceil(d)==d % strictly positive integer 28 | s = 1; 29 | else % general real number 30 | s = sign(m0); m0 = abs(m0); 31 | end 32 | m = s.*m0.^d; % mean 33 | dm = @(q) dm0( (d*m0.^(d-1)).*q ); % directional derivative -------------------------------------------------------------------------------- /matlab/ext/gpml/mean/meanPref.m: -------------------------------------------------------------------------------- 1 | function [m,dm] = meanPref(mean, hyp, x) 2 | 3 | % meanPref - mean function for preference learning. 4 | % 5 | % m(x) = m_0(x1)-m_0(x2), where x1=x(:,1:D), x2=x(:,D+1:2*D), D = size(x,2)/2. 6 | % 7 | % The hyperparameters are: 8 | % 9 | % hyp = [ hyp_m0 ] 10 | % 11 | % This function doesn't actually compute very much on its own, it merely does 12 | % some bookkeeping, and calls another mean function to do the actual work. 13 | % 14 | % See Collaborative Gaussian Processes for Preference Learning, NIPS 2014. 15 | % 16 | % Copyright (c) by Hannes Nickisch and Roman Garnett, 2016-04-16. 17 | % 18 | % See also MEANFUNCTIONS.M and COVPREF.M. 19 | 20 | if nargin<3, m = strrep(feval(mean{:}),'D','D/2'); return; end % no of params 21 | 22 | [m1,dm1] = feval(mean{:}, hyp, x(:,1 :end/2)); 23 | [m2,dm2] = feval(mean{:}, hyp, x(:,1+end/2:end )); 24 | m = m1-m2; dm = @(q) dm1(q)-dm2(q); -------------------------------------------------------------------------------- /matlab/ext/gpml/mean/meanProd.m: -------------------------------------------------------------------------------- 1 | function [m,dm] = meanProd(mean, hyp, x) 2 | 3 | % meanProd - compose a mean function as the product of other mean functions. 4 | % This function doesn't actually compute very much on its own, it merely does 5 | % some bookkeeping, and calls other mean functions to do the actual work. 6 | % 7 | % m(x) = \prod_i m_i(x) 8 | % 9 | % Copyright (c) by Carl Edward Rasmussen & Hannes Nickisch 2016-04-15. 10 | % 11 | % See also MEANFUNCTIONS.M. 12 | 13 | nm = numel(mean); 14 | for ii = 1:nm % iterate over mean functions 15 | f = mean(ii); if iscell(f{:}), f = f{:}; end % expand cell array if necessary 16 | j(ii) = cellstr(feval(f{:})); % collect number hypers 17 | end 18 | 19 | if nargin<3 % report number of parameters 20 | m = char(j(1)); for ii=2:nm, m = [m, '+', char(j(ii))]; end; return 21 | end 22 | [n,D] = size(x); 23 | 24 | v = []; % v vector indicates to which mean parameters belong 25 | for ii = 1:nm, v = [v repmat(ii, 1, eval(char(j(ii))))]; end 26 | 27 | m = ones(n,1); mi = cell(nm,1); dmi = cell(nm,1); % allocate space 28 | for ii = 1:nm % iteration over factor functions 29 | f = mean(ii); if iscell(f{:}), f = f{:}; end % expand cell array if needed 30 | [mi{ii},dmi{ii}] = feval(f{:}, hyp(v==ii), x); 31 | m = m.*mi{ii}; % accumulate means 32 | end 33 | dm = @(q) dirder(q,mi,dmi,v,nm); % directional derivative 34 | 35 | function dhyp = dirder(q,mi,dmi,v,nm) 36 | dhyp = zeros(nm,1); 37 | for ii = 1:nm 38 | qi = q; for jj=1:nm, if ii~=jj, qi = qi .* mi{jj}; end, end % accumulate 39 | dhyp(v==ii,1) = dmi{ii}(qi); 40 | end -------------------------------------------------------------------------------- /matlab/ext/gpml/mean/meanScale.m: -------------------------------------------------------------------------------- 1 | function [m,dm] = meanScale(mean, hyp, x) 2 | 3 | % meanScale - compose a mean function as a scaled version of another one. 4 | % 5 | % m(x) = a * m_0(x) 6 | % 7 | % The hyperparameters are: 8 | % 9 | % hyp = [ a; 10 | % hyp_m0 ] 11 | % 12 | % This function doesn't actually compute very much on its own, it merely does 13 | % some bookkeeping, and calls other mean functions to do the actual work. 14 | % 15 | % Copyright (c) by Carl Edward Rasmussen & Hannes Nickisch 2016-04-15. 16 | % 17 | % See also MEANFUNCTIONS.M. 18 | 19 | if nargin<3 % report number of parameters 20 | m = [feval(mean{:}),'+1']; return 21 | end 22 | 23 | a = hyp(1); 24 | [m0,dm0] = feval(mean{:},hyp(2:end),x); % evaluate m0 25 | m = a*m0; % mean 26 | dm = @(q) [m0'*q(:); a*dm0(q)]; % directional derivative 27 | -------------------------------------------------------------------------------- /matlab/ext/gpml/mean/meanSum.m: -------------------------------------------------------------------------------- 1 | function [m,dm] = meanSum(mean, hyp, x) 2 | 3 | % meanSum - compose a mean function as the sum of other mean functions. 4 | % This function doesn't actually compute very much on its own, it merely does 5 | % some bookkeeping, and calls other mean functions to do the actual work. 6 | % 7 | % m(x) = \sum_i m_i(x) 8 | % 9 | % Copyright (c) by Carl Edward Rasmussen & Hannes Nickisch 2016-04-15. 10 | % 11 | % See also MEANFUNCTIONS.M. 12 | 13 | nm = numel(mean); 14 | for ii = 1:nm % iterate over mean functions 15 | f = mean(ii); if iscell(f{:}), f = f{:}; end % expand cell array if necessary 16 | j(ii) = cellstr(feval(f{:})); % collect number hypers 17 | end 18 | 19 | if nargin<3 % report number of parameters 20 | m = char(j(1)); for ii=2:nm, m = [m, '+', char(j(ii))]; end; return 21 | end 22 | [n,D] = size(x); 23 | 24 | v = []; % v vector indicates to which mean parameters belong 25 | for ii = 1:nm, v = [v repmat(ii, 1, eval(char(j(ii))))]; end 26 | 27 | m = zeros(n,1); dmi = cell(nm,1); % allocate space 28 | for ii = 1:nm % iteration over summand functions 29 | f = mean(ii); if iscell(f{:}), f = f{:}; end % expand cell array if needed 30 | [mi,dmi{ii}] = feval(f{:}, hyp(v==ii), x); 31 | m = m+mi; % accumulate means 32 | end 33 | dm = @(q) dirder(q,dmi,v,nm); % directional derivative 34 | 35 | function dhyp = dirder(q,dmi,v,nm) 36 | dhyp = zeros(nm,1); 37 | for ii = 1:nm, dhyp(v==ii,1) = dmi{ii}(q); end -------------------------------------------------------------------------------- /matlab/ext/gpml/mean/meanWSPC.m: -------------------------------------------------------------------------------- 1 | function [m,dm] = meanWSPC(d, hyp, x) 2 | 3 | % Weighted Sum of Projected Cosines or Random Kitchen Sink features. 4 | % 5 | % This function represents the feature function of a zero mean GP with 6 | % stationary covariance function. See the paper "Sparse spectrum GP regression" 7 | % by Lazaro-Gredilla et al., JMLR, 2010 for details. 8 | % 9 | % m(x) = sqrt(2/d) sum_j=1..d a_j * cos(w_j'*x + b_j) 10 | % 11 | % The hyperparameter is: 12 | % hyp = [w_1; b_1; a_1; ..; w_d; b_d; a_d] 13 | % 14 | % Copyright (c) by William Herlands and Hannes Nickisch, 2016-04-15. 15 | % 16 | % See also MEANFUNCTIONS.M. 17 | 18 | if nargin<3, m = sprintf('(D+2)*%d',d); return; end % report number of hypers 19 | [n,D] = size(x); 20 | if any(length(hyp)~=eval(sprintf('(D+2)*%d',d))) 21 | error('Incorrect number of hyperparameters for meanRKS.') 22 | end 23 | hyp = reshape(hyp,D+2,d); 24 | w = hyp(1:D,:); b = hyp(D+1,:); a = hyp(D+2,:)'; % separate hyps into w, b, a 25 | 26 | r = bsxfun(@plus,x*w,b); cr = cos(r); m = sqrt(2/d)*cr*a; % mean 27 | dm = @(q) dirder(q,x,a,r,cr,d); % directional derivative 28 | 29 | function dhyp = dirder(q,x,a,r,cr,d) 30 | msr = -sin(r); dhyp = [x'*(msr.*(q*a')); (q'*msr).*a'; q'*cr]; 31 | dhyp = sqrt(2/d)*dhyp(:); -------------------------------------------------------------------------------- /matlab/ext/gpml/mean/meanWarp.m: -------------------------------------------------------------------------------- 1 | function [m,dm] = meanWarp(mean, g, dg, hyp, x) 2 | 3 | % meanWarp - compose a mean function by warping another mean function m0. 4 | % 5 | % m(x) = g( m_0(x) ). 6 | % 7 | % The hyperparameter is: 8 | % 9 | % hyp = [ hyp_m0 ] 10 | % 11 | % This function doesn't actually compute very much on its own, it merely does 12 | % some bookkeeping, and calls other mean function to do the actual work. 13 | % 14 | % Copyright (c) by William Herlands & Hannes Nickisch, 2016-04-15. 15 | % 16 | % See also MEANFUNCTIONS.M 17 | 18 | if nargin<5, m = feval(mean{:}); return, end % report number of parameters 19 | 20 | [m0,dm0] = feval(mean{:},hyp,x); % evaluate m0 21 | m = g(m0); % mean 22 | dm = @(q) dm0(dg(m0).*q); % directional derivative -------------------------------------------------------------------------------- /matlab/ext/gpml/mean/meanZero.m: -------------------------------------------------------------------------------- 1 | function [m,dm] = meanZero(hyp, x) 2 | 3 | % Zero mean function. The mean function does not have any parameters. 4 | % 5 | % m(x) = 0 6 | % 7 | % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch, 2016-04-15. 8 | % 9 | % See also MEANFUNCTIONS.M. 10 | 11 | if nargin<2, m = '0'; return; end % report number of hyperparameters 12 | m = zeros(size(x,1),1); % mean 13 | dm = @(q) zeros(0,1); % directional derivative 14 | -------------------------------------------------------------------------------- /matlab/ext/gpml/prior/priorClamped.m: -------------------------------------------------------------------------------- 1 | function [lp,dlp] = priorClamped(x) 2 | 3 | % Dummy hyperparameter prior distribution to fix the value of a hyperparameter. 4 | % The function is not intended to be evaluated but exists merely to make 5 | % the user aware of the possibility to use it. The function is equivalent 6 | % to priorDelta. 7 | % 8 | % For more help on design of priors, try "help priorDistributions". 9 | % 10 | % Copyright (c) by Roman Garnett and Hannes Nickisch, 2014-12-06. 11 | % 12 | % See also PRIORDISTRIBUTIONS.M. 13 | 14 | error('The function is not intended to be called directly.') -------------------------------------------------------------------------------- /matlab/ext/gpml/prior/priorClampedMulti.m: -------------------------------------------------------------------------------- 1 | function [lp,dlp] = priorClampedMulti(x) 2 | 3 | % Dummy hyperparameter prior distribution to fix the value of a hyperparameter. 4 | % The function is not intended to be evaluated but exists merely to make 5 | % the user aware of the possibility to use it. The function is equivalent 6 | % to priorDeltaMulti. 7 | % 8 | % For more help on design of priors, try "help priorDistributions". 9 | % 10 | % Copyright (c) by Roman Garnett and Hannes Nickisch, 2014-12-06. 11 | % 12 | % See also PRIORDISTRIBUTIONS.M. 13 | 14 | error('The function is not intended to be called directly.') -------------------------------------------------------------------------------- /matlab/ext/gpml/prior/priorDelta.m: -------------------------------------------------------------------------------- 1 | function [lp,dlp] = priorDelta(x) 2 | 3 | % Dummy hyperparameter prior distribution to fix the value of a hyperparameter. 4 | % The function is not intended to be evaluated but exists merely to make 5 | % the user aware of the possibility to use it. The function is equivalent 6 | % to priorClamped. 7 | % 8 | % For more help on design of priors, try "help priorDistributions". 9 | % 10 | % Copyright (c) by Roman Garnett and Hannes Nickisch, 2014-12-06. 11 | % 12 | % See also PRIORDISTRIBUTIONS.M. 13 | 14 | error('The function is not intended to be called directly.') -------------------------------------------------------------------------------- /matlab/ext/gpml/prior/priorDeltaMulti.m: -------------------------------------------------------------------------------- 1 | function [lp,dlp] = priorDeltaMulti(x) 2 | 3 | % Dummy hyperparameter prior distribution to fix the value of a hyperparameter. 4 | % The function is not intended to be evaluated but exists merely to make 5 | % the user aware of the possibility to use it. The function is equivalent 6 | % to priorClampedMulti. 7 | % 8 | % For more help on design of priors, try "help priorDistributions". 9 | % 10 | % Copyright (c) by Roman Garnett and Hannes Nickisch, 2014-12-06. 11 | % 12 | % See also PRIORDISTRIBUTIONS.M. 13 | 14 | error('The function is not intended to be called directly.') -------------------------------------------------------------------------------- /matlab/ext/gpml/prior/priorEqualMulti.m: -------------------------------------------------------------------------------- 1 | function [lp,dlp] = priorEqualMulti(x) 2 | 3 | % Dummy hyperparameter prior distribution to have a group of hyperparameter 4 | % share the same value. 5 | % The function is not intended to be evaluated but exists merely to make 6 | % the user aware of the possibility to use it. The function is equivalent 7 | % to priorSameMulti. 8 | % 9 | % For more help on design of priors, try "help priorDistributions". 10 | % 11 | % Copyright (c) by Hannes Nickisch, 2016-10-26. 12 | % 13 | % See also PRIORDISTRIBUTIONS.M. 14 | 15 | error('The function is not intended to be called directly.') -------------------------------------------------------------------------------- /matlab/ext/gpml/prior/priorGamma.m: -------------------------------------------------------------------------------- 1 | function [lp,dlp] = priorGamma(k,t,x) 2 | 3 | % Univariate Gamma hyperparameter prior distribution. 4 | % Compute log-likelihood and its derivative or draw a random sample. 5 | % The prior distribution is parameterized as: 6 | % 7 | % p(x) = exp(x/t)/gamma(k)*x^(k-1)/t^k 8 | % 9 | % where k(1x1) is the shape parameter, t(1x1) is the scale parameter 10 | % and x(1xN) contains query hyperparameters for prior evaluation. 11 | % 12 | % Sampling is done using the algorithm from p. 53 of the paper Generating gamma 13 | % variates by a modified rejection technique by J.H. Ahrens and U. Dieter, 1982, 14 | % ACM, 25, 47–54. 15 | % 16 | % For more help on design of priors, try "help priorDistributions". 17 | % 18 | % Copyright (c) by Roman Garnett and Hannes Nickisch, 2014-09-08. 19 | % 20 | % See also PRIORDISTRIBUTIONS.M. 21 | 22 | if nargin<2, error('k and t parameters need to be provided'), end 23 | if ~(isscalar(k)&&isscalar(t)) 24 | error('k and t parameters need to be scalars'), end 25 | if nargin<3 26 | m = 1; 27 | d = k-floor(k); % fractional part 28 | v0 = exp(1)/(exp(1)+d); 29 | while true 30 | v = rand(3,1); 31 | if v(1)<=v0 32 | r = v(2)^(1/d); s = v(3)*r^(d-1); 33 | else 34 | r = 1-log(v(2)); s = v(3)*exp(-r); 35 | end 36 | if s<=r^(d-1)*exp(-r), break, end 37 | m = m+1; 38 | end 39 | u = rand(floor(k),1); 40 | lp = t*(r-sum(log(u))); 41 | return 42 | end 43 | 44 | lx = log(x); 45 | lp = -gammaln(k) - k*log(t) + (k-1)*lx - x/t; 46 | dlp = (k-1)./x - 1/t; 47 | lp(x<0) = -inf; dlp(x<0) = 0; -------------------------------------------------------------------------------- /matlab/ext/gpml/prior/priorGauss.m: -------------------------------------------------------------------------------- 1 | function [lp,dlp] = priorGauss(mu,s2,x) 2 | 3 | % Univariate Gaussian hyperparameter prior distribution. 4 | % Compute log-likelihood and its derivative or draw a random sample. 5 | % The prior distribution is parameterized as: 6 | % 7 | % p(x) = exp(-(x-mu)^2/(2*s2)) / sqrt(2*pi*s2), where 8 | % 9 | % mu(1x1) is the mean parameter, s2(1x1) is the variance parameter and 10 | % x(1xN) contains query hyperparameters for prior evaluation. 11 | % 12 | % For more help on design of priors, try "help priorDistributions". 13 | % 14 | % Copyright (c) by Roman Garnett and Hannes Nickisch, 2014-09-09. 15 | % 16 | % See also PRIORDISTRIBUTIONS.M. 17 | 18 | if nargin<2, error('mu and s2 parameters need to be provided'), end 19 | if ~(isscalar(mu)&&isscalar(s2)) 20 | error('mu and s2 parameters need to be scalars') 21 | end 22 | if nargin<3, lp = sqrt(s2)*randn+mu; return, end % return a sample 23 | lp = -(x-mu).^2/(2*s2) - log(2*pi*s2)/2; 24 | dlp = -(x-mu)/s2; -------------------------------------------------------------------------------- /matlab/ext/gpml/prior/priorGaussMulti.m: -------------------------------------------------------------------------------- 1 | function [lp,dlp] = priorGaussMulti(mu,s2,x) 2 | 3 | % Multivariate Gaussian hyperparameter prior distribution. 4 | % Compute log-likelihood and its derivative or draw a random sample. 5 | % The prior distribution is parameterized as: 6 | % 7 | % p(x) = exp(-r2/2) / sqrt(det(2*pi*s2)) where r2(x) = (x-mu)'*inv(s2)*(x-mu), 8 | % 9 | % mu(Dx1) is the mean parameter, s2(Dx1) or s2(DxD) is the variance parameter 10 | % and x(DxN) contains query hyperparameters for prior evaluation. 11 | % 12 | % For more help on design of priors, try "help priorDistributions". 13 | % 14 | % Copyright (c) by Roman Garnett and Hannes Nickisch, 2014-09-12. 15 | % 16 | % See also PRIORDISTRIBUTIONS.M, PRIORGAUSS.M. 17 | 18 | if nargin<2, error('mu and s2 parameters need to be provided'), end 19 | if ndims(mu)~=2 || size(mu,2)~=1, error('mu needs to be (Dx1)'), end 20 | D = size(mu,1); 21 | s2_ok = ndims(s2)==2 && all(size(s2)==[D,1] | size(s2)==[D,D]); 22 | if ~s2_ok, error('s2 needs to be (DxD) or (Dx1)'), end 23 | if size(s2,2)==D % full multivariate case 24 | s = chol(s2)'; lds = sum(log(diag(s))); % lds = log(det(s2))/2 25 | else % diagonal covariance 26 | s = sqrt(s2); lds = sum(log(s)); 27 | end 28 | if nargin<3 % return a random sample 29 | lp = randn(D,1); % unit sample 30 | if size(s,2)==D, lp = s*lp+mu; else lp = s.*lp+mu; end % affine transformation 31 | return 32 | end 33 | if D==1 && size(x,1)>1 % both mu/s2 scalar => inflate 34 | D = size(x,1); mu = mu*ones(D,1); s = s*ones(D,1); lds = D*lds; 35 | end 36 | if ~(ndims(x)==2 && size(x,1)==D), error('x needs to be (Dxn)'), end 37 | 38 | oN = ones(1,size(x,2)); 39 | if size(s,2)==D 40 | xs = s\(x-mu*oN); dlp = -s'\xs; 41 | else 42 | xs = (x-mu*oN)./(s*oN); dlp = -xs./(s*oN); 43 | end 44 | lp = -sum(xs.^2,1)/2 - D*log(2*pi)/2 - lds; -------------------------------------------------------------------------------- /matlab/ext/gpml/prior/priorInvGauss.m: -------------------------------------------------------------------------------- 1 | function [lp,dlp] = priorInvGauss(mu,lam,x) 2 | 3 | % Univariate Inverse Gaussian hyperparameter prior distribution. 4 | % Compute log-likelihood and its derivative or draw a random sample. 5 | % The prior distribution is parameterized as: 6 | % 7 | % p(x) = exp(-lam*(x-mu)^2/(2*mu^2*x)) / sqrt(2*pi*x^3/lam) 8 | % 9 | % where mu(1x1) is the mean parameter, lam(1x1) is the scale parameter 10 | % and x(1xN) contains query hyperparameters for prior evaluation. 11 | % 12 | % For more help on design of priors, try "help priorDistributions". 13 | % 14 | % Copyright (c) by Roman Garnett and Hannes Nickisch, 2014-09-08. 15 | % 16 | % See also PRIORDISTRIBUTIONS.M. 17 | 18 | if nargin<2, error('mu and lam parameters need to be provided'), end 19 | if ~(isscalar(mu)&&isscalar(lam)) 20 | error('mu and lam parameters need to be scalars'),end 21 | if nargin<3 % return a sample 22 | n = randn; y = n*n; 23 | r = mu + mu*(mu*y-sqrt(4*mu*lam*y+mu^2*y^2))/(2*lam); 24 | z = rand; 25 | if z<=mu/(mu+r) 26 | lp = r; 27 | else 28 | lp = mu^2/r; 29 | end 30 | return 31 | end 32 | 33 | lp = -lam*(x-mu).^2./(2*mu^2*x) - log(2*pi*x.^3/lam)/2; 34 | q = (x-mu)./x; 35 | dlp = -lam*q.*(2-q)/(2*mu^2) - 3./(2*x); 36 | lp(x<0) = -inf; dlp(x<0) = 0; -------------------------------------------------------------------------------- /matlab/ext/gpml/prior/priorLaplace.m: -------------------------------------------------------------------------------- 1 | function [lp,dlp] = priorLaplace(mu,s2,x) 2 | 3 | % Univariate Laplacian hyperparameter prior distribution. 4 | % Compute log-likelihood and its derivative or draw a random sample. 5 | % The prior distribution is parameterized as: 6 | % 7 | % p(x) = exp(-abs(x-mu)/b)/(2*b), where b = sqrt(s2/2), 8 | % 9 | % mu(1x1) is the mean parameter, s2(1x1) is the variance parameter and 10 | % x(1xN) contains query hyperparameters for prior evaluation. 11 | % 12 | % For more help on design of priors, try "help priorDistributions". 13 | % 14 | % Copyright (c) by Roman Garnett and Hannes Nickisch, 2014-09-09. 15 | % 16 | % See also PRIORDISTRIBUTIONS.M. 17 | 18 | if nargin<3 % return a sample 19 | u = rand-1/2; lp = mu - sqrt(s2/2)*sign(u)*log(1-2*abs(u)); return 20 | end 21 | 22 | b = sqrt(s2/2); 23 | lp = -abs(x-mu)/b - log(2*b); 24 | dlp = -sign(x-mu)/b; -------------------------------------------------------------------------------- /matlab/ext/gpml/prior/priorLogNormal.m: -------------------------------------------------------------------------------- 1 | function [lp,dlp]=priorLogNormal(mu,s2,x) 2 | 3 | % Univariate Log-normal hyperparameter prior distribution. 4 | % Compute log-likelihood and its derivative or draw a random sample. 5 | % The prior distribution is parameterized as: 6 | % 7 | % p(x) = exp(-(log(x)-mu)^2/(2*s2)) / (sqrt(2*pi*s2)*x) 8 | % 9 | % where mu(1x1) is the log scale parameter, s2(1x1) is the shape parameter 10 | % and x(1xN) contains query hyperparameters for prior evaluation. 11 | % 12 | % For more help on design of priors, try "help priorDistributions". 13 | % 14 | % Copyright (c) by Roman Garnett and Hannes Nickisch, 2014-09-08. 15 | % 16 | % See also PRIORDISTRIBUTIONS.M. 17 | 18 | if nargin<2, error('mu and s2 parameters need to be provided'), end 19 | if ~(isscalar(mu)&&isscalar(s2)) 20 | error('mu and s2 parameters need to be scalars'), end 21 | if nargin<3, lp = exp(sqrt(s2)*randn+mu); return, end % return a sample 22 | 23 | lx = log(x); 24 | lp = -(lx-mu).^2/(2*s2) - log(2*pi*s2)/2 - lx; 25 | dlp = -(lx-mu+s2)./(x*s2); 26 | lp(x<0) = -inf; dlp(x<0) = 0; -------------------------------------------------------------------------------- /matlab/ext/gpml/prior/priorMix.m: -------------------------------------------------------------------------------- 1 | function [lp,dlp] = priorMix(w,priors,x) 2 | 3 | % Mixture of Univariate or Multivariate hyperparameter prior distributions. 4 | % Compute log-likelihood and its derivative or draw a random sample. 5 | % The prior distribution is parameterized as: 6 | % 7 | % p(x) = sum_i w_i p_i(x), 8 | % 9 | % w(bx1) is the mixture weight vector (nonnegative, normalised to add up to 1), 10 | % priors(bx1) is a cell array containing the priors to be mixed and x(1xN) 11 | % contains query hyperparameters for prior evaluation. 12 | % 13 | % For more help on design of priors, try "help priorDistributions". 14 | % 15 | % Copyright (c) by Roman Garnett and Hannes Nickisch, 2014-09-08. 16 | % 17 | % See also PRIORDISTRIBUTIONS.M. 18 | 19 | if nargin<2, error('specification of w and priors required'), end 20 | n = numel(w); w = w(:); 21 | if abs(sum(w)-1)>1e-9, error('w needs to sum up to 1'), end 22 | if any(w<0), error('w needs to be nonnegative'), end 23 | for i=1:n, if ~iscell(priors{i}), priors{i} = {priors{i}}; end, end % sample 24 | if nargin<3, i = 1+nnz(rand>cumsum(w)); lp = feval(priors{i}{:}); return, end 25 | 26 | lpi = zeros(numel(x),n); dlpi = zeros(numel(x),n); 27 | for i=1:n, [lpi(:,i),dlpi(:,i)] = feval(priors{i}{:},x(:)); end 28 | 29 | mx = max(lpi,[],2); lp = log(exp(lpi-mx*ones(1,n))*w) + mx; 30 | pi = exp(lpi); dlp = ((pi.*dlpi)*w)./(pi*w); -------------------------------------------------------------------------------- /matlab/ext/gpml/prior/priorSameMulti.m: -------------------------------------------------------------------------------- 1 | function [lp,dlp] = priorSameMulti(x) 2 | 3 | % Dummy hyperparameter prior distribution to have a group of hyperparameter 4 | % share the same value. 5 | % The function is not intended to be evaluated but exists merely to make 6 | % the user aware of the possibility to use it. The function is equivalent 7 | % to priorEqualMulti. 8 | % 9 | % For more help on design of priors, try "help priorDistributions". 10 | % 11 | % Copyright (c) by Hannes Nickisch, 2016-10-26. 12 | % 13 | % See also PRIORDISTRIBUTIONS.M. 14 | 15 | error('The function is not intended to be called directly.') -------------------------------------------------------------------------------- /matlab/ext/gpml/prior/priorSmoothBox1.m: -------------------------------------------------------------------------------- 1 | function [lp,dlp] = priorSmoothBox1(a,b,eta,x) 2 | 3 | % Univariate smoothed box prior distribution with linear decay in the log domain 4 | % and infinite support over the whole real axis. 5 | % Compute log-likelihood and its derivative or draw a random sample. 6 | % The prior distribution is parameterized as: 7 | % 8 | % p(x) = 1/w*sigmoid(eta*(x-a))*(1-sigmoid(eta*(x-b))), 9 | % where w = abs(b-a) and sigmoid(z) = 1/(1+exp(-z)) 10 | % 11 | % a(1x1) is the lower bound parameter, b(1x1) is the upper bound parameter, 12 | % eta(1x1)>0 is the slope parameter and x(1xN) contains query hyperparameters 13 | % for prior evaluation. Larger values of eta make the distribution more 14 | % box-like. 15 | % 16 | % The distribution p(x) has mean and variance given by: 17 | % mu = (a+b)/2 and s2 = w^2/(1-exp(-2*g))*(1+(pi/g)^2)/12, g = eta*w/2. 18 | % 19 | % /------------\ 20 | % / \ 21 | % -------- | | --------> x 22 | % a b 23 | % 24 | % For more help on design of priors, try "help priorDistributions". 25 | % 26 | % Copyright (c) by Jose Vallet and Hannes Nickisch, 2015-03-27. 27 | % 28 | % See also PRIORDISTRIBUTIONS.M. 29 | 30 | if nargin<3, error('a, b and eta parameters need to be provided'), end 31 | if b<=a, error('b must be greater than a.'), end 32 | if ~(isscalar(a)&&isscalar(b)&&isscalar(eta)) 33 | error('a, b and eta parameters need to be scalar values') 34 | end 35 | 36 | if nargin<4 % inverse sampling 37 | u = exp((b-a)*eta*rand()); 38 | lp = log((u-1)/(exp(-eta*a)-u*exp(-eta*b)))/eta; 39 | return 40 | end 41 | 42 | [lpa,dlpa] = logr(eta*(x-a)); [lpb,dlpb] = logr(-eta*(x-b)); 43 | lp = lpa + lpb - log(b-a) + log(1-exp((a-b)*eta)); 44 | dlp = eta*(dlpa - dlpb); 45 | 46 | % r(z) = 1/(1+exp(-z)), log(r(z)) = -log(1+exp(-z)) 47 | function [lr,dlr] = logr(z) 48 | lr = z; ok = -35 2 is the degrees of freedom parameter and x(1xN) contains query 12 | % hyperparameters for prior evaluation. 13 | % 14 | % For more help on design of priors, try "help priorDistributions". 15 | % 16 | % Copyright (c) by Roman Garnett and Hannes Nickisch, 2014-10-16. 17 | % 18 | % See also PRIORDISTRIBUTIONS.M. 19 | 20 | if nargin<3, error('mu, s2 and nu parameters need to be provided'), end 21 | if ~(isscalar(mu)&&isscalar(s2)&&isscalar(nu)) 22 | error('mu, s2 and nu parameters need to be scalars') 23 | end 24 | if nargin<4, lp = mu + sqrt(s2*(nu-2)/priorGamma(nu/2,2))*randn; return, end 25 | 26 | lZ = gammaln((nu+1)/2)-gammaln(nu/2)-log(pi*(nu-2)*s2)/2; 27 | lp = -(nu+1)/2*log(1+(x-mu).^2/(s2*(nu-2))) + lZ; 28 | dlp = (nu+1)*(mu-x)./(mu^2-2*mu*x+s2*(nu-2)+x.^2); -------------------------------------------------------------------------------- /matlab/ext/gpml/prior/priorTransform.m: -------------------------------------------------------------------------------- 1 | function [lp,dlp] = priorTransform(g,dg,ig,prior,x) 2 | 3 | % Transformed univariate hyperparameter prior distribution. 4 | % Compute log-likelihood and its derivative or draw a random sample. 5 | % The prior distribution is parameterized as: 6 | % 7 | % prior(y), where y = g(x), 8 | % 9 | % g is the transformation function (monotonically increasing and invertable), 10 | % dg is its derivative, ig is its inverse, prior is the distribution to be 11 | % transformed and x(1xN) contains query hyperparameters for prior evaluation. 12 | % Note that p(x) = prior(g(x)) is not necessarily normalised w.r.t. x. 13 | % 14 | % For example, to put a nonnegative gamma prior on the lenthscale 15 | % parameter ell of covSEiso, one can use 16 | % {@priorTransform,@exp,@exp,@log,{@priorGamma,k,t}} 17 | % since ell is represented in the log domain. 18 | % 19 | % For more help on design of priors, try "help priorDistributions". 20 | % 21 | % Copyright (c) by Roman Garnett and Hannes Nickisch, 2014-09-08. 22 | % 23 | % See also PRIORDISTRIBUTIONS.M. 24 | 25 | if nargin<4, error('g, dg, ig and prior parameters need to be provided'), end 26 | if nargin<5, lp = ig(feval(prior{:})); return, end % apply inverse sampling 27 | 28 | if ~iscell(prior), prior = {prior}; end 29 | [lp,dlp] = feval(prior{:},g(x)); dlp = dlp.*dg(x); -------------------------------------------------------------------------------- /matlab/ext/gpml/prior/priorWeibull.m: -------------------------------------------------------------------------------- 1 | function [lp,dlp] = priorWeibull(lam,k,x) 2 | 3 | % Univariate Weibull hyperparameter prior distribution. 4 | % Compute log-likelihood and its derivative or draw a random sample. 5 | % The prior distribution is parameterized as: 6 | % 7 | % p(x) = (k/lam) * (x/lam)^(k-1) * exp(-(x/lam)^k) 8 | % 9 | % where lam(1x1) is the scale parameter, k(1x1) is the scale parameter 10 | % and x(1xN) contains query hyperparameters for prior evaluation. 11 | % 12 | % For more help on design of priors, try "help priorDistributions". 13 | % 14 | % Copyright (c) by Roman Garnett and Hannes Nickisch, 2014-09-08. 15 | % 16 | % See also PRIORDISTRIBUTIONS.M. 17 | 18 | if nargin<2, error('lam and k parameters need to be provided'), end 19 | if ~(isscalar(lam)&&isscalar(k)) 20 | error('lam and k parameters need to be scalars'), end 21 | if nargin<3,lp = lam*(-log(rand))^(1/k); return, end % return a sample 22 | 23 | lp = log(k/lam) + (k-1)*log(x/lam) - (x/lam).^k; 24 | dlp = (k-1)./x - (k/lam)*(x/lam).^(k-1); 25 | lp(x<0) = -inf; dlp(x<0) = 0; -------------------------------------------------------------------------------- /matlab/ext/gpml/startup.m: -------------------------------------------------------------------------------- 1 | % startup script to make Octave/Matlab aware of the GPML package 2 | % 3 | % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch 2016-10-16. 4 | 5 | disp(['executing gpml startup script...']); 6 | 7 | OCT = exist('OCTAVE_VERSION') ~= 0; % check if we run Matlab or Octave 8 | 9 | me = mfilename; % what is my filename 10 | mydir = which(me); mydir = mydir(1:end-2-numel(me)); % where am I located 11 | if OCT && numel(mydir)==2 12 | if strcmp(mydir,'./'), mydir = [pwd,mydir(2:end)]; end 13 | end % OCTAVE 3.0.x relative, MATLAB and newer have absolute path 14 | 15 | addpath(mydir(1:end-1)) 16 | addpath([mydir,'cov']) 17 | addpath([mydir,'doc']) 18 | addpath([mydir,'inf']) 19 | addpath([mydir,'lik']) 20 | addpath([mydir,'mean']) 21 | addpath([mydir,'prior']) 22 | addpath([mydir,'util']) 23 | 24 | clear me mydir 25 | -------------------------------------------------------------------------------- /matlab/ext/gpml/util/any2vec.m: -------------------------------------------------------------------------------- 1 | % Extract the numerical values from "s" into the column vector "v". The 2 | % variable "s" can be of any type, including struct and cell array. 3 | % Non-numerical elements are ignored. See also the reverse vec2any.m. 4 | 5 | function v = any2vec(s) 6 | v = []; 7 | if isnumeric(s) 8 | v = s(:); % numeric values are recast to column vector 9 | elseif isstruct(s) 10 | v = any2vec(struct2cell(orderfields(s)));% alphabetize, conv to cell, recurse 11 | elseif iscell(s) 12 | for i = 1:numel(s) % cell array elements are handled sequentially 13 | v = [v; any2vec(s{i})]; 14 | end 15 | end % other types are ignored 16 | -------------------------------------------------------------------------------- /matlab/ext/gpml/util/covFITC.m: -------------------------------------------------------------------------------- 1 | % Wrapper to apxSparse to remain backwards compatible. 2 | % 3 | % Note that covFITC is not a valid covariance function on its own right. 4 | % 5 | % Copyright (c) by Ed Snelson, Carl Edward Rasmussen 6 | % and Hannes Nickisch, 2016-08-25. 7 | 8 | function varargout = covFITC(varargin) 9 | varargout = cell(nargout, 1); [varargout{:}] = apxSparse(varargin{:}); -------------------------------------------------------------------------------- /matlab/ext/gpml/util/covGrid.m: -------------------------------------------------------------------------------- 1 | % Wrapper to apxGrid to remain backwards compatible. 2 | % 3 | % Note that covGrid is not a valid covariance function on its own right. 4 | % 5 | % Copyright (c) by Hannes Nickisch and Andrew Wilson 2016-08-25. 6 | 7 | function varargout = covGrid(varargin) 8 | varargout = cell(nargout, 1); [varargout{:}] = apxGrid(varargin{:}); 9 | -------------------------------------------------------------------------------- /matlab/ext/gpml/util/elsympol.m: -------------------------------------------------------------------------------- 1 | % Evaluate the order R elementary symmetric polynomials using Newton's identity, 2 | % the Newton-Girard formulae: http://en.wikipedia.org/wiki/Newton's_identities 3 | % 4 | % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch, 2010-01-10. 5 | % speedup contributed by Truong X. Nghiem, 2016-01-20. 6 | 7 | function E = elsympol(Z,R) 8 | sz = size(Z); % evaluate 'power sums' of the individual terms in Z 9 | E = zeros([sz(1:2),R+1]); % E(:,:,r+1) yields polynomial r 10 | % fast and efficient version of: for r=1:R, P(:,:,r) = sum(Z.^r,3); end 11 | Zr = Z; P(:,:,1) = sum(Zr,3); for r=2:R, Zr = Zr.*Z; P(:,:,r) = sum(Zr,3); end 12 | E(:,:,1) = ones(sz(1:2)); if R==0, return, end % init recursion 13 | E(:,:,2) = P(:,:,1); if R==1, return, end % init recursion 14 | for r=2:R 15 | E(:,:,r+1) = P(:,:,1).*E(:,:,r)/r; % i=1 is simpler than the rest 16 | for i=2:r 17 | E(:,:,r+1) = E(:,:,r+1) + P(:,:,i).*E(:,:,r+1-i)*(-1)^(i-1)/r; 18 | end 19 | end -------------------------------------------------------------------------------- /matlab/ext/gpml/util/glm_invlink_exp.m: -------------------------------------------------------------------------------- 1 | % Compute the log intensity for the inverse link function g(f) = exp(f). 2 | % Output range: 0 <= g(f). 3 | % 4 | % The function can be used in GLM likelihoods such as likPoisson, likGamma, and 5 | % likInvGauss. 6 | % 7 | % Copyright (c) by Hannes Nickisch, 2016-10-04. 8 | 9 | function [lg,dlg,d2lg,d3lg] = glm_invlink_exp(f) 10 | lg = f; 11 | if nargout>1 12 | dlg = ones(size(f)); 13 | if nargout>2 14 | d2lg = zeros(size(f)); 15 | if nargout>2 16 | d3lg = zeros(size(f)); 17 | end 18 | end 19 | end -------------------------------------------------------------------------------- /matlab/ext/gpml/util/glm_invlink_expexp.m: -------------------------------------------------------------------------------- 1 | % Compute the log intensity for the inverse link function g(f) = exp(-exp(-f)). 2 | % Output range: 0 <= g(f) <= 1. 3 | % 4 | % The function can be used in GLM likelihoods such as likBeta. 5 | % 6 | % Copyright (c) by Hannes Nickisch, 2016-10-04. 7 | 8 | function [lg,dlg,d2lg,d3lg] = glm_invlink_expexp(f) 9 | lg = -exp(-f); 10 | if nargout>1 11 | dlg = -lg; 12 | if nargout>2 13 | d2lg = lg; 14 | if nargout>2 15 | d3lg = -lg; 16 | end 17 | end 18 | end -------------------------------------------------------------------------------- /matlab/ext/gpml/util/glm_invlink_logistic.m: -------------------------------------------------------------------------------- 1 | % Compute the log intensity for the inverse link function g(f) = log(1+exp(f))). 2 | % Output range: 0 <= g(f). 3 | % 4 | % The function can be used in GLM likelihoods such as likPoisson, likGamma, and 5 | % likInvGauss. 6 | % 7 | % Copyright (c) by Hannes Nickisch, 2016-10-04. 8 | 9 | function [lg,dlg,d2lg,d3lg] = glm_invlink_logistic(f) 10 | l1pef = max(0,f) + log(1+exp(-abs(f))); % safely compute log(1+exp(f)) 11 | lg = log(l1pef); id = f<-15; lg(id) = f(id); % fix log(log(1+exp(f))) limits 12 | if nargout>1 13 | sm = 1./(1+exp(-f)); 14 | dlg = sm./l1pef; dlg(f<-15) = 1; 15 | if nargout>2 16 | sp = 1./(1+exp(f)); 17 | d2lg = dlg.*(sp-dlg); 18 | if nargout>2 19 | d3lg = d2lg.*(sp-2*dlg) - dlg.*sp.*sm; 20 | end 21 | end 22 | end -------------------------------------------------------------------------------- /matlab/ext/gpml/util/glm_invlink_logistic2.m: -------------------------------------------------------------------------------- 1 | % Compute the log intensity for the inverse link function (twice logistic) 2 | % g(f) = h(f*(1+a*h(f))), where is the logistic h(f) = log(1+exp(f))). 3 | % Output range: 0 <= g(f). 4 | % 5 | % The function can be used in GLM likelihoods such as likPoisson, likGamma, and 6 | % likInvGauss. 7 | % 8 | % See Seeger et al., Bayesian Intermittent Demand Forecasting for Large 9 | % Inventories, NIPS, 2016. 10 | % 11 | % Copyright (c) by Hannes Nickisch, 2016-10-04. 12 | 13 | function [lg,dlg,d2lg,d3lg] = glm_invlink_logistic2(a,f) 14 | [lh,dlh,d2lh,d3lh] = glm_invlink_logistic(f); h = exp(lh); 15 | ft = f + a*f.*h; 16 | dft = 1 + a*h.*(1 + f.*dlh); w = a*h.*(dlh.^2 + d2lh); 17 | d2ft = 2*a*h.*dlh + f.*w; 18 | d3ft = 3*w + a*f.*h.*(dlh.^3+3*d2lh.*dlh+d3lh); 19 | [lgt,dlgt,d2lgt,d3lgt] = glm_invlink_logistic(ft); 20 | lg = lgt; dlg = dlgt.*dft; 21 | d2lg = d2lgt.*dft.^2 + dlgt.*d2ft; 22 | d3lg = d3lgt.*dft.^3 + 3*d2lgt.*dft.*d2ft + dlgt.*d3ft; -------------------------------------------------------------------------------- /matlab/ext/gpml/util/glm_invlink_logit.m: -------------------------------------------------------------------------------- 1 | % Compute the log intensity for the inverse link function g(f) = 1/(1+exp(-f)). 2 | % Output range: 0 <= g(f) <= 1. 3 | % 4 | % The function can be used in GLM likelihoods such as likBeta. 5 | % 6 | % Copyright (c) by Hannes Nickisch, 2016-10-04. 7 | 8 | function varargout = glm_invlink_logit(f) 9 | varargout = cell(nargout, 1); % allocate the right number of output arguments 10 | [varargout{:}] = glm_invlink_logistic(f); 11 | if nargout>0 12 | elg = exp(varargout{1}); 13 | varargout{1} = min(f-elg,0); % upper bound g by 1 14 | if nargout>1 15 | dlg = varargout{2}; 16 | varargout{2} = 1 - elg.*dlg; 17 | if nargout>2 18 | d2lg = varargout{3}; 19 | varargout{3} = -elg.*(dlg.^2+d2lg); 20 | if nargout>3 21 | d3lg = varargout{4}; 22 | varargout{4} = -elg.*(dlg.^3+3*d2lg.*dlg+d3lg); 23 | end 24 | end 25 | end 26 | end -------------------------------------------------------------------------------- /matlab/ext/gpml/util/infExact.m: -------------------------------------------------------------------------------- 1 | % Wrapper to infGaussLik to remain backwards compatible. 2 | % 3 | % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch 2016-08-25. 4 | 5 | function varargout = infExact(varargin) 6 | varargout = cell(nargout, 1); [varargout{:}] = infGaussLik(varargin{:}); -------------------------------------------------------------------------------- /matlab/ext/gpml/util/infFITC.m: -------------------------------------------------------------------------------- 1 | % Wrapper to infGaussLik to remain backwards compatible. 2 | % 3 | % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch 2016-08-25. 4 | 5 | function varargout = infFITC(varargin) 6 | varargout = cell(nargout, 1); [varargout{:}] = infGaussLik(varargin{:}); -------------------------------------------------------------------------------- /matlab/ext/gpml/util/infFITC_Laplace.m: -------------------------------------------------------------------------------- 1 | % Wrapper to infLaplace to remain backwards compatible. 2 | % 3 | % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch 2016-10-13. 4 | 5 | function varargout = infFITC_Laplace(varargin) 6 | varargout = cell(nargout, 1); [varargout{:}] = infLaplace(varargin{:}); -------------------------------------------------------------------------------- /matlab/ext/gpml/util/lbfgsb/matlabexception.cpp: -------------------------------------------------------------------------------- 1 | #include "matlabexception.h" 2 | 3 | // Function definitions for class MatlabException. 4 | // ----------------------------------------------------------------- 5 | MatlabException::MatlabException (const char* message) throw() 6 | : exception() { 7 | this->message = message; 8 | } 9 | 10 | MatlabException::MatlabException (const MatlabException& source) throw() 11 | : exception() { 12 | message = source.message; 13 | } 14 | 15 | MatlabException& MatlabException::operator= (const MatlabException& source) 16 | { 17 | message = source.message; 18 | return *this; 19 | } 20 | -------------------------------------------------------------------------------- /matlab/ext/gpml/util/lbfgsb/matlabexception.h: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDE_MATLABEXCEPTION 2 | #define INCLUDE_MATLABEXCEPTION 3 | 4 | #include 5 | 6 | // Class MatlabException 7 | // ----------------------------------------------------------------- 8 | // This class just makes it easier for me to throw exceptions. Its 9 | // functionality really has nothing to do with MATLAB. 10 | class MatlabException : public std::exception { 11 | public: 12 | MatlabException (const char* message) throw(); 13 | ~MatlabException() throw() { }; 14 | 15 | // The copy constructor makes a shallow copy. 16 | MatlabException (const MatlabException& source) throw(); 17 | 18 | // The copy assignment operator makes a shallow copy as well. 19 | MatlabException& operator= (const MatlabException& source); 20 | 21 | // Return the message string. 22 | virtual const char* what () const throw() { return message; }; 23 | 24 | private: 25 | const char* message; // The error message. 26 | }; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /matlab/ext/gpml/util/lbfgsb/matlabmatrix.cpp: -------------------------------------------------------------------------------- 1 | #include "matlabmatrix.h" 2 | #include "matlabexception.h" 3 | 4 | // Function definitions. 5 | // ----------------------------------------------------------------- 6 | double* getMatlabMatrixDouble (const mxArray* ptr) { 7 | if (mxGetNumberOfDimensions(ptr) != 2) 8 | throw MatlabException("Matlab array must be a matrix"); 9 | if (!mxIsDouble(ptr)) 10 | throw MatlabException("Matlab array must be of type double"); 11 | return mxGetPr(ptr); 12 | } 13 | 14 | double* createMatlabMatrixDouble (mxArray*& ptr, int height, int width) { 15 | ptr = mxCreateDoubleMatrix(height,width,mxREAL); 16 | return mxGetPr(ptr); 17 | } 18 | 19 | // Function definitions for class Matrix. 20 | // ----------------------------------------------------------------- 21 | Matrix::Matrix (int height, int width) 22 | : Array(height*width) { 23 | h = height; 24 | w = width; 25 | } 26 | 27 | Matrix::Matrix (double* data, int height, int width) 28 | : Array(data,height*width) { 29 | h = height; 30 | w = width; 31 | } 32 | 33 | Matrix::Matrix (const mxArray* ptr) 34 | : Array(getMatlabMatrixDouble(ptr),mxGetNumberOfElements(ptr)) { 35 | h = mxGetM(ptr); 36 | w = mxGetN(ptr); 37 | } 38 | 39 | Matrix::Matrix (mxArray*& ptr, int height, int width) 40 | : Array(createMatlabMatrixDouble(ptr,height,width), 41 | height*width) { 42 | h = height; 43 | w = width; 44 | } 45 | 46 | Matrix::Matrix (const Matrix& source) 47 | : Array(source) { 48 | h = source.h; 49 | w = source.w; 50 | } 51 | 52 | Matrix& Matrix::operator= (const Matrix& source) { 53 | inject(source); 54 | return *this; 55 | } 56 | 57 | bool Matrix::operator== (const Matrix& X) const { 58 | return (h == X.h) && (w == X.w); 59 | } 60 | 61 | double& Matrix::entry (int r, int c) { 62 | return elems[h*c + r]; 63 | } 64 | 65 | double Matrix::entry (int r, int c) const { 66 | return elems[h*c + r]; 67 | } 68 | -------------------------------------------------------------------------------- /matlab/ext/gpml/util/lbfgsb/matlabscalar.cpp: -------------------------------------------------------------------------------- 1 | #include "matlabscalar.h" 2 | #include "matlabexception.h" 3 | 4 | // Function definitions. 5 | // ----------------------------------------------------------------- 6 | double& getMatlabScalar (const mxArray* ptr) { 7 | if (!mxIsDouble(ptr)) 8 | throw MatlabException("Matlab array must be of type double"); 9 | if (mxGetNumberOfElements(ptr) != 1) 10 | throw MatlabException("The Matlab array must be a scalar"); 11 | return *mxGetPr(ptr); 12 | } 13 | 14 | double& createMatlabScalar (mxArray*& ptr) { 15 | ptr = mxCreateDoubleScalar(0); 16 | return *mxGetPr(ptr); 17 | } 18 | 19 | // Function definitions for class MatlabScalar. 20 | // --------------------------------------------------------------- 21 | MatlabScalar::MatlabScalar (const mxArray* ptr) 22 | : x(getMatlabScalar(ptr)) { } 23 | 24 | MatlabScalar::MatlabScalar (mxArray*& ptr, double value) 25 | : x(createMatlabScalar(ptr)) { 26 | x = value; 27 | } 28 | 29 | MatlabScalar::MatlabScalar (MatlabScalar& source) 30 | : x(source.x) { } 31 | 32 | MatlabScalar& MatlabScalar::operator= (double value) { 33 | x = value; 34 | return *this; 35 | } 36 | -------------------------------------------------------------------------------- /matlab/ext/gpml/util/lbfgsb/matlabscalar.h: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDE_MATLABSCALAR 2 | #define INCLUDE_MATLABSCALAR 3 | 4 | #include "mex.h" 5 | 6 | // Class MatlabScalar 7 | // ----------------------------------------------------------------- 8 | // The main appeal of this class is that one can create a scalar 9 | // object that accesses a MATLAB array. 10 | // 11 | // Note that the copy assignment operator is not valid for this class 12 | // because we cannot reassign a reference. 13 | class MatlabScalar { 14 | public: 15 | 16 | // This constructor accepts as input a pointer to a Matlab array 17 | // which must be a scalar in double precision. 18 | explicit MatlabScalar (const mxArray* ptr); 19 | 20 | // This constructor creates a new Matlab array which is a scalar 21 | // in double precision. 22 | MatlabScalar (mxArray*& ptr, double value); 23 | 24 | // The copy constructor. 25 | MatlabScalar (MatlabScalar& source); 26 | 27 | // The destructor. 28 | ~MatlabScalar() { }; 29 | 30 | // Access the value of the scalar. 31 | operator const double () const { return x; }; 32 | 33 | // Assign the value of the scalar. 34 | MatlabScalar& operator= (double value); 35 | 36 | protected: 37 | double& x; 38 | 39 | // The copy assignment operator is kept protected because it is 40 | // invalid. 41 | MatlabScalar& operator= (const MatlabScalar& source) { return *this; }; 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /matlab/ext/gpml/util/lbfgsb/matlabstring.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "matlabstring.h" 3 | #include "matlabexception.h" 4 | 5 | // Function definitions. 6 | // ----------------------------------------------------------------- 7 | char* copystring (const char* source) { 8 | int n = strlen(source); // The length of the string. 9 | char* dest = new char[n+1]; // The return value. 10 | strcpy(dest,source); 11 | return dest; 12 | } 13 | 14 | // Function definitions for class MatlabString. 15 | // ----------------------------------------------------------------- 16 | MatlabString::MatlabString (const mxArray* ptr) { 17 | s = 0; 18 | 19 | // Check to make sure the Matlab array is a string. 20 | if (!mxIsChar(ptr)) 21 | throw MatlabException("Matlab array must be a string (of type CHAR)"); 22 | 23 | // Get the string passed as a Matlab array. 24 | s = mxArrayToString(ptr); 25 | if (s == 0) 26 | throw MatlabException("Unable to obtain string from Matlab array"); 27 | } 28 | 29 | MatlabString::MatlabString (const MatlabString& source) { 30 | s = 0; 31 | 32 | // Copy the source string. 33 | s = copystring(source.s); 34 | } 35 | 36 | MatlabString::~MatlabString() { 37 | if (s) 38 | mxFree(s); 39 | } 40 | 41 | -------------------------------------------------------------------------------- /matlab/ext/gpml/util/lbfgsb/matlabstring.h: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDE_MATLABSTRING 2 | #define INCLUDE_MATLABSTRING 3 | 4 | #include "mex.h" 5 | #include 6 | 7 | // Function declarations. 8 | // ----------------------------------------------------------------- 9 | // Copy a C-style string (i.e. a null-terminated character array). 10 | char* copystring (const char* source); 11 | 12 | // Class MatlabString. 13 | // ----------------------------------------------------------------- 14 | // This class encapsulates read-only access to a MATLAB character 15 | // array. 16 | class MatlabString { 17 | public: 18 | 19 | // The constructor accepts as input a pointer to a Matlab array, 20 | // which must be a valid string (array of type CHAR). 21 | explicit MatlabString (const mxArray* ptr); 22 | 23 | // The copy constructor makes a full copy of the source string. 24 | MatlabString (const MatlabString& source); 25 | 26 | // The destructor. 27 | ~MatlabString(); 28 | 29 | // Conversion operator for null-terminated string. 30 | operator const char* () const { return s; }; 31 | 32 | protected: 33 | char* s; // The null-terminated string. 34 | 35 | // The copy assignment operator is not proper, thus remains 36 | // protected. 37 | MatlabString& operator= (const MatlabString& source) 38 | { return *this; }; 39 | }; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /matlab/ext/gpml/util/lbfgsb/timer.f: -------------------------------------------------------------------------------- 1 | c 2 | c L-BFGS-B is released under the “New BSD License” (aka “Modified BSD 3 | c License” or “3-clause license”) 4 | c Please read attached file License.txt 5 | c 6 | subroutine timer(ttime) 7 | double precision ttime 8 | c 9 | real temp 10 | c 11 | c This routine computes cpu time in double precision; it makes use of 12 | c the intrinsic f90 cpu_time therefore a conversion type is 13 | c needed. 14 | c 15 | c J.L Morales Departamento de Matematicas, 16 | c Instituto Tecnologico Autonomo de Mexico 17 | c Mexico D.F. 18 | c 19 | c J.L Nocedal Department of Electrical Engineering and 20 | c Computer Science. 21 | c Northwestern University. Evanston, IL. USA 22 | c 23 | c January 21, 2011 24 | c 25 | temp = sngl(ttime) 26 | call cpu_time(temp) 27 | ttime = dble(temp) 28 | 29 | return 30 | 31 | end 32 | 33 | -------------------------------------------------------------------------------- /matlab/ext/gpml/util/lik_epquad.m: -------------------------------------------------------------------------------- 1 | % Compute infEP part of a likelihood function based on the infLaplace part using 2 | % Gaussian-Hermite quadrature. 3 | % 4 | % The function is used in GLM likelihoods such as likPoisson, likGamma, likBeta 5 | % and likInvGauss. 6 | % 7 | % Copyright (c) by Hannes Nickisch, 2013-10-16. 8 | 9 | function varargout = lik_epquad(lik,hyp,y,mu,s2) 10 | n = max([length(y),length(mu),length(s2)]); on = ones(n,1); 11 | N = 20; [t,w] = gauher(N); oN = ones(1,N); lw = ones(n,1)*log(w'); 12 | y = y(:).*on; mu = mu(:).*on; sig = sqrt(s2(:)).*on; % vectors only 13 | [lpi,dlpi,d2lpi] = feval(lik{:},hyp,y*oN,sig*t'+mu*oN,[],'infLaplace'); 14 | lZ = s(lpi+lw); 15 | dlZ = {}; d2lZ = {}; 16 | if nargout>1 % 1st derivative wrt mean 17 | % Using p*dlp=dp, p=exp(lp), Z=sum_i wi*pi, dZ = sum_i wi*dpi we obtain 18 | % dlZ = sum_i exp(lpi-lZ+lwi)*dlpi = sum_i ai*dlpi. 19 | a = exp(lpi - lZ*oN + lw); 20 | dlZ = sum(a.*dlpi,2); 21 | if nargout>2 % 2nd derivative wrt mean 22 | % Using d2lZ=(d2Z*Z-dZ^2)/Z^2 <=> d2Z=Z*(d2lZ+dlZ^2) and 23 | % d2Z = sum_i wi*d2Zi, we get d2lZ = sum_i ai*(d2lpi+dlpi^2)-dlZ^2. 24 | d2lZ = sum(a.*(d2lpi+dlpi.*dlpi),2) - dlZ.*dlZ; 25 | end 26 | end 27 | varargout = {lZ,dlZ,d2lZ}; 28 | 29 | % computes y = log( sum(exp(x),2) ), the softmax in a numerically safe way by 30 | % subtracting the row maximum to avoid cancelation after taking the exp 31 | % the sum is done along the rows 32 | function [y,x] = s(logx) 33 | N = size(logx,2); max_logx = max(logx,[],2); 34 | % we have all values in the log domain, and want to calculate a sum 35 | x = exp(logx-max_logx*ones(1,N)); 36 | y = log(sum(x,2)) + max_logx; -------------------------------------------------------------------------------- /matlab/ext/gpml/util/logsumexp2.m: -------------------------------------------------------------------------------- 1 | % Compute y = log( sum(exp(x),2) ), the softmax in a numerically safe way by 2 | % subtracting the row maximum to avoid cancelation after taking the exp 3 | % the sum is done along the rows. 4 | % 5 | % Copyright (c) by Hannes Nickisch, 2013-10-16. 6 | 7 | function [y,x] = logsumexp2(logx) 8 | N = size(logx,2); max_logx = max(logx,[],2); 9 | % we have all values in the log domain, and want to calculate a sum 10 | x = exp(logx-max_logx*ones(1,N)); 11 | y = log(sum(x,2)) + max_logx; -------------------------------------------------------------------------------- /matlab/ext/gpml/util/minfunc/License: -------------------------------------------------------------------------------- 1 | The software on this webpage is distributed under the FreeBSD-style license below. 2 | 3 | Although it is not required, I would also appreciate that any re-distribution of the 4 | software contains a link to the original webpage. For example, the webpage for the 5 | 'minFunc' software is: 6 | http://www.cs.ubc.ca/~schmidtm/Software/minFunc.html 7 | 8 | ======================================================================================= 9 | 10 | Copyright 2005-2015 Mark Schmidt. All rights reserved. 11 | 12 | Redistribution and use in source and binary forms, with or without modification, are 13 | permitted provided that the following conditions are met: 14 | 15 | 1. Redistributions of source code must retain the above copyright notice, this list of 16 | conditions and the following disclaimer. 17 | 18 | 2. Redistributions in binary form must reproduce the above copyright notice, this list 19 | of conditions and the following disclaimer in the documentation and/or other materials 20 | provided with the distribution. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED 23 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 24 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR 25 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 28 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 30 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /matlab/ext/gpml/util/minfunc/compiled/lbfgsAddC.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MethodsOfMachineLearning/entropy-search/3f968b190670ab23e7a99fee6ef574bbc80c1656/matlab/ext/gpml/util/minfunc/compiled/lbfgsAddC.mexa64 -------------------------------------------------------------------------------- /matlab/ext/gpml/util/minfunc/compiled/lbfgsAddC.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MethodsOfMachineLearning/entropy-search/3f968b190670ab23e7a99fee6ef574bbc80c1656/matlab/ext/gpml/util/minfunc/compiled/lbfgsAddC.mexglx -------------------------------------------------------------------------------- /matlab/ext/gpml/util/minfunc/compiled/lbfgsAddC.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MethodsOfMachineLearning/entropy-search/3f968b190670ab23e7a99fee6ef574bbc80c1656/matlab/ext/gpml/util/minfunc/compiled/lbfgsAddC.mexmaci64 -------------------------------------------------------------------------------- /matlab/ext/gpml/util/minfunc/compiled/lbfgsAddC.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MethodsOfMachineLearning/entropy-search/3f968b190670ab23e7a99fee6ef574bbc80c1656/matlab/ext/gpml/util/minfunc/compiled/lbfgsAddC.mexw64 -------------------------------------------------------------------------------- /matlab/ext/gpml/util/minfunc/compiled/lbfgsC.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MethodsOfMachineLearning/entropy-search/3f968b190670ab23e7a99fee6ef574bbc80c1656/matlab/ext/gpml/util/minfunc/compiled/lbfgsC.mexa64 -------------------------------------------------------------------------------- /matlab/ext/gpml/util/minfunc/compiled/lbfgsC.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MethodsOfMachineLearning/entropy-search/3f968b190670ab23e7a99fee6ef574bbc80c1656/matlab/ext/gpml/util/minfunc/compiled/lbfgsC.mexglx -------------------------------------------------------------------------------- /matlab/ext/gpml/util/minfunc/compiled/lbfgsC.mexmac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MethodsOfMachineLearning/entropy-search/3f968b190670ab23e7a99fee6ef574bbc80c1656/matlab/ext/gpml/util/minfunc/compiled/lbfgsC.mexmac -------------------------------------------------------------------------------- /matlab/ext/gpml/util/minfunc/compiled/lbfgsC.mexmaci: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MethodsOfMachineLearning/entropy-search/3f968b190670ab23e7a99fee6ef574bbc80c1656/matlab/ext/gpml/util/minfunc/compiled/lbfgsC.mexmaci -------------------------------------------------------------------------------- /matlab/ext/gpml/util/minfunc/compiled/lbfgsC.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MethodsOfMachineLearning/entropy-search/3f968b190670ab23e7a99fee6ef574bbc80c1656/matlab/ext/gpml/util/minfunc/compiled/lbfgsC.mexmaci64 -------------------------------------------------------------------------------- /matlab/ext/gpml/util/minfunc/compiled/lbfgsC.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MethodsOfMachineLearning/entropy-search/3f968b190670ab23e7a99fee6ef574bbc80c1656/matlab/ext/gpml/util/minfunc/compiled/lbfgsC.mexw32 -------------------------------------------------------------------------------- /matlab/ext/gpml/util/minfunc/compiled/lbfgsC.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MethodsOfMachineLearning/entropy-search/3f968b190670ab23e7a99fee6ef574bbc80c1656/matlab/ext/gpml/util/minfunc/compiled/lbfgsC.mexw64 -------------------------------------------------------------------------------- /matlab/ext/gpml/util/minfunc/compiled/lbfgsProdC.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MethodsOfMachineLearning/entropy-search/3f968b190670ab23e7a99fee6ef574bbc80c1656/matlab/ext/gpml/util/minfunc/compiled/lbfgsProdC.mexa64 -------------------------------------------------------------------------------- /matlab/ext/gpml/util/minfunc/compiled/lbfgsProdC.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MethodsOfMachineLearning/entropy-search/3f968b190670ab23e7a99fee6ef574bbc80c1656/matlab/ext/gpml/util/minfunc/compiled/lbfgsProdC.mexglx -------------------------------------------------------------------------------- /matlab/ext/gpml/util/minfunc/compiled/lbfgsProdC.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MethodsOfMachineLearning/entropy-search/3f968b190670ab23e7a99fee6ef574bbc80c1656/matlab/ext/gpml/util/minfunc/compiled/lbfgsProdC.mexmaci64 -------------------------------------------------------------------------------- /matlab/ext/gpml/util/minfunc/compiled/lbfgsProdC.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MethodsOfMachineLearning/entropy-search/3f968b190670ab23e7a99fee6ef574bbc80c1656/matlab/ext/gpml/util/minfunc/compiled/lbfgsProdC.mexw64 -------------------------------------------------------------------------------- /matlab/ext/gpml/util/minfunc/compiled/mcholC.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MethodsOfMachineLearning/entropy-search/3f968b190670ab23e7a99fee6ef574bbc80c1656/matlab/ext/gpml/util/minfunc/compiled/mcholC.mexa64 -------------------------------------------------------------------------------- /matlab/ext/gpml/util/minfunc/compiled/mcholC.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MethodsOfMachineLearning/entropy-search/3f968b190670ab23e7a99fee6ef574bbc80c1656/matlab/ext/gpml/util/minfunc/compiled/mcholC.mexglx -------------------------------------------------------------------------------- /matlab/ext/gpml/util/minfunc/compiled/mcholC.mexmac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MethodsOfMachineLearning/entropy-search/3f968b190670ab23e7a99fee6ef574bbc80c1656/matlab/ext/gpml/util/minfunc/compiled/mcholC.mexmac -------------------------------------------------------------------------------- /matlab/ext/gpml/util/minfunc/compiled/mcholC.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MethodsOfMachineLearning/entropy-search/3f968b190670ab23e7a99fee6ef574bbc80c1656/matlab/ext/gpml/util/minfunc/compiled/mcholC.mexmaci64 -------------------------------------------------------------------------------- /matlab/ext/gpml/util/minfunc/compiled/mcholC.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MethodsOfMachineLearning/entropy-search/3f968b190670ab23e7a99fee6ef574bbc80c1656/matlab/ext/gpml/util/minfunc/compiled/mcholC.mexw32 -------------------------------------------------------------------------------- /matlab/ext/gpml/util/minfunc/compiled/mcholC.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MethodsOfMachineLearning/entropy-search/3f968b190670ab23e7a99fee6ef574bbc80c1656/matlab/ext/gpml/util/minfunc/compiled/mcholC.mexw64 -------------------------------------------------------------------------------- /matlab/ext/gpml/util/minfunc/dampedUpdate.m: -------------------------------------------------------------------------------- 1 | function [old_dirs,old_stps,Hdiag,Bcompact] = lbfgsUpdate(y,s,corrections,debug,old_dirs,old_stps,Hdiag) 2 | 3 | %B0 = eye(length(y))/Hdiag; 4 | S = old_dirs(:,2:end); 5 | Y = old_stps(:,2:end); 6 | k = size(Y,2); 7 | L = zeros(k); 8 | for j = 1:k 9 | for i = j+1:k 10 | L(i,j) = S(:,i)'*Y(:,j); 11 | end 12 | end 13 | D = diag(diag(S'*Y)); 14 | N = [S/Hdiag Y]; 15 | M = [S'*S/Hdiag L;L' -D]; 16 | 17 | ys = y'*s; 18 | Bs = s/Hdiag - N*(M\(N'*s)); % Product B*s 19 | sBs = s'*Bs; 20 | 21 | eta = .02; 22 | if ys < eta*sBs 23 | if debug 24 | fprintf('Damped Update\n'); 25 | end 26 | theta = min(max(0,((1-eta)*sBs)/(sBs - ys)),1); 27 | y = theta*y + (1-theta)*Bs; 28 | end 29 | 30 | 31 | numCorrections = size(old_dirs,2); 32 | if numCorrections < corrections 33 | % Full Update 34 | old_dirs(:,numCorrections+1) = s; 35 | old_stps(:,numCorrections+1) = y; 36 | else 37 | % Limited-Memory Update 38 | old_dirs = [old_dirs(:,2:corrections) s]; 39 | old_stps = [old_stps(:,2:corrections) y]; 40 | end 41 | 42 | % Update scale of initial Hessian approximation 43 | Hdiag = (y'*s)/(y'*y); -------------------------------------------------------------------------------- /matlab/ext/gpml/util/minfunc/isLegal.m: -------------------------------------------------------------------------------- 1 | function [legal] = isLegal(v) 2 | legal = sum(any(imag(v(:))))==0 & sum(isnan(v(:)))==0 & sum(isinf(v(:)))==0; -------------------------------------------------------------------------------- /matlab/ext/gpml/util/minfunc/lbfgs.m: -------------------------------------------------------------------------------- 1 | function [d] = lbfgs(g,s,y,Hdiag) 2 | % BFGS Search Direction 3 | % 4 | % This function returns the (L-BFGS) approximate inverse Hessian, 5 | % multiplied by the gradient 6 | % 7 | % If you pass in all previous directions/sizes, it will be the same as full BFGS 8 | % If you truncate to the k most recent directions/sizes, it will be L-BFGS 9 | % 10 | % s - previous search directions (p by k) 11 | % y - previous step sizes (p by k) 12 | % g - gradient (p by 1) 13 | % Hdiag - value of initial Hessian diagonal elements (scalar) 14 | 15 | [p,k] = size(s); 16 | 17 | for i = 1:k 18 | ro(i,1) = 1/(y(:,i)'*s(:,i)); 19 | end 20 | 21 | q = zeros(p,k+1); 22 | r = zeros(p,k+1); 23 | al =zeros(k,1); 24 | be =zeros(k,1); 25 | 26 | q(:,k+1) = g; 27 | 28 | for i = k:-1:1 29 | al(i) = ro(i)*s(:,i)'*q(:,i+1); 30 | q(:,i) = q(:,i+1)-al(i)*y(:,i); 31 | end 32 | 33 | % Multiply by Initial Hessian 34 | r(:,1) = Hdiag*q(:,1); 35 | 36 | for i = 1:k 37 | be(i) = ro(i)*y(:,i)'*r(:,i); 38 | r(:,i+1) = r(:,i) + s(:,i)*(al(i)-be(i)); 39 | end 40 | d=r(:,k+1); -------------------------------------------------------------------------------- /matlab/ext/gpml/util/minfunc/lbfgsAdd.m: -------------------------------------------------------------------------------- 1 | function [S,Y,YS,lbfgs_start,lbfgs_end,Hdiag,skipped] = lbfgsAdd(y,s,S,Y,YS,lbfgs_start,lbfgs_end,Hdiag,useMex) 2 | ys = y'*s; 3 | skipped = 0; 4 | corrections = size(S,2); 5 | if ys > 1e-10 6 | if lbfgs_end < corrections 7 | lbfgs_end = lbfgs_end+1; 8 | if lbfgs_start ~= 1 9 | if lbfgs_start == corrections 10 | lbfgs_start = 1; 11 | else 12 | lbfgs_start = lbfgs_start+1; 13 | end 14 | end 15 | else 16 | lbfgs_start = min(2,corrections); 17 | lbfgs_end = 1; 18 | end 19 | 20 | if useMex 21 | lbfgsAddC(y,s,Y,S,ys,int32(lbfgs_end)); 22 | else 23 | S(:,lbfgs_end) = s; 24 | Y(:,lbfgs_end) = y; 25 | end 26 | YS(lbfgs_end) = ys; 27 | 28 | % Update scale of initial Hessian approximation 29 | Hdiag = ys/(y'*y); 30 | else 31 | skipped = 1; 32 | end -------------------------------------------------------------------------------- /matlab/ext/gpml/util/minfunc/lbfgsProd.m: -------------------------------------------------------------------------------- 1 | function [d] = lbfgsProd(g,S,Y,YS,lbfgs_start,lbfgs_end,Hdiag) 2 | % BFGS Search Direction 3 | % 4 | % This function returns the (L-BFGS) approximate inverse Hessian, 5 | % multiplied by the negative gradient 6 | 7 | % Set up indexing 8 | [nVars,maxCorrections] = size(S); 9 | if lbfgs_start == 1 10 | ind = 1:lbfgs_end; 11 | nCor = lbfgs_end-lbfgs_start+1; 12 | else 13 | ind = [lbfgs_start:maxCorrections 1:lbfgs_end]; 14 | nCor = maxCorrections; 15 | end 16 | al = zeros(nCor,1); 17 | be = zeros(nCor,1); 18 | 19 | d = -g; 20 | for j = 1:length(ind) 21 | i = ind(end-j+1); 22 | al(i) = (S(:,i)'*d)/YS(i); 23 | d = d-al(i)*Y(:,i); 24 | end 25 | 26 | % Multiply by Initial Hessian 27 | d = Hdiag*d; 28 | 29 | for i = ind 30 | be(i) = (Y(:,i)'*d)/YS(i); 31 | d = d + S(:,i)*(al(i)-be(i)); 32 | end 33 | -------------------------------------------------------------------------------- /matlab/ext/gpml/util/minfunc/lbfgsUpdate.m: -------------------------------------------------------------------------------- 1 | function [old_dirs,old_stps,Hdiag] = lbfgsUpdate(y,s,corrections,debug,old_dirs,old_stps,Hdiag) 2 | ys = y'*s; 3 | if ys > 1e-10 4 | numCorrections = size(old_dirs,2); 5 | if numCorrections < corrections 6 | % Full Update 7 | old_dirs(:,numCorrections+1) = s; 8 | old_stps(:,numCorrections+1) = y; 9 | else 10 | % Limited-Memory Update 11 | old_dirs = [old_dirs(:,2:corrections) s]; 12 | old_stps = [old_stps(:,2:corrections) y]; 13 | end 14 | 15 | % Update scale of initial Hessian approximation 16 | Hdiag = ys/(y'*y); 17 | else 18 | if debug 19 | fprintf('Skipping Update\n'); 20 | end 21 | end -------------------------------------------------------------------------------- /matlab/ext/gpml/util/minfunc/mchol.m: -------------------------------------------------------------------------------- 1 | function [l,d,perm] = mchol(A,mu) 2 | % [l,d,perm] = mchol(A,mu) 3 | % Compute the Gill-Murray modified LDL factorization of A, 4 | 5 | if nargin < 2 6 | mu = 1e-12; 7 | end 8 | 9 | n = size(A,1); 10 | l = eye(n); 11 | d = zeros(n,1); 12 | perm = 1:n; 13 | 14 | for i = 1:n 15 | c(i,i) = A(i,i); 16 | end 17 | 18 | % Compute modification parameters 19 | gamma = max(abs(diag(A))); 20 | xi = max(max(abs(setdiag(A,0)))); 21 | delta = mu*max(gamma+xi,1); 22 | if n > 1 23 | beta = sqrt(max([gamma xi/sqrt(n^2-1) mu])); 24 | else 25 | beta = sqrt(max([gamma mu])); 26 | end 27 | 28 | for j = 1:n 29 | 30 | % Find q that results in Best Permutation with j 31 | [maxVal maxPos] = max(abs(diag(c(j:end,j:end)))); 32 | q = maxPos+j-1; 33 | 34 | % Permute d,c,l,a 35 | d([j q]) = d([q j]); 36 | perm([j q]) = perm([q j]); 37 | c([j q],:) = c([q j],:); 38 | c(:,[j q]) = c(:,[q j]); 39 | l([j q],:) = l([q j],:); 40 | l(:,[j q]) = l(:,[q j]); 41 | A([j q],:) = A([q j],:); 42 | A(:,[j q]) = A(:,[q j]); 43 | 44 | for s = 1:j-1 45 | l(j,s) = c(j,s)/d(s); 46 | end 47 | for i = j+1:n 48 | c(i,j) = A(i,j) - sum(l(j,1:j-1).*c(i,1:j-1)); 49 | end 50 | theta = 0; 51 | if j < n 52 | theta = max(abs(c(j+1:n,j))); 53 | end 54 | d(j) = max([abs(c(j,j)) (theta/beta)^2 delta]); 55 | if j < n 56 | for i = j+1:n 57 | c(i,i) = c(i,i) - (c(i,j)^2)/d(j); 58 | end 59 | end 60 | end -------------------------------------------------------------------------------- /matlab/ext/gpml/util/minfunc/mcholinc.m: -------------------------------------------------------------------------------- 1 | function [R,tau] = mcholinc(H,verbose) 2 | % Computes Cholesky of H+tau*I, for suitably large tau that matrix is pd 3 | 4 | p = size(H,1); 5 | 6 | beta = norm(H,'fro'); 7 | if min(diag(H)) > 1e-12 8 | tau = 0; 9 | else 10 | if verbose 11 | fprintf('Small Value on Diagonal, Adjusting Hessian\n'); 12 | end 13 | tau = max(beta/2,1e-12); 14 | end 15 | while 1 16 | [R,posDef] = chol(H+tau*eye(p)); 17 | if posDef == 0 18 | break; 19 | else 20 | if verbose 21 | fprintf('Cholesky Failed, Adjusting Hessian\n'); 22 | end 23 | tau = max(2*tau,beta/2); 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /matlab/ext/gpml/util/minfunc/mex/lbfgsAddC.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "mex.h" 3 | 4 | /* See lbfgsAdd.m for details */ 5 | /* This function will not exit gracefully on bad input! */ 6 | 7 | void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) 8 | { 9 | /* Variable Declarations */ 10 | 11 | double *s,*y,*S, *Y, ys; 12 | int i,j,nVars,lbfgs_end; 13 | 14 | /* Get Input Pointers */ 15 | 16 | y = mxGetPr(prhs[0]); 17 | s = mxGetPr(prhs[1]); 18 | Y = mxGetPr(prhs[2]); 19 | S = mxGetPr(prhs[3]); 20 | ys= mxGetScalar(prhs[4]); 21 | lbfgs_end = (int)mxGetScalar(prhs[5]); 22 | 23 | if (!mxIsClass(prhs[5],"int32")) 24 | mexErrMsgTxt("lbfgs_end must be int32"); 25 | 26 | /* Compute number of variables, maximum number of corrections */ 27 | 28 | nVars = mxGetDimensions(prhs[2])[0]; 29 | 30 | for(j=0;j 1 14 | gd2(t3) = gd2(t3) + T(t1,t2,t3)*d(t1)*d(t2); 15 | end 16 | 17 | if nargout > 2 18 | Hd(t2,t3) = Hd(t2,t3) + T(t1,t2,t3)*d(t1); 19 | end 20 | end 21 | 22 | end 23 | end 24 | 25 | f = f + g'*d + (1/2)*d'*H*d + (1/6)*fd3; 26 | 27 | if nargout > 1 28 | g = g + H*d + (1/2)*gd2; 29 | end 30 | 31 | if nargout > 2 32 | H = H + Hd; 33 | end 34 | 35 | if any(abs(d) > 1e5) 36 | % We want the optimizer to stop if the solution is unbounded 37 | g = zeros(p,1); 38 | end -------------------------------------------------------------------------------- /matlab/ext/gpml/util/solve_chol.m: -------------------------------------------------------------------------------- 1 | % solve_chol - solve linear equations from the Cholesky factorization. 2 | % Solve A*X = B for X, where A is square, symmetric, positive definite. The 3 | % input to the function is R the Cholesky decomposition of A and the matrix B. 4 | % Example: X = solve_chol(chol(A),B); 5 | % 6 | % NOTE: The program code is written in the C language for efficiency and is 7 | % contained in the file solve_chol.c, and should be compiled using matlabs mex 8 | % facility. However, this file also contains a (less efficient) matlab 9 | % implementation, supplied only as a help to people unfamiliar with mex. If 10 | % the C code has been properly compiled and is available, it automatically 11 | % takes precendence over the matlab code in this file. 12 | % 13 | % Copyright (c) by Carl Edward Rasmussen and Hannes Nickisch 2010-09-18. 14 | 15 | function X = solve_chol(L, B) 16 | 17 | if nargin ~= 2 || nargout > 1 18 | error('Wrong number of arguments.'); 19 | end 20 | 21 | if size(L,1) ~= size(L,2) || size(L,1) ~= size(B,1) 22 | error('Wrong sizes of matrix arguments.'); 23 | end 24 | 25 | X = L\(L'\B); -------------------------------------------------------------------------------- /matlab/ext/gpml/util/vec2any.m: -------------------------------------------------------------------------------- 1 | % Map the numerical elements in the vector "v" onto the variables "s" which can 2 | % be of any type. The number of numerical elements must match; on exit "v" 3 | % should be empty. Non-numerical entries are just copied. See also any2vec.m. 4 | 5 | function [s v] = vec2any(s, v) 6 | if isnumeric(s) 7 | if numel(v) < numel(s) 8 | error('The vector for conversion contains too few elements') 9 | end 10 | s = reshape(v(1:numel(s)), size(s)); % numeric values are reshaped 11 | v = v(numel(s)+1:end); % remaining arguments passed on 12 | elseif isstruct(s) 13 | [s p] = orderfields(s); p(p) = 1:numel(p); % alphabetize, store ordering 14 | [t v] = vec2any(struct2cell(s), v); % convert to cell, recurse 15 | s = orderfields(cell2struct(t,fieldnames(s),1),p); % conv to struct, reorder 16 | elseif iscell(s) 17 | for i = 1:numel(s) % cell array elements are handled sequentially 18 | [s{i} v] = vec2any(s{i}, v); 19 | end 20 | end % other types are not processed 21 | -------------------------------------------------------------------------------- /matlab/ext/logsumexp/logsumexp.m: -------------------------------------------------------------------------------- 1 | function s = logsumexp(a, dim) 2 | % Returns log(sum(exp(a),dim)) while avoiding numerical underflow. 3 | % Default is dim = 1 (columns). 4 | % logsumexp(a, 2) will sum across rows instead of columns. 5 | % Unlike matlab's "sum", it will not switch the summing direction 6 | % if you provide a row vector. 7 | 8 | % Written by Tom Minka 9 | % (c) Microsoft Corporation. All rights reserved. 10 | 11 | if nargin < 2 12 | dim = 1; 13 | end 14 | 15 | % subtract the largest in each column 16 | [y, i] = max(a,[],dim); 17 | dims = ones(1,ndims(a)); 18 | dims(dim) = size(a,dim); 19 | a = a - repmat(y, dims); 20 | s = y + log(sum(exp(a),dim)); 21 | i = find(~isfinite(y)); 22 | if ~isempty(i) 23 | s(i) = y(i); 24 | end 25 | -------------------------------------------------------------------------------- /matlab/ext/tprod/ddtprod.c: -------------------------------------------------------------------------------- 1 | /* Simple wrapper function for building repop for different input types */ 2 | #include "mxInfo.h" /* for the type enum */ 3 | #define XDTYPE DOUBLE_DTYPE 4 | #define YDTYPE DOUBLE_DTYPE 5 | #include "tprod.c" 6 | -------------------------------------------------------------------------------- /matlab/ext/tprod/dstprod.c: -------------------------------------------------------------------------------- 1 | /* Simple wrapper function for building repop for different input types */ 2 | #include "mxInfo.h" /* for the type enum */ 3 | #define XDTYPE DOUBLE_DTYPE 4 | #define YDTYPE SINGLE_DTYPE 5 | #include "tprod.c" 6 | -------------------------------------------------------------------------------- /matlab/ext/tprod/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2006-2009, Jason Farquhar 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the distribution 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /matlab/ext/tprod/mxInfo_mex.h: -------------------------------------------------------------------------------- 1 | #ifndef mxInfoMexH 2 | #define mxInfoMexH 3 | /* 4 | matlab specific helper functions 5 | */ 6 | 7 | #include "mex.h" 8 | #include "matrix.h" 9 | #include "mxInfo.h" 10 | 11 | mxArray* mkmxArrayCopy(const MxInfo info); 12 | /* convert back to mxArray */ 13 | mxArray* mkmxArray(const MxInfo info); 14 | MxInfo mkmxInfoMxArray(const mxArray *mat, int nd); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /matlab/ext/tprod/mxUtils.h: -------------------------------------------------------------------------------- 1 | #ifndef mxUtilsH 2 | #define mxUtilsH 3 | /* File: mxUtils.H 4 | 5 | Header for set of utility functions to setup mxInfo arrays for testing 6 | */ 7 | #include "mxInfo.h" 8 | 9 | int parseInfo(int nd, char *typestr, char *szstr, int *type, int *complexp, 10 | int *sz, int *numel); 11 | char* readMx(int *numel, char *datstr, void *data, int dtype); 12 | FILE* freadMx(int *numel, FILE *fd, void *data, int dtype); 13 | int datFill(char *datSrc, int numel,void *rp, void *ip, int dtype); 14 | MxInfo loadMxInfo(FILE *fd); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /matlab/ext/tprod/readme: -------------------------------------------------------------------------------- 1 | This directory contains all the files needed install and run tprod. 2 | 3 | To install: 4 | 1) Put all these files in a directory where matlab can see them. 5 | 2) There is no step 2. ;-) 6 | just go ahead and type: tprod() or tprod_testcases() to check it works. 7 | (Actually the codes are written such that matlab will automatically make 8 | the required mex files when you first use them -- provided you matlab is 9 | set-up correctly this should be transparent to you). 10 | 11 | To get help: 12 | help tprod 13 | from the matlab prompt 14 | 15 | FILELIST 16 | 17 | INSTALL -- this file 18 | mxInfo.c mxInfo.h -- utility functions for storing info about matrices 19 | tprod.c tprod.h -- generic (i.e. non-matlab specific) tprod code 20 | tprod_mex.c -- matlab wrapper code to use tprod.c 21 | tprod.def -- macro-code to auto-generate code for the different 22 | real/complex argument mixes for tprod calls. 23 | tprod.m -- M-file wrapper for the tprod help and for the mex-hiding 24 | routines. 25 | tprod_testcases.m -- M-file to run a load of tprod unit-tests to verify 26 | correctness. 27 | 28 | -------------------------------------------------------------------------------- /matlab/ext/tprod/sdtprod.c: -------------------------------------------------------------------------------- 1 | /* Simple wrapper function for building repop for different input types */ 2 | #include "mxInfo.h" /* for the type enum */ 3 | #define XDTYPE SINGLE_DTYPE 4 | #define YDTYPE DOUBLE_DTYPE 5 | #include "tprod.c" 6 | -------------------------------------------------------------------------------- /matlab/ext/tprod/sstprod.c: -------------------------------------------------------------------------------- 1 | /* Simple wrapper function for building repop for different input types */ 2 | #include "mxInfo.h" /* for the type enum */ 3 | #define XDTYPE SINGLE_DTYPE 4 | #define YDTYPE SINGLE_DTYPE 5 | #include "tprod.c" 6 | -------------------------------------------------------------------------------- /matlab/k_matrix.m: -------------------------------------------------------------------------------- 1 | function K = k_matrix(GP,x,z) 2 | % Kernel gram matrix, without outputs for the derivatives 3 | 4 | switch nargin 5 | case 2 6 | N = numel(x); 7 | if ~GP.deriv 8 | K = feval(GP.covfunc{:},GP.hyp.cov,x); % + exp(2*GP.hyp.lik)*eye(N); 9 | else 10 | K = feval(GP.covfunc{:},GP.hyp.cov,x); 11 | K_dx = feval(GP.covfunc_dx{:},GP.hyp.cov,x); 12 | K_dx2 = feval(GP.covfunc_dxdz{:},GP.hyp.cov,x); 13 | K = [K -K_dx; 14 | K_dx K_dx2]'; % + exp(2*GP.hyp.lik)*eye(2*N); 15 | end 16 | case 3 17 | if isempty(z) 18 | K = []; 19 | elseif ~GP.deriv 20 | K = (feval(GP.covfunc{:},GP.hyp.cov,x,z))'; 21 | else 22 | K = feval(GP.covfunc{:},GP.hyp.cov,x,z); 23 | K_dx = feval(GP.covfunc_dx{:},GP.hyp.cov,x,z); 24 | K = [K; K_dx]'; 25 | end 26 | end 27 | end 28 | 29 | -------------------------------------------------------------------------------- /matlab/k_matrix_full.m: -------------------------------------------------------------------------------- 1 | function K = k_matrix_full(GP,x,z) 2 | % Kernel gram matrix, with outputs for the derivatives 3 | switch nargin 4 | case 2 5 | N = size(x,1); 6 | if ~GP.deriv 7 | K = feval(GP.covfunc{:},GP.hyp.cov,x); % + exp(2*GP.hyp.lik)*eye(N); 8 | else 9 | K = feval(GP.covfunc{:},GP.hyp.cov,x); 10 | K_dx = feval(GP.covfunc_dx{:},GP.hyp.cov,x); 11 | K_dx2 = feval(GP.covfunc_dxdz{:},GP.hyp.cov,x); 12 | K = [K -K_dx; 13 | K_dx K_dx2]'; % + exp(2*GP.hyp.lik)*eye(2*N); 14 | end 15 | case 3 16 | if isempty(z) || isempty(x) 17 | K = zeros(size(z,1),size(x,1)); 18 | elseif ~GP.deriv 19 | K = (feval(GP.covfunc{:},GP.hyp.cov,x,z))'; 20 | else 21 | K = feval(GP.covfunc{:},GP.hyp.cov,x,z); 22 | K_dx = feval(GP.covfunc_dx{:},GP.hyp.cov,x,z); 23 | K_dx2 = feval(GP.covfunc_dxdz{:},GP.hyp.cov,x,z); 24 | K = [K -K_dx; % why the minus? This is a special aspect of SE? 25 | K_dx K_dx2]'; % why no transpose on the K? So size(K(x,y)) = [size(y),size(x)] ? That seems odd. 26 | end 27 | end 28 | end 29 | 30 | -------------------------------------------------------------------------------- /matlab/logdet.m: -------------------------------------------------------------------------------- 1 | function D = logdet(M) 2 | % logarithm of determinant of positive definite matrix 3 | % Philipp Hennig, 12 July 2011 4 | 5 | D = 2 * sum(log(diag(chol(M)))); -------------------------------------------------------------------------------- /matlab/poly_mat.m: -------------------------------------------------------------------------------- 1 | function H = poly_mat(x,order,with_deriv) 2 | %UNTITLED Summary of this function goes here 3 | % Detailed explanation goes here 4 | 5 | H = ones(order+1,size(x,1)); 6 | 7 | for i=1:order 8 | H(i+1,:) = H(i,:) .* x'; 9 | end 10 | 11 | if with_deriv 12 | HD = zeros(order+1,numel(x)); 13 | for i=2:order+1 14 | HD(i,:) = x' .^ (i-2) * (i-1); 15 | end 16 | H = [H, HD]; 17 | end 18 | -------------------------------------------------------------------------------- /matlab/y_vector.m: -------------------------------------------------------------------------------- 1 | function [ y ] = y_vector(GP) 2 | %UNTITLED3 Summary of this function goes here 3 | % Detailed explanation goes here 4 | if ~GP.deriv 5 | y = GP.y; 6 | else 7 | y = [GP.y; GP.dy]; 8 | end 9 | 10 | end 11 | 12 | --------------------------------------------------------------------------------