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

A feature space. More...

#include <feature_matrix.hpp>

Inheritance diagram for kqp::SpaceBase< Scalar >:
kqp::AbstractSpace kqp::DenseSpace< Scalar > kqp::KernelSumSpace< Scalar > kqp::SparseDenseSpace< Scalar > kqp::SparseSpace< Scalar > kqp::UnaryKernelSpace< Scalar > kqp::GaussianSpace< Scalar > kqp::PolynomialSpace< Scalar >

Public Member Functions

 KQP_SCALAR_TYPEDEFS (Scalar)
 
virtual Index dimension () const =0
 Dimension of the underlying space (-1 for infinity)
 
virtual boost::shared_ptr
< SpaceBase< Scalar > > 
copy () const =0
 Copy.
 
virtual const ScalarMatrix & k (const FMatrixBase &mX) const =0
 Gram matrix.
 
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\).
 
virtual ScalarMatrix k (const FMatrixBase &mX1, const ScalarAltMatrix &mY1, const RealAltVector &mD1, const FMatrixBase &mX2, const ScalarAltMatrix &mY2, const RealAltVector &mD2) const =0
 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\).
 
virtual void updatePartials (Real, std::vector< Real > &, int, const std::vector< KernelValues< Scalar > > &, int, int) const
 Update the partials.
 
void updatePartials (Real alpha, std::vector< Real > &partials, const std::vector< KernelValues< Scalar > > &kernelValues, int mode) const
 
virtual void update (std::vector< KernelValues< Scalar > > &, int=0) const
 
virtual int numberOfParameters (bool) const
 
virtual void getBounds (bool, std::vector< Real > &, std::vector< Real > &, int=0) const
 
virtual void getParameters (bool, std::vector< Real > &, int=0) const
 
virtual void setParameters (bool, const std::vector< Real > &, int=0)
 
virtual int getNumberOfConstraints (bool) const
 
virtual void getConstraints (bool, std::vector< Real > &, int=0) const
 
virtual int numberOfKernelValues () const
 
virtual picojson::object save () const override
 Save in JSON.
 
virtual FMatrixBasePtr newMatrix () const =0
 Creates a new feature matrix.
 
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 void load (const picojson::object &json)=0
 
virtual const std::string & name () const =0
 Name of the space.
 

Static Public Member Functions

static int & counter ()
 

Protected Member Functions

virtual bool _canLinearlyCombine () const
 Returns whether the pre-images can be linearly combined (false by default)
 

Detailed Description

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

A feature space.

Member Function Documentation

template<typename Scalar >
template<typename T >
const T& kqp::SpaceBase< Scalar >::as ( ) const
inline

Dynamic casts

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

Computes the <= 0 constraints values

Reimplemented in kqp::KernelSumSpace< Scalar >.

template<typename Scalar >
FMatrixPtr kqp::SpaceBase< Scalar >::linearCombination ( const FMatrixBase &  mX,
const ScalarAltMatrix &  mA,
Scalar  alpha,
const FMatrixBase &  mY,
const ScalarAltMatrix &  mB,
Scalar  beta 
) const
inline

Linear combination of the feature vectors.

Computes \( \alpha XA + \beta Y B \) where \(X\) is the current feature matrix, and \(A\) is the argument

template<typename Scalar >
FMatrixPtr kqp::SpaceBase< Scalar >::linearCombination ( const FMatrixBase &  mX,
const ScalarAltMatrix &  mA,
Scalar  alpha = (Scalar)1 
) const
inline

Linear combination of the feature vectors.

Computes \( XA \) where \(X\) is the current feature matrix, and \(A\) is the argument

template<typename Scalar >
FMatrixPtr kqp::SpaceBase< Scalar >::linearCombination ( const FMatrixCPtr &  mX,
const ScalarAltMatrix &  mA,
Scalar  alpha = (Scalar)1 
) const
inline
template<typename Scalar >
virtual int kqp::SpaceBase< Scalar >::numberOfKernelValues ( ) const
inlinevirtual

Returns the number of stored kernel values for this kernel

Reimplemented in kqp::KernelSumSpace< Scalar >, and kqp::UnaryKernelSpace< Scalar >.

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

Returns the number of parameters for this feature space

Reimplemented in kqp::PolynomialSpace< Scalar >, kqp::KernelSumSpace< Scalar >, and kqp::GaussianSpace< Scalar >.

template<typename Scalar >
virtual void kqp::SpaceBase< 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 in kqp::PolynomialSpace< Scalar >, kqp::KernelSumSpace< Scalar >, and kqp::GaussianSpace< Scalar >.


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