C++ API Reference for Intel® Data Analytics Acceleration Library 2018 Update 3

pca_explained_variance_batch.h
1 /* file: pca_explained_variance_batch.h */
2 /*******************************************************************************
3 * Copyright 2014-2018 Intel Corporation.
4 *
5 * This software and the related documents are Intel copyrighted materials, and
6 * your use of them is governed by the express license under which they were
7 * provided to you (License). Unless the License provides otherwise, you may not
8 * use, modify, copy, publish, distribute, disclose or transmit this software or
9 * the related documents without Intel's prior written permission.
10 *
11 * This software and the related documents are provided as is, with no express
12 * or implied warranties, other than those that are expressly stated in the
13 * License.
14 *******************************************************************************/
15 
16 /*
17 //++
18 // Interface of the linear regression single beta quality metric in the batch processing mode.
19 //--
20 */
21 
22 #ifndef __PCA_EXPLAINED_VARIANCE_BATCH_H__
23 #define __PCA_EXPLAINED_VARIANCE_BATCH_H__
24 
25 #include "algorithms/algorithm.h"
26 #include "algorithms/pca/pca_explained_variance_types.h"
27 
28 namespace daal
29 {
30 namespace algorithms
31 {
32 namespace pca
33 {
34 namespace quality_metric
35 {
39 namespace explained_variance
40 {
41 
42 namespace interface1
43 {
56 template<typename algorithmFPType, Method method, CpuType cpu>
57 class DAAL_EXPORT BatchContainer : public daal::algorithms::AnalysisContainerIface<batch>
58 {
59 public:
61  BatchContainer(daal::services::Environment::env *daalEnv);
63  virtual ~BatchContainer();
64 
70  virtual services::Status compute() DAAL_C11_OVERRIDE;
71 };
72 
85 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
86 class DAAL_EXPORT Batch : public daal::algorithms::quality_metric::Batch
87 {
88 public:
89  typedef algorithms::pca::quality_metric::explained_variance::Input InputType;
90  typedef algorithms::pca::quality_metric::explained_variance::Parameter ParameterType;
91  typedef algorithms::pca::quality_metric::explained_variance::Result ResultType;
92 
93  InputType input;
94  ParameterType parameter;
97  Batch(size_t nFeatures = 0, size_t nComponents = 0): parameter(nFeatures, nComponents)
98  {
99  initialize();
100  }
101 
108  Batch(const Batch<algorithmFPType, method> &other): parameter(other.parameter)
109  {
110  initialize();
111  input.set(eigenvalues, other.input.get(eigenvalues));
112  }
113 
118  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
119 
124  ResultPtr getResult() const
125  {
126  return _result;
127  }
128 
135  services::Status setResult(const ResultPtr& result)
136  {
137  DAAL_CHECK(result, services::ErrorNullResult)
138  _result = result;
139  _res = _result.get();
140  return services::Status();
141  }
142 
147  virtual void setInput(const algorithms::Input *other) DAAL_C11_OVERRIDE
148  {
149  const InputType *inputPtr = static_cast<const InputType *>(other);
150  input.set(eigenvalues, inputPtr->get(eigenvalues));
151  }
152 
158  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
159  {
160  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
161  }
162 
163 protected:
164  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
165  {
166  return new Batch<algorithmFPType, method>(*this);
167  }
168 
169  services::Status allocateResult() DAAL_C11_OVERRIDE
170  {
171  services::Status s = _result->allocate<algorithmFPType>(&input, &parameter, (int) method);
172  _res = _result.get();
173  return s;
174  }
175 
176  virtual algorithms::ResultPtr getResultImpl() const DAAL_C11_OVERRIDE
177  {
178  return _result;
179  }
180 
181  void initialize()
182  {
183  Analysis<batch>::_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
184  _in = &input;
185  _par = &parameter;
186  _result.reset(new ResultType());
187  }
188 
189 private:
190  ResultPtr _result;
191 };
193 } // namespace interface1
194 using interface1::BatchContainer;
195 using interface1::Batch;
196 
197 }
198 }
199 }
200 }
201 }
202 #endif
daal::algorithms::pca::quality_metric::explained_variance::interface1::BatchContainer
Class containing methods to compute regression quality metric.
Definition: pca_explained_variance_batch.h:57
daal
Definition: algorithm_base_common.h:31
daal::algorithms::AnalysisContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the analy...
Definition: analysis.h:53
daal::algorithms::pca::quality_metric::explained_variance::interface1::Batch::setInput
virtual void setInput(const algorithms::Input *other) DAAL_C11_OVERRIDE
Definition: pca_explained_variance_batch.h:147
daal::algorithms::pca::quality_metric::explained_variance::interface1::Batch::input
InputType input
Definition: pca_explained_variance_batch.h:93
daal::batch
Definition: daal_defines.h:106
daal::algorithms::pca::quality_metric::explained_variance::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: pca_explained_variance_batch.h:158
daal::algorithms::pca::quality_metric::explained_variance::interface1::Batch::Batch
Batch(size_t nFeatures=0, size_t nComponents=0)
Definition: pca_explained_variance_batch.h:97
daal::algorithms::pca::quality_metric::explained_variance::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: pca_explained_variance_batch.h:108
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:68
daal::algorithms::pca::quality_metric::explained_variance::eigenvalues
Definition: pca_explained_variance_types.h:61
daal::algorithms::pca::quality_metric::explained_variance::interface1::Batch::getResult
ResultPtr getResult() const
Definition: pca_explained_variance_batch.h:124
daal::algorithms::pca::quality_metric::explained_variance::interface1::Batch::setResult
services::Status setResult(const ResultPtr &result)
Definition: pca_explained_variance_batch.h:135
daal::algorithms::pca::quality_metric::explained_variance::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: pca_explained_variance_batch.h:118
daal::services::ErrorNullResult
Definition: error_indexes.h:96
daal::algorithms::pca::quality_metric::explained_variance::interface1::Batch::parameter
ParameterType parameter
Definition: pca_explained_variance_batch.h:94
daal::algorithms::pca::quality_metric::explained_variance::interface1::Batch
Computes the linear regression quality metric in the batch processing mode.
Definition: pca_explained_variance_batch.h:86

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