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

pca_explained_variance_batch.h
1 /* file: pca_explained_variance_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 // Interface of the PCA quality metric in the batch processing mode.
21 //--
22 */
23 
24 #ifndef __PCA_EXPLAINED_VARIANCE_BATCH_H__
25 #define __PCA_EXPLAINED_VARIANCE_BATCH_H__
26 
27 #include "algorithms/algorithm.h"
28 #include "algorithms/pca/pca_explained_variance_types.h"
29 
30 namespace daal
31 {
32 namespace algorithms
33 {
34 namespace pca
35 {
36 namespace quality_metric
37 {
41 namespace explained_variance
42 {
43 
44 namespace interface1
45 {
58 template<typename algorithmFPType, Method method, CpuType cpu>
59 class BatchContainer : public daal::algorithms::AnalysisContainerIface<batch>
60 {
61 public:
63  BatchContainer(daal::services::Environment::env *daalEnv);
65  virtual ~BatchContainer();
66 
72  virtual services::Status compute() DAAL_C11_OVERRIDE;
73 };
74 
87 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
88 class DAAL_EXPORT Batch : public daal::algorithms::quality_metric::Batch
89 {
90 public:
91  typedef algorithms::pca::quality_metric::explained_variance::Input InputType;
92  typedef algorithms::pca::quality_metric::explained_variance::Parameter ParameterType;
93  typedef algorithms::pca::quality_metric::explained_variance::Result ResultType;
94 
95  InputType input;
96  ParameterType parameter;
99  Batch(size_t nFeatures = 0, size_t nComponents = 0): parameter(nFeatures, nComponents)
100  {
101  initialize();
102  }
103 
110  Batch(const Batch<algorithmFPType, method> &other): parameter(other.parameter)
111  {
112  initialize();
113  input.set(eigenvalues, other.input.get(eigenvalues));
114  }
115 
120  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
121 
126  ResultPtr getResult() const
127  {
128  return _result;
129  }
130 
137  services::Status setResult(const ResultPtr& result)
138  {
139  DAAL_CHECK(result, services::ErrorNullResult)
140  _result = result;
141  _res = _result.get();
142  return services::Status();
143  }
144 
149  virtual void setInput(const algorithms::Input *other) DAAL_C11_OVERRIDE
150  {
151  const InputType *inputPtr = static_cast<const InputType *>(other);
152  input.set(eigenvalues, inputPtr->get(eigenvalues));
153  }
154 
160  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
161  {
162  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
163  }
164 
165 protected:
166  virtual Batch<algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
167  {
168  return new Batch<algorithmFPType, method>(*this);
169  }
170 
171  services::Status allocateResult() DAAL_C11_OVERRIDE
172  {
173  services::Status s = _result->allocate<algorithmFPType>(&input, &parameter, (int) method);
174  _res = _result.get();
175  return s;
176  }
177 
178  virtual algorithms::ResultPtr getResultImpl() const DAAL_C11_OVERRIDE
179  {
180  return _result;
181  }
182 
183  void initialize()
184  {
185  Analysis<batch>::_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
186  _in = &input;
187  _par = &parameter;
188  _result.reset(new ResultType());
189  }
190 
191 private:
192  ResultPtr _result;
193 };
195 } // namespace interface1
196 using interface1::BatchContainer;
197 using interface1::Batch;
198 
199 }
200 }
201 }
202 }
203 }
204 #endif
daal::algorithms::pca::quality_metric::explained_variance::interface1::Batch::parameter
ParameterType parameter
Definition: pca_explained_variance_batch.h:96
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:149
daal::batch
Definition: daal_defines.h:112
daal::algorithms::pca::quality_metric::explained_variance::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: pca_explained_variance_batch.h:120
daal::algorithms::pca::quality_metric::explained_variance::interface1::Batch::setResult
services::Status setResult(const ResultPtr &result)
Definition: pca_explained_variance_batch.h:137
daal::services::ErrorNullResult
Definition: error_indexes.h:98
daal::algorithms::AnalysisContainerIface
Abstract interface class that provides virtual methods to access and run implementations of the analy...
Definition: analysis.h:55
daal::algorithms::pca::quality_metric::explained_variance::interface1::BatchContainer::~BatchContainer
virtual ~BatchContainer()
daal::algorithms::pca::quality_metric::explained_variance::interface1::BatchContainer::compute
virtual services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::pca::quality_metric::explained_variance::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: pca_explained_variance_batch.h:110
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:99
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:88
daal::algorithms::pca::quality_metric::explained_variance::interface1::BatchContainer
Class containing methods to compute regression quality metric.
Definition: pca_explained_variance_batch.h:59
daal::algorithms::pca::quality_metric::explained_variance::interface1::Batch::input
InputType input
Definition: pca_explained_variance_batch.h:95
daal::algorithms::pca::quality_metric::explained_variance::interface1::Batch::getResult
ResultPtr getResult() const
Definition: pca_explained_variance_batch.h:126
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:70
daal::algorithms::pca::quality_metric::explained_variance::eigenvalues
Definition: pca_explained_variance_types.h:63
daal::algorithms::pca::quality_metric::explained_variance::interface1::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::pca::quality_metric::explained_variance::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: pca_explained_variance_batch.h:160

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