<commit_before><commit_msg>ENH: kernel used for kernel function/density estimation<commit_after>/*==========================================================================

  Program:   Insight Segmentation & Registration Toolkit
  Module:    itkKernelFunction.h
  Language:  C++
  Date:      $Date$
  Version:   $Revision$

  Copyright (c) 2000 National Library of Medicine
  All rights reserved.

  See COPYRIGHT.txt for copyright details.
  
==========================================================================*/
#ifndef _itkKernelFunction_h
#define _itkKernelFunction_h

#include "vnl/vnl_math.h"

namespace itk
{

/**
 * \class KernelFunction
 * \brief Kernel used for kernel function/density estimation.
 */
class ITK_EXPORT KernelFunction : public Object
{
public:  
  /**
   * Standard "Self" typedef.
   */
  typedef KernelFunction Self;

  /**
   * Standard "Superclass" typedef.
   */
  typedef Object Superclass;

  /** 
   * Smart pointer typedef support.
   */
  typedef SmartPointer<Self>  Pointer;

  /**
   * Evaluate the function.
   */
  virtual double Evaluate (const double u) = 0;

protected:  
  KernelFunction(){};  
  ~KernelFunction(){};

};

/**
 * \class GaussianKernelFunction
 * \brief Gaussian kernel used for kernel function/density estimation.
 */
class ITK_EXPORT GaussianKernelFunction : public KernelFunction
{
public:
  /**
   * Standard "Self" typedef.
   */
  typedef GaussianKernelFunction Self;

  /**
   * Standard "Superclass" typedef.
   */
  typedef KernelFunction Superclass;

  /** 
   * Smart pointer typedef support.
   */
  typedef SmartPointer<Self>  Pointer;

  /**
   * Method for creation through the object factory.
   */
  itkNewMacro(Self);  

  /**
   * Evaluate the function.
   */
  inline double Evaluate (const double u)
  {
    return ( exp( -0.5 * vnl_math_sqr( u ) ) * m_Factor );
  }

protected:

  GaussianKernelFunction()
  { 
    m_Factor = 1.0 / vnl_math_sqrt( 2.0 * vnl_math::pi ); 
  };

  ~GaussianKernelFunction(){};

private:
  double m_Factor;

};

} // namespace itk

#endif
{'fraction_non_alphanumeric': 0.17541302235179787, 'fraction_numerical': 0.005344995140913508, 'mean_word_length': 3.390191897654584, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1054599', 'n_tokens_mistral': 635, 'n_tokens_neox': 596, 'n_words': 162}