Добавил:
Studfiles2
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Лабораторная работа №1 / main
.cpp#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <vcl.h>
#include <inifiles.hpp>
#include <jpeg.hpp>
#pragma hdrstop
void __fastcall ReportException(const Exception &e) {
AnsiString message = "";
message.printf("Exception %s : %s\n", ((Exception&)e).ClassName().operator AnsiString().c_str(), e.Message.c_str());
printf(message.c_str());
}
AnsiString project_file;
AnsiString project_path;
AnsiString input_type;
bool input_webs_continuous;
AnsiString input_file_name;
AnsiString input_func_name;
double input_func_xmin;
double input_func_xmax;
int input_func_count;
AnsiString evaluation_input;
AnsiString output_report;
double mistakes_value;
bool __fastcall ReadProject(const AnsiString &filename) {
project_file = ExpandFileName(filename);
project_path = ExtractFilePath(project_file);
if (!FileExists(project_file)) return false;
TIniFile *ini = new TIniFile(project_file);
input_type = ini->ReadString("input", "type", "file").LowerCase();
input_webs_continuous = ini->ReadString("input", "webs", "random").LowerCase()!="random";
input_file_name = project_path + ini->ReadString("input.file", "name", "input.txt");
input_func_name = ini->ReadString("input.function", "name", "sin").LowerCase();
input_func_xmin = ini->ReadFloat("input.function", "xmin", 0.0);
input_func_xmax = ini->ReadFloat("input.function", "xmax", 2.0*M_PI);
input_func_count = ini->ReadInteger("input.function", "count", 30);
evaluation_input = project_path + ini->ReadString("evaluation", "input", "evaluation.txt");
output_report = project_path + ini->ReadString("output", "report", "report.html");
mistakes_value = ini->ReadFloat("mistakes.evaluation", "value", 0.0);
if (ini) { delete (ini); ini = 0; }
return true;
}
struct point {
double x, y;
__fastcall point(const point &p) { x=p.x; y=p.y; }
__fastcall point(const double ax = 0.0, const double ay = 0.0) { x=ax; y=ay; }
point __fastcall operator=(const point &p) { x=p.x; y=p.y; return(*this); }
void __fastcall Scan(FILE *file = stdin) { fscanf(file, "%lf %lf", &x, &y); };
void __fastcall Print(FILE *file = stdout) { fprintf(file, "%.8lf %.8lf\n", x, y); }
};
int N = 0;
point **node = 0; // node[n=0..N-1][k=0..n]
void __fastcall AllocateNodes(int count) {
N = count;
node = new point*[N+1];
for (int i=0; i<N; i++) node[i] = 0;
node[N] = new point[N];
}
void __fastcall FreeNodes() {
if (node) {
for (int i=0; i<=N; i++) if (node[i]) { delete[] node[i]; node[i] = 0;};
delete[] node;
}
}
void __fastcall GenerateWebs() {
if (input_webs_continuous) {
for (int i=N-1; i>0; i--) {
node[i] = new point[i];
for (int j=0; j<i; j++) { node[i][j] = node[i+1][j]; }
}
} else {
for (int i=N-1; i>0; i--) {
node[i] = new point[i];
int no = random(i+1);
for (int j=0; j<i; j++) { node[i][j] = (j>=no) ? node[i+1][j+1] : node[i+1][j]; }
}
}
}
typedef double (*Func)(double arg);
Func func = 0;
bool __fastcall PrepareNodes() {
if (input_type=="file") {
if (!FileExists(input_file_name)) {
printf(("Error : File \""+input_file_name+"\" doesn't exists!\n").c_str());
return false;
};
FILE *file = fopen(input_file_name.c_str(), "r");
if (file) {
int count = 0; fscanf(file, "%d", &count);
AllocateNodes(count);
for (int i=0; i<N; i++) node[N][i].Scan(file);
fclose(file);
} else {
printf(("Error : Unable to open a file \""+input_file_name+"\"!\n").c_str());
return false;
}
} else if (input_type=="function") {
AllocateNodes(input_func_count);
if (input_func_name=="acos") func = acos; else
if (input_func_name=="asin") func = asin; else
if (input_func_name=="atan") func = atan; else
if (input_func_name=="cos") func = cos; else
if (input_func_name=="cosh") func = cosh; else
if (input_func_name=="exp") func = exp; else
if (input_func_name=="log") func = log; else
if (input_func_name=="log10") func = log10; else
if (input_func_name=="sin") func = sin; else
if (input_func_name=="sinh") func = sinh; else
if (input_func_name=="sqrt") func = sqrt; else
if (input_func_name=="tan") func = tan; else
if (input_func_name=="tanh") func = tanh; else {
printf(("Error : Unknown function name : \""+input_func_name+"\"!\n").c_str());
return false;
}
double xi = (N>1) ? (input_func_xmax-input_func_xmin)/(1.0*(N-1)) : 0;
for (int i=0; i<N; i++) {
double x = input_func_xmin+xi*i;
double y = func(x);
node[N][i].x = x; node[N][i].y = y;
}
} else {
printf(("Error : Unknown input method \""+input_type+"\"\n").c_str());
return false;
}
GenerateWebs();
return true;
}
int _matherr (struct _exception *a) {
return 1;
}
double __fastcall EvalPoly(int n, double x) {
double s = 0.0;
for (int j=0; j<n; j++) {
double p = node[n][j].y;
for (int i=0; i<n; i++) if (i!=j) p*=(x-node[n][i].x)/(node[n][j].x-node[n][i].x);
s += p;
}
return s;
}
struct testparam {
int count, n;
};
struct evaluation {
double x, y, mistake, blur;
__fastcall evaluation() { x=0.0; y=0.0; mistake=0.0; blur=0.0; }
};
int test_count = 0;
testparam *test_param = 0; // n=x count=y
evaluation **test = 0;
bool __fastcall ProcessTests() {
if (!FileExists(evaluation_input)) {
printf(("Error : File \""+input_file_name+"\" doesn't exists!\n").c_str());
return false;
};
FILE *file = fopen(evaluation_input.c_str(), "r");
if (file) {
fscanf(file, "%d", &test_count);
test_param = new testparam[test_count];
test = new evaluation*[test_count];
for (int i=0; i<test_count; i++) {
fscanf(file, "%d %d", &(test_param[i].n), &(test_param[i].count));
test[i] = new evaluation[test_param[i].count];
for (int j=0; j<test_param[i].count; j++) {
fscanf(file, "%lf", &(test[i][j].x));
}
}
fclose(file);
} else {
printf(("Error : Unable to open a file \""+evaluation_input+"\"!\n").c_str());
return false;
}
for (int i=0; i<test_count; i++) {
for (int j=0; j<test_param[i].count; j++) {
test[i][j].y = EvalPoly(test_param[i].n, test[i][j].x);
if (test_param[i].n<N) {
try {
test[i][j].mistake = EvalPoly(test_param[i].n, test[i][j].x)-EvalPoly(test_param[i].n+1, test[i][j].x);
} catch(const Exception &e) {
test[i][j].mistake = 1.0/0.0;
}
} else {
test[i][j].mistake = sqrt(-1);
}
if (test_param[i].n<N-1) {
try {
test[i][j].blur = fabs((EvalPoly(test_param[i].n+1, test[i][j].x)-EvalPoly(test_param[i].n+2, test[i][j].x))/test[i][j].mistake);
} catch(const Exception &e) {
test[i][j].blur = 1.0/0.0;
}
} else {
test[i][j].blur = sqrt(-1);
}
}
}
return true;
}
void __fastcall FreeTests() {
if (test) {
for (int i=0; i<test_count; i++) { if (test[i]) delete[] test[i]; test[i] = 0; }
delete[] test; test = 0;
}
if (test_param) { delete[] test_param; test_param = 0; }
}
point *mistake = 0;
bool __fastcall ProcessMistakes() {
mistake = new point[N];
for (int n=2; n<N; n++) {
mistake[n].x = EvalPoly(n, mistakes_value)-EvalPoly(n+1, mistakes_value);
mistake[n].y = (func) ? EvalPoly(n, mistakes_value) - func(mistakes_value) : sqrt(-1);
}
return true;
}
void __fastcall FreeMistakes() {
if (mistake) { delete[] mistake; mistake = 0; }
}
typedef void (__fastcall *TableFunc)(int num, double &x, double &y);
int bg_mx = 384, bg_my = 384;
const int bg_margin = 35;
double bg_xmin = 1.0e300, bg_xmax = 1.0e-300, bg_xscale = 1.0;
double bg_ymin = 1.0e300, bg_ymax = 1.0e-300, bg_yscale = 1.0;
double __fastcall bg_x(double x) {
return bg_margin+(x-bg_xmin)*bg_xscale;
}
double __fastcall bg_y(double y) {
return bg_my-(bg_margin+(y-bg_ymin)*bg_yscale);
}
Graphics::TBitmap *bmp = 0;
bool __fastcall CreateGraphic(int mx = 384, int my = 384) {
bg_mx = mx; bg_my = my;
bmp = new Graphics::TBitmap();
bmp->Width = bg_mx; bmp->Height = bg_my;
bmp->Canvas->Brush->Style = bsSolid;
bmp->Canvas->Brush->Color = (TColor)0x00D0D0D0;
bmp->Canvas->FillRect(TRect(0, 0, bg_mx, bg_my));
bg_xmin = 1.0e300; bg_xmax = 1.0e-300;
bg_ymin = 1.0e300; bg_ymax = 1.0e-300;
return true;
}
bool __fastcall FlushGraphic(const AnsiString &filename) {
TJPEGImage *jpg = new TJPEGImage();
try {
jpg->Smoothing = false;
jpg->CompressionQuality = 90;
jpg->Assign(bmp);
jpg->SaveToFile(filename);
} catch(const Exception &e) {
printf(("Error : Unable to save a file \""+filename+"\"!\n").c_str());
return false;
}
if (bmp) { delete (bmp); bmp = 0; }
if (jpg) { delete (jpg); jpg = 0; }
return true;
}
bool __fastcall EvaluateScales(TableFunc func, int count) {
double x = 0, y = 0;
for (int i=0; i<count; i++) {
func(i, x, y);
if (x<bg_xmin) bg_xmin = x;
if (x>bg_xmax) bg_xmax = x;
if (y<bg_ymin) bg_ymin = y;
if (y>bg_ymax) bg_ymax = y;
}
bg_xscale = 1.0*(bg_mx-2*bg_margin)/(bg_xmax-bg_xmin);
bg_yscale = 1.0*(bg_my-2*bg_margin)/(bg_ymax-bg_ymin);
return true;
}
bool __fastcall RenderBeauty(AnsiString xdescr, AnsiString ydescr) {
double xxi = (bg_xmax-bg_xmin)/9;
double yyi = (bg_ymax-bg_ymin)/9;
/* cells */
bmp->Canvas->Brush->Style = bsSolid;
bmp->Canvas->Brush->Color = (TColor)0x00D0D0D0;
bmp->Canvas->Pen->Color = (TColor)0x00808080;
bmp->Canvas->Pen->Style = psDot;
for (int i=0; i<10; i++) {
bmp->Canvas->MoveTo(bg_x(bg_xmin+xxi*i), bg_margin);
bmp->Canvas->LineTo(bg_x(bg_xmin+xxi*i), bg_my-bg_margin);
bmp->Canvas->MoveTo(bg_margin, bg_y(bg_ymin+yyi*i));
bmp->Canvas->LineTo(bg_mx-bg_margin, bg_y(bg_ymin+yyi*i));
}
/* axises */
bmp->Canvas->Brush->Style = bsClear;
bmp->Canvas->Font->Color = (TColor)0x00000000;
bmp->Canvas->Font->Charset = ANSI_CHARSET;
bmp->Canvas->Font->Size = 9;
bmp->Canvas->Font->Name = "Courier New";
bmp->Canvas->Font->Pitch = fpFixed;
bmp->Canvas->Font->Style = TFontStyles();
int xprec = log10(fabs(bg_xmax-bg_xmin));
if (xprec!=0) xdescr = "e"+IntToStr(xprec)+", "+xdescr;
int yprec = log10(fabs(bg_ymax-bg_ymin));
if (yprec!=0) ydescr = "e"+IntToStr(yprec)+", "+ydescr;
bmp->Canvas->TextOut(bg_mx-80, bg_my-18, xdescr);
bmp->Canvas->TextOut(5, 5, ydescr);
/* масштабы */
bmp->Canvas->Font->Color = (TColor)0x00600000;
bmp->Canvas->Font->Name = "Arial";
bmp->Canvas->Font->Size = 8;
for (int i=0; i<10; i++) {
double x = bg_xmin+xxi*i;
double y = bg_ymin+yyi*i;
bmp->Canvas->TextOut(bg_x(x)-8, bg_my-bg_margin+3, FormatFloat("0.00", x/exp(xprec*log(10))));
bmp->Canvas->TextOut(bg_margin-28, bg_y(y)-8, FormatFloat("0.00", y/exp(yprec*log(10))));
}
return true;
}
bool __fastcall RenderGraphic(TableFunc func, int count, unsigned int color = 0x00000000) {
bmp->Canvas->Pen->Color = (TColor)color;
bmp->Canvas->Pen->Style = psSolid;
double x = 0.0, y = 0.0;
func(0, x, y);
bmp->Canvas->MoveTo(bg_x(x), bg_y(y));
for (int i=1; i<count; i++) {
func(i, x, y);
bmp->Canvas->LineTo(bg_x(x), bg_y(y));
}
return true;
}
bool __fastcall RenderPoints(TableFunc func, int count) {
bmp->Canvas->Brush->Color = (TColor)0x00D00000;
bmp->Canvas->Brush->Style = bsSolid;
double x= 0.0, y = 0.0;
for (int i=0; i<count; i++) {
func(i, x, y);
bmp->Canvas->Ellipse(bg_x(x)-2, bg_y(y)-2, bg_x(x)+2, bg_y(y)+2);
}
return true;
}
int test_func_n = 0;
int test_func_i = 0;
double test_func_xmin = 0;
double test_func_xmax = 0;
double test_func_xi = 0;
void __fastcall TestFunc(int num, double &x, double &y) {
x = test_func_xmin + test_func_xi * num;
y = EvalPoly(test_func_n, x);
}
void __fastcall TestPoint(int num, double &x, double &y) {
x = test[test_func_i][num].x;
y = test[test_func_i][num].y;
}
void __fastcall MistakeX(int num, double &x, double &y) {
x = num;
y = mistake[2+num].x;
}
void __fastcall MistakeY(int num, double &x, double &y) {
x = num;
y = mistake[2+num].y;
}
void __fastcall MistakeK(int num, double &x, double &y) {
x = num;
y = 1.0-mistake[2+num].y/mistake[2+num].x;
}
int ma_n = 0;
double ma_xmin = 0;
double ma_xmax = 0;
double ma_xi = 0;
void __fastcall MistakeAverage(int num, double &x, double &y) {
x = ma_xmin+ma_xi*num;
y = fabs(EvalPoly(ma_n, x)-EvalPoly(ma_n+1, x))+1.0e-15;
y = -log(y);
x = (x-ma_xmin)/(ma_xmax-ma_xmin);
}
bool __fastcall ProcessGraphics() {
for (int i=0; i<test_count; i++) {
test_func_i = i; test_func_n = test_param[i].n;
test_func_xmin = node[test_func_n][0].x;
test_func_xmax = node[test_func_n][test_func_n-1].x;
test_func_xi = (test_func_xmax-test_func_xmin)/(1.0*(256-1));
CreateGraphic();
EvaluateScales(TestFunc, 256);
RenderBeauty("x", "P"+IntToStr(test_param[i].n)+"(x)");
RenderGraphic(TestFunc, 256);
RenderPoints(TestPoint, test_param[i].count);
FlushGraphic(project_path+"polynom"+IntToStr(i)+".jpg");
}
CreateGraphic();
EvaluateScales(MistakeX, N-2);
EvaluateScales(MistakeY, N-2);
RenderBeauty("n-2", "delta(n), delta(n)exact");
RenderGraphic(MistakeX, N-2, 0x00F00000);
RenderGraphic(MistakeY, N-2, 0x00008000);
FlushGraphic(project_path+"mistake1.jpg");
CreateGraphic();
EvaluateScales(MistakeK, N-2);
RenderBeauty("n-2", "deltaK");
RenderGraphic(MistakeK, N-2, 0x000000F0);
FlushGraphic(project_path+"mistake2.jpg");
CreateGraphic(512,512);
ma_n=18;
ma_xmin = node[2][0].x;
ma_xmax = node[2][1].x;
ma_xi = (ma_xmax-ma_xmin)/(1.0*(256-1));
for (ma_n=2; ma_n<N; ma_n++) {
EvaluateScales(MistakeAverage, 256);
}
RenderBeauty("<x>", "-lg|delta(n)|");
for (ma_n=2; ma_n<N; ma_n++) {
RenderGraphic(MistakeAverage, 256);
}
FlushGraphic(project_path+"mistake3.jpg");
return true;
}
bool __fastcall GenerateReport() {
FILE *file = fopen(output_report.c_str(), "w");
if (file) {
fprintf(file, "<!-- computer generated -->\n");
fprintf(file, "<html>\n");
fprintf(file, "<head>\n");
fprintf(file, " <title>Отчет по лабораторной работе №1</title>\n");
fprintf(file, " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1251\">\n");
fprintf(file, " <meta name=\"Generator\" content=\"term3.vmath.work1\">\n");
fprintf(file, " <meta name=\"Author\" content=\"twirpx@narod.ru\">\n");
fprintf(file, " <meta name=\"Description\" content=\"Отчет по лабораторной работе №1 по вычислительной математике. Сгенерирован автоматически.\">\n");
fprintf(file, "</head>\n");
fprintf(file, "<body style=\"font-family: verdana;\">\n");
fprintf(file, " <a name=\"begin\"></a>\n");
fprintf(file, " <center>\n");
fprintf(file, " <h1>Отчет по лабораторной работе №1</h1>\n");
fprintf(file, " <h2>по Вычислилельной математике</h2>\n");
fprintf(file, " <h3>студента II курса ФИРТ Т28-220 <a href=\"mailto:twirpx@narod.ru?subject=term3.vmath.work1\">Дымова Владислава</a></h3>\n");
fprintf(file, " </center>\n");
/* содержание */
fprintf(file, " <center><h2>Содержание</h2>\n");
fprintf(file, " <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"50%\"><tbody align=\"center\">\n");
fprintf(file, " <tr><td><a href=\"#input\">Исходные данные</a></td></tr>\n");
fprintf(file, " <tr><td><a href=\"#evaluations\">Вычисления по интерполяционным многочленам</a></td></tr>\n");
fprintf(file, " <tr><td><a href=\"#mistakes\">Погрешность интерполяции</a></td></tr>\n");
fprintf(file, " </table></center>\n");
/* исходные данные */
fprintf(file, " <a name=\"input\"></a><center><h2>Исходные данные</h2></center>\n");
fprintf(file, " <center><div style=\"margin: 10px;\">");
if (input_type=="file") {
fprintf(file, "Исходные данные берутся из файла \"%s\"", input_file_name.c_str());
} else if (input_type=="function") {
fprintf(file, "В качестве источника исходных данных берутся %d значений функции y=%s(x) на промежутке [%.10lg; %.10lg]", N, input_func_name.c_str(), input_func_xmin, input_func_xmax);
}
fprintf(file, "</div>\n");
for(int j=N; j>1; j--) {
fprintf(file, " <center><div style=\"margin: 10px;\">");
if (j==N) {
fprintf(file, "Узловые точки используемые для построения интерполяционного многочлена максимальной степени P<sub>%d</sub>(x)", j);
} else {
fprintf(file, "Узловые точки выбранные для построения интерполяционного многочлена P<sub>%d</sub>(x)", j);
}
fprintf(file, "</div>\n");
fprintf(file, " <table border=\"1px\" cellpadding=\"0\" cellspacing=\"0\" width=\"60%\"><tbody align=\"center\">\n");
fprintf(file, " <tr style=\"background-color: #c0c0c0;\">\n");
fprintf(file, " <td width=\"20%\">i</td>\n");
fprintf(file, " <td width=\"40%\">x<sub>i</sub></td>\n");
fprintf(file, " <td width=\"40%\">y<sub>i</sub>=f(x<sub>i</sub>)</td>\n");
fprintf(file, " </tr>\n");
for (int i=0; i<j; i++) {
fprintf(file, " <tr><td>%d</td><td>%.10lg</td><td>%.10lg</td></tr>\n", i+1, node[j][i].x, node[j][i].y);
}
fprintf(file, " </tbody></table><br>\n");
}
fprintf(file, " </center>\n");
/* вычисления по интерполяционным многочленам */
fprintf(file, " <a name=\"evaluations\"></a><center><h2>Вычисления по интерполяционным многочленам</h2></center>\n");
fprintf(file, " <center><div style=\"margin: 10px;\">");
fprintf(file, "Абсциссы точкек, для которых необходимо просчитать значения интерполяционного многочлена, погрешности интерполяции и размытости, вводятся из файла \"%s\"", evaluation_input.c_str());
fprintf(file, "</div>\n");
for(int j=0; j<test_count; j++) {
fprintf(file, " <center><div style=\"margin: 10px;\">");
fprintf(file, "Результаты вычислений для многочлена P<sub>%d</sub>(x)", test_param[j].n);
fprintf(file, "</div>\n");
fprintf(file, " <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n");
fprintf(file, " <tr><td width=\"60%\">\n");
fprintf(file, " <table border=\"1px\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tbody align=\"center\">\n");
fprintf(file, " <tr style=\"background-color: #c0c0c0;\">\n");
fprintf(file, " <td width=\"12%%\">№</td>\n");
fprintf(file, " <td width=\"22%%\">x</td>\n");
fprintf(file, " <td width=\"22%%\">P<sub>%d</sub>(x)</td>\n", test_param[j].n);
fprintf(file, " <td width=\"22%%\">Δ<sub>%d</sub>(x)</td>\n", test_param[j].n);
fprintf(file, " <td width=\"22%%\">δ<sub>%d</sub>(x)</td>\n", test_param[j].n);
fprintf(file, " </tr>\n");
for (int i=0; i<test_param[j].count; i++) {
fprintf(file, " <tr><td>%d</td><td>%.10lg</td><td>%.10lg</td><td>%.10lg</td><td>%.10lg</td></tr>\n", i+1, test[j][i].x, test[j][i].y, test[j][i].mistake, test[j][i].blur);
}
fprintf(file, " </tbody></table>\n");
fprintf(file, " </td><td width=\"40%%\" align=\"center\"><img src=\"polynom%d.jpg\"></td></tr>\n", j);
fprintf(file, " </table><br>\n");
}
fprintf(file, " </center>\n");
/* погрешность интерполяции */
fprintf(file, " <a name=\"mistakes\"></a><center><h2>Оценка погрешности интерполяции</h2></center>\n");
fprintf(file, " <center><div style=\"margin: 10px;\">");
fprintf(file, "Результаты вычислений для %d интерполяционных многочленов разных степеней для значения x=%.10lg", N-2, mistakes_value);
fprintf(file, "</div>\n");
fprintf(file, " <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n");
fprintf(file, " <tr><td width=\"60%\">\n");
fprintf(file, " <table border=\"1px\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tbody align=\"center\">\n");
fprintf(file, " <tr style=\"background-color: #c0c0c0;\">\n");
fprintf(file, " <td width=\"16%%\">n</td>\n");
fprintf(file, " <td width=\"28%%\" style=\"color: #0000f0\">Δ<sub>n</sub></td>\n");
fprintf(file, " <td width=\"28%%\" style=\"color: #008000\">Δ<sub>n</sub><sup>exact<sup></td>\n");
fprintf(file, " <td width=\"28%%\" style=\"color: #f00000\">k<sub>Δ</sub></td>\n");
fprintf(file, " </tr>\n");
for(int n=2; n<=N; n++) {
fprintf(file, " <tr><td>%d</td><td>%.10lg</td><td>%.10lg</td><td>%.10lg</td></tr>\n", n, mistake[n].x, mistake[n].y, 1.0-mistake[n].y/mistake[n].x);
}
fprintf(file, " </tbody></table>\n");
fprintf(file, " </td><td width=\"40%%\" align=\"center\"><img src=\"mistake1.jpg\"><br><br><img src=\"mistake2.jpg\"></td></tr>\n");
fprintf(file, " </table><br>\n");
fprintf(file, " <div style=\"margin: 10px;\">");
fprintf(file, "График для оценки погрешности построен для погрешностей до Δ<sub>%d</sub> включительно и значений <x> из интервала [%.10lg, %.10lg]", N-1, node[2][0].x, node[2][1].x);
fprintf(file, "</div>\n");
fprintf(file, " <br><img src=\"mistake3.jpg\">\n");
fprintf(file, " </center>\n");
fprintf(file, " <center><a href=\"#begin\">В начало</a></center>\n");
fprintf(file, "</body>\n");
fprintf(file, "</html>\n");
fclose(file);
return true;
} else {
printf(("Error : Unable to rewrite a file \""+output_report+"\"!\n").c_str());
return false;
}
}
#pragma argsused
int main(int argc, char* argv[]) {
if (!ReadProject((argc>1) ? argv[1] : "example\\project.ini")) {
printf("Error : Unable to read project file!\n");
return 1;
};
if (!PrepareNodes()) {
printf("Error : Unable to prepare node points!\n");
return 1;
}
if (!ProcessTests()) {
printf("Error : Unable to perfom evaluations with interpolation polynoms!\n");
return 1;
}
if (!ProcessMistakes()) {
printf("Error : Unable to perfom mistake evaluations with interpolation polynoms!\n");
return 1;
}
if (!ProcessGraphics()) {
printf("Error : Unable to generate images and graphics!\n");
return 1;
}
if (!GenerateReport()) {
printf("Error : Unable to generate report!\n");
return 1;
} else {
ShellExecute(0, "open", output_report.c_str(), 0, project_path.c_str(), SW_SHOWMAXIMIZED);
}
FreeMistakes(); FreeTests(); FreeNodes();
return 0;
}