-
Notifications
You must be signed in to change notification settings - Fork 224
Expand file tree
/
Copy pathkernel_function.h
More file actions
143 lines (125 loc) · 4.62 KB
/
kernel_function.h
File metadata and controls
143 lines (125 loc) · 4.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/* file: kernel_function.h */
/*******************************************************************************
* Copyright 2014 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
/*
//++
// Public interface for kernel functions.
//--
*/
#ifndef __KERNEL_FUNCTION_H__
#define __KERNEL_FUNCTION_H__
#include "algorithms/algorithm.h"
#include "data_management/data/numeric_table.h"
#include "algorithms/kernel_function/kernel_function_types.h"
namespace daal
{
namespace algorithms
{
namespace kernel_function
{
/**
* @addtogroup kernel_function
* @{
*/
/**
* <a name="DAAL-ENUM-ALGORITHMS__KERNEL_FUNCTION__KERNELFUNCTIONTYPE"></a>
* \brief Available kernel function types
*/
enum KernelFunctionType
{
linearKernel = 0, /*!< Linear kernel function: k(X,Y) + b */
rbfKernel = 1, /*!< Radial Basis Function (RBF) kernel */
polynomialKernel = 2 /*!< Polynomial kernel function */
};
namespace interface1
{
/**
* <a name="DAAL-CLASS-ALGORITHMS__KERNEL_FUNCTION__KERNELIFACE"></a>
* \brief Abstract class that specifies the interface of the algorithms
* for computing kernel functions in the batch processing mode
*/
class KernelIface : public daal::algorithms::Analysis<batch>
{
public:
typedef algorithms::kernel_function::Input InputType;
typedef algorithms::kernel_function::ParameterBase ParameterType;
typedef algorithms::kernel_function::Result ResultType;
KernelIface() { initialize(); }
/**
* Constructs an algorithm for computing kernel functions by copying input objects and parameters
* of another algorithm for computing kernel functions
* \param[in] other An algorithm to be used as the source to initialize the input objects
* and parameters of the algorithm
*/
KernelIface(const KernelIface & /*other*/) { initialize(); }
/**
* Get input objects for the kernel function algorithm
* \return %Input objects for the kernel function algorithm
*/
virtual Input * getInput() = 0;
/**
* Get parameters of the kernel function algorithm
* \return Parameters of the kernel function algorithm
*/
virtual ParameterBase * getParameter() = 0;
virtual ~KernelIface() {}
/**
* Returns the structure that contains computed results of the kernel function algorithm
* \returns the Structure that contains computed results of the kernel function algorithm
*/
ResultPtr getResult() { return _result; }
/**
* Registers user-allocated memory to store results of the kernel function algorithm
* \param[in] res Structure to store the results
*/
services::Status setResult(const ResultPtr & res)
{
DAAL_CHECK(res, services::ErrorNullResult)
_result = res;
_res = _result.get();
return services::Status();
}
/**
* Returns a pointer to the newly allocated algorithm for computing kernel functions with a copy of input objects
* and parameters of this algorithm for computing kernel functions
* \return Pointer to the newly allocated algorithm
*/
DAAL_FORCEINLINE services::SharedPtr<KernelIface> clone() const { return services::SharedPtr<KernelIface>(cloneImpl()); }
protected:
void initialize() { _result = ResultPtr(new kernel_function::Result()); }
KernelIface * cloneImpl() const override = 0;
ResultPtr _result;
private:
KernelIface & operator=(const KernelIface &);
};
typedef services::SharedPtr<KernelIface> KernelIfacePtr;
/**
* Creates a kernel function of specified type
* \tparam algorithmFPType Data type for the kernel function (float or double)
* \param[in] type Type of the kernel function to create
* \return Pointer to the newly created kernel function
*/
template <typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE>
DAAL_EXPORT KernelIfacePtr createKernelFunction(KernelFunctionType type);
} // namespace interface1
using interface1::KernelIface;
using interface1::KernelIfacePtr;
using interface1::createKernelFunction;
/** @} */
} // namespace kernel_function
} // namespace algorithms
} // namespace daal
#endif