예제 #1
0
void PolyaevaEV::lab7()
{
    double norm, eps = 0.0001;
    double* AP = new double[N];
    double* DIS = new double[N];
	  zeroing(x);
	  zeroing(AP);

    do {
		    double *TEMP = multiplication_matrix_on_vector(A, x);
		    difference(DIS, TEMP, b);

        double tau = multiplication_of_vectors(DIS, DIS);
		    double tempTau = multiplication_of_vectors(multiplication_matrix_on_vector(A, DIS), DIS);
		    tau = tau/tempTau;
		    if (tau != tau) tau = eps;

		    for (int i = 0; i < N; i++) TEMP[i] = DIS[i]*tau;
        difference(AP, AP, TEMP);

        norm = fabs(x[0] - AP[0]);
		    for (int i = 0; i < N; i++)
        {
			       if (fabs(x[i] - AP[i]) > norm) norm = fabs(x[i] - AP[i]);
			       x[i] = AP[i];
		    }
		   delete[] TEMP;
    } while (norm > eps);
	  delete[] AP;
	  delete[] DIS;
}
예제 #2
0
/** \brief constructor based on a value
 */
skey_ciph_t::skey_ciph_t(const skey_ciph_type_t &ciph_type)			throw()
{
	zeroing();
	this->ciph_type	= ciph_type;
	if( init_gcry_hd() ){
		this->ciph_type	= skey_ciph_type_t();
		return;
	}
}
예제 #3
0
파일: schedule.cpp 프로젝트: dino-lang/dino
 /* The following constructor creates initial size null vector of
    heads of lists of resource occurrences. */
 resource_heads_vector (class resource_occurrence_pool *pool)
   {
     resource_occurrences = pool;
     initial_resource_heads_vector_size = 100;
     current_resource_heads_vector_size
       = initial_resource_heads_vector_size;
     resource_heads = (((struct scheduler_state::resource_occurrence **)
                        scheduler::allocate
                        (sizeof (struct
                                 scheduler_state::resource_occurrence *)
                         * current_resource_heads_vector_size)));
     zeroing (resource_heads, initial_resource_heads_vector_size);
   }
