<?php $isip_window_title = "ISIP Homepage"; ?>
<?php include("/data/isip/www/templates/documentation/header/header.html"); ?>

<!--#set var="isip_page_title" value="Kernel" -->
<?php include("/data/isip/www/templates/documentation/body/index_class.html"); ?>
<?php include("/data/isip/www/templates/documentation/body/bar.html"); ?>

<a name="name">
<b>
name:
<a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/Kernel.h">Kernel</a></b>

<br><br>

<a name="synopsis">
<b>synopsis:</b>
<br><br>

<blockquote>
<pre>
g++ [flags ...] file ... -l /isip/tools/lib/$ISIP_BINARY/lib_numeric.a

#include &lt;Kernel.h&gt;
#include &lt;Kernel.h&gt;

boolean setConstants(const VectorFloat& constants);
boolean compute(float& value, const VectorFloat& x, const VectorFloat& y);
</pre>
</blockquote>

<a name="quick_start">
<b>quick start:</b>
<br><br>

<blockquote>
<pre>
// define kernel constants
//
VectorFloat constants(L"1.4");

// define kernel
//
Kernel k;
k.setAlgorithm(Kernel::RBF);
k.setConstants(constants);

// evaluate result = kernel(x, y)
//
VectorFloat x(L"1, 3, 5");
VectorFloat y(L"2, 4, 6");
float result;
k.compute(result, x, y);
</pre>
</blockquote>

<a name="description"> 
<b>description:</b>
<br><br>

The Kernel class is used to evaluate Kernel functions.
Equations of the currently supported kernels are shown below:
<br><br>

<img src="./index.jpg">
<br><br>

<a name="dependencies">
<b>dependencies:</b>
<br><br>

<ul>
  <li> <a href="../../system/NameMap/index.html">NameMap</a>
       
  <li> <a href="../../math/vector/VectorDouble/index.html">VectorDouble</a>
       
  <li> <a href="../../math/vector/VectorFloat/index.html">VectorFloat</a>
       
</ul>

<a name="constants">
<b>public constants:</b>
<br><br>

<ul>
  <li> define the class name:
       
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/kern_00.cc&constant=CLASS_NAME">static const String CLASS_NAME = L"Kernel";</a></pre>

  <li> kernel choices:
       
       <pre>enum ALGORITHM { LINEAR = 0,  POLYNOMIAL, RBF, SIGMOID, DEF_ALGORITHM = LINEAR };</pre>

  <li> define static NameMap objects:
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/kern_00.cc&constant=ALGO_MAP">static const NameMap ALGO_MAP;</a></pre>

  <li> i/o related constants:
       
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/kern_00.cc&constant=DEF_PARAM">static const String DEF_PARAM = L"";</pre>
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/kern_00.cc&constant=PARAM_ALGORITHM">static const String PARAM_ALGORITHM = L"algorithm";</a></pre>
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/kern_00.cc&constant=PARAM_CONSTANTS">static const String PARAM_CONSTANTS = L"constants";</a></pre>

  <li> define the default value(s) of the class data:
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/kern_00.cc&constant=DEF_LIN_CONSTANTS">static const VectorFloat DEF_LIN_CONSTANTS;</a></pre>
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/kern_00.cc&constant=DEF_POLY_CONSTANTS">static const VectorFloat DEF_POLY_CONSTANTS;</a></pre>
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/kern_00.cc&constant=DEF_RBF_CONSTANTS">static const VectorFloat DEF_RBF_CONSTANTS;</a></pre>
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/kern_00.cc&constant=DEF_SIGM_CONSTANTS">static const VectorFloat DEF_SIGM_CONSTANTS;</a></pre>
</ul>

<a name="error">
<b>error codes:</b>
<br><br>

<ul>
  <li> error codes:

       <pre><a href="/perl/ifc_document.pl?err=00035700">static const long ERR = 35700;</a></pre>
       <pre><a href="/perl/ifc_document.pl?err=00035701">static const long ERR = 35701;</a></pre>
       <pre><a href="/perl/ifc_document.pl?err=00035702">static const long ERR = 35702;</a></pre>
</ul>

<a name="protected">
<b>protected data:</b>
<br><br>

<ul>
  <li> parameters of the Kernel function

       <pre>ALGORITHM algorithm_d;</pre>
       <pre>VectorFloat constants_d;</pre>
       <pre>boolean is_valid_d;</pre>       

  <li> a static memory manager:

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/kern_00.cc&static=mgr_d">static MemoryManager mgr_d;</pre></a>

  <li> debug level:

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/kern_00.cc&static=debug_level_d">static Integral::DEBUG debug_level_d;</a></pre>
       
</ul>

<a name="public">
<b>required public methods:</b>
<br><br>

