#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 size_t nVectorsInBlock = 250;
size_t nFeatures;
const string dataFileNames[] =
{
"../data/distributed/pca_normalized_1.csv", "../data/distributed/pca_normalized_2.csv",
"../data/distributed/pca_normalized_3.csv", "../data/distributed/pca_normalized_4.csv"
};
int main(int argc, char *argv[])
{
checkArguments(argc, argv, 4, &dataFileNames[0], &dataFileNames[1], &dataFileNames[2], &dataFileNames[3]);
pca::Distributed<step2Master, algorithmFPType, pca::svdDense> masterAlgorithm;
for (size_t i = 0; i < nBlocks; i++)
{
FileDataSource<CSVFeatureManager> dataSource(dataFileNames[i], DataSource::doAllocateNumericTable,
DataSource::doDictionaryFromContext);
dataSource.loadDataBlock(nVectorsInBlock);
pca::Distributed<step1Local, algorithmFPType, pca::svdDense> localAlgorithm;
localAlgorithm.input.set(pca::data, dataSource.getNumericTable());
localAlgorithm.compute();
masterAlgorithm.input.add(pca::partialResults, localAlgorithm.getPartialResult());
}
masterAlgorithm.compute();
masterAlgorithm.finalizeCompute();
pca::ResultPtr result = masterAlgorithm.getResult();
printNumericTable(result->get(pca::eigenvalues), "Eigenvalues:");
printNumericTable(result->get(pca::eigenvectors), "Eigenvectors:");
return 0;
}