Update ToString() for all kernels except the PSpectrumStringKernel.
This commit is contained in:
@@ -34,14 +34,16 @@ class CosineDistance
|
||||
*/
|
||||
template<typename VecType>
|
||||
static double Evaluate(const VecType& a, const VecType& b);
|
||||
|
||||
/**
|
||||
* Returns a string representation of this object.
|
||||
*/
|
||||
std::string ToString() const{
|
||||
std::string ToString() const
|
||||
{
|
||||
std::ostringstream convert;
|
||||
convert << "CosineDistance [" << this << "]" << std::endl;
|
||||
return convert.str();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//! Kernel traits for the cosine distance.
|
||||
|
||||
@@ -31,12 +31,13 @@ double EpanechnikovKernel::Evaluate(const double distance) const
|
||||
return std::max(0.0, 1 - std::pow(distance, 2.0) * inverseBandwidthSquared);
|
||||
}
|
||||
|
||||
// Return String of Object
|
||||
std::string EpanechnikovKernel::ToString() const{
|
||||
// Return string of object.
|
||||
std::string EpanechnikovKernel::ToString() const
|
||||
{
|
||||
std::ostringstream convert;
|
||||
convert << "EpanechnikovKernel [" << this << "]" << std::endl;
|
||||
convert << "Bandwidth: " << bandwidth << std::endl;
|
||||
convert << "Inverse Bandwidth Squared: ";
|
||||
convert << " Bandwidth: " << bandwidth << std::endl;
|
||||
convert << " Inverse squared bandwidth: ";
|
||||
convert << inverseBandwidthSquared << std::endl;
|
||||
return convert.str();
|
||||
}
|
||||
|
||||
@@ -98,18 +98,20 @@ class ExampleKernel
|
||||
* @param b Second vector.
|
||||
* @return K(a, b).
|
||||
*/
|
||||
std::string ToString() const{
|
||||
template<typename VecType>
|
||||
static double Evaluate(const VecType& a, const VecType& b) { return 0; }
|
||||
|
||||
/**
|
||||
* Returns a string for the kernel object; in this case, with only the memory
|
||||
* address for the kernel. If your kernel has any members, your ToString()
|
||||
* method should include those as neccessary as well.
|
||||
**/
|
||||
std::string ToString() const
|
||||
{
|
||||
std::ostringstream convert;
|
||||
convert << "ExampleKernel [" << this << "]" << std::endl;
|
||||
return convert.str();
|
||||
}
|
||||
/**
|
||||
* Returns a String for the Kernel Object; in this case, with only the memory
|
||||
* address for the Kernel. If your kernel has any members, your ToString
|
||||
* method should include those as neccessary as well.
|
||||
**/
|
||||
template<typename VecType>
|
||||
static double Evaluate(const VecType& a, const VecType& b) { return 0; }
|
||||
|
||||
/**
|
||||
* Obtains the convolution integral [integral K(||x-a||)K(||b-x||)dx]
|
||||
@@ -138,10 +140,10 @@ class ExampleKernel
|
||||
* @return the normalization constant.
|
||||
*/
|
||||
static double Normalizer() { return 0; }
|
||||
|
||||
// Modified to remove unused variable "dimension"
|
||||
|
||||
// Modified to remove unused variable "dimension"
|
||||
//static double Normalizer(size_t dimension=1) { return 0; }
|
||||
|
||||
|
||||
};
|
||||
|
||||
}; // namespace kernel
|
||||
|
||||
@@ -115,10 +115,12 @@ class GaussianKernel
|
||||
//! Get the precalculated constant.
|
||||
double Gamma() const { return gamma; }
|
||||
|
||||
// convert object to string
|
||||
std::string ToString() const{
|
||||
//! Convert object to string.
|
||||
std::string ToString() const
|
||||
{
|
||||
std::ostringstream convert;
|
||||
convert << "GaussianKernel [" << this << "]" << std::endl;
|
||||
convert << " Bandwidth: " << bandwidth << std::endl;
|
||||
return convert.str();
|
||||
}
|
||||
|
||||
|
||||
@@ -65,10 +65,13 @@ class HyperbolicTangentKernel
|
||||
//! Modify offset for the kernel.
|
||||
double& Offset() { return offset; }
|
||||
|
||||
// Convert Object to String
|
||||
std::string ToString() const{
|
||||
//! Convert object to string.
|
||||
std::string ToString() const
|
||||
{
|
||||
std::ostringstream convert;
|
||||
convert << "HyperbolicTangentKernel [" << this << "]" << std::endl;
|
||||
convert << " Scale: " << scale << std::endl;
|
||||
convert << " Offset: " << offset << std::endl;
|
||||
return convert.str();
|
||||
}
|
||||
|
||||
|
||||
@@ -76,11 +76,16 @@ class LaplacianKernel
|
||||
double Bandwidth() const { return bandwidth; }
|
||||
//! Modify the bandwidth.
|
||||
double& Bandwidth() { return bandwidth; }
|
||||
std::string ToString() const{
|
||||
|
||||
//! Return a string representation of the kernel.
|
||||
std::string ToString() const
|
||||
{
|
||||
std::ostringstream convert;
|
||||
convert << "LaplacianKernel [" << this << "]" << std::endl;
|
||||
convert << " Bandwidth: " << bandwidth << std::endl;
|
||||
return convert.str();
|
||||
}
|
||||
|
||||
private:
|
||||
//! Kernel bandwidth.
|
||||
double bandwidth;
|
||||
|
||||
@@ -48,9 +48,11 @@ class LinearKernel
|
||||
return arma::dot(a, b);
|
||||
}
|
||||
|
||||
std::string ToString() const{
|
||||
//! Return a string representation of the kernel.
|
||||
std::string ToString() const
|
||||
{
|
||||
std::ostringstream convert;
|
||||
convert << "Linear Kernel [" << this << "]" << std::endl;
|
||||
convert << "LinearKernel [" << this << "]" << std::endl;
|
||||
return convert.str();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -59,14 +59,17 @@ class PolynomialKernel
|
||||
const double& Offset() const { return offset; }
|
||||
//! Modify the offset of the dot product of the arguments.
|
||||
double& Offset() { return offset; }
|
||||
|
||||
// Return String of Object
|
||||
std::string ToString() const{
|
||||
|
||||
//! Return a string representation of the kernel.
|
||||
std::string ToString() const
|
||||
{
|
||||
std::ostringstream convert;
|
||||
convert << "PolynomialKernel [" << this << "]" << std::endl;
|
||||
convert << " Degree: " << degree << std::endl;
|
||||
convert << " Offset: " << offset << std::endl;
|
||||
return convert.str();
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
//! The degree of the polynomial.
|
||||
double degree;
|
||||
|
||||
@@ -80,10 +80,12 @@ class SphericalKernel
|
||||
return (t <= bandwidth) ? 1.0 : 0.0;
|
||||
}
|
||||
|
||||
// convert object to string
|
||||
std::string ToString() const{
|
||||
//! Return a string representation of the kernel.
|
||||
std::string ToString() const
|
||||
{
|
||||
std::ostringstream convert;
|
||||
convert << "SphericalKernel [" << this << "]" << std::endl;
|
||||
convert << " Bandwidth: " << bandwidth << std::endl;
|
||||
return convert.str();
|
||||
}
|
||||
|
||||
|
||||
@@ -61,10 +61,12 @@ class TriangularKernel
|
||||
//! Modify the bandwidth of the kernel.
|
||||
double& Bandwidth() { return bandwidth; }
|
||||
|
||||
// convert object to string
|
||||
std::string ToString() const{
|
||||
//! Return a string representation of the kernel.
|
||||
std::string ToString() const
|
||||
{
|
||||
std::ostringstream convert;
|
||||
convert << "TriangularKernel [" << this << "]" << std::endl;
|
||||
convert << " Bandwidth: " << bandwidth << std::endl;
|
||||
return convert.str();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user