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

bernoulli.h
1 /* file: bernoulli.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 bernoulli distribution
21 //--
22 */
23 
24 #ifndef __BERNOULLI_H__
25 #define __BERNOULLI_H__
26 
27 #include "algorithms/distributions/distribution.h"
28 #include "algorithms/distributions/bernoulli/bernoulli_types.h"
29 
30 namespace daal
31 {
32 namespace algorithms
33 {
34 namespace distributions
35 {
36 namespace bernoulli
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::bernoulli::Parameter<algorithmFPType> ParameterType;
96  typedef typename super::ResultType ResultType;
97 
102  Batch(algorithmFPType p) : parameter(p)
103  {
104  initialize();
105  }
106 
111  Batch(const Batch<algorithmFPType, method> &other): super(other), parameter(other.parameter)
112  {
113  initialize();
114  }
115 
120  virtual int getMethod() const DAAL_C11_OVERRIDE { return(int) method; }
121 
126  ResultPtr getResult() { return _result; }
127 
134  services::Status setResult(const ResultPtr& result)
135  {
136  DAAL_CHECK(result, services::ErrorNullResult)
137  _result = result;
138  _res = _result.get();
139  return services::Status();
140  }
141 
147  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
148  {
149  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
150  }
151 
157  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
158  {
159  _par = &parameter;
160  services::Status s = this->_result->template allocate<algorithmFPType>(&(this->input), &parameter, (int) method);
161  this->_res = this->_result.get();
162  return s;
163  }
164 
165  Parameter<algorithmFPType> parameter;
167 protected:
168  virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
169  {
170  return new Batch<algorithmFPType, method>(*this);
171  }
172 
173  void initialize()
174  {
175  Analysis<batch>::_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
176  _in = &input;
177  _par = &parameter;
178  _result.reset(new ResultType());
179  }
180 
181 private:
182  ResultPtr _result;
183 };
184 
185 } // namespace interface1
186 using interface1::BatchContainer;
187 using interface1::Batch;
189 } // namespace bernoulli
190 } // namespace distributions
191 } // namespace algorithms
192 } // namespace daal
193 #endif
daal::algorithms::distributions::bernoulli::interface1::Batch::allocateResult
virtual services::Status allocateResult() DAAL_C11_OVERRIDE
Definition: bernoulli.h:157
daal::algorithms::distributions::bernoulli::interface1::Batch::Batch
Batch(const Batch< algorithmFPType, method > &other)
Definition: bernoulli.h:111
daal::batch
Definition: daal_defines.h:112
daal::algorithms::distributions::bernoulli::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: bernoulli.h:120
daal::algorithms::distributions::bernoulli::interface1::BatchContainer
Provides methods to run implementations of the bernoulli distribution. This class is associated with ...
Definition: bernoulli.h:56
daal::algorithms::distributions::bernoulli::interface1::Batch::setResult
services::Status setResult(const ResultPtr &result)
Definition: bernoulli.h:134
daal::algorithms::distributions::bernoulli::interface1::Batch::parameter
Parameter< algorithmFPType > parameter
Definition: bernoulli.h:165
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::bernoulli::interface1::Batch::getResult
ResultPtr getResult()
Definition: bernoulli.h:126
daal::algorithms::distributions::bernoulli::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: bernoulli.h:147
daal::algorithms::distributions::bernoulli::interface1::Parameter
Bernoulli distribution parameters.
Definition: bernoulli_types.h:66
daal::algorithms::distributions::bernoulli::interface1::BatchContainer::compute
services::Status compute() DAAL_C11_OVERRIDE
daal::algorithms::distributions::bernoulli::interface1::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
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::bernoulli::interface1::Batch
Provides methods for bernoulli distribution computations in the batch processing mode.
Definition: bernoulli.h:89
daal::algorithms::distributions::bernoulli::interface1::Batch::Batch
Batch(algorithmFPType p)
Definition: bernoulli.h:102

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