C++ API Reference for Intel® Data Analytics Acceleration Library 2020 Update 1

coordinate_descent_batch.h
1 /* file: coordinate_descent_batch.h */
2 /*******************************************************************************
3 * Copyright 2014-2020 Intel Corporation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *******************************************************************************/
17 
18 /*
19 //++
20 // Implementation of the interface for the Coordinate descent (COORDINATE_DESCENT) algorithm
21 // in the batch processing mode
22 //--
23 */
24 
25 #ifndef __COORDINATE_DESCENT_BATCH_H__
26 #define __COORDINATE_DESCENT_BATCH_H__
27 
28 #include "data_management/data/numeric_table.h"
29 #include "services/daal_defines.h"
30 #include "algorithms/optimization_solver/iterative_solver/iterative_solver_batch.h"
31 #include "coordinate_descent_types.h"
32 
33 namespace daal
34 {
35 namespace algorithms
36 {
37 namespace optimization_solver
38 {
39 namespace coordinate_descent
40 {
41 namespace interface1
42 {
56 template<typename algorithmFPType, Method method, CpuType cpu>
57 class BatchContainer : public daal::algorithms::AnalysisContainerIface<batch>
58 {
59 public:
65  BatchContainer(daal::services::Environment::env *daalEnv);
67  ~BatchContainer();
73  virtual services::Status compute() DAAL_C11_OVERRIDE;
74 };
75 
90 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
91 class DAAL_EXPORT Batch : public iterative_solver::Batch
92 {
93 public:
94  typedef algorithms::optimization_solver::coordinate_descent::Input InputType;
95  typedef algorithms::optimization_solver::coordinate_descent::Parameter ParameterType;
96  typedef algorithms::optimization_solver::coordinate_descent::Result ResultType;
97 
98  InputType input;
101  Batch(const sum_of_functions::BatchPtr& objectiveFunction = sum_of_functions::BatchPtr());
102 
109  Batch(const Batch<algorithmFPType, method> &other);
110 
111  ~Batch()
112  {
113  delete _par;
114  }
119  ParameterType& parameter() { return *static_cast<ParameterType*>(_par); }
120 
125  const ParameterType& parameter() const { return *static_cast<const ParameterType*>(_par); }
126 
131  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
132 
137  virtual iterative_solver::Input * getInput() DAAL_C11_OVERRIDE { return &input; }
138 
143  virtual iterative_solver::Parameter * getParameter() DAAL_C11_OVERRIDE { return &parameter(); }
144 
150  virtual services::Status createResult() DAAL_C11_OVERRIDE
151  {
152  _result = iterative_solver::ResultPtr(new ResultType());
153  _res = NULL;
154  return services::Status();
155  }
156 
162  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
163  {
164  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
165  }
166 
171  static services::SharedPtr<Batch<algorithmFPType, method> > create();
172 
173 protected:
174  virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
175  {
176  return new Batch<algorithmFPType, method>(*this);
177  }
178 
179  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
180  {
181  services::Status s = static_cast<ResultType*>(_result.get())->allocate<algorithmFPType>(&input, _par, (int)method);
182  _res = _result.get();
183  return s;
184  }
185 
186  void initialize()
187  {
188  Analysis<batch>::_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
189  _in = &input;
190  _result.reset(new ResultType());
191  }
192 };
194 } // namespace interface1
195 using interface1::BatchContainer;
196 using interface1::Batch;
197 
198 } // namespace coordinate_descent
199 } // namespace optimization_solver
200 } // namespace algorithm
201 } // namespace daal
202 #endif
daal::batch
Definition: daal_defines.h:112
daal::algorithms::optimization_solver::coordinate_descent::interface1::BatchContainer::compute
virtual services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::optimization_solver::coordinate_descent::interface1::Batch::parameter
const ParameterType & parameter() const
Definition: coordinate_descent_batch.h:125
daal::algorithms::optimization_solver::coordinate_descent::interface1::Batch::getInput
virtual iterative_solver::Input * getInput() DAAL_C11_OVERRIDE
Definition: coordinate_descent_batch.h:137
daal::algorithms::optimization_solver::coordinate_descent::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: coordinate_descent_batch.h:162
daal::algorithms::AnalysisContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the analy...
Definition: analysis.h:55
daal_defines.h
daal::algorithms::optimization_solver::coordinate_descent::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: coordinate_descent_batch.h:131
daal::algorithms::optimization_solver::coordinate_descent::interface1::Batch::parameter
ParameterType & parameter()
Definition: coordinate_descent_batch.h:119
daal::algorithms::optimization_solver::coordinate_descent::interface1::BatchContainer
Provides methods to run implementations of the coordinate descent algorithm. This class is associated...
Definition: coordinate_descent_batch.h:57
daal::algorithms::optimization_solver::coordinate_descent::interface1::Batch::getParameter
virtual iterative_solver::Parameter * getParameter() DAAL_C11_OVERRIDE
Definition: coordinate_descent_batch.h:143
daal::algorithms::optimization_solver::coordinate_descent::interface1::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::optimization_solver::coordinate_descent::interface1::BatchContainer::~BatchContainer
~BatchContainer()
daal::algorithms::optimization_solver::coordinate_descent::interface1::Batch
Computes Coordinate descent in the batch processing mode.
Definition: coordinate_descent_batch.h:91
daal::algorithms::optimization_solver::coordinate_descent::interface1::Batch::createResult
virtual services::Status createResult() DAAL_C11_OVERRIDE
Definition: coordinate_descent_batch.h:150
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:70
daal::algorithms::optimization_solver::coordinate_descent::interface1::Batch::input
InputType input
Definition: coordinate_descent_batch.h:98

For more complete information about compiler optimizations, see our Optimization Notice.