コード例 #1
0
int main(){

	float a[10000]; /* a is an array of 10000 floats */
	float b[10000]; /* b is an array of 10000 floats */

	/* initialize elements of array n to 0 */
	for (int i = 0; i < 10000; i++) {
		a[i] = i + 1; /* set element at location i to i + 1 */
		b[i] = i + 1; /* set element at location i to i + 1 */
	}

	struct timeval start, end;
	double elapsedTime;
	gettimeofday(&start, NULL);
	compute1(a, 10000);
	gettimeofday(&end, NULL);
	elapsedTime = (end.tv_sec - start.tv_sec) * 1000.0;      // sec to ms
    elapsedTime += (end.tv_usec - start.tv_usec) / 1000.0;   // us to ms
	printf("In compute1 work took %f ms\n", elapsedTime);

	gettimeofday(&start, NULL);
	compute2(b, 10000);
	gettimeofday(&end, NULL);
	elapsedTime = (end.tv_sec - start.tv_sec) * 1000.0;      // sec to ms
    elapsedTime += (end.tv_usec - start.tv_usec) / 1000.0;   // us to ms
	printf("In compute2 work took %f ms\n", elapsedTime);
}
コード例 #2
0
ファイル: oslabe2.c プロジェクト: nit-ce/nit-ce.github.io
int main(void)
{
	pthread_t t1;
	int i;
	pthread_create(&t1, NULL, thread1, NULL);
	compute1();
	compute2();
	compute3();
	pthread_join(t1, NULL);
	return 0;
}
コード例 #3
0
void eval(void) 
{ int tmp ;
  int tmp___0 ;
  int tmp___1 ;
  int tmp___2 ;
  int tmp___3 ;

  {
  {
  while (1) {
    while_4_continue: /* CIL Label */ ;
    if ((int )wl_st == 0) {

    } else {
      if ((int )c1_st == 0) {

      } else {
        if ((int )c2_st == 0) {

        } else {
          if ((int )wb_st == 0) {

          } else {
            if ((int )r_st == 0) {

            } else {
              goto while_4_break;
            }
          }
        }
      }
    }
    if ((int )wl_st == 0) {
      {
	tmp =  __VERIFIER_nondet_int(); 
      }
      if (tmp) {
        {
        wl_st = 1;
        write_loop();
        }
      } else {

      }
    } else {

    }
    if ((int )c1_st == 0) {
      {
	tmp___0 =  __VERIFIER_nondet_int(); 
      }
      if (tmp___0) {
        {
        c1_st = 1;
        compute1();
        }
      } else {

      }
    } else {

    }
    if ((int )c2_st == 0) {
      {
	tmp___1 =  __VERIFIER_nondet_int(); 
      }
      if (tmp___1) {
        {
        c2_st = 1;
        compute2();
        }
      } else {

      }
    } else {

    }
    if ((int )wb_st == 0) {
      {
	tmp___2 =  __VERIFIER_nondet_int(); 
      }
      if (tmp___2) {
        {
        wb_st = 1;
        write_back();
        }
      } else {

      }
    } else {

    }
    if ((int )r_st == 0) {
      {
	tmp___3 = __VERIFIER_nondet_int();
      }
      if (tmp___3) {
        {
        r_st = 1;
        read();
        }
      } else {

      }
    } else {

    }
  }
  while_4_break: /* CIL Label */ ;
  }

  return;
}
}
コード例 #4
0
double kshell_tri_interp(vector<double> &x, vector<double> &y, vector<double> &z, vector<double> &data, double x0, double y1, double z1, int KK)
{
  //cout << "Entering kshel" << endl;
  int NI = 53;
  int NJ = 60;
  int NK = 65;
  double p[NI][NJ];
  double q[NI][NJ];
  double data1[NI][NJ];
  double d = 0.0;
  double p1,q1;

  for(int i = 0; i < NI; i++)
  {
    for(int j = 0; j < NJ; j++)
    {
      p[i][j] = x[shellIndex(i,j,KK)];
      q[i][j] = sqrt(pow(y[shellIndex(i,j,KK)],2.0)+pow(z[shellIndex(i,j,KK)],2.0));
      p1=x0;
      q1=sqrt(pow(y1,2.0)+pow(z1,2.0));
      data1[i][j] = data[shellIndex(i,j,KK)];
    }
  }

  //Find out which triangle is (p1.q1) in
  //search through (i,j) pairs, each cell is divided into two triangles
  // 1 (i,j) (i+1,j),(i,j+1)
  // 2 (i+1,j+1) (i+1,j), (i,j+1)

  double s1[2];
  double s2[2];
  double s3[2];
  double s4[2];
  double xx1,yy1,ff1,xx2,yy2,ff2,xx3,yy3,ff3;

  for(int i = 0; i < NI-1; i++)
  {
    for(int j = 0; j < NJ-1; j++)
    {
      s1[0] = p[i][j]-p1;
      s1[1] = q[i][j]-q1;
      s2[0] = p[i+1][j]-p1;
      s2[1] = q[i+1][j]-q1;
      s3[0] = p[i+1][j+1]-p1;
      s3[1] = q[i+1][j+1]-q1;
      s4[0] = p[i][j+1]-p1;
      s4[1] = q[i][j+1]-q1;

      //Triangle 1, ANG(12)+ANG(24)+ANG(41)=2*pi
      double theta12, theta24, theta41;
      theta12=acos((s1[0]*s2[0]+s1[1]*s2[1])/sqrt((pow(s1[0],2)+pow(s1[1],2))*(pow(s2[0],2)+pow(s2[1],2))));
      theta24=acos((s2[0]*s4[0]+s2[1]*s4[1])/sqrt((pow(s2[0],2)+pow(s2[1],2))*(pow(s4[0],2)+pow(s4[1],2))));
      theta41=acos((s4[0]*s1[0]+s4[1]*s1[1])/sqrt((pow(s4[0],2)+pow(s4[1],2))*(pow(s1[0],2)+pow(s1[1],2))));

      if(abs(theta12+theta24+theta41-2.0*PI) < 0.001)
      {
        xx1=p[i][j];
        yy1=q[i][j];
        ff1=data1[i][j];
        xx2=p[i+1][j];
        yy2=q[i+1][j];
        ff2=data1[i+1][j];
        xx3=p[i][j+1];
        yy3=q[i][j+1];
        ff3=data1[i][j+1];
        break;
      }

      //Triangle 2, ANG(23)+ANG(34)+ANG(42)=2*pi
      double theta23, theta34, theta42;
      theta23=acos((s2[0]*s3[0]+s2[1]*s3[1])/sqrt((pow(s2[0],2)+pow(s2[1],2))*(pow(s3[0],2)+pow(s3[1],2))));
      theta34=acos((s3[0]*s4[0]+s3[1]*s4[1])/sqrt((pow(s3[0],2)+pow(s3[1],2))*(pow(s4[0],2)+pow(s4[1],2))));
      theta42=acos((s4[0]*s2[0]+s4[1]*s2[1])/sqrt((pow(s4[0],2)+pow(s4[1],2))*(pow(s2[0],2)+pow(s2[1],2))));


      if(abs(theta23+theta34+theta42-2.0*PI) < 0.001)
      {
        xx1=p[i+1][j+1];
        yy1=q[i+1][j+1];
        ff1=data1[i+1][j+1];
        xx2=p[i+1][j];
        yy2=q[i+1][j];
        ff2=data1[i+1][j];
        xx3=p[i][j+1];
        yy3=q[i][j+1];
        ff3=data1[i][j+1];
        break;
      }

    }
  }

  Array2D< double > arr1(3,3);
  Array2D< double > arr2(3,3);
  Array2D< double > arr3(3,3);
  Array2D< double > arr(3,3);

  double temp[3][3] = { {xx1, yy1, 1},
                       {xx2, yy2, 1},
                       {xx3, yy3, 1}};
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      arr[i][j] = temp[i][j];
    }
  }

  double temp1[3][3] = { {p1, q1, 1},
                        {xx2, yy2, 1},
                        {xx3, yy3, 1}};
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      arr1[i][j] = temp1[i][j];
    }
  }

  double temp2[3][3] = { {p1, q1, 1},
                        {xx1, yy1, 1},
                        {xx3, yy3, 1}};
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      arr2[i][j] = temp2[i][j];
    }
  }

  double temp3[3][3] = { {p1, q1, 1},
                        {xx1, yy1, 1},
                        {xx2, yy2, 1}};
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      arr3[i][j] = temp3[i][j];
    }
  }

  JAMA::LU< double > compute(arr);
  JAMA::LU< double > compute1(arr1);
  JAMA::LU< double > compute2(arr2);
  JAMA::LU< double > compute3(arr3);

  d = (ff1*compute1.det() - ff2*compute2.det() + ff3*compute3.det())/compute.det();


  return d;


}
コード例 #5
0
ファイル: LBSP.cpp プロジェクト: caomw/litiv
void LBSP::compute2(const std::vector<cv::Mat>& voImageCollection, std::vector<std::vector<cv::KeyPoint> >& vvoPointCollection, std::vector<cv::Mat>& voDescCollection) const {
    CV_Assert(voImageCollection.size() == vvoPointCollection.size());
    voDescCollection.resize(voImageCollection.size());
    for(size_t i=0; i<voImageCollection.size(); i++)
        compute2(voImageCollection[i], vvoPointCollection[i], voDescCollection[i]);
}