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

mt19937.h
1 /* file: mt19937.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 Mersenne Twister engine in the batch processing mode
21 //--
22 */
23 
24 #ifndef __MT19937_H__
25 #define __MT19937_H__
26 
27 #include "algorithms/engines/mt19937/mt19937_types.h"
28 #include "algorithms/engines/engine.h"
29 
30 namespace daal
31 {
32 namespace algorithms
33 {
34 namespace engines
35 {
36 namespace mt19937
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 engines::BatchBase
90 {
91 public:
92  typedef engines::BatchBase super;
93 
94  typedef typename super::InputType InputType;
95  typedef typename super::ResultType ResultType;
96 
103  static services::SharedPtr<Batch<algorithmFPType, method> > create(size_t seed = 777);
104 
109  virtual int getMethod() const DAAL_C11_OVERRIDE { return (int)method; }
110 
115  ResultPtr getResult() { return _result; }
116 
123  services::Status setResult(const ResultPtr& result)
124  {
125  DAAL_CHECK(result, services::ErrorNullResult)
126  _result = result;
127  _res = _result.get();
128  return services::Status();
129  }
130 
136  services::SharedPtr<Batch<algorithmFPType, method> > clone() const
137  {
138  return services::SharedPtr<Batch<algorithmFPType, method> >(cloneImpl());
139  }
140 
146  virtual services::Status allocateResult() DAAL_C11_OVERRIDE
147  {
148  services::Status s = this->_result->template allocate<algorithmFPType>(&(this->input), NULL, (int) method);
149  this->_res = this->_result.get();
150  return s;
151  }
152 
153 protected:
154  Batch(size_t seed = 777)
155  {
156  initialize();
157  }
158 
159  Batch(const Batch<algorithmFPType, method> &other): super(other)
160  {
161  initialize();
162  }
163 
164  virtual Batch<algorithmFPType, method> *cloneImpl() const DAAL_C11_OVERRIDE
165  {
166  return new Batch<algorithmFPType, method>(*this);
167  }
168 
169  void initialize()
170  {
171  Analysis<batch>::_ac = new __DAAL_ALGORITHM_CONTAINER(batch, BatchContainer, algorithmFPType, method)(&_env);
172  _in = &input;
173  _result.reset(new ResultType());
174  }
175 
176 private:
177  ResultPtr _result;
178 };
179 typedef services::SharedPtr<Batch<> > mt19937Ptr;
180 typedef services::SharedPtr<const Batch<> > mt19937ConstPtr;
181 
182 } // namespace interface1
183 using interface1::BatchContainer;
184 using interface1::Batch;
185 using interface1::mt19937Ptr;
186 using interface1::mt19937ConstPtr;
188 } // namespace mt19937
189 } // namespace engines
190 } // namespace algorithms
191 } // namespace daal
192 #endif
daal::algorithms::engines::mt19937::interface1::Batch
Provides methods for mt19937 engine computations in the batch processing mode.
Definition: mt19937.h:89
daal::batch
Definition: daal_defines.h:112
daal::algorithms::engines::mt19937::interface1::BatchContainer
Provides methods to run implementations of the mt19937 engine. This class is associated with the mt19...
Definition: mt19937.h:56
daal::algorithms::engines::mt19937::interface1::BatchContainer::compute
services::Status compute() DAAL_C11_OVERRIDE
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::engines::mt19937::interface1::BatchContainer::BatchContainer
BatchContainer(daal::services::Environment::env *daalEnv)
daal::algorithms::engines::mt19937::interface1::Batch::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: mt19937.h:109
daal::algorithms::engines::mt19937::interface1::Batch::setResult
services::Status setResult(const ResultPtr &result)
Definition: mt19937.h:123
daal::algorithms::engines::mt19937::interface1::Batch::allocateResult
virtual services::Status allocateResult() DAAL_C11_OVERRIDE
Definition: mt19937.h:146
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:70
daal::algorithms::engines::mt19937::interface1::Batch::getResult
ResultPtr getResult()
Definition: mt19937.h:115
daal::algorithms::engines::mt19937::interface1::Batch::clone
services::SharedPtr< Batch< algorithmFPType, method > > clone() const
Definition: mt19937.h:136

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