#include "daal.h"
#include "service.h"
using namespace std;
using namespace daal;
using namespace daal::algorithms;
typedef float algorithmFPType;
const size_t nBlocks = 4;
const string datasetFileNames[] =
{
"../data/distributed/covcormoments_csr_1.csv",
"../data/distributed/covcormoments_csr_2.csv",
"../data/distributed/covcormoments_csr_3.csv",
"../data/distributed/covcormoments_csr_4.csv"
};
int main(int argc, char *argv[])
{
checkArguments(argc, argv, 4, &datasetFileNames[0], &datasetFileNames[1], &datasetFileNames[2], &datasetFileNames[3]);
pca::Distributed<step2Master> masterAlgorithm;
for (size_t i = 0; i < nBlocks; i++)
{
CSRNumericTable *dataTable = createSparseTable<float>(datasetFileNames[i]);
pca::Distributed<step1Local> localAlgorithm;
localAlgorithm.parameter.covariance = services::SharedPtr<covariance::Distributed<step1Local, algorithmFPType, covariance::fastCSR> >
(new covariance::Distributed<step1Local, algorithmFPType, covariance::fastCSR>());
localAlgorithm.input.set(pca::data, CSRNumericTablePtr(dataTable));
localAlgorithm.compute();
masterAlgorithm.input.add(pca::partialResults, localAlgorithm.getPartialResult());
}
masterAlgorithm.parameter.covariance = services::SharedPtr<covariance::Distributed<step2Master, algorithmFPType, covariance::fastCSR> >
(new covariance::Distributed<step2Master, algorithmFPType, covariance::fastCSR>());
masterAlgorithm.compute();
masterAlgorithm.finalizeCompute();
pca::ResultPtr result = masterAlgorithm.getResult();
printNumericTable(result->get(pca::eigenvalues), "Eigenvalues:");
printNumericTable(result->get(pca::eigenvectors), "Eigenvectors:");
return 0;
}