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

normal.h
1 /* file: normal.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 normal distribution
21 //--
22 */
23 
24 #ifndef __NORMAL_H__
25 #define __NORMAL_H__
26 
27 #include "algorithms/distributions/distribution.h"
28 #include "algorithms/distributions/normal/normal_types.h"
29 
30 namespace daal
31 {
32 namespace algorithms
33 {
34 namespace distributions
35 {
36 namespace normal
37 {
43 namespace interface1
44 {
55 template<typename algorithmFPType, Method method, CpuType cpu>
56 class BatchContainer : public daal::algorithms::AnalysisContainerIface<batch>
57 {
58 public:
64  BatchContainer(daal::services::Environment::env *daalEnv);
65  ~BatchContainer();
71  services::Status compute() DAAL_C11_OVERRIDE;
72 };
73 
88 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
89 class DAAL_EXPORT Batch : public distributions::BatchBase
90 {
91 public:
92  typedef distributions::BatchBase super;
93 
94  typedef typename super::InputType InputType;
95  typedef algorithms::distributions::normal::Parameter<algorithmFPType> ParameterType;
96  typedef typename super::ResultType ResultType;
97 
103  Batch(algorithmFPType a = 0.0, algorithmFPType sigma = 1.0) : parameter(a, sigma)
104  {
105  initialize();
106  }
107 
112  Batch(const Batch<algorithmFPType, method> &other): super(other), parameter(other.parameter)
113  {
114  initialize();
115  }
116 
121  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
122 
127  ResultPtr getResult() { return _result; }
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 
148  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
149  {
150  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
151  }
152 
158  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
159  {
160  _par = &parameter;
161  services::Status s = this->_result->template allocate<algorithmFPType>(&(this->input), &parameter, (int) method);
162  this->_res = this->_result.get();
163  return s;
164  }
165 
166  Parameter<algorithmFPType> parameter;
168 protected:
169  virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
170  {
171  return new Batch<algorithmFPType, method>(*this);
172  }
173 
174  void initialize()
175  {
176  Analysis<batch>::_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
177  _in = &input;
178  _par = &parameter;
179  _result.reset(new ResultType());
180  }
181 
182 private:
183  ResultPtr _result;
184 };
185 
186 } // namespace interface1
187 using interface1::BatchContainer;
188 using interface1::Batch;
190 } // namespace normal
191 } // namespace distributions
192 } // namespace algorithms
193 } // namespace daal
194 #endif
daal::algorithms::distributions::normal::interface1::Batch::setResult
services::Status setResult(const ResultPtr &result)
Definition: normal.h:135
daal::algorithms::distributions::normal::interface1::BatchContainer
Provides methods to run implementations of the normal distribution. This class is associated with the...
Definition: normal.h:56
daal::algorithms::distributions::normal::interface1::Batch::parameter
Parameter< algorithmFPType > parameter
Definition: normal.h:166
daal::algorithms::distributions::normal::interface1::Batch
Provides methods for normal distribution computations in the batch processing mode.
Definition: normal.h:89
daal::batch
Definition: daal_defines.h:112
daal::algorithms::distributions::normal::interface1::BatchContainer::compute
services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::distributions::normal::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: normal.h:112
daal::algorithms::distributions::normal::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: normal.h:148
daal::algorithms::distributions::normal::interface1::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::distributions::normal::interface1::Batch::Batch
Batch(algorithmFPType a=0.0, algorithmFPType sigma=1.0)
Definition: normal.h:103
daal::algorithms::distributions::normal::interface1::Batch::allocateResult
virtual services::Status allocateResult() DAAL_C11_OVERRIDE
Definition: normal.h:158
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::distributions::normal::interface1::Batch::getResult
ResultPtr getResult()
Definition: normal.h:127
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:70
daal::algorithms::distributions::normal::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: normal.h:121
daal::algorithms::distributions::normal::interface1::Parameter
Normal distribution parameters.
Definition: normal_types.h:67

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