<ul>
  <li>  static methods:

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/Kernel.h&method=name">static const String& name();</a></pre>
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/kern_02.cc&method=diagnose">static boolean diagnose(Integral::DEBUG debug_level);</a></pre>

  <li> debug methods:
       
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/Kernel.h&method=setDebug">boolean setDebug(Integral::DEBUG debug_level);</a></pre>
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/kern_01.cc&method=debug">boolean debug(const unichar* message) const;</a></pre>

  <li> destructor/constructor(s):
       
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/Kernel.h&method=destructor">~Kernel();</a></pre>
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/Kernel.h&method=default+constructor">Kernel();</a></pre>
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/Kernel.h&method=copy+constructor">Kernel(const Kernel& arg);</a></pre>     

  <li> assign methods:
       
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/kern_00.cc&method=assign">boolean assign(const Kernel& arg)</a></pre>

  <li> operator= methods:
       
      <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/Kernel.h&method=operator%3D">Kernel& operator= (const Kernel& arg);</a></pre>
                     
  <li> i/o methods:
       
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/kern_04.cc&method=sofSize">long sofSize() const;</a></pre>
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/kern_03.cc&method=read">boolean read(Sof& sof, long tag, const String& name = CLASS_NAME);</a></pre>
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/kern_04.cc&method=write">boolean write(Sof& sof, long tag, const String& name = CLASS_NAME) const;</a></pre>
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/kern_03.cc&method=readData">boolean readData(Sof& sof, const String& pname = DEF_PARAM,long size = SofParser::FULL_OBJECT, boolean param = true, boolean nested = false);</a></pre>
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/kern_04.cc&method=writeData">boolean writeData(Sof& sof, const String& pname = DEF_PARAM) const;</a></pre>
       
  <li> equality methods:
       
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/kern_00.cc&method=eq">boolean eq(const Kernel& arg) const;</a></pre>

  <li> memory management methods:
       
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/Kernel.h&method=new">static void* operator new(size_t size);</a></pre>
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/Kernel.h&method=new[]">static void* operator new[](size_t size);</a></pre>
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/Kernel.h&method=delete">static void operator delete(void* ptr);</a></pre>
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/Kernel.h&method=delete[]">static void operator delete[](void* ptr);</a></pre>  
        <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/Kernel.h&method=setGrowSize">static boolean setGrowSize(long grow_size);</a></pre>  
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/kern_00.cc&method=clear">boolean clear(Integral::CMODE ctype = Integral::DEF_CMODE);</a></pre>
</ul>

<a name="specific">
<b>class-specific public methods:</b>
<br><br>

<ul>
  <li> set methods:
       
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/Kernel.h&method=setAlgorithm">boolean setAlgorithm(ALGORITHM algorithm);</a></pre>
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/kern_06.cc&method=setConstants">boolean setConstants(const VectorFloat& constants);</a></pre>

  <li> get methods:
       
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/Kernel.h&method=getAlgorithm">ALGORITHM getAlgorithm();</a></pre>
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/Kernel.h&method=getConstants">const VectorFloat& getConstants() const;</a></pre>
       
  <li> computational methods:
       
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/kern_05.cc&method=compute&instance=0">boolean compute(float& value, const VectorFloat& x, const VectorFloat& y);</a></pre>
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/kern_05.cc&method=compute&instance=1">boolean compute(double& value, const VectorDouble& x, const VectorDouble& y);</a></pre>

  <li> initialization methods:
       
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/kern_00.cc&method=init">boolean init();</a></pre>

</ul>
  
<a name="private">
<b>private methods:</b>
<br><br>

<ul>
  <li> templatized computation methods:

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/kern_05.cc&method=computeLinear&instance=0">boolean computeLinear(float& value, const VectorFloat& x, const VectorFloat& y);</a></pre>
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/kern_05.cc&method=computeLinear&instance=1">boolean computeLinear(double& value, const VectorDouble& x, const VectorDouble& y);</a></pre>
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/kern_05.cc&method=computePolynomial&instance=0">boolean computePolynomial(float& value, const VectorFloat& x, const VectorFloat& y);</a></pre>
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/kern_05.cc&method=computePolynomial&instance=1">boolean computePolynomial(double& value, const VectorDouble& x, const VectorDouble& y);</a></pre>
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/kern_05.cc&method=computeRBF&instance=0">boolean computeRBF(float& value, const VectorFloat& x, const VectorFloat& y);</a></pre>
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/kern_05.cc&method=computeRBF&instance=1">boolean computeRBF(double& value, const VectorDouble& x, const VectorDouble& y);</a></pre>
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/kern_05.cc&method=computeSigmoid&instance=0">boolean computeSigmoid(float& value, const VectorFloat& x, const VectorFloat& y);</a></pre>
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/numeric/Kernel/kern_05.cc&method=computeSigmoid&instance=1">boolean computeSigmoid(double& value, const VectorDouble& x, const VectorDouble& y);</a></pre>
</ul>

<a name="examples">
<b>examples:</b>
<br><br>

<ul>

  <li> This example shows how to create and evaluate different Kernel functions:

<pre>
// isip include files
//
#include &lt;Kernel.h&gt
#include &lt;Console.h&gt

// main program starts here
//
int main (int argc, const char **argv) {

  // define two vectors
  //
  VectorFloat x(L"1.2, 0.3, 0.1");
  VectorFloat y(L"0.2, 1.1, 0.8");

  // define output string and resulting value
  //
  String out;
  float result;

  // define kernel and kernel constants
  //
  Kernel k;
  VectorFloat constants;

  // evaluate y = kernel(x, y) for LINEAR, POLYNOMIAL, RBF and SIGMOID kernels
  //
  k.setAlgorithm(Kernel::LINEAR);
  k.compute(result, x, y);
  out.assign(result);
  Console::put(out);

  k.setAlgorithm(Kernel::POLYNOMIAL);
  constants.assign(L"0.2");
  k.setConstants(constants);
  k.compute(result, x, y);
  out.assign(result);
  Console::put(out);

  k.setAlgorithm(Kernel::RBF);
  constants.assign(L"0.5");
  k.setConstants(constants);
  k.compute(result, x, y);
  out.assign(result);
  Console::put(out);

  k.setAlgorithm(Kernel::SIGMOID);
  constants.assign(L"0.2, 0.4");
  k.setConstants(constants);
  k.compute(result, x, y);
  out.assign(result);
  Console::put(out);

  // exit gracefully
  //
  Integral::exit();
}
</pre>       
</ul>

<a name="notes">
<b>notes:</b>
<ul>
  <li> None.
</ul>

<!--#include virtual="/hse/ies/templates/documentation/footer/footer.html" -->