예제 #4
0
void PolyaevaEV::lab8()
{
	double norm, eps = 0.0001;
	double** M = new double*[N];
	double** MT = new double*[N];
	double** AA = new double*[N];
	zeroing(x);

	for (int i = 0; i < N; i++)
	{
		AA[i] = new double[N];
		for (int j = 0; j < N; j++) AA[i][j] = 0;
	};

    do
	{
		int i_max = 0, j_max = 1;
		double max_el = abs(A[0][1]);

		for (int i = 0; i < N; i++)
			for (int j = i+1; j < N; j++)
				if (abs(A[i][j]) >= max_el) { max_el = abs(A[i][j]); i_max = i; j_max = j; };
		double phi = atan(2*max_el/(A[i_max][i_max] - A[j_max][j_max]))/2;

		for (int i = 0; i < N; i++) {
			M[i] = new double[N]; MT[i] = new double[N];
			for (int j = 0; j < N; j++) { MT[i][j] = 0; if(i == j) M[i][j] = 1; else M[i][j] = 0; };
		};
		M[i_max][i_max] = M[j_max][j_max] = cos(phi);
		M[i_max][j_max] = - sin(phi);
		M[j_max][i_max] = sin(phi);

		transposition(M, MT);
		multiplication(MT, A, AA);
		multiplication(AA, M, A);

    norm = 0;
    for (int i = 0; i < N; i++)
			  for (int j = i+1; j < N; j++) norm += pow(A[i][j],2);
    } while (sqrt(norm) > eps);
	for(int i = 0; i < N; i++) x[i] = A[i][i];

	delete[] M;
	delete[] MT;
	delete[] AA;
}
예제 #5
0
void build_scenery( int matrix[][50], char filename[]) // this function will open the scenery.txt file and convert into a matrix
{
    record = 0;
    int i,j; // generic counters
    char rec[5]; // the vector with the characters of record
    FILE *scenery;
    scenery = fopen(filename,"r");
    if(scenery==NULL) {
        zeroing(matrix);
    }
    else
    {
        for(i=0; i<25; i++)
        {
            for(j=0; j<=50; j++)
            {
                if(j==50) {
                    rec[0] = getc(scenery);
                }
                else
                {
                    matrix[i][j] = charint(getc(scenery));
                    if(matrix[i][j]==1) {
                        portal1[0] = i;
                        portal1[1] = j;
                    }
                    else if(matrix[i][j]==2) {
                        portal2[0] = i;
                        portal2[1] = j;
                    }
                }
            }
        }
    }
    for(i=0; i<5; i++) {
        rec[i] = getc(scenery);   // at this point, the function knows all characters of record
    }
    for(i=0; i<5; i++) {
        record += (charint((int)rec[i]))*pow(10,4-i);   // now, the function will convert the string into a  integer
    }
    fclose(scenery);
}
예제 #6
0
void PolyaevaEV::lab6()
{
  	double norm, eps = 0.00001;
  	double* p = new double[N];
  	zeroing(x);

    do {
          for (int i = 0; i < N; i++) p[i] = x[i];
          for (int i = 0; i < N; i++)
          {
              double var = 0;
              for (int j = 0; j < i; j++) var += (A[i][j] * x[j]);
              for (int j = i + 1; j < N; j++) var += (A[i][j] * p[j]);
              x[i] = (b[i] - var) / A[i][i];
          }
          norm = 0;
          for (int i = 0; i < N; i++) norm += (x[i] - p[i])*(x[i] - p[i]);
      }
      while (sqrt(norm) >= eps);
      delete[] p;
}
예제 #7
0
ROM::ROM()
{
	zeroing();
}
예제 #8
0
void select_stage( int matrix[][50]) // if wall mode is off
{
    int k = 0, i,j,s=0;
    char button;
    char address[13] = "sceneryx.txt";  // the generic address to some scenery
    BITMAP *buffer2 = create_bitmap(600,272);
    BITMAP *mb = load_bitmap("Image/Miniblock.bmp",NULL);// load the miniblock
    FILE *scenery; // pointer of file
    while(s != 1)
    {
        clear_to_color(buffer2,0x6F6F6F);
        rect(buffer2,173,71,425,198,0x000000);// boot the rectangle
        rect(buffer2,172,70,426,199,0x000000);// boot the rectangle
        rectfill(buffer2,174,72,424,197,0xFFFFFF);// boot the rectangle
        address[7] = intchar(k);
        scenery = fopen(address,"r");
        if(scenery==NULL) {
            zeroing(matrix);
        }
        else
        {
            for(i=0; i<25; i++)
            {
                for(j=0; j<=50; j++)
                {
                    if(j==50) {
                        getc(scenery);
                    }
                    else matrix[i][j] = charint(getc(scenery));
                }
            }
            fclose(scenery);
        }
        for(i=0; i<25; i++)
        {
            for(j=0; j<50; j++)
            {
                if(matrix[i][j]==8) {
                    blit(mb,buffer2,0,0,(177+j*5)-2,(75+i*5)-2,5,5);
                }
            }
        }
        blit(buffer2,screen,0,0,0,0,600,272);
        outnumber(240,210,k);
        textout_ex(screen,font,"Field ",185,210,0xFFFFFF,0x6F6F6F);
        button = readkey();
        rest(20);
        if((button==enter)&&(scenery!=NULL)&&(k!=0)) {
            clear_to_color(screen,0xFFFFFF);
            build_scenery(matrix,address);
            s = 1;
            scenery_number = k;
        }
        else if((button==enter)&&(scenery==NULL)) {
            build_scenery(matrix,"scenery_.txt");
            s = 1;
            scenery_number = 0;
        }
        else if((button==l)||(button==d)) {
            if(k>0) {
                k--;
            }
        }
        else {
            if(k<9) {
                k++;
            }
        }
    }
}
예제 #9
0
	dh_param_t(const dh_param_t &other)	throw()	{ zeroing(); copy(other);	}
예제 #10
0
	dh_param_t()				throw()	{ zeroing();			}