#include "pch.h"
#include <fstream>
#include <iostream>
#include <iomanip>
#include "PardisoProvider.h"
#include "DataReader.h"
#include <string>
#include <mkl.h>

using namespace std;

int main(int argc, char* argv[])
{
	mkl_cbwr_set(MKL_CBWR_SSE2);

	std::ofstream out;
	PardisoProvider pardiso;
	DataReader dataReader;
	double* csrA, *rhs, *solutions;
	int* csrRowPtr;
	int* csrColInd;
	int n = 21182;
	int nrhs = 1;

	csrA = dataReader.GetValues();
	csrRowPtr = dataReader.GetRows();
	csrColInd = dataReader.GetColumns();
	rhs = dataReader.GetRHS();
	solutions = new double[n];

	pardiso.Initialization(n, nrhs, csrA, csrColInd, csrRowPtr);
	pardiso.Factorization();
	pardiso.Solve(rhs, solutions);
	
	out.open("result.csv");
	if (out.is_open())
	{
		for (size_t i = 0; i < n; i++)
		{
			out << std::setprecision(20) << solutions[i] << std::endl;
		}		
	}

	out.close();
 	delete[] solutions;

	return 0;
}
