23 #ifndef __COVARIANCE_DISTRIBUTED_H__
24 #define __COVARIANCE_DISTRIBUTED_H__
26 #include "algorithms/algorithm.h"
27 #include "data_management/data/numeric_table.h"
28 #include "services/daal_defines.h"
29 #include "algorithms/covariance/covariance_types.h"
30 #include "algorithms/covariance/covariance_online.h"
54 template<ComputeStep step>
55 class DistributedContainerIface
67 class DistributedContainerIface<step2Master> :
public daal::algorithms::AnalysisContainerIface<distributed>
70 DistributedContainerIface() {};
71 virtual ~DistributedContainerIface() {};
77 virtual services::Status compute() = 0;
82 virtual services::Status finalizeCompute() = 0;
95 template<ComputeStep step,
typename algorithmFPType, Method method, CpuType cpu>
96 class DAAL_EXPORT DistributedContainer
104 template<
typename algorithmFPType, Method method, CpuType cpu>
105 class DAAL_EXPORT DistributedContainer<step2Master, algorithmFPType, method, cpu> :
public DistributedContainerIface<step2Master>
113 DistributedContainer(daal::services::Environment::env *daalEnv);
115 virtual ~DistributedContainer();
120 virtual services::Status compute() DAAL_C11_OVERRIDE;
125 virtual services::Status finalizeCompute() DAAL_C11_OVERRIDE;
149 template<ComputeStep step>
150 class DAAL_EXPORT DistributedIface :
public daal::algorithms::Analysis<distributed>
175 class DistributedIface<step1Local> :
public OnlineImpl
178 typedef OnlineImpl super;
180 typedef algorithms::covariance::DistributedInput<step1Local> InputType;
181 typedef super::ParameterType ParameterType;
182 typedef super::ResultType ResultType;
183 typedef super::PartialResultType PartialResultType;
186 DistributedIface() : OnlineImpl()
196 DistributedIface(
const DistributedIface<step1Local> &other) : OnlineImpl(other)
205 services::SharedPtr<DistributedIface<step1Local> > clone()
const
207 return services::SharedPtr<DistributedIface<step1Local> >(cloneImpl());
211 virtual DistributedIface<step1Local> * cloneImpl() const DAAL_C11_OVERRIDE = 0;
236 class DAAL_EXPORT DistributedIface<step2Master> : public daal::algorithms::Analysis<distributed>
239 typedef algorithms::covariance::DistributedInput<step2Master> InputType;
240 typedef algorithms::covariance::Parameter ParameterType;
241 typedef algorithms::covariance::Result ResultType;
242 typedef algorithms::covariance::PartialResult PartialResultType;
257 DistributedIface(
const DistributedIface<step2Master> &other) : parameter(other.parameter)
260 data_management::DataCollectionPtr collection = other.input.get(partialResults);
261 for (
size_t i = 0; i < collection->size(); i++)
263 input.add(partialResults,
264 services::staticPointerCast<PartialResultType, data_management::SerializationIface>((*collection)[i]));
268 virtual ~DistributedIface() {}
274 ResultPtr getResult()
283 virtual services::Status setResult(
const ResultPtr &result)
285 DAAL_CHECK(result, services::ErrorNullResult)
287 _res = _result.get();
288 return services::Status();
295 PartialResultPtr getPartialResult()
297 return _partialResult;
305 virtual services::Status setPartialResult(
const PartialResultPtr &partialResult,
bool initFlag =
false)
307 DAAL_CHECK(partialResult, services::ErrorNullPartialResult);
308 _partialResult = partialResult;
309 _pres = _partialResult.get();
310 setInitFlag(initFlag);
311 return services::Status();
317 services::Status checkFinalizeComputeParams() DAAL_C11_OVERRIDE
320 if(this->_partialResult)
322 s |= this->_partialResult->check(this->_par, getMethod());
327 return services::Status(services::ErrorNullResult);
332 s |= this->_result->check(this->_pres, this->_par, getMethod());
337 return services::Status(services::ErrorNullResult);
348 services::SharedPtr<DistributedIface<step2Master> > clone()
const
350 return services::SharedPtr<DistributedIface<step2Master> >(cloneImpl());
353 DistributedInput<step2Master> input;
354 ParameterType parameter;
357 virtual services::Status initializePartialResult() DAAL_C11_OVERRIDE
359 return services::Status();
366 _result.reset(
new ResultType());
367 _partialResult.reset(
new PartialResultType());
370 virtual DistributedIface<step2Master> * cloneImpl() const DAAL_C11_OVERRIDE = 0;
372 PartialResultPtr _partialResult;
397 template<ComputeStep step, typename algorithmFPType = DAAL_ALGORITHM_FP_TYPE, Method method = defaultDense>
398 class DAAL_EXPORT Distributed : public DistributedIface<step>
422 template<
typename algorithmFPType, Method method>
423 class DAAL_EXPORT Distributed<step1Local, algorithmFPType, method> :
public Online<algorithmFPType, method>
426 typedef Online<algorithmFPType, method> super;
428 typedef algorithms::covariance::DistributedInput<step1Local> InputType;
429 typedef typename super::ParameterType ParameterType;
430 typedef typename super::ResultType ResultType;
431 typedef typename super::PartialResultType PartialResultType;
433 Distributed<step1Local, algorithmFPType, method>() : Online<algorithmFPType, method>()
443 Distributed(
const Distributed<step1Local, algorithmFPType, method> &other) :
444 Online<algorithmFPType, method>(other)
453 services::SharedPtr<Distributed<step1Local, algorithmFPType, method> > clone()
const
455 return services::SharedPtr<Distributed<step1Local, algorithmFPType, method> >(cloneImpl());
459 virtual Distributed<step1Local, algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
461 return new Distributed<step1Local, algorithmFPType, method>(*this);
486 template<
typename algorithmFPType, Method method>
487 class DAAL_EXPORT Distributed<step2Master, algorithmFPType, method> :
public DistributedIface<step2Master>
490 typedef DistributedIface<step2Master> super;
492 typedef typename super::InputType InputType;
493 typedef typename super::ParameterType ParameterType;
494 typedef typename super::ResultType ResultType;
495 typedef typename super::PartialResultType PartialResultType;
510 Distributed(
const Distributed<step2Master, algorithmFPType, method> &other) :
511 DistributedIface<step2Master>(other)
516 virtual ~Distributed() {}
522 virtual int getMethod() const DAAL_C11_OVERRIDE {
return(
int)method; }
530 services::SharedPtr<Distributed<step2Master, algorithmFPType, method> > clone()
const
532 return services::SharedPtr<Distributed<step2Master, algorithmFPType, method> >(cloneImpl());
536 virtual Distributed<step2Master, algorithmFPType, method> * cloneImpl() const DAAL_C11_OVERRIDE
538 return new Distributed<step2Master, algorithmFPType, method>(*this);
541 virtual services::Status allocateResult() DAAL_C11_OVERRIDE
543 ResultPtr result = this->getResult();
544 services::Status s = result->template allocate<algorithmFPType>(this->_partialResult.get(), this->_par, (int)method);
545 this->_res = this->_result.get();
546 this->_pres = this->_partialResult.get();
550 virtual services::Status allocatePartialResult() DAAL_C11_OVERRIDE
552 services::Status s = this->_partialResult->template allocate<algorithmFPType>(&(this->input), this->_par, (
int)method);
553 this->_pres = this->_partialResult.get();
559 this->_ac =
new __DAAL_ALGORITHM_CONTAINER(distributed, DistributedContainer, step2Master, algorithmFPType, method)(&_env);
564 using interface1::DistributedContainerIface;
565 using interface1::DistributedContainer;
566 using interface1::DistributedIface;
567 using interface1::Distributed;
572 #endif // __COVARIANCE_DISTRIBUTED_H__
daal::algorithms::covariance::interface1::DistributedIface< step2Master >::setResult
virtual services::Status setResult(const ResultPtr &result)
Definition: covariance_distributed.h:283
daal::algorithms::covariance::interface1::DistributedIface< step2Master >
Interface for correlation or variance-covariance matrix computation algorithms in the distributed pro...
Definition: covariance_distributed.h:236
daal::algorithms::covariance::interface1::DistributedIface< step2Master >::DistributedIface
DistributedIface(const DistributedIface< step2Master > &other)
Definition: covariance_distributed.h:257
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::covariance::interface1::Distributed< step1Local, algorithmFPType, method >::clone
services::SharedPtr< Distributed< step1Local, algorithmFPType, method > > clone() const
Definition: covariance_distributed.h:453
daal::algorithms::covariance::interface1::Distributed< step1Local, algorithmFPType, method >::Distributed
Distributed(const Distributed< step1Local, algorithmFPType, method > &other)
Definition: covariance_distributed.h:443
daal::algorithms::covariance::interface1::DistributedIface< step2Master >::parameter
ParameterType parameter
Definition: covariance_distributed.h:354
daal::services::ErrorNullPartialResult
Definition: error_indexes.h:105
daal::algorithms::covariance::interface1::DistributedIface< step2Master >::clone
services::SharedPtr< DistributedIface< step2Master > > clone() const
Definition: covariance_distributed.h:348
daal::ComputeStep
ComputeStep
Definition: daal_defines.h:115
daal::algorithms::covariance::interface1::OnlineImpl
Abstract class that specifies interface of the algorithms for computing correlation or variance-covar...
Definition: covariance_online.h:287
daal::algorithms::covariance::interface1::DistributedIface< step1Local >::clone
services::SharedPtr< DistributedIface< step1Local > > clone() const
Definition: covariance_distributed.h:205
daal::algorithms::covariance::Method
Method
Definition: covariance_types.h:46
daal::algorithms::covariance::interface1::Online
Computes correlation or variance-covariance matrix in the online processing mode. ...
Definition: covariance_online.h:410
daal::algorithms::covariance::interface1::Distributed< step2Master, algorithmFPType, method >
Computes correlation or variance-covariance matrix in the second step of the distributed processing m...
Definition: covariance_distributed.h:487
daal::algorithms::covariance::interface1::DistributedContainer
Provides methods to run implementations of the correlation or variance-covariance matrix algorithm in...
Definition: covariance_distributed.h:96
daal::algorithms::covariance::interface1::DistributedIface
Interface for the correlation or variance-covariance matrix algorithm in the distributed processing m...
Definition: covariance_distributed.h:150
daal::algorithms::covariance::interface1::Distributed< step2Master, algorithmFPType, method >::getMethod
virtual int getMethod() const DAAL_C11_OVERRIDE
Definition: covariance_distributed.h:522
daal::algorithms::kmeans::init::interface1::Distributed
class DAAL_EXPORT Distributed
Computes initial clusters for the K-Means algorithm in the distributed processing mode...
Definition: kmeans_init_distributed.h:255
daal::distributed
Definition: daal_defines.h:107
daal::algorithms::covariance::interface1::DistributedIface< step2Master >::input
DistributedInput< step2Master > input
Definition: covariance_distributed.h:353
daal::algorithms::covariance::interface1::Distributed< step2Master, algorithmFPType, method >::Distributed
Distributed()
Definition: covariance_distributed.h:498
daal::algorithms::covariance::partialResults
Definition: covariance_types.h:110
daal::algorithms::covariance::interface1::DistributedIface< step2Master >::setPartialResult
virtual services::Status setPartialResult(const PartialResultPtr &partialResult, bool initFlag=false)
Definition: covariance_distributed.h:305
daal::algorithms::covariance::interface1::DistributedIface< step2Master >::getPartialResult
PartialResultPtr getPartialResult()
Definition: covariance_distributed.h:295
daal::algorithms::covariance::interface1::DistributedIface< step1Local >::DistributedIface
DistributedIface()
Definition: covariance_distributed.h:186
daal::algorithms::covariance::interface1::Distributed< step2Master, algorithmFPType, method >::clone
services::SharedPtr< Distributed< step2Master, algorithmFPType, method > > clone() const
Definition: covariance_distributed.h:530
daal::algorithms::covariance::interface1::Distributed< step1Local, algorithmFPType, method >
Computes correlation or variance-covariance matrix in the first step of the distributed processing mo...
Definition: covariance_distributed.h:423
daal::algorithms::covariance::interface1::DistributedContainerIface
Class that spcifies interfaces of the correlation or variance-covariance matrix algorithm. This class is associated with daal::algorithms::covariance::DistributedIface class.
Definition: covariance_distributed.h:55
daal::algorithms::covariance::interface1::DistributedIface< step2Master >::getResult
ResultPtr getResult()
Definition: covariance_distributed.h:274
daal::algorithms::covariance::interface1::DistributedIface< step2Master >::DistributedIface
DistributedIface()
Definition: covariance_distributed.h:245
daal::algorithms::Analysis
Provides methods for execution of operations over data, such as computation of Summary Statistics est...
Definition: analysis.h:68
daal::algorithms::covariance::covariance
Definition: covariance_types.h:88
daal::algorithms::kmeans::interface1::DistributedContainer
class DAAL_EXPORT DistributedContainer
Provides methods to run implementations of the K-Means algorithm. This class is associated with the d...
Definition: kmeans_distributed.h:55
daal::step1Local
Definition: daal_defines.h:117
daal::step2Master
Definition: daal_defines.h:118
daal::algorithms::covariance::interface1::Distributed
Computes correlation or variance-covariance matrix in the distributed processing mode.
Definition: covariance_distributed.h:398
daal::algorithms::covariance::interface1::DistributedIface< step1Local >
Interface for correlation or variance-covariance matrix computation algorithms in the distributed pro...
Definition: covariance_distributed.h:175
daal::algorithms::covariance::defaultDense
Definition: covariance_types.h:48
daal::algorithms::covariance::interface1::DistributedIface< step1Local >::DistributedIface
DistributedIface(const DistributedIface< step1Local > &other)
Definition: covariance_distributed.h:196
daal::algorithms::covariance::interface1::DistributedIface< step2Master >::checkFinalizeComputeParams
services::Status checkFinalizeComputeParams() DAAL_C11_OVERRIDE
Definition: covariance_distributed.h:317
daal::services::ErrorNullResult
Definition: error_indexes.h:96
daal::algorithms::covariance::interface1::Distributed< step2Master, algorithmFPType, method >::Distributed
Distributed(const Distributed< step2Master, algorithmFPType, method > &other)
Definition: covariance_distributed.h:510