123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- #ifndef _NICE_OBJREC_KERNELDATAINCLUDE
- #define _NICE_OBJREC_KERNELDATAINCLUDE
- #include "core/basics/Config.h"
- #include "core/algebra/CholeskyRobust.h"
- #include "core/vector/MatrixT.h"
- namespace OBJREC {
- class KernelData
- {
- public:
- enum {
- QUADRATIC_DISTANCES = 0
- };
- protected:
- bool verbose;
- NICE::CholeskyRobust *cr;
- protected:
- NICE::Matrix kernelMatrix;
- NICE::Matrix inverseKernelMatrix;
- NICE::Matrix choleskyMatrix;
- std::map<int, NICE::Matrix *> cachedMatrices;
- double logdet;
- void initFromConfig ( const NICE::Config *conf, const std::string & section );
- NICE::Matrix B;
- NICE::Matrix U;
- NICE::Matrix V;
- NICE::Matrix F;
- NICE::Matrix F_inv;
- public:
-
- KernelData();
-
- KernelData( const KernelData & src );
-
- KernelData( const NICE::Config *conf, const std::string & section = "Kernel" );
-
- KernelData( const NICE::Config *conf, const NICE::Matrix & kernelMatrix, const std::string & section = "Kernel", bool updateCholesky = true );
-
- virtual ~KernelData();
-
- virtual void updateCholeskyFactorization ();
-
- virtual void updateInverseKernelMatrix ();
-
- virtual void computeInverseKernelMultiply ( const NICE::Vector & x, NICE::Vector & result ) const;
-
- virtual const NICE::Matrix & getKernelMatrix() const;
- virtual NICE::Matrix & getKernelMatrix();
- virtual const NICE::Matrix & getInverseKernelMatrix() const;
- virtual NICE::Matrix & getInverseKernelMatrix();
- virtual const NICE::Matrix & getCholeskyMatrix() const;
-
- double getLogDetKernelMatrix () const {
- return logdet;
- };
-
- virtual uint getKernelMatrixSize () const;
-
- const NICE::Matrix & getCachedMatrix (int i) const;
-
- void setCachedMatrix (int i, NICE::Matrix *m);
-
- bool hasCholeskyFactorization () const {
- return (choleskyMatrix.rows() == kernelMatrix.rows());
- };
-
- void getLooEstimates ( const NICE::Vector & y, NICE::Vector & muLoo, NICE::Vector & sigmaLoo ) const;
-
- virtual KernelData *clone(void) const;
- void getGPLikelihoodWithOneNewRow( const NICE::Vector & y, const double & oldLogdetK, const int & rowIndex, const NICE::Vector & newRow, const NICE::Vector & oldAlpha, NICE::Vector & newAlpha, double & loglike);
- void getGPLikelihoodWithOneNewRow_FirstPart( const int & rowIndex, const NICE::Vector & newRow);
- void getGPLikelihoodWithOneNewRow_SecondPart( const NICE::Vector & y, const double & oldLogdetK, const NICE::Vector & oldAlpha, NICE::Vector & newAlpha, double & loglike);
- void perform_Rank_2_Update(const int & rowIndex, const NICE::Vector & newRow);
- void perform_Rank_2k_Update(const std::vector<int> & rowIndices, const std::vector<NICE::Vector> & newRows);
- void delete_one_row(const int & rowIndex);
- void delete_multiple_rows(std::vector<int> & indices);
- void setKernelMatrix(const NICE::Matrix & k_matrix);
- void increase_size_by_One();
- void increase_size_by_k(const uint & k);
- void set_verbose(const bool & _verbose) {
- verbose = _verbose;
- };
- bool get_verbose() {
- return verbose;
- };
- };
- }
- #endif
|