Kernel Quantum Probability Library
The KQP library aims at providing tools for working with quantums probabilities
Public Types | Public Member Functions | Protected Member Functions
kqp::GaussianSpace< Scalar > Class Template Reference

Gaussian Kernel \(k'(x,y) = \exp(\frac{2 Re(k(x,y)) - k(x) - k(y) \vert}{\sigma^2})\). More...

#include <unary_kernel.hpp>

Inheritance diagram for kqp::GaussianSpace< Scalar >:
kqp::UnaryKernelSpace< Scalar > kqp::SpaceBase< Scalar > kqp::AbstractSpace

Public Types

typedef GaussianSpace< Scalar > Self
 

Public Member Functions

 KQP_SPACE_TYPEDEFS ("gaussian", Scalar)
 
 GaussianSpace (Real sigma, const FSpacePtr &base)
 
virtual FSpacePtr copy () const override
 Copy.
 
virtual Index dimension () const override
 Dimension of the underlying space (-1 for infinity)
 
virtual bool _canLinearlyCombine () const override
 Returns whether the pre-images can be linearly combined (false by default)
 
virtual ScalarMatrix k (const FMatrixBase &mX1, const ScalarAltMatrix &mY1, const RealAltVector &mD1, const FMatrixBase &mX2, const ScalarAltMatrix &mY2, const RealAltVector &mD2) const override
 Inner products \(D_1^\dagger Y_1^\dagger X_1^\dagger X_2 Y_2 D_2\).
 
virtual void update (std::vector< KernelValues< Scalar > > &values, int kOffset=0) const override
 
virtual void updatePartials (Real alpha, std::vector< Real > &partials, int offset, const std::vector< KernelValues< Scalar > > &values, int kOffset, int mode) const
 Update the partials.
 
virtual int numberOfParameters (bool onlyFreeParameters) const
 
virtual void getParameters (bool onlyFreeParameters, std::vector< Real > &parameters, int offset=0) const
 
virtual void getBounds (bool onlyFreeParameters, std::vector< Real > &lower, std::vector< Real > &upper, int offset=0) const
 
virtual void setParameters (bool onlyFreeParameters, const std::vector< Real > &parameters, int offset=0)
 
virtual void load (const picojson::object &json) override
 
virtual picojson::object save () const override
 Save in JSON.
 
- Public Member Functions inherited from kqp::UnaryKernelSpace< Scalar >
 KQP_SCALAR_TYPEDEFS (Scalar)
 
 UnaryKernelSpace (const FSpacePtr &base)
 
virtual FMatrixBasePtr newMatrix () const override
 Creates a new feature matrix.
 
virtual const ScalarMatrix & k (const FMatrixBase &mX) const override
 Gram matrix.
 
FSpaceCPtr base () const
 
virtual int numberOfKernelValues () const override
 
- Public Member Functions inherited from kqp::SpaceBase< Scalar >
 KQP_SCALAR_TYPEDEFS (Scalar)
 
virtual ScalarMatrix k (const FMatrixBase &mX, const ScalarAltMatrix &mY, const RealAltVector &mD) const
 Inner products \(D_1^\dagger Y_1^\dagger X_1^\dagger X_2 Y_2 D_2\).
 
ScalarMatrix k (const FMatrixBase &mX1, const ScalarAltMatrix &mY1, const FMatrixBase &mX2, const ScalarAltMatrix &mY2) const
 Inner products \(Y_1^\dagger X_1^\dagger X_2 Y_2\).
 
ScalarMatrix k (const FMatrixBase &mX1, const FMatrixBase &mX2) const
 Inner products \(X_1^\dagger X_2\).
 
void updatePartials (Real alpha, std::vector< Real > &partials, const std::vector< KernelValues< Scalar > > &kernelValues, int mode) const
 
virtual int getNumberOfConstraints (bool) const
 
virtual void getConstraints (bool, std::vector< Real > &, int=0) const
 
virtual FMatrixBasePtr linearCombination (const FMatrixBase &, const ScalarAltMatrix &, Scalar, const FMatrixBase *, const ScalarAltMatrix *, Scalar) const
 Linear combination of pre-images \( \alpha X A + \beta Y B \).
 
template<typename T >
const T & as () const
 
template<typename T >
T & as ()
 
template<typename T >
bool castable_as () const
 
const ScalarMatrix & k (const FMatrixCPtr &mX) const
 Gram matrix.
 
ScalarMatrix k (const FMatrixCPtr &mX, const ScalarAltMatrix &mY, const RealAltVector &mD) const
 Inner products \(D_1^\dagger Y_1^\dagger X_1^\dagger X_2 Y_2 D_2\).
 
ScalarMatrix k (const FMatrixCPtr &mX, const ScalarAltMatrix &mY) const
 Inner products \(D_1^\dagger Y_1^\dagger X_1^\dagger X_2 Y_2 D_2\).
 
ScalarMatrix k (const FMatrixBase &mX, const ScalarAltMatrix &mY) const
 Inner products \(D_1^\dagger Y_1^\dagger X_1^\dagger X_2 Y_2 D_2\).
 
ScalarMatrix k (const FMatrixCPtr &mX1, const ScalarAltMatrix &mY1, const RealAltVector &mD1, const FMatrixCPtr &mX2, const ScalarAltMatrix &mY2, const RealAltVector &mD2) const
 Inner products \(D_1^\dagger Y_1^\dagger X_1^\dagger X_2 Y_2 D_2\).
 
ScalarMatrix k (const FMatrixCPtr &mX1, const ScalarAltMatrix &mY1, const FMatrixCPtr &mX2, const ScalarAltMatrix &mY2) const
 Inner product \(X_1^\dagger X_2\).
 
ScalarMatrix k (const FMatrixCPtr &mX1, const FMatrixCPtr &mX2) const
 Inner product \(X_1^\dagger X_2\).
 
bool canLinearlyCombine () const
 Returns whether the pre-images can be linearly combined.
 
FMatrixPtr linearCombination (const FMatrixBase &mX, const ScalarAltMatrix &mA, Scalar alpha, const FMatrixBase &mY, const ScalarAltMatrix &mB, Scalar beta) const
 Linear combination of the feature vectors.
 
FMatrixPtr linearCombination (const FMatrixBase &mX, const ScalarAltMatrix &mA, Scalar alpha=(Scalar) 1) const
 Linear combination of the feature vectors.
 
FMatrixPtr linearCombination (const FMatrixCPtr &mX, const ScalarAltMatrix &mA, Scalar alpha=(Scalar) 1) const
 
void setUseLinearCombination (bool flag)
 Sets the flag for linear combination use (debug)
 
std::string demangle () const
 
- Public Member Functions inherited from kqp::AbstractSpace
virtual const std::string & name () const =0
 Name of the space.
 

Protected Member Functions

virtual void fillGram (ScalarMatrix &gram, Index tofill, const FMatrixBase &mX) const override
 Fill a part of the Gram matrix.
 

Additional Inherited Members

- Static Public Member Functions inherited from kqp::SpaceBase< Scalar >
static int & counter ()
 
- Protected Attributes inherited from kqp::UnaryKernelSpace< Scalar >
FSpacePtr m_base
 The base feature space.
 

Detailed Description

template<typename Scalar>
class kqp::GaussianSpace< Scalar >

Gaussian Kernel \(k'(x,y) = \exp(\frac{2 Re(k(x,y)) - k(x) - k(y) \vert}{\sigma^2})\).

Member Function Documentation

template<typename Scalar >
virtual void kqp::GaussianSpace< Scalar >::fillGram ( ScalarMatrix &  gram,
Index  tofill,
const FMatrixBase &  mX 
) const
inlineoverrideprotectedvirtual

Fill a part of the Gram matrix.

Fill the right columns (tofill) of a Gram matrix

Implements kqp::UnaryKernelSpace< Scalar >.

template<typename Scalar >
virtual void kqp::GaussianSpace< Scalar >::load ( const picojson::object &  json)
inlineoverridevirtual

Load from JSON

Parameters
nodeThe node to load

Reimplemented from kqp::UnaryKernelSpace< Scalar >.

template<typename Scalar >
virtual int kqp::GaussianSpace< Scalar >::numberOfParameters ( bool  ) const
inlinevirtual

Returns the number of parameters for this feature space

Reimplemented from kqp::SpaceBase< Scalar >.

template<typename Scalar >
virtual void kqp::GaussianSpace< Scalar >::updatePartials ( Real  ,
std::vector< Real > &  ,
int  ,
const std::vector< KernelValues< Scalar > > &  ,
int  ,
int   
) const
inlinevirtual

Update the partials.

Update the partials with \( \alpha \times \frac{\partial k(X,Y)}{\partial \theta}\) where \(theta\) are the parameters

Parameters
alphaThe weight \(\alpha\)
partialsThe partials to update
offsetThe offset within the real values stored in partials
mXA vector in the feature space
mYA vector in the feature space

Reimplemented from kqp::SpaceBase< Scalar >.


The documentation for this class was generated from the following file: