Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void burnToFile(Queue<TaskMeta> &generated)
- {
- std::ofstream output;
- time_t seconds;
- time(&seconds);
- std::stringstream ss;
- ss << seconds;
- std::string ts = ss.str();
- std::string fileName = ts + "-output.tex";
- std::string buffer;
- output.open(fileName);
- output << beginFile();
- while (true)
- {
- if (generated.size() > 0)
- {
- TaskMeta taskObject = generated.pop();
- /*
- * Send Matrix A to a file;
- */
- output << "\\section{Issue}\\subsection{Real Input}\n precision = ";
- output << taskObject.precision;
- output << "\\\\";
- output << "$\nMatrixA =\\begin{bmatrix}";
- std::vector<std::vector<double>> temp = vecToMatr(taskObject.matrixA);
- for (size_t i = 0; i < std::sqrt(taskObject.matrixA.size()); ++i)
- {
- for (size_t j = 0; j < std::sqrt(taskObject.matrixA.size()); ++j)
- {
- output << temp[i][j];
- output << " & ";
- }
- output << " \\\\ ";
- }
- /*
- * Send Matrix B to a file
- */
- output << "\\end{bmatrix}\n";
- output << "\\\\\nMatrixB =\\begin{bmatrix}";
- for (size_t i = 0; i < taskObject.matrixB.size(); ++i)
- {
- output << taskObject.matrixB[i];
- output << "\\\\\n";
- }
- output << "\\end{bmatrix}\n $\n";
- /*
- * Write iterations into a file
- */
- if (taskObject.storedIterations.size() > 0)
- {
- output << "\\subsection{Iterations}\n\\begin{table}[h]\\begin{tabular}{|l|";
- for (size_t i = 0; i < taskObject.matrixB.size(); ++i)
- output << "l";
- output << "|}\\hline ";
- for (size_t i = 1; i < taskObject.matrixB.size() + 1; ++i)
- {
- output << " & \\multicolumn{1}{l|}{$X_";
- output << i;
- output << "$} ";
- }
- output << "\\\\ \\hline ";
- size_t i = 1;
- std::vector<double> tempOut;
- for (std::list<std::vector<double >>::iterator it = taskObject.storedIterations.begin();
- it != taskObject.storedIterations.end();
- it++)
- {
- tempOut = *it;
- output << i;
- output << " & ";
- ++i;
- for (size_t j = 0; j < tempOut.size(); ++j)
- {
- output << tempOut[j];
- if (j != (tempOut.size() - 1))
- output << " & ";
- }
- output << " \\\\ \\hline ";
- }
- output << " \\end{tabular}\\end{table} ";
- /*
- * Print final answer
- */
- output << "\\subsection{ Result }\n$\nX=\\begin{bmatrix}\n";
- tempOut = taskObject.storedIterations.back();
- for (size_t i = 0; i < tempOut.size(); ++i)
- {
- output << tempOut[i];
- output << " \\\\ ";
- }
- output << "\n\\end{bmatrix}\n$";
- }
- else
- {
- output << "\n\\subsection{Result}\nFAILED!\n";
- }
- }
- else
- {
- break;
- }
- }
- output << endOfFile();
- output.close();
- buffer = "D:\\Dev\\Tools\\texlive\\2014\\bin\\win32\\pdflatex.exe " + fileName;
- char command[1024];
- strncpy_s(command, buffer.c_str(), sizeof(command));
- command[sizeof(command) - 1] = 0;
- system(command);
- strncpy_s(command, fileName.c_str(), sizeof(command));
- command[sizeof(command) - 1] = 0;
- system(command);
- }
Advertisement
Add Comment
Please, Sign In to add comment