int main(int argc, char *argv[])
{
std::string fileName("G:\\largesparse.txt");
SparseMatrix<double> mtrx, backMtrx;
FileSparseMtrxBuilder<double> builder(fileName);
vector<pair<size_t, double> > indeVec;
vector<pair<size_t, double> > result;
vector<size_t> resultIds;
if (!builder.Build(mtrx, indeVec, resultIds))
{
cerr << "Building failed!" << endl;
system("pause");
return -1;
}
backMtrx = mtrx;
/*
//PrintSparseMatrix(mtrx);
//PrintPairVector(indeVec);
//DisplayContainer(relatedIds, " ");
NodeGraph graph;
GenNodeGraphOfSparseMatrix(mtrx, graph);
//PrintNodeGraph(graph);
ElemOrderMap eomap = DynamicOrdering(graph).Reorder();
//PrintPairVector(eomap);
ReorderSparseMatrix(eomap, mtrx);
//PrintSparseMatrix(mtrx);
ReorderSparseVector(eomap, indeVec);
ReorderResultIds(eomap, resultIds);
//PrintPairVector(indeVec);
//DisplayContainer(resultIds, " ");
Factorization(mtrx);
PrintSparseMatrix(mtrx);
SparseMtrxFirstElems<double> firElems = GenFirstElems(mtrx);
//PrintFirstElems(firElems);
vector<pair<size_t, double> > ffResult;
//FactorPath path(mtrx.size());
//GenFactorPath(firElems, resultIds, path);
//PrintFactorPath(path);
FastForwardSubstitution(mtrx, firElems, indeVec, ffResult);
PrintPairVector(ffResult);
vector<pair<size_t, double> > fbResult;
FastBackwardSubstitution(mtrx, firElems, ffResult, resultIds, fbResult);
PrintPairVector(fbResult);
/*vector<size_t> facSeq = GenFactorSeqFromPath(path);
DisplayContainer(facSeq, " ");
cout << endl;
*/
SparseVectorMethod<double> svm;
svm(mtrx, indeVec, resultIds, result);
vector<double> checkResult;
MultiplySparseMatrixVector(backMtrx, result, checkResult);
cout <<
"Check result: " << endl;
DisplayContainer(checkResult, " ");
system("PAUSE");
return EXIT_SUCCESS;
}