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

A feature matrix where vectors are sparse vectors in a high dimensional space. More...

#include <kernel_sum.hpp>

Inheritance diagram for kqp::KernelSumSpace< Scalar >:
kqp::SpaceBase< Scalar > kqp::AbstractSpace

Public Types

typedef KernelSumSpace< Scalar > Self
 
typedef KernelSumMatrix< Scalar > TMatrix
 

Public Member Functions

 KQP_SPACE_TYPEDEFS ("sum", Scalar)
 
void addSpace (Real weight, const FSpacePtr &space)
 
 KernelSumSpace (const KernelSumSpace &other)
 
virtual Index dimension () const override
 Dimension of the underlying space (-1 for infinity)
 
virtual boost::shared_ptr
< SpaceBase< Scalar > > 
copy () const
 Copy.
 
virtual bool _canLinearlyCombine () const override
 Returns whether the pre-images can be linearly combined (false by default)
 
virtual FMatrixBasePtr newMatrix () const override
 Creates a new feature matrix.
 
virtual FMatrixBasePtr newMatrix (const FeatureMatrixBase< Scalar > &other) const override
 
virtual const ScalarMatrix & k (const FMatrixBase &mX) const
 Gram matrix.
 
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 override
 Update the partials.
 
virtual int numberOfKernelValues () const
 
virtual int numberOfParameters (bool onlyFreeParameters) const
 
virtual void getParameters (bool onlyFreeParameters, std::vector< Real > &parameters, int offset=0) const override
 
virtual void setParameters (bool onlyFreeParameters, const std::vector< Real > &parameters, int offset=0) override
 
virtual void getBounds (bool onlyFreeParameters, std::vector< Real > &lower, std::vector< Real > &upper, int offset=0) const override
 
virtual int getNumberOfConstraints (bool onlyFreeParameters) const
 
virtual void getConstraints (bool onlyFreeParameters, std::vector< Real > &constraintValues, int offset=0) const
 
FSpacePtr space (size_t i)
 
FSpaceCPtr space (size_t i) const
 
Real weight (size_t i) const
 
size_t size () const
 
virtual void load (const picojson::object &json)
 
virtual picojson::object save () const override
 Save in JSON.
 
Real getNormalizedWeight (size_t i) const
 
- 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 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.
 

Static Public Member Functions

static FSpacePtr create ()
 
- Static Public Member Functions inherited from kqp::SpaceBase< Scalar >
static int & counter ()
 

Friends

class KernelSumMatrix< Scalar >
 

Detailed Description

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

A feature matrix where vectors are sparse vectors in a high dimensional space.

This class makes the hypothesis that vectors have only a few non null components (compared to the dimensionality of the space).

Member Function Documentation

template<typename Scalar>
void kqp::KernelSumSpace< Scalar >::addSpace ( Real  weight,
const FSpacePtr &  space 
)
inline

Add a new space

template<typename Scalar>
virtual void kqp::KernelSumSpace< Scalar >::getConstraints ( bool  ,
std::vector< Real > &  ,
int  = 0 
) const
inlinevirtual

Computes the <= 0 constraints values

Reimplemented from kqp::SpaceBase< Scalar >.

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

Load from JSON

Parameters
nodeThe node to load

Implements kqp::AbstractSpace.

template<typename Scalar>
virtual int kqp::KernelSumSpace< Scalar >::numberOfKernelValues ( ) const
inlinevirtual

Returns the number of stored kernel values for this kernel

Reimplemented from kqp::SpaceBase< Scalar >.

template<typename Scalar>
virtual int kqp::KernelSumSpace< 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::KernelSumSpace< Scalar >::updatePartials ( Real  ,
std::vector< Real > &  ,
int  ,
const std::vector< KernelValues< Scalar > > &  ,
int  ,
int   
) const
inlineoverridevirtual

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: