C++ API Reference for Intel® Data Analytics Acceleration Library 2019 Update 5

bernoulli.h
1 /* file: bernoulli.h */
2 /*******************************************************************************
3 * Copyright 2014-2019 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 // Implementation of the bernoulli distribution
19 //--
20 */
21 
22 #ifndef __BERNOULLI_H__
23 #define __BERNOULLI_H__
24 
25 #include "algorithms/distributions/distribution.h"
26 #include "algorithms/distributions/bernoulli/bernoulli_types.h"
27 
28 namespace daal
29 {
30 namespace algorithms
31 {
32 namespace distributions
33 {
34 namespace bernoulli
35 {
41 namespace interface1
42 {
53 template<typename algorithmFPType, Method method, CpuType cpu>
54 class DAAL_EXPORT BatchContainer : public daal::algorithms::AnalysisContainerIface<batch>
55 {
56 public:
62  BatchContainer(daal::services::Environment::env *daalEnv);
63  ~BatchContainer();
69  services::Status compute() DAAL_C11_OVERRIDE;
70 };
71 
86 template<typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
87 class DAAL_EXPORT Batch : public distributions::BatchBase
88 {
89 public:
90  typedef distributions::BatchBase super;
91 
92  typedef typename super::InputType InputType;
93  typedef algorithms::distributions::bernoulli::Parameter<algorithmFPType> ParameterType;
94  typedef typename super::ResultType ResultType;
95 
100  Batch(algorithmFPType p) : parameter(p)
101  {
102  initialize();
103  }
104 
109  Batch(const Batch<algorithmFPType, method> &other): super(other), parameter(other.parameter)
110  {
111  initialize();
112  }
113 
118  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
119 
124  ResultPtr getResult() { return _result; }
125 
132  services::Status setResult(const ResultPtr& result)
133  {
134  DAAL_CHECK(result, services::ErrorNullResult)
135  _result = result;
136  _res = _result.get();
137  return services::Status();
138  }
139 
145  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
146  {
147  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
148  }
149 
155  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
156  {
157  _par = &parameter;
158  services::Status s = this->_result->template allocate<algorithmFPType>(&(this->input), &parameter, (int) method);
159  this->_res = this->_result.get();
160  return s;
161  }
162 
163  Parameter<algorithmFPType> parameter;
165 protected:
166  virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
167  {
168  return new Batch<algorithmFPType, method>(*this);
169  }
170 
171  void initialize()
172  {
173  Analysis<batch>::_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
174  _in = &input;
175  _par = &parameter;
176  _result.reset(new ResultType());
177  }
178 
179 private:
180  ResultPtr _result;
181 };
182 
183 } // namespace interface1
184 using interface1::BatchContainer;
185 using interface1::Batch;
187 } // namespace bernoulli
188 } // namespace distributions
189 } // namespace algorithms
190 } // namespace daal
191 #endif
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::distributions::bernoulli::interface1::Batch
Provides methods for bernoulli distribution computations in the batch processing mode.
Definition: bernoulli.h:87
daal::algorithms::distributions::bernoulli::interface1::Parameter
Bernoulli distribution parameters.
Definition: bernoulli_types.h:64
daal::algorithms::distributions::bernoulli::interface1::Batch::getResult
ResultPtr getResult()
Definition: bernoulli.h:124
daal::algorithms::distributions::bernoulli::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: bernoulli.h:145
daal::batch
Definition: daal_defines.h:110
daal::algorithms::distributions::bernoulli::interface1::Batch::Batch
Batch(algorithmFPType p)
Definition: bernoulli.h:100
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:68
daal::algorithms::distributions::bernoulli::interface1::BatchContainer
Provides methods to run implementations of the bernoulli distribution. This class is associated with ...
Definition: bernoulli.h:54
daal::algorithms::distributions::bernoulli::interface1::Batch::allocateResult
virtual services::Status allocateResult() DAAL_C11_OVERRIDE
Definition: bernoulli.h:155
daal::algorithms::distributions::bernoulli::interface1::Batch::parameter
Parameter< algorithmFPType > parameter
Definition: bernoulli.h:163
daal::algorithms::distributions::bernoulli::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: bernoulli.h:109
daal::services::ErrorNullResult
Definition: error_indexes.h:96
daal::algorithms::distributions::bernoulli::interface1::Batch::setResult
services::Status setResult(const ResultPtr &result)
Definition: bernoulli.h:132
daal::algorithms::distributions::bernoulli::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: bernoulli.h:118

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