mlpack  master
IPMetric< KernelType > Class Template Reference

The inner product metric, IPMetric, takes a given Mercer kernel (KernelType), and when Evaluate() is called, returns the distance between the two points in kernel space: More...

Inheritance diagram for IPMetric< KernelType >:

Public Member Functions

 IPMetric ()
 Create the IPMetric without an instantiated kernel. More...

 
 IPMetric (KernelType &kernel)
 Create the IPMetric with an instantiated kernel. More...

 
 ~IPMetric ()
 Destroy the IPMetric object. More...

 
template
<
typename
VecTypeA
,
typename
VecTypeB
>
VecTypeA::elem_type Evaluate (const VecTypeA &a, const VecTypeB &b)
 Evaluate the metric. More...

 
const KernelType & Kernel () const
 Get the kernel. More...

 
KernelType & Kernel ()
 Modify the kernel. More...

 
template
<
typename
Archive
>
void Serialize (Archive &ar, const unsigned int version)
 Serialize the metric. More...

 

Detailed Description


template
<
typename
KernelType
>

class mlpack::metric::IPMetric< KernelType >

The inner product metric, IPMetric, takes a given Mercer kernel (KernelType), and when Evaluate() is called, returns the distance between the two points in kernel space:

\[ d(x, y) = \sqrt{ K(x, x) + K(y, y) - 2K(x, y) }. \]

Template Parameters
KernelTypeType of Kernel to use. This must be a Mercer kernel (positive definite), otherwise the metric may not be valid.

Definition at line 32 of file ip_metric.hpp.

Constructor & Destructor Documentation

◆ IPMetric() [1/2]

IPMetric ( )

Create the IPMetric without an instantiated kernel.

◆ IPMetric() [2/2]

IPMetric ( KernelType &  kernel)

Create the IPMetric with an instantiated kernel.

◆ ~IPMetric()

~IPMetric ( )

Destroy the IPMetric object.

Member Function Documentation

◆ Evaluate()

VecTypeA::elem_type Evaluate ( const VecTypeA &  a,
const VecTypeB &  b 
)

Evaluate the metric.

Template Parameters
VecTypeAType of first vector.
VecTypeBType of second vector.
Parameters
aFirst vector.
bSecond vector.
Returns
Distance between the two points in kernel space.

◆ Kernel() [1/2]

const KernelType& Kernel ( ) const
inline

Get the kernel.

Definition at line 57 of file ip_metric.hpp.

◆ Kernel() [2/2]

KernelType& Kernel ( )
inline

Modify the kernel.

Definition at line 59 of file ip_metric.hpp.

◆ Serialize()

void Serialize ( Archive &  ar,
const unsigned int  version 
)

Serialize the metric.

Referenced by IPMetric< mlpack::kernel::CosineDistance >::Kernel().


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