00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00043
#include "SourceKernel.h"
00044
00045
namespace PLearn {
00046
using namespace std;
00047
00049
00051 SourceKernel::SourceKernel()
00052
00053 {}
00054
00055
PLEARN_IMPLEMENT_OBJECT(
SourceKernel,
00056
"A kernel built upon an underlying source kernel",
00057
"The default behavior of a SourceKernel is to forward all calls to the underlying\n"
00058
"kernel. However, subclasses will probably want to override the methods to perform\n"
00059
"more complex operations."
00060 );
00061
00063
00065 void SourceKernel::declareOptions(
OptionList& ol)
00066 {
00067
declareOption(ol,
"source_kernel", &SourceKernel::source_kernel, OptionBase::buildoption,
00068
"The underlying kernel.");
00069
00070
00071 inherited::declareOptions(ol);
00072 }
00073
00075
00077 void SourceKernel::build()
00078 {
00079 inherited::build();
00080
build_();
00081 }
00082
00084
00086 void SourceKernel::build_()
00087 {
00088 this->is_symmetric =
source_kernel->is_symmetric;
00089 this->data_inputsize =
source_kernel->dataInputsize();
00090 this->n_examples =
source_kernel->nExamples();
00091
if (specify_dataset) {
00092
00093
if (static_cast<VMatrix*>(specify_dataset) != static_cast<VMatrix*>(
source_kernel->specify_dataset)) {
00094
source_kernel->specify_dataset = specify_dataset;
00095
source_kernel->build();
00096 }
00097 }
00098 }
00099
00101
00103 void SourceKernel::addDataForKernelMatrix(
const Vec& newRow) {
00104
00105
00106
00107
source_kernel->addDataForKernelMatrix(newRow);
00108 }
00109
00111
00113 void SourceKernel::computeGramMatrix(
Mat K)
const {
00114
source_kernel->computeGramMatrix(K);
00115 }
00116
00118
00120 real SourceKernel::evaluate(
const Vec& x1,
const Vec& x2)
const {
00121
return source_kernel->evaluate(x1, x2);
00122 }
00123
00125
00127 real SourceKernel::evaluate_i_j(
int i,
int j)
const {
00128
return source_kernel->evaluate_i_j(i,j);
00129 }
00130
00132
00134 real SourceKernel::evaluate_i_x(
int i,
const Vec& x,
real squared_norm_of_x)
const {
00135
return source_kernel->evaluate_i_x(i,
x, squared_norm_of_x);
00136 }
00137
00139
00141 real SourceKernel::evaluate_x_i(
const Vec& x,
int i,
real squared_norm_of_x)
const {
00142
return source_kernel->evaluate_x_i(
x, i, squared_norm_of_x);
00143 }
00144
00146
00148 Vec SourceKernel::getParameters()
const {
00149
return source_kernel->getParameters();
00150 }
00151
00153
00155 void SourceKernel::makeDeepCopyFromShallowCopy(map<const void*, void*>& copies)
00156 {
00157 inherited::makeDeepCopyFromShallowCopy(copies);
00158
deepCopyField(
source_kernel, copies);
00159 }
00160
00162
00164 void SourceKernel::setDataForKernelMatrix(
VMat the_data) {
00165 inherited::setDataForKernelMatrix(the_data);
00166
source_kernel->setDataForKernelMatrix(the_data);
00167 }
00168
00170
00172 void SourceKernel::setParameters(
Vec paramvec) {
00173
source_kernel->setParameters(paramvec);
00174 }
00175
00176 }
00177