Пример #1
0
void updateF (bhtree *node, planet *p, double s) {
    double d = sqrt((p->x-node->cxn/node->num_body) * (p->x-node->cxn/node->num_body) +
            (p->y-node->cyn/node->num_body) * (p->y-node->cyn/node->num_body));
    if (node->num_body==1)
        computeV(p, node);
    else if (s/d<THETA)
        computeV(p, node);
    else {
        if (node->nw!=NULL) updateF(node->nw, p, s/2);
        if (node->ne!=NULL) updateF(node->ne, p, s/2);
        if (node->sw!=NULL) updateF(node->sw, p, s/2);
        if (node->se!=NULL) updateF(node->se, p, s/2);
    }
}
Пример #2
0
double FuzzyIndices::CampelloIndices::compute_b(const std::vector<int> &elements) const {
	double result = 0.0;
	for (size_t j1 = 0; j1 < elements.size(); j1++) {
		for(size_t j2 = j1+1; j2 < elements.size(); j2++) {
			result += std::min(computeV(elements[j1], elements[j2]), computeZ(elements[j1], elements[j2]));
		}
	}

	return result;
}
Пример #3
0
int main(int argc, char**) {
  {
    long long t1=0;
    float s1=0;
    long long t2=0;
    float s2=0;
    long long t3=0;
    float s3=0;
    
    
    fillR();
    computeV();
    
    
    for (int i=0; i!=10000; ++i) {
      fillO();

      t1 -= rdtsc();
      computeV();
      t1 += rdtsc();
      s1+=sum();
      
      t2 -= rdtsc();
      computeA();
      t2 += rdtsc();
      s2+=sum();
      
      t3 -= rdtsc();
      computeB();
      t3 += rdtsc();
      s3+=sum();
      
    }
    std::cout << "native vector " << s1 << " " << double(t1)/10000 << std::endl;
    std::cout << "vector by elements " << s2 << " " << double(t2)/10000 << std::endl;
    std::cout << "scalar " << s3 << " " << double(t3)/10000 << std::endl << std::endl;

  }
  {
    long long t1=0;
    float s1=0;
    long long t2=0;
    float s2=0;
    long long t3=0;
    float s3=0;
    
    
    fillO();
    computeV();
    
    
    for (int i=0; i!=10000; ++i) {
      fillR();
      t1 -= rdtsc();
      computeV();
      t1 += rdtsc();
      s1+=sum();
      
      t2 -= rdtsc();
      computeA();
      t2 += rdtsc();
      s2+=sum();
      
      memcpy(a,va,sizeof(float)*1024*vfl);
      t3 -= rdtsc();
      computeL();
      t3 += rdtsc();
      memcpy(vb,b,sizeof(float)*1024*vfl);
      s3+=sum();
      
    }
    std::cout << "native vector " << s1 << " " << double(t1)/10000 << std::endl;
    std::cout << "vector by elements " << s2 << " " << double(t2)/10000 << std::endl;
    std::cout << "scalar " << s3 << " " << double(t3)/10000 << std::endl << std::endl;
  }
  {
    long long t1=0;
    float s1=0;
    long long t2=0;
    float s2=0;
    long long t3=0;
    float s3=0;
    
    
    fillO();
    computeV();
    
    
    for (int i=0; i!=10000; ++i) {
      fillW();
      t1 -= rdtsc();
      computeV();
      t1 += rdtsc();
      s1+=sum();
      
      t2 -= rdtsc();
      computeA();
      t2 += rdtsc();
      s2+=sum();
      
      t3 -= rdtsc();
      computeB();
      t3 += rdtsc();
      s3+=sum();
      
    }
    std::cout << "native vector " << s1 << " " << double(t1)/10000 << std::endl;
    std::cout << "vector by elements " << s2 << " " << double(t2)/10000 << std::endl;
    std::cout << "scalar " << s3 << " " << double(t3)/10000 << std::endl << std::endl;
  }
  return 0;
    
}