Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdio.h"
- #include <stdlib.h>
- #include "math.h"
- #include "main.h"
- double V_nplus1_m(double v_n_mplus1, double v_n_m){
- return (tao/(2*h))*(v_n_mplus1 - v_n_m) + v_n_m;
- }
- double V_nplus1_m_nelin(double v_n_mplus1, double v_n_m){
- // if (t_local > 0.995)
- //{ printf(" \n res2: %.25lf \n v_n_m: %.25lf \n res %.25lf \n \n",(tao*0.5)*(pow(v_n_mplus1, 2) - pow(v_n_m, 2))/h, v_n_m, (tao/(2*h))*(v_n_mplus1*v_n_mplus1 - v_n_m*v_n_m) + v_n_m);};
- return ((tao*0.5)*(pow(v_n_mplus1, 2) - pow(v_n_m, 2))/h + v_n_m);
- }
- double proverka(double value){
- if (fabs(value)<1e-15) value = 0.0;
- return value;
- }
- int stepx_by_x(double x){
- return (int)(fabs(x - x_begin)/h);
- }
- int stept_by_t(double t){
- return (int)(fabs(t - t_begin)/tao);
- }
- double t_by_stept(int step){
- return (double)(t_begin + step*tao);
- }
- double x_by_stepx(int step){
- return (double)((x_begin + step*h));
- }
- void print_block(double * block, int length){
- int i;
- for (i = 0; i < length; ++i)
- {
- printf("%-4.5g %g \n", block[i], x_by_stepx(i));
- }
- printf("\n");
- }
- double delta(double v_n_m, double x, double t){
- double delta;
- /*if (x<=-0.5*t){
- delta = fabs(v_n_m - 1);
- // printf("delta %g\n", delta);
- }
- else{
- delta = fabs(v_n_m);
- // printf("delta %g\n", delta);
- }*/
- /*if (x<=-0.5*t){
- delta = fabs(v_n_m);
- // printf("delta %g\n", delta);
- }
- else if ((x>-0.5*t)&&(x<=-0.5*t+0.25)) {
- delta = fabs(v_n_m - 4*x-2*t);
- // printf("delta %g\n", delta);
- }
- else {delta = fabs(v_n_m-1);}
- return delta;*/
- if (x<=-0.5*t){
- delta = fabs(v_n_m);
- // printf("delta %g\n", delta);
- }
- else if ((x>-0.5*t)&&(x<=-0.5*t+0.25)) {
- delta = fabs(v_n_m - 4*x-2*t);
- // printf("delta %g\n", delta);
- }
- else {delta = fabs(v_n_m-1);}
- return delta;
- }
- double delta_nel(double v_n_m, double x, double t){
- double delta;
- if (x<=-t){
- delta = fabs(v_n_m - 1);
- // printf("delta %g\n", delta);
- }
- else if((x<=0)&&(x>-t)){
- delta = fabs(v_n_m+x/t);
- // printf("delta %g\n", delta);
- }
- else {delta = fabs(v_n_m);};
- /*if ((t<=0.25)&&(x<=0)){
- delta = fabs(v_n_m);
- // printf("delta %g\n", delta);
- }
- else if((t<=0.25)&&(x>0)&&(x<=-t+0.25)){
- delta = fabs(v_n_m-(4.0*x/(1-4.0*t)));
- // printf("delta %g\n", delta);
- }
- else if ((t<=0.25)&&(x>-t+0.25)){delta = fabs(v_n_m - 1);}
- else if ((t>0.25)&&(fabs(x +(0.5*(t-0.25)))<0.00000001)) {delta = fabs(v_n_m -(4.0*x/(1-4.0*t)) );}
- else if ((t>0.25)&&(x<-0.5*(t-0.25))){delta = fabs(v_n_m);}
- else if ((t>0.25)&&(x>-0.5*(t-0.25))) {delta = fabs (v_n_m - 1); };*/
- return delta;
- }
- void norma_c(double delta, double *max){
- if (fabs(delta) > *max) *max = fabs(delta);
- }
- void norma_l(double v_n_m, double * norma){
- *norma += fabs(v_n_m);
- }
- void print_matrix(double * matrix, int length){
- printf("\nMATRIX PRINT\n");
- int i,j;
- for (i = 0; i < length; i++)
- for (j = 0; j < length; j++){
- printf("%-4.5g ", *(matrix + i*length + j));
- }
- printf("\n");
- }
- void print_block_to_file(double * block, int length, FILE * fout){
- int i;
- for (i = 0; i < length; ++i)
- {
- fprintf(fout, "%-8g ", block[i]);
- }
- fprintf(fout, "\n");
- }
- void begin_value(double * block, int length){
- int i;
- for (i = 0; i < length; ++i)
- {
- if (x_by_stepx(i) <= 0)
- block[i] = 1.0;
- else
- block[i] = 0.0;
- }
- /*for (i = 0; i < length; ++i)
- {
- if (x_by_stepx(i) <= 0)
- block[i] = 0.0;
- else if((x_by_stepx(i)>0)&&(x_by_stepx(i)<=0.25))
- {block[i] = 4.0*x_by_stepx(i);}
- else {block[i] = 1.0;}*/
- //printf("BLOCK[%g] = %g\n", x_by_stepx(i), block[i]);
- }
- void characteristic(double * block){
- block[0] = 1.0;
- block[m-1] = 0.0;
- //block[0] = 0.0;
- //block[m-1] = 1.0;
- }
- void characteristic_for_b(double * b){
- /*b[0] = 1-tao/(4*h);
- b[m-3] = 0.0;*/
- b[0] = 0.0;
- b[m-3] = 1+tao/(4*h);
- }
- void next_block(double * block, int length, double step_by_t,//явный случай
- double * norma_DELTA_c_line, double * norma_delta_c_line, //[c]
- double * norma_DELTA_l_line, double * norma_delta_l_line //[l]
- ){
- int i;
- double x = x_begin;
- double del;
- *norma_DELTA_c_line = 0; *norma_delta_c_line = 0; //начальное максимальное значение [c]
- *norma_DELTA_l_line = 0; *norma_delta_l_line = 0; //начальное значение [l]
- characteristic(block);
- for (i = 0; i < m-1; ++i)
- {
- block[i] = V_nplus1_m(block[i+1], block[i]);
- //block[i] = proverka(block[i]);
- del = delta(block[i], x, (step_by_t+1)*tao); // разность между численным решением и точным решением
- norma_c(del, norma_DELTA_c_line); //[c]
- norma_c(block[i], norma_delta_c_line); //[c]
- norma_l(del, norma_DELTA_l_line); //[l]
- norma_l(block[i], norma_delta_l_line);
- // printf("%g %g \n", del, x);
- x+=h;
- //if (del >= 1) { printf("t: %g\n ", tao*(step_by_t+1));};
- } //printf("----------------- \n");
- // printf("NORMA 2 %g\n", *norma_delta_c_line);
- }
- void next_block_nelin(double * block, int length, double step_by_t,//явный случай
- double * norma_DELTA_c_line, double * norma_delta_c_line, //[c]
- double * norma_DELTA_l_line, double * norma_delta_l_line //[l]
- ){
- int i;
- double x = x_begin;
- double del;
- *norma_DELTA_c_line = 0; *norma_delta_c_line = 0; //начальное максимальное значение [c]
- *norma_DELTA_l_line = 0; *norma_delta_l_line = 0; //начальное значение [l]
- characteristic(block);
- for (i = 0; i<m-1 ; ++i)
- {
- block[i] = V_nplus1_m_nelin(block[i+1], block[i]);
- //block[i] = proverka(block[i]);
- del = delta_nel(block[i], x, (step_by_t+1)*tao); // разность между численным решением и точным решением
- norma_c(del, norma_DELTA_c_line); //[c]
- norma_c(block[i], norma_delta_c_line); //[c]
- norma_l(del, norma_DELTA_l_line); //[l]
- norma_l(block[i], norma_delta_l_line);
- printf("%.15lf %g \n", block[i], x);
- //if (del >= 1) { printf("t: %g\n ", tao*(step_by_t+1));};
- x+=h;
- //x = proverka(x);
- }
- printf("------------------");
- // printf("NORMA 2 %g\n", *norma_delta_c_line);
- }
- void matrix_b(double * b){
- int i;
- characteristic_for_b(b);
- //printf("b[%d]: %f\n", 0,b[0]);
- for (i = 1; i < m-1; i++)
- { if (x_by_stepx(i) <= 0)
- b[i] = 0.0;
- else if((x_by_stepx(i)>0)&&(x_by_stepx(i)<=0.25))
- {b[i] = 4*x_by_stepx(i);}
- else { b[i] = 1.0;}
- /*if (x_by_stepx(i) <= 0)
- b[i] = 1.0;
- else
- b[i] = 0.0;*/
- //printf("b[%d]: %f\n", i,b[i]);
- }
- //printf("b[%d]: %f\n", m-1,b[m-1]);
- }
- void matrix_b1(double * b){
- int i;
- characteristic_for_b(b);
- for (i = 1; i < m-2; i++)
- {
- if ((x_by_stepx(i+2)==0)&&(x_by_stepx(i+1)!=0)){ // ОБЯЗАТЕЛЬНОЕ ПОПАДАНИЕ В 0
- b[i] = tao/8*(4*x_by_stepx(i+2));
- }
- else if ((x_by_stepx(i+1)==0)&&(x_by_stepx(i)!=0)){
- b[i] = tao/8*(4*x_by_stepx(i+2)-16*x_by_stepx(i+1));
- }
- else if ((x_by_stepx(i)==0)&&(x_by_stepx(i-1)!=0)){
- b[i] = 4*x_by_stepx(i)+tao/8*(4*x_by_stepx(i+2)-16*x_by_stepx(i+1)+24*x_by_stepx(i));
- }
- else if ((x_by_stepx(i-1)==0)&&(x_by_stepx(i-2)!=0)){
- b[i] = 4*x_by_stepx(i+1)+tao/8*(4*x_by_stepx(i+2)-16*x_by_stepx(i+1)+24*x_by_stepx(i)-16*x_by_stepx(i-1));
- }
- else if ((x_by_stepx(i-2)>0)&&(x_by_stepx(i+2)<=0.25)){
- b[i] = 4*x_by_stepx(i);
- }
- else if ((x_by_stepx(i+2)>0.25)&&(x_by_stepx(i+1)<=0.25)){ // ОБЯЗАТЕЛЬНОЕ ПОПАДАНИЕ В 0
- b[i] = 4*x_by_stepx(i)+tao/8*(1-16*x_by_stepx(i+1)+24*x_by_stepx(i)-16*x_by_stepx(i-1)+4*x_by_stepx(i-2));
- }
- else if ((x_by_stepx(i+1)>0.25)&&(x_by_stepx(i)<=0.25)){
- b[i] = 4*x_by_stepx(i)+tao/8*(-3+24*x_by_stepx(i)-16*x_by_stepx(i-1)+4*x_by_stepx(i-2));
- }
- else if ((x_by_stepx(i)>0.25)&&(x_by_stepx(i-1)<=0.25)){
- b[i] = 1+tao/8*(3-16*x_by_stepx(i-1)+4*x_by_stepx(i-2));
- }
- else if ((x_by_stepx(i-1)>0.25)&&(x_by_stepx(i-2)<=0.25)){
- b[i] = 1+tao/8*(-1+4*x_by_stepx(i-2));
- }
- else if (x_by_stepx(i-2) > 0.25){
- b[i] = 1.0;
- }
- else
- b[i] = 0.0;
- }
- }
- void matrix_U( double U_1[m-2], double U_2[m-3], double b[m-2]){
- int i,j;
- double l=0; // начальное l
- for (i=0; i<m-2; i++){
- if (i==0) { //вырожденный случай
- U_1[i] = 1;
- U_2[i] = -tao/(4*h);
- b[i] = b[i];
- l = (tao/(4*h))/U_1[i];
- } else if (i!=m-3) {
- U_1[i] = 1 - l*U_2[i-1];
- U_2[i] = -tao/(4*h);
- b[i] = b[i] - l*b[i-1];
- l = (tao/(4*h))/U_1[i];
- } else {
- U_1[i] = 1 - l*U_2[i-1];
- b[i] = b[i] - l*b[i-1];
- }
- }
- }
- void matrix_V_hat(double U_1[m-2], double U_2[m-3], double b[m-2], double V_hat[m], double step_by_t,//неявный случай
- double * norma_DELTA_c_line, double * norma_delta_c_line, //[c]
- double * norma_DELTA_l_line, double * norma_delta_l_line){
- int i;
- double del;
- *norma_DELTA_c_line = 0; *norma_delta_c_line = 0; //начальное максимальное значение [c]
- *norma_DELTA_l_line = 0; *norma_delta_l_line = 0;
- characteristic(V_hat);
- //printf("V_hat[%d]: %g\n", m-1,V_hat[m-1]);
- for(i=m-2; i>=1; i--){
- if (i==m-2) V_hat[i] = b[i-1]/U_1[i-1];
- else {
- V_hat[i] = (b[i-1] - U_2[i-1]*V_hat[i+1])/U_1[i-1];
- V_hat[i] = proverka(V_hat[i]);
- }
- del = delta(V_hat[i], x_by_stepx(i), (step_by_t+1)*tao); // разность между численным решением и точным решением
- //printf("del: %g\n", del);
- norma_c(del, norma_DELTA_c_line); //[c]
- norma_c(V_hat[i], norma_delta_c_line); //[c]
- norma_l(del, norma_DELTA_l_line); //[l]
- norma_l(V_hat[i], norma_delta_l_line);
- //printf("NORMA_DELTA_c_line %g\n", *norma_DELTA_c_line);
- //printf("%.10f %g\n",del, x_by_stepx(i));
- } //printf("--------------- \n");
- }
- void equal(double b[m-2], double V_hat[m]){
- int i;
- b[m-3] = V_hat[m-2]+tao/(4*h);
- b[m-3] = proverka(b[m-3]);
- for(i=0; i<m-3; i++){
- b[i] = V_hat[i+1];
- }
- }
- void equal1(double b[m-2], double V_hat[m]){
- int i;
- b[0] = V_hat[1] +(tao/8.)*(V_hat[3] - 4*V_hat[2] + 6*V_hat[1] ) ;
- b[1] = V_hat[2] + (tao/8.)*(V_hat[4] - 4*V_hat[3] + 6*V_hat[2] - 4.0*V_hat[1] );
- for(i=2; i<m-4; i++){
- b[i] = V_hat[i+1] +(tao/8.)*(V_hat[i+3] - 4*V_hat[i+2] + 6*V_hat[i+1] - 4*V_hat[i] + V_hat[i-1]);
- }
- b[m-4] = V_hat[m-3] + (tao/8.)*(V_hat[m-5] - 4*V_hat[m-4] + 6*V_hat[m-3] - 4*V_hat[m-2]+1);
- b[m-3] = V_hat[m-2] + (tao/8.)*(V_hat[m-4] - 4*V_hat[m-3] + 6*V_hat[m-2]-3)+ tao/(4*h);
- }
- void main_loop_lin_simple(){
- int i;
- double block[m];
- //по всей сетке [c]
- double norma_DELTA_c_line; double norma_delta_c_line; //по линиям
- //по всей сетке [l]
- double norma_DELTA_l_line; double norma_delta_l_line; //по линиям
- //FILE * fout = fopen("output_1.txt", "w+");
- int length = (int)(sizeof(block)/sizeof(double));
- begin_value(block, length);
- for (i = 0; i < n; ++i){
- next_block(block, length, i, &norma_DELTA_c_line, &norma_delta_c_line, &norma_DELTA_l_line, &norma_delta_l_line);
- /*norma_c(norma_DELTA_c_line, &norma_DELTA_c);
- norma_c(norma_delta_c_line, &norma_delta_c);
- norma_l(norma_DELTA_l_line, &norma_DELTA_l);
- norma_l(norma_delta_l_line, &norma_delta_l);*/
- // print_block_to_file(block, length, fout);
- }
- printf("NORMA_DELTA_c %g\n", norma_DELTA_c_line);
- printf("NORMA_delta_c %g\n", norma_DELTA_c_line/norma_delta_c_line);
- printf("NORMA_DELTA_l %g\n", h*norma_DELTA_l_line);
- printf("NORMA_delta_l %g\n", norma_DELTA_l_line/norma_delta_l_line);
- printf("tao h DeltaC DeltaL deltaC delta l\n");
- printf("%g & %g & %e & %e & %e & %e ", tao, h, norma_DELTA_c_line, h*norma_DELTA_l_line, norma_DELTA_c_line/norma_delta_c_line, norma_DELTA_l_line/norma_delta_l_line);
- }
- void main_loop_lin_nelin(){
- // double previous_block[m];
- int i;
- double block[m];
- //по всей сетке [c]
- double norma_DELTA_c_line; double norma_delta_c_line; //по линиям
- //по всей сетке [l]
- double norma_DELTA_l_line; double norma_delta_l_line; //по линиям
- FILE * fout = fopen("output_2.txt", "w+");
- int length = (int)(sizeof(block)/sizeof(double));
- begin_value(block, length);
- for (i = 0; i < n; ++i){
- next_block_nelin(block, length, i, &norma_DELTA_c_line, &norma_delta_c_line, &norma_DELTA_l_line, &norma_delta_l_line);
- print_block_to_file(block, length, fout);
- }
- printf("NORMA_DELTA_c %g\n", norma_DELTA_c_line);
- printf("NORMA_delta_c %g\n", norma_DELTA_c_line/norma_delta_c_line);
- printf("NORMA_DELTA_l %g\n", h*norma_DELTA_l_line);
- printf("NORMA_delta_l %g\n", norma_DELTA_l_line/norma_delta_l_line);
- printf("tao h DeltaC DeltaL deltaC delta l\n");
- printf("%g & %g & %e & %e & %e & %e ", tao, h, norma_DELTA_c_line, h*norma_DELTA_l_line, norma_DELTA_c_line/norma_delta_c_line, norma_DELTA_l_line/norma_delta_l_line);
- }
- //########################НЕЛИНЕЙНЫЙ СЛУЧАЙ###############################
- void begin_value_pristrel(double * block, int length){
- int i;
- for (i = 0; i < length; ++i){
- block[i] = 0.1;
- }
- }
- void matrix_J( double U_1[m-2], double U_2[m-3], double V_pr[m], double G_2[m-2]){
- int i,j;
- double l = 0; // íà÷àëüíîå l
- double a = 2*tao/(4*h);
- for (i=0; i<m-2; i++){
- if (i==0) { //âûðîæäåííûé ñëó÷àé
- U_1[i] = 1;
- U_2[i] = -a*V_pr[2];
- G_2[i] = G_2[i];
- l = a*V_pr[1]/U_1[i]; // ????????
- } else if (i!=m-3) {
- U_1[i] = 1 - l*U_2[i-1];
- U_2[i] = -a*V_pr[i+2];
- G_2[i] = G_2[i] - l*G_2[i-1];
- l = a*V_pr[i+1]/U_1[i]; // ??????????
- } else {
- U_1[i] = 1 - l*U_2[i-1];
- G_2[i] = G_2[i] - l*G_2[i-1];
- }
- }
- for (i = 0; i < m-3; ++i){
- //printf("U_1[%-2d]: %-13g, U_2[%-2d]: %-13g \n", i, U_1[i], i, U_2[i]);
- }
- }
- void matrix_G(double V_pr[m], double G[m-2], double V[m]){
- int i;
- double a = tao/(4.0*h);
- for (i=0; i<m-2; i++){
- if (i==0) {
- G[0] = -(V_pr[1] - V[1] - a*(pow(V_pr[2],2) - 1));
- } else if (i==m-3) {
- G[m-3] = -(V_pr[m-2] - V[m-2] - a*(0 - pow(V_pr[m-3],2)));
- } else {G[i] = -(V_pr[i+1] - V[i+1] - a*(pow(V_pr[i+2],2) - pow(V_pr[i],2)));
- }
- }
- }
- void matrix_G1(double V_pr[m], double G[m-2], double V[m]){
- int i;
- double a = tao/(4*h);
- for (i=0; i<m-2; i++){
- if (i==0) {
- G[0] = -(V_pr[1] - V[1] - a*(V_pr[2]*V_pr[2] - 1) -tao*0.125*(V[i+3]-4*V[i+2]+6*V[i]));
- } else if (i == 1)
- {
- G[1] = -(V_pr[2] - V[2] - a*(V_pr[3]*V_pr[3] - V_pr[1]*V_pr[1]) -tao*0.125*(V[i+3]-4*V[i+2]+6*V[i]-4*V[i-1]));
- }
- else if ((i!=m-3)&&(i!=m-4) ){
- G[i] = -(V_pr[i+1] - V[i+1] - a*(V_pr[i+2]*V_pr[i+2] - V_pr[i]*V_pr[i]) - tao*0.125*(V[i+3]-4*V[i+2]+6*V[i]-4*V[i-1]+V[i-2]));
- }
- else if (i== m-4)
- {G[i] = -(V_pr[i+1] - V[i+1] - a*(V_pr[i+2]*V_pr[i+2] - V_pr[i]*V_pr[i])-tao*0.125*(1-4*V[i+2]+6*V[i]-4*V[i-1]+V[i-2]));
- }
- else { //i = m-3
- G[i-3] = -(V_pr[i-2] - V[i-2] - a*(0 - V_pr[i-3]*V_pr[i-3])- tao*0.125*(1-4+6*V[i]-4*V[i-1]+V[i-2]));
- }
- }
- }
- void new_vector_X(double U_1[m-2], double U_2[m-3], double G_2[m-2], double X[m-2]){
- int i;
- double del;
- for(i=m-3; i>=0; i--){
- if (i == m-3) {
- X[i] = G_2[i]/U_1[i];
- }
- else {
- X[i] = (G_2[i] - U_2[i]*X[i+1])/U_1[i];
- }
- }
- }
- void new_V_pr(double X[m-2], double V_pr[m]){
- int i;
- for (i = 0; i < m-2; ++i){
- V_pr[i+1] = V_pr[i+1] + X[i];
- }
- }
- void equal_G2_G1(double G_1[m-2], double G_2[m-2]){
- int i;
- for (i = 0; i < m-2; ++i)
- {
- G_2[i] = G_1[i];
- }
- }
- void equal_V_Vpr(double V[m], double V_pr[m]){
- int i;
- for (i = 0; i < m-2; ++i)
- {
- V[i] = V_pr[i];
- }
- }
- double norma_G(double G[m-2]){
- double norma = 0;
- int i;
- for (i = 0; i < m-2; ++i){
- norma += fabs(G[i]);
- }
- return norma*h;
- }
- double norma_G_2(double G[m-2]){
- double norma = 0;
- int i;
- for (i = 0; i < m-2; ++i){
- norma += G[i]*G[i];
- }
- norma = sqrt(norma);
- return norma;
- }
- int main(){
- printf("Size: %d x %d\n", m,n);
- // main_loop_lin_simple();
- //main_loop_lin_nelin();
- //return 0;
- int i;
- //double A[m][m];
- double U_1[m-2]; double U_2[m-3]; double b[m-2]; double V_hat[m];
- double V_pr[m]; double V_0[m]; double G_1[m-2]; double G_2[m-2]; double V[m]; double X[m-2]; double norma_for_G = 1; //чтобы зашло
- int length = (int)(sizeof(V_hat)/sizeof(double));
- //по всей сетке [c]
- double norma_DELTA_c_line; double norma_delta_c_line; //по линиям
- //по всей сетке [l]
- double norma_DELTA_l_line; double norma_delta_l_line; //по линиям
- FILE * fout = fopen("output_2.txt", "w+");
- FILE * fout_once = fopen("output_once.txt", "w");
- //##########################################
- i = 0;
- begin_value(V, length);
- equal_V_Vpr(&V_0, &V); // V === begin_value
- for (i = 0; i < n; ++i)
- {
- //begin_value_pristrel(V_pr, length); // V_pr === begin_value
- equal_V_Vpr(&V_pr, &V_0);
- V_pr[m-1] = 0;
- V_pr[0]=1;
- while (fabs(norma_for_G) > 0.0000001) {
- //printf("%g - NORMAAAAAAAAAAAAAAAAAAAAAAAAAA GGGGGGGGGGGGG\n\n", norma_for_G);
- matrix_G(&V_pr, &G_1, &V);
- //print_block(G_1, length);
- equal_G2_G1(&G_1, &G_2);
- matrix_J(&U_1, &U_2, &V_pr, &G_2);
- /*printf("\n\n");
- print_block(U_1, m-2);
- printf("\n\n");
- print_block(U_2, m-3);
- printf("\n\n");*/
- new_vector_X(&U_1, &U_2, &G_2, &X);
- /*print_block(X, m-2);
- printf("\n\n");*/
- new_V_pr(&X, &V_pr);
- //printf("XXXXXXX\n\n");
- //if (t_by_stept(i+1)>0.45) print_block(X, m-2);
- matrix_G(&V_pr, &G_1, &V); // изменение G для нового вектора пристреленного
- //if (t_by_stept(i+1)>0.45) printf("norma_g: %g \n", norma_for_G);
- norma_for_G = norma_G(&G_1);
- }
- printf("V_pr\n\n");
- print_block(V_pr, m);
- norma_for_G = 1;
- equal_V_Vpr(&V_0,&V);
- equal_V_Vpr(&V, &V_pr);
- printf("t %g\n", t_by_stept(i+1));
- //if(t_by_stept(i+1)>0.25) break;
- }
- return 0;
- //##############################################################
- i = 0;
- matrix_b1(&b);
- for(i=0; i<n; i++){
- //printf("\nTao: %f, Step %d\n\n", t_by_stept(i+1), i);
- matrix_U( &U_1, &U_2, &b);
- matrix_V_hat(&U_1, &U_2, &b, &V_hat, i, &norma_DELTA_c_line, &norma_delta_c_line, &norma_DELTA_l_line, &norma_delta_l_line);
- equal1(&b, &V_hat);
- //printf("NORMA_DELTA_c_line %g\n", norma_DELTA_c_line);
- print_block_to_file(V_hat, length, fout);
- //printf("NORMA_DELTA_c %g\n", norma_DELTA_c);
- }
- //printf("NORMA_DELTA_c %g\n", norma_DELTA_c);
- //printf("NORMA_delta_c %g\n", norma_DELTA_c/norma_delta_c);
- //printf("NORMA_DELTA_l %g\n", h*norma_DELTA_l);
- printf("tao h DeltaC DeltaL deltaC delta l\n");
- printf("%g & %g & %.15lf & %e & %e & %e ", tao, h, norma_DELTA_c_line, h*norma_DELTA_l_line, norma_DELTA_c_line/norma_delta_c_line, norma_DELTA_l_line/norma_delta_l_line);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement