/** 
* @file KernelEXPHIK.cpp
* @brief Interface for the generalized rbf kernel with HIK metric
* @author Paul Bodesheim
* @date 02/07/2013

*/

#include <iostream>

#include <math.h>
#include "KernelEXPHIK.h"

using namespace OBJREC;

using namespace std;
using namespace NICE;

KernelEXPHIK::KernelEXPHIK ( double _gamma, double _alpha, double _beta ) : KernelHIK(_alpha, _beta)
{
        gamma = _gamma;
}

KernelEXPHIK::KernelEXPHIK ( const KernelEXPHIK & src ) : KernelHIK(src.alpha, src.beta)
{
        gamma = src.gamma;
}

KernelEXPHIK::KernelEXPHIK ( const KernelHIK & src, double _gamma ) : KernelHIK(src)
{
        gamma = _gamma;
}

KernelEXPHIK::~KernelEXPHIK()
{
}

KernelEXPHIK *KernelEXPHIK::clone(void) const
{
	return new KernelEXPHIK ( *this );
}

	
double KernelEXPHIK::K (const NICE::Vector & x, const NICE::Vector & y) const
{
	if ( x.size() != y.size() ) {
		cerr << "KernelEXPHIK: dimensions: " << x.size() << " vs " << y.size() << endl;
		fthrow(Exception, "Vector dimensions do not match!");
	}

	double dist = KernelHIK::K(x,x) + KernelHIK::K(y,y) - 2.0*KernelHIK::K(x,y);

        return exp(-gamma*dist);
}

void KernelEXPHIK::updateKernelData ( KernelData *kernelData ) const
{
        NICE::Matrix & kernelMatrix = kernelData->getKernelMatrix();
        fthrow(Exception, "Not yet implemented!");

}

void KernelEXPHIK::getKernelJacobi ( size_t parameter, const NICE::Vector & parameters, const KernelData *kernelData, NICE::Matrix & jacobiMatrix ) const
{
	fthrow(Exception, "Not yet implemented!");
}

void KernelEXPHIK::setParameters( const NICE::Vector & newParameters ) 
{
        alpha = newParameters[0];
        beta = newParameters[1];
        gamma = newParameters[2];
}

void KernelEXPHIK::getParameters( NICE::Vector & newParameters ) const
{
	newParameters.resize(3);
        newParameters[0] = alpha;
        newParameters[1] = beta;
        newParameters[2] = gamma;
}
