Esempio n. 1
0
// detect what mode we are using
static int
get_mode( GLU_mode *mode )
{
  // look for which mode we are running in
  {
    const int mode_idx = tag_search( "MODE" ) ;
    if( mode_idx == GLU_FAILURE ) { return tag_failure( "MODE" ) ; }
    // what mode do we want?
    if( are_equal( INPUT[mode_idx].VALUE , "GAUGE_FIXING" ) ) {
      *mode = MODE_GF ;
    } else if( are_equal( INPUT[mode_idx].VALUE , "CUTTING" ) ) {
      *mode = MODE_CUTS ;
    } else if( are_equal( INPUT[mode_idx].VALUE , "SMEARING" ) ) {
      *mode = MODE_SMEARING ;
    } else if( are_equal( INPUT[mode_idx].VALUE , "SUNCxU1" ) ) {
      *mode = MODE_CROSS_U1 ;
    } else if( are_equal( INPUT[mode_idx].VALUE , "HEATBATH" ) ) {
      *mode = MODE_HEATBATH ;
    } else {
      *mode = MODE_REWRITE ;
    }
  }
  // look at what seed type we are going to use
  {
    const int seed_idx = tag_search( "SEED" ) ;
    if( seed_idx == GLU_FAILURE ) { return tag_failure( "SEED" ) ; }
    sscanf( INPUT[seed_idx].VALUE , "%u" , &Latt.Seed[0] ) ;
  }
  return GLU_SUCCESS ;
}
Esempio n. 2
0
void RfPiggyBox::CloseFile(RfReference &key)
{
    if (!files)
        throw IntelibX_refal_failure(key);
    RfFile *temp;
    if (are_equal(files->key, key)) {
        temp = files;
        files = files->next;
        temp->next = 0;
        delete temp;
        return;
    }
    RfFile *start = files;
    while (start->next) {
        if (are_equal(start->next->key, key)) {
            temp = start->next;
            start->next = start->next->next;
            temp->next = 0;
            delete temp;
            return;
        }
        start = start->next;
    }
    throw IntelibX_refal_failure(key);
}
Esempio n. 3
0
// the one for the U(1) data
static int
read_suNC_x_U1( struct u1_info *U1INFO )
{
  // U1 coupling strength
  if( setdbl( &( U1INFO -> alpha ) , "U1_ALPHA" ) == GLU_FAILURE ) {
    return GLU_FAILURE ;
  }
  // U1 charge
  if( setdbl( &( U1INFO -> charge ) , "U1_CHARGE" ) == GLU_FAILURE ) {
    return GLU_FAILURE ;
  }
  // U1 measurement type default is just the plaquette
  {
    const int U1_meas_idx = tag_search( "U1_MEAS" ) ;
    if( U1_meas_idx == GLU_FAILURE ) { return tag_failure( "U1_MEAS" ) ; }
    //
    U1INFO -> meas = U1_PLAQUETTE ;
    if( are_equal( INPUT[ U1_meas_idx ].VALUE , "U1_RECTANGLE" ) ) {
      U1INFO -> meas = U1_RECTANGLE ;
    } else if ( are_equal( INPUT[ U1_meas_idx ].VALUE , "U1_TOPOLOGICAL" ) ) {
      U1INFO -> meas = U1_TOPOLOGICAL ;
    }
  }
  return GLU_SUCCESS ;
}
Esempio n. 4
0
bool find_line_polygon_side_intersection(const LineCoefficients line_coeff, const Segment& side_segment,
                                         int side, IntersectionPoint& inter)
{
    const Point line_direction(line_coeff.A, line_coeff.B);
    const double cur_d = line_coeff.C;
    bool is_intersected = false;
    double test_cur = line_direction.xx * side_segment.head.xx + line_direction.yy * side_segment.head.yy - cur_d;
    double test_next = line_direction.xx * side_segment.tail.xx + line_direction.yy * side_segment.tail.yy - cur_d;

    if (test_cur * test_next < 0.0) {
        is_intersected = true;
        inter.side = side;
        LineCoefficients side_line(side_segment.head.yy - side_segment.tail.yy,
                                   side_segment.tail.xx - side_segment.head.xx,
                                   side_segment.head.xx * side_segment.tail.yy -
                                   side_segment.tail.xx * side_segment.head.yy);
        double down = line_direction.xx * side_line.B - side_line.A * line_direction.yy;
        inter.coord = Point((cur_d * side_line.B + side_line.C * line_direction.yy) / down,
                            (-line_direction.xx * side_line.C - side_line.A * cur_d) / down);
    } else if (are_equal(test_cur, 0.0, DBL_EPSILON) && !are_equal(test_next, 0.0, DBL_EPSILON)) {
        is_intersected = true;
        inter.side = side;
        inter.coord = side_segment.head;
    }

    return is_intersected;
}
Esempio n. 5
0
 bool Intersector::intersect(const Circle &circle0, const Circle &circle1) {
   if (are_equal(circle0.get_centre().x(), circle1.get_centre().x()) &&
       are_equal(circle0.get_centre().y(), circle1.get_centre().y())) {
     return are_equal(circle0.get_radius(), circle1.get_radius());
   }
   return is_less_equal(
       Distance::compute(circle0.get_centre(), circle1.get_centre()),
       (circle0.get_radius() + circle1.get_radius()));
 }
Esempio n. 6
0
// are we performing a random transform?
static GLU_bool
rtrans( void )
{
  const int rtrans_idx = tag_search( "RANDOM_TRANSFORM" ) ;
  if( are_equal( INPUT[rtrans_idx].VALUE , "YES" ) ) return GLU_TRUE ;
  return GLU_FALSE ;
}
Esempio n. 7
0
void test_array_are_equal(){
	Array_util a = create(sizeof(int), 6);
	Array_util b = create(sizeof(int), 6);
	int * arr1 = (int *)a.base;
	int * arr2 = (int *)b.base;
	arr1[0] = 12;
	arr2[0] = 11;
	int res = are_equal(a,b);
	assert(res == 0);
	arr1[0] = 12;
	arr2[0] = 12;
	res = are_equal(a,b);
	assert(res == 1);
	free(a.base);
	free(b.base);
};
Esempio n. 8
0
File: test.c Progetto: mzhaolz/hpc
Point run(void* arri_1, void* arri_2, size_t num, size_t size, int (*compar) (const void*, const void*))
{
	clock_t start;
	//assert(are_equal(arri_1, arri_2, num, size, compar));
	clock_t difference;	clock_t difference_std;
	start = clock();
	qsort(arri_2, num, size, compar);	
	difference_std = clock() - start;
	//assert(!is_ordered(arri_2, num, size, compar));
	//time the standard library
	start = clock();
	my_qsort(arri_1, num, size, compar);
	difference = clock() - start;	
	//we're just testing for speed now
	//print_int_array(arri_1, num);
	//print_int_array(arri_2, num);
	assert(are_equal(arri_1, arri_2, num, size, compar));
	free(arri_1); free(arri_2);
	Point p = { .x = difference * 1000/CLOCKS_PER_SEC, .y = difference_std * 1000/CLOCKS_PER_SEC};
	return p;
}

Point test_int_array(size_t num, size_t size) 
{
	void* compar = &compar_int;
	int* arri_1 = random_int_array(num);
	int* arri_2 = (int*) duplicate_array(arri_1, num, size);
	return run(arri_1, arri_2, num, size, compar);
}
Esempio n. 9
0
// read the gauge fixing information
static int
read_gf_struct ( struct gf_info *GFINFO )
{
  // look at what seed type we are going to use
  {
    const int gf_idx = tag_search( "GFTYPE" ) ;
    if( gf_idx == GLU_FAILURE ) { return tag_failure( "GFTYPE" ) ; } 
    if( are_equal( INPUT[gf_idx].VALUE , "LANDAU" ) ) { 
      GFINFO -> type = GLU_LANDAU_FIX ;
    } else if ( are_equal( INPUT[gf_idx].VALUE , "COULOMB" ) ) {
      GFINFO -> type = GLU_COULOMB_FIX ;
    } else {
      fprintf( stderr , "[IO] unknown type [%s] : Defaulting to "
	       "NO GAUGE FIXING \n" , INPUT[gf_idx].VALUE ) ; 
      GFINFO -> type = DEFAULT_NOFIX ; 
    }
  }
  // have a look to see what "improvements" we would like
  {
    const int improve_idx = tag_search( "IMPROVEMENTS" ) ;
    if( improve_idx == GLU_FAILURE ) { return tag_failure( "IMPROVEMENTS" ) ; } 
    GFINFO -> improve = NO_IMPROVE ; // default is no "Improvements" 
    if( are_equal( INPUT[improve_idx].VALUE , "MAG" ) ) {
      GFINFO -> improve = MAG_IMPROVE ; 
    } else if ( are_equal( INPUT[improve_idx].VALUE , "SMEAR" ) ) {
      GFINFO -> improve = SMPREC_IMPROVE ; 
    } else if(  are_equal( INPUT[improve_idx].VALUE , "RESIDUAL" ) ) {
      GFINFO -> improve = RESIDUAL_IMPROVE ; 
    }
  }
  // set the accuracy is 10^{-ACCURACY}
  if( setdbl( &( GFINFO -> accuracy ) , "ACCURACY" ) == GLU_FAILURE ) {
    return GLU_FAILURE ;
  } 
  GFINFO -> accuracy = pow( 10.0 , -GFINFO -> accuracy ) ;
  // set the maximum number of iterations of the routine
  if( setint( &( GFINFO -> max_iters ) , "MAX_ITERS" ) == GLU_FAILURE ) {
    return GLU_FAILURE ;
  }
  // set the alpha goes in Latt.gf_alpha for some reason
  if( setdbl( &Latt.gf_alpha , "GF_TUNE" ) == GLU_FAILURE ) {
    printf( "Failure \n" ) ;
    return GLU_FAILURE ;
  }
  return GLU_SUCCESS ;
}
Esempio n. 10
0
int is_any(c_array* array, byte* the_one, int (*are_equal)(byte*, byte*))
{
	size_t i;
	for (i=0; i<array->len; ++i) {
		if (are_equal(the_one, &array->data[i*array->elem_size]))
			return 1;
	}
	return 0;
}
Esempio n. 11
0
// look for a tag and return the index if found, else return -1
static int
tag_search( const char *tag ) 
{
  int i ;
  for( i = 0 ; i < NTAGS ; i++ ) {
    if( are_equal( INPUT[i].TOKEN , tag ) ) return i ;
  }
  return GLU_FAILURE ;
}
Esempio n. 12
0
void svg_renderer::update_drawing (const QTransform &transform, const QRectF &rect_to_update, int cache_object_type)
{
  m_cache->lock ();
  DO_ON_EXIT (m_cache->unlock ());

  double cache_zoom_x = m_cache->zoom_x ();
  double cache_zoom_y = m_cache->zoom_y ();
  double cur_zoom_x = transform.m11 ();
  double cur_zoom_y = transform.m22 ();
  QRectF rect_to_draw = rect_to_update;
  QTransform real_transform = transform;

  SkBitmap bitmap;
  bitmap.setConfig (SkBitmap::kARGB_8888_Config, rect_to_draw.width (), rect_to_draw.height ());
  bitmap.allocPixels ();
  SkBitmapDevice device (bitmap);
  SkCanvas canvas (&device);

  if (!are_equal (cache_zoom_x, cur_zoom_x) || !are_equal (cache_zoom_y, cur_zoom_y))
    {
      QTransform scale_transform = QTransform::fromScale (cache_zoom_x / cur_zoom_x, cache_zoom_y / cur_zoom_y);
      real_transform = real_transform * scale_transform;
      canvas.setMatrix (qt2skia::matrix (scale_transform.inverted ()));
      rect_to_draw = scale_transform.mapRect (rect_to_draw);
    }

  canvas.drawColor (SK_ColorTRANSPARENT, SkXfermode::kSrc_Mode);

  pair<render_cache_id, render_cache_id> it_pair = render_cache_id::get_id_for_pixel_rect (real_transform, rect_to_draw, cache_object_type);

  for (int x = it_pair.first.x (); x <= it_pair.second.x (); x++)
    for (int y = it_pair.first.y (); y <= it_pair.second.y (); y++)
      {
        render_cache_id cur_id (x, y, cache_object_type);
        SkBitmap bitmap = m_cache->bitmap (cur_id);
        if (bitmap.empty ())
          continue;

        QRectF pixel_rect = cur_id.pixel_rect (real_transform);
        canvas.drawBitmap (bitmap, SkFloatToScalar (pixel_rect.x ()), SkFloatToScalar (pixel_rect.y ()));
      }

  m_cache->set_current_screen (bitmap, cache_object_type);
}
Esempio n. 13
0
FILE *RfPiggyBox::GetDesc(RfReference &key)
{
    RfFile *temp = files;
    while (temp) {
        if (are_equal(temp->key, key))
            return temp->fd;
        temp = temp->next;
    }
    return 0;
}
Esempio n. 14
0
// checks if three lines are intersecting at one point
// algorithm: if intersection of 1st and 2nd is same as intersection of 1st and 3rd
bool are_intersecting(double line1[3], double line2[3], double line3[3])
{
    return
        !is_parallel(line1, line2) &&
        !is_parallel(line1, line3) &&
        !is_parallel(line2, line3) &&
        are_equal
        (
            intersection(line1, line2),
            intersection(line1, line3)
        );
}
Esempio n. 15
0
File: main.cpp Progetto: CCJY/coliru
int main()
{
    std::vector<uint8_t> test = { 'a', 'b', 'c' };
    
    
    // test non-owning range
    ByteRange alias(test.data(), test.data() + test.size(), ByteRange::Refer{});    
    auto alias_copy = alias;
    VERIFY(!alias.owns() && !alias_copy.owns());
    VERIFY(are_equal(alias, alias_copy) && are_identical(alias, alias_copy));
    
    
    // test owning range
    ByteRange owner(test.data(), test.data() + test.size(), ByteRange::Copy{});
    auto owner_copy = owner;
    VERIFY(owner.owns() && owner_copy.owns());
    VERIFY(are_equal(owner, owner_copy) && !are_identical(owner, owner_copy));
    
    
    // test cross-type assignments
    VERIFY((alias = owner, alias.owns()));
    VERIFY((owner = alias_copy, !owner.owns()));
}
Esempio n. 16
0
File: test.c Progetto: mzhaolz/hpc
double test_array(void* arri_1, size_t num, size_t size, int (*compar) (const void*, const void*)) 
{
	void* arri_2 = duplicate_array(arri_1, num, size);
	clock_t difference;	
	clock_t start = clock();
	my_qsort(arri_1, num, size, compar);
	difference = clock() - start;	
	//clock_t start = clock();
	qsort(arri_2, num, size, compar);	
	//difference = clock() - start;
	assert(are_equal(arri_1, arri_2, num, size, compar));
	free(arri_2);
	return difference * 1000/CLOCKS_PER_SEC;
}
Esempio n. 17
0
void test_check_equal_in_str_case(){
	Array_util a = create(sizeof(char), 2);
	Array_util b = create(sizeof(char), 2);
	char *arr1 = a.base;
	char *arr2 = b.base;
	// arr1 = "wow";
	// arr2 = "wow";
	// int res = are_equal(a,b);
	// assert(res == 1);
	arr1 = "wow";
	arr2 = "mom";
	int res = are_equal(a,b);
	assert(res == 1);
	free(a.base);
	free(b.base);
};
static void test_flatten(skiatest::Reporter* reporter, const SkMatrix& m) {
    // add 100 in case we have a bug, I don't want to kill my stack in the test
    char buffer[SkMatrix::kMaxFlattenSize + 100];
    uint32_t size1 = m.writeToMemory(NULL);
    uint32_t size2 = m.writeToMemory(buffer);
    REPORTER_ASSERT(reporter, size1 == size2);
    REPORTER_ASSERT(reporter, size1 <= SkMatrix::kMaxFlattenSize);

    SkMatrix m2;
    uint32_t size3 = m2.readFromMemory(buffer);
    REPORTER_ASSERT(reporter, size1 == size3);
    REPORTER_ASSERT(reporter, are_equal(reporter, m, m2));

    char buffer2[SkMatrix::kMaxFlattenSize + 100];
    size3 = m2.writeToMemory(buffer2);
    REPORTER_ASSERT(reporter, size1 == size3);
    REPORTER_ASSERT(reporter, memcmp(buffer, buffer2, size1) == 0);
}
Esempio n. 19
0
void test_type(const T& gets_written){
   const char * testfile = boost::archive::tmpnam(NULL);
   BOOST_REQUIRE(testfile != NULL);
   {
      test_ostream os(testfile, TEST_STREAM_FLAGS);
      test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
      oa << boost::serialization::make_nvp("written", gets_written);
   }

   T got_read;
   {
      test_istream is(testfile, TEST_STREAM_FLAGS);
      test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
      ia >> boost::serialization::make_nvp("written", got_read);
   }
   BOOST_CHECK(boost::apply_visitor(are_equal(), gets_written, got_read));

   std::remove(testfile);
}
Esempio n. 20
0
int
main(int argc, char **argv)
{
    domainname      d1, d2;
    char           *data1, *data2, *data3, *data4;
    if (argc < 3) {
        printf("Usage: %s domainname domainname\n", argv[0]);
        return 1;
    }
    data1 = (char *) malloc(MAX_LENGTH);
    data2 = (char *) malloc(MAX_LENGTH);
    data3 = (char *) malloc(MAX_LENGTH);
    data4 = (char *) malloc(MAX_LENGTH);
    d1 = text_to_domain(argv[1]);
    if (!VALID(d1)) {
        printf("Invalid domain name \"%s\"\n", argv[1]);
        return 1;
    }
    d2 = text_to_domain(argv[2]);
    if (!VALID(d2)) {
        printf("Invalid domain name \"%s\"\n", argv[2]);
        return 1;
    }
    printf
        ("The canonical version of \"%s\" is \"%s\"; its TLD is \"%s\".\n\t**s registered domain is \"%s\", it has %i labels\n",
         orig_domain_name(data1, d1), domain_name(data2, d1), tld(data3, d1),
         registered_domain_name(data4, d1), (int) nlabels(d1));
    if (are_equal(d1, d2)) {
        printf("%s and %s are equivalent domain names\n", argv[1], argv[2]);
    } else {
        printf("%s and %s are NOT equivalent domain names\n", argv[1], argv[2]);
    }
    if (are_identical(d1, d2)) {
        printf("%s and %s are absolutely identical\n", argv[1], argv[2]);
    } else {
        printf("%s and %s are NOT absolutely identical\n", argv[1], argv[2]);
    }
    free(data1);
    free(data2);
    free(data3);
    free(data4);
    return 0;
}
Esempio n. 21
0
int main(int argc, char* argv[])
{
    if (argc != 4)
    {
        printf("Exactly 3 arguments should be provied!\n");
        return 1;
    }

    if (are_equal(argv[1], argv[2], argv[3]))
    {
        printf("equal\n");
    }
    else
    {
        printf("not equal\n");
    }

    return 0;
}
Esempio n. 22
0
void run_iterations(int* a, int* b, int* c, int itr, int print, int pause)
{	
	
	int i;
	for(i = 0; i < itr; i++)
	{
		if (current_state == 0)
		{
			if (print) {
				print_array(a);
			}
			iterate(a, b);
			current_state = 1;
		}
		else if (current_state == 1)
		{
			if (print) {
				print_array(b);
			}
			iterate(b, c);
			current_state = 2;
		}
		else
		{
			if (print) {
				print_array(c);
			}
			iterate(c, a);
			current_state = 0;
		}

		if (are_equal(a, b) || are_equal(b, c) || are_equal(c, a))
		{
			printf("the game has stabilized on iteration %i of %i\nwith final configuration:\n", i, itr+1);
			print_array(current_state==1 ? a : (current_state==2 ? b : c));
			i = itr;
		}
		else if (pause){
			printf("please press the anykey to continue");
			getchar();
			printf("\f");
		}
	}
	if (!(are_equal(a, b) || are_equal(b, c) || are_equal(c, a)))
	{
		printf("the game has finished all %i iterations\nwith final configuration:\n", itr);
		print_array(current_state==1 ? a : (current_state==2 ? b : c));
	}
}
Esempio n. 23
0
Intersection find_bisection(const Point& line_direction, const std::vector<Point>& polygon)
{
    int min_offset_ind;
    OffsetRange offset_range;
    find_offset_range(line_direction, polygon, min_offset_ind, offset_range);

    const double whole_area = polygon_area(polygon);
    double area_difference = whole_area;
    Intersection inter;

    while (!are_equal(area_difference, 0.0, EPS * whole_area)) {
        double cur_offset = offset_range.middle_of_range();
        inter = find_line_polygon_intersection(line_direction, cur_offset,  polygon);
        std::vector<Point> half_pol = construct_polygon_part(polygon, inter.left, inter.right);

        area_difference = whole_area - 2 * polygon_area(half_pol);

        (is_half_consisting_min_offset_ind_greater(min_offset_ind, area_difference, inter) ? offset_range.right : offset_range.left) = cur_offset;
    }
    return inter;
}
Esempio n. 24
0
File: em_weight.c Progetto: b-k/tea
//This is a substitute for apop_pmf_compress, because
//we can use knowledge of our special case to work more efficiently
void merge_two_sets(apop_data *left, apop_data *right){
    for  (int i=0; i< right->matrix->size1; i++) {
        Apop_row(right, i, Rrow);
        double *r = gsl_vector_ptr(Rrow->weights, 0);
        if (!*r) continue;
        int j;
        bool done = false;
        #pragma omp parallel for private(j) shared(done)
        for (j=0; j< left->matrix->size1; j++){
            Apop_row(left, j, Lrow);
            if (are_equal(Rrow, Lrow)){
                *gsl_vector_ptr(Lrow->weights, 0) += *r;
                *r = 0;
                done = true;
                if (done) j = left->matrix->size1;
            }
        }
    }
    apop_data_rm_rows(right, .do_drop=weightless);
    //apop_data_listwise_delete(left, .inplace='y');
    apop_data_stack(left, right, .inplace='y');
}
Esempio n. 25
0
void RfPiggyBox::OpenFile(RfReference &key, char *name, char *mode)
{
    FILE *fd = fopen(name, mode);

    if (!fd)
        throw IntelibX_refal_failure(0);
    
    RfFile *start = files;
    while (start) {
        if (are_equal(start->key, key))
            throw IntelibX_refal_failure(0);
        start = start->next;
    }

    if (!files) {
        files = new RfFile(key, fd);
    }
    else {
        RfFile *temp = new RfFile(key, fd);
        temp->next = files;
        files = temp;
    }
}
Esempio n. 26
0
// the code that writes out all of the config details
static int
out_details( GLU_output *storage , 
	     const GLU_mode mode )
{  
  // get the storage type
  {
    const int storage_idx = tag_search( "STORAGE" ) ;
    if( storage_idx == GLU_FAILURE ) { return tag_failure( "STORAGE" ) ; }
    if( are_equal( INPUT[storage_idx].VALUE , "NERSC_SMALL" ) ) {
      // small is not available for larger NC default to NCxNC
      #if NC > 3
      *storage = OUTPUT_NCxNC ;
      #else
      *storage = ( mode != MODE_CROSS_U1 ) ? OUTPUT_SMALL : OUTPUT_NCxNC ;
      #endif
    } else if( are_equal( INPUT[storage_idx].VALUE , "NERSC_GAUGE" ) ) {
      *storage = ( mode != MODE_CROSS_U1 ) ? OUTPUT_GAUGE : OUTPUT_NCxNC ;
    } else if( are_equal( INPUT[storage_idx].VALUE , "NERSC_NCxNC" ) ) {
      *storage = OUTPUT_NCxNC ;
    } else if( are_equal( INPUT[storage_idx].VALUE , "HIREP" ) ) {
      *storage = OUTPUT_HIREP ;
    } else if( are_equal( INPUT[storage_idx].VALUE , "MILC" ) ) {
      *storage = OUTPUT_MILC ;
    } else if( are_equal( INPUT[storage_idx].VALUE , "SCIDAC" ) ) {
      *storage = OUTPUT_SCIDAC ;
    } else if( are_equal( INPUT[storage_idx].VALUE , "ILDG" ) ) {
      *storage = OUTPUT_ILDG ;
    } else {
      fprintf( stdout , "[IO] output type %s not recognised .. leaving \n" , 
	       INPUT[storage_idx].VALUE ) ;
      return GLU_FAILURE ;
    }
  }
  // we now do reach this point
  return GLU_SUCCESS ;
}
Esempio n. 27
0
DEF_TEST(Matrix, reporter) {
    SkMatrix    mat, inverse, iden1, iden2;

    mat.reset();
    mat.setTranslate(SK_Scalar1, SK_Scalar1);
    REPORTER_ASSERT(reporter, mat.invert(&inverse));
    iden1.setConcat(mat, inverse);
    REPORTER_ASSERT(reporter, is_identity(iden1));

    mat.setScale(SkIntToScalar(2), SkIntToScalar(4));
    REPORTER_ASSERT(reporter, mat.invert(&inverse));
    iden1.setConcat(mat, inverse);
    REPORTER_ASSERT(reporter, is_identity(iden1));
    test_flatten(reporter, mat);

    mat.setScale(SK_Scalar1/2, SkIntToScalar(2));
    REPORTER_ASSERT(reporter, mat.invert(&inverse));
    iden1.setConcat(mat, inverse);
    REPORTER_ASSERT(reporter, is_identity(iden1));
    test_flatten(reporter, mat);

    mat.setScale(SkIntToScalar(3), SkIntToScalar(5), SkIntToScalar(20), 0);
    mat.postRotate(SkIntToScalar(25));
    REPORTER_ASSERT(reporter, mat.invert(NULL));
    REPORTER_ASSERT(reporter, mat.invert(&inverse));
    iden1.setConcat(mat, inverse);
    REPORTER_ASSERT(reporter, is_identity(iden1));
    iden2.setConcat(inverse, mat);
    REPORTER_ASSERT(reporter, is_identity(iden2));
    test_flatten(reporter, mat);
    test_flatten(reporter, iden2);

    mat.setScale(0, SK_Scalar1);
    REPORTER_ASSERT(reporter, !mat.invert(NULL));
    REPORTER_ASSERT(reporter, !mat.invert(&inverse));
    mat.setScale(SK_Scalar1, 0);
    REPORTER_ASSERT(reporter, !mat.invert(NULL));
    REPORTER_ASSERT(reporter, !mat.invert(&inverse));

    // rectStaysRect test
    {
        static const struct {
            SkScalar    m00, m01, m10, m11;
            bool        mStaysRect;
        }
        gRectStaysRectSamples[] = {
            {          0,          0,          0,           0, false },
            {          0,          0,          0,  SK_Scalar1, false },
            {          0,          0, SK_Scalar1,           0, false },
            {          0,          0, SK_Scalar1,  SK_Scalar1, false },
            {          0, SK_Scalar1,          0,           0, false },
            {          0, SK_Scalar1,          0,  SK_Scalar1, false },
            {          0, SK_Scalar1, SK_Scalar1,           0, true },
            {          0, SK_Scalar1, SK_Scalar1,  SK_Scalar1, false },
            { SK_Scalar1,          0,          0,           0, false },
            { SK_Scalar1,          0,          0,  SK_Scalar1, true },
            { SK_Scalar1,          0, SK_Scalar1,           0, false },
            { SK_Scalar1,          0, SK_Scalar1,  SK_Scalar1, false },
            { SK_Scalar1, SK_Scalar1,          0,           0, false },
            { SK_Scalar1, SK_Scalar1,          0,  SK_Scalar1, false },
            { SK_Scalar1, SK_Scalar1, SK_Scalar1,           0, false },
            { SK_Scalar1, SK_Scalar1, SK_Scalar1,  SK_Scalar1, false }
        };

        for (size_t i = 0; i < SK_ARRAY_COUNT(gRectStaysRectSamples); i++) {
            SkMatrix    m;

            m.reset();
            m.set(SkMatrix::kMScaleX, gRectStaysRectSamples[i].m00);
            m.set(SkMatrix::kMSkewX,  gRectStaysRectSamples[i].m01);
            m.set(SkMatrix::kMSkewY,  gRectStaysRectSamples[i].m10);
            m.set(SkMatrix::kMScaleY, gRectStaysRectSamples[i].m11);
            REPORTER_ASSERT(reporter,
                    m.rectStaysRect() == gRectStaysRectSamples[i].mStaysRect);
        }
    }

    mat.reset();
    mat.set(SkMatrix::kMScaleX, SkIntToScalar(1));
    mat.set(SkMatrix::kMSkewX,  SkIntToScalar(2));
    mat.set(SkMatrix::kMTransX, SkIntToScalar(3));
    mat.set(SkMatrix::kMSkewY,  SkIntToScalar(4));
    mat.set(SkMatrix::kMScaleY, SkIntToScalar(5));
    mat.set(SkMatrix::kMTransY, SkIntToScalar(6));
    SkScalar affine[6];
    REPORTER_ASSERT(reporter, mat.asAffine(affine));

    #define affineEqual(e) affine[SkMatrix::kA##e] == mat.get(SkMatrix::kM##e)
    REPORTER_ASSERT(reporter, affineEqual(ScaleX));
    REPORTER_ASSERT(reporter, affineEqual(SkewY));
    REPORTER_ASSERT(reporter, affineEqual(SkewX));
    REPORTER_ASSERT(reporter, affineEqual(ScaleY));
    REPORTER_ASSERT(reporter, affineEqual(TransX));
    REPORTER_ASSERT(reporter, affineEqual(TransY));
    #undef affineEqual

    mat.set(SkMatrix::kMPersp1, SkScalarToPersp(SK_Scalar1 / 2));
    REPORTER_ASSERT(reporter, !mat.asAffine(affine));

    SkMatrix mat2;
    mat2.reset();
    mat.reset();
    SkScalar zero = 0;
    mat.set(SkMatrix::kMSkewX, -zero);
    REPORTER_ASSERT(reporter, are_equal(reporter, mat, mat2));

    mat2.reset();
    mat.reset();
    mat.set(SkMatrix::kMSkewX, SK_ScalarNaN);
    mat2.set(SkMatrix::kMSkewX, SK_ScalarNaN);
    REPORTER_ASSERT(reporter, !are_equal(reporter, mat, mat2));

    test_matrix_min_max_scale(reporter);
    test_matrix_is_similarity(reporter);
    test_matrix_recttorect(reporter);
    test_matrix_decomposition(reporter);
    test_matrix_homogeneous(reporter);
}
Esempio n. 28
0
// yep, that is what I chose to call it : Help functions
int
GLU_helps_those_who_help_themselves( const char *help_str )
{
  if( are_equal( help_str , "--help=MODE" ) ) {
    mode_types( ) ;
  } else if( are_equal( help_str , "--help=HEADER" ) ) {
    header_types( ) ;
  } else if( are_equal( help_str , "--help=DIM" ) ) {
    fprintf( stdout , "DIM_%%d = %%d - Specified lattice dimensions for the "
	     "UNIT, RANDOM and INSTANTON\n"
	     "              types of HEADER. If we are not using these, "
	     "lattice\n"
	     "              dimensions are taken from the configuration "
	     "header\n" ) ;
  } else if( are_equal( help_str , "--help=CONFNO" ) ) {
    fprintf( stdout , "CONFNO = %%d - User-specified configuration number. "
	     "All configuration types except NERSC do not directly provide\n"
	     "              a configuration number. So you should supply one "
	     "for the output configuration\n" ) ;
  } else if( are_equal( help_str , "--help=RANDOM_TRANSFORM" ) ) {
    fprintf( stdout , "RANDOM_TRANSFORM = YES    - Perform a lattice-wide "
	     "random gauge transformation of the fields\n"
	     "                 = {!YES} - Do nothing\n" ) ;
  } else if( are_equal( help_str , "--help=SEED" ) ) {
    fprintf( stdout , "SEED = %%d - User specified RNG seed \n" 
	     "        0 - Generates a SEED from urandom if it is available\n") ;
  } else if( are_equal( help_str , "--help=GFTYPE" ) ) {
    gftype_types( ) ;
  } else if( are_equal( help_str , "--help=GFTUNE" ) ) {
    fprintf( stdout , "GFTUNE = %%lf - User specified tuning parameter for "
	     "the gauge fixing this should generally be < 0.1, less "
	     "important for the default CG routines\n" ) ;
  } else if( are_equal( help_str , "--help=IMPROVEMENTS" ) ) {
    improvement_types( ) ;
  } else if( are_equal( help_str , "--help=ACCURACY" ) ) {
    fprintf( stdout , "ACCURACY = %%d - Stops the gauge fixing after an "
	     "average accuracy of better than 10^{-ACCURACY} has been "
	     "achieved\n" ) ;
  } else if( are_equal( help_str , "--help=MAX_ITERS" ) ) {
    fprintf( stdout , "MAX_ITERS = %%d - After this many iterations the "
	     "routine restarts from the beginning with a random transformation "
	     "of the\n"
	     "                 fields and after %d restarts it complains about "
	     "changing the tuning\n" , GF_GLU_FAILURES ) ;
  } else if( are_equal( help_str , "--help=CUTTYPE" ) ) {
    cuttype_types( ) ;
  } else if( are_equal( help_str , "--help=FIELD_DEFINTION" ) ) {
    fprintf( stdout , "FIELD_DEFINITION = LOG        - Exact logarithm "
	     "definition of the gauge fields\n" ) ;
    fprintf( stdout , "FIELD_DEFINITION = {ALL ELSE} - Hermitian projection "
	     "definition of the gauge fields (denoted LINEAR)\n" ) ;
  } else if( are_equal( help_str , "--help=MOM_CUT" ) ) {
    momcut_types( ) ;
  } else if( are_equal( help_str , "--help=MAX_T" ) ) {
    fprintf( stdout , "MAX_T = %%d - serves as the maximum T separation for "
	     "the Polyakov lines\n"
	     "             in the STATIC_POTENTIAL code. Computes "
	     "T=1,2,...,MAX_T separations\n" ) ;
  } else if( are_equal( help_str , "--help=MAXMOM" ) ) {
    fprintf( stdout , "MAXMOM = %%d - maximum allowed n_{mu}n_{mu} "
	     "where n_{mu} is a Fourier mode\n" ) ;
  } else if( are_equal( help_str , "--help=CYL_WIDTH" ) ) {
    fprintf( stdout , "CYL_WIDTH = %%lf - momenta are allowed within the "
	     "body-diagonal cylinder of width CYL_WIDTH * 2 \\pi / L \n"
	     "                  where L is the smallest lattice direction's "
	     "length\n" ) ;
  } else if( are_equal( help_str , "--help=ANGLE" ) ) {
    fprintf( stdout , "ANGLE = %%lf - conical cut's angle of the apex of "
	     "the cone\n" ) ;
  } else if( are_equal( help_str , "--help=OUTPUT" ) ) {
    fprintf( stdout , "OUTPUT = %%s - prefix destination for where the "
	     "output file for the cut procedure will be written. The actual "
	     "output file\n"
	     "              is generated within the code, the output format "
	     "requires CONFNO to be set \n" ) ;
  } else if( are_equal( help_str , "--help=SMEARTYPE" ) ) {
    smeartype_types( ) ;
  } else if( are_equal( help_str , "--help=DIRECTION" ) ) {
    fprintf( stdout , "DIRECTION = SPATIAL    - smears the fields for each "
	     "time-slice only in the ND-1 polarisation directions\n" ) ;
    fprintf( stdout , "          = {ALL ELSE} - fully smears all the links "
	     "in all the directions\n" ) ;
  } else if( are_equal( help_str , "--help=SMITERS" ) ) {
    fprintf( stdout , "SMITERS = %%d - maximum number of smearing iterations "
	     "to perform, some routines such as the Wilson flow will "
	     "often finish\n"
	     "               before this number is reached\n" ) ;
  } else if( are_equal( help_str , "--help=ALPHA" ) ) {
    fprintf( stdout , "ALPHA_%%d = %%lf - Smearing parameters for each "
	     "level of smearing, expects ND-1 of these\n"
	     "                 e.g. ALPHA_1, ALPHA_2 .. ALPHA_ND-1 "
	     "for Hypercubically blocked smearing in\n"
	     "                 all directions. For the Wilson flow and for "
	     "APE, LOG and STOUT smearings ALPHA_1 is the only relevant\n"
	     "                 parameter and all others are ignored\n" ) ;
  } else if( are_equal( help_str , "--help=U1_MEAS" ) ) {
    U1meas_types( ) ;
  } else if( are_equal( help_str , "--help=U1_ALPHA" ) ) {
    fprintf( stdout , "U1_ALPHA = %%lf - The non-compact bare coupling "
	     "g^{2} / 4\\pi, beta is 1 / ( \\pi ND U1_ALPHA ) \n" ) ;
    fprintf( stdout , "\n*caution* FFTW must be linked\n" ) ; 
  } else if( are_equal( help_str , "--help=U1_CHARGE" ) ) {
    fprintf( stdout , "U1_CHARGE = %%lf - Charges the U(1) fields upon "
	     "compactification \n" 
	     "                  U(1)_{mu} = exp( i U1_CHARGE "
	     "sqrt( 4 \\pi U1_ALPHA ) A_{mu} ) \n" ) ;
  } else if( are_equal( help_str , "--help=CONFIG_INFO" ) ) {
    fprintf( stdout , "CONFIG_INFO = %%s - Provide some small details "
	     "for when we write out the configuration file\n" ) ;
  } else if( are_equal( help_str , "--help=STORAGE" ) ) {
    storage_types( ) ;
  } else if( are_equal( help_str , "--help=BETA" ) ) {
    fprintf( stdout , "BETA = %%f - the parameter 2N/g_0^2 with which "
	     "we weight the ensembles in the heatbath\n" ) ;
  } else if( are_equal( help_str , "--help=ITERS" ) ) {
    fprintf( stdout , "ITERS = %%d - the total number of iterations after "
	     "thermalisation that the HB-OR does\n" ) ;
  } else if( are_equal( help_str , "--help=MEASURE" ) ) {
    fprintf( stdout , "MEASURE = %%d - the number of combined HB-OR iters "
	     "before a measurement of the plaquette and polyakov loops\n" ) ;
  } else if( are_equal( help_str , "--help=OVER_ITERS" ) ) {
    fprintf( stdout , "OVER_ITERS = %%d - the number of overrelaxation "
	     "iterations in the combined HB-OR\n" ) ;
  } else if( are_equal( help_str , "--help=SAVE" ) ) {
    fprintf( stdout , "SAVE = %%d - the iteration count at which we save "
	     "a configuration in the HB-OR\n" ) ;
  } else if( are_equal( help_str , "--help=THERMALISATION" ) ) {
    fprintf( stdout , "THERMALISATION = %%d - the number of HB-OR iterations "
	     "of thermalisation before measurement and saving\n" ) ;    
  } else if( are_equal( help_str , "--autoin=LANDAU" ) ) {
    create_input_file( "GAUGE_FIXING" , "LANDAU" ,
		       "TOPOLOGICAL_SUSCEPTIBILITY" ) ;
  } else if( are_equal( help_str , "--autoin=COULOMB" ) ) {
    create_input_file( "GAUGE_FIXING" , "COULOMB" ,
		       "TOPOLOGICAL_SUSCEPTIBILITY" ) ;
  } else if( are_equal( help_str , "--autoin=HEATBATH" ) ) {
    create_input_file( "HEATBATH" , "COULOMB" ,
		       "TOPOLOGICAL_SUSCEPTIBILITY") ;   
  } else if( are_equal( help_str , "--autoin=STATIC_POTENTIAL" ) ) {
    create_input_file( "CUTTING" , "LANDAU" ,
		       "STATIC_POTENTIAL" ) ;
  } else if( are_equal( help_str , "--autoin=SUNCxU1" ) ) {
    create_input_file( "SUNCxU1" , "LANDAU" ,
		       "TOPOLOGICAL_SUSCEPTIBILITY" ) ;
  } else if( are_equal( help_str , "--autoin=WFLOW" ) ) {
    create_input_file( "SMEARING" , "LANDAU" ,
		       "TOPOLOGICAL_SUSCEPTIBILITY" ) ;
  } else {
    fprintf( stdout , "[IO] Unrecognised {input_file} query \"%s\" for\n" , 
	     help_str ) ;
    help_usage() ;
  }
  return GLU_SUCCESS ;
}
Esempio n. 29
0
// parse the information from the c-str of xml info
int
parse_and_set_xml_SCIDAC( char *xml_info ,
			  struct head_data *HEAD_DATA ) 
{
  // scidac is always big endian, which is nice
  HEAD_DATA -> endianess = B_ENDIAN ;

  // We use the C tokenize capabilities to parse this string
  char *pch = strtok( xml_info , "<>" ) ;
  // this is not an error
  if (strncmp( pch , "?xml" , 4 ) ) {
    return 0 ;
  }
  int dimensions = 0 ;

  // set up the search for extra dimensions, extra space for terminating null
  const char open[4][3] = { "lx" , "ly" , "lz" , "lt" } ;
  char search[ND][3] ;
  size_t mu ;
  for( mu = 0 ; mu < ND-1 ; mu++ ) {
    if( mu < 4 ) {
      sprintf( search[mu] , "%s" , open[mu] ) ;
    } else {
      sprintf( search[mu] , "l%zu" , mu ) ;
    }
  }
  sprintf( search[ND-1] , "%s" , open[3] ) ;

  // We've removed the XML header, now we can set up a state 
  // machine to parse the file
  while( ( pch = strtok( 0 , "<>" ) ) ) {
    while( ( pch = strtok( 0 , "<>" ) ) ) {
      
      // break if we are at the end of a scidac file or record
      if( are_equal( pch , "/scidacRecord" ) ) break ;
      if( are_equal( pch , "/scidacFile" ) ) break ;
      if( are_equal( pch , "/ildgFormat" ) ) break ;

      // get number of spacetime dimensions
      if( are_equal( pch , "spacetime" ) ) {
	if( ( dimensions = get_int_tag( pch , "spacetime" ) ) != 0 ) {
	  if( dimensions != ND ) {
	    fprintf( stderr , "[IO] ND mismatch compiled %d vs. read %d \n" ,
		     ND , dimensions ) ;
	    return GLU_FAILURE ;
	  }
	}
        #ifdef DEBUG
	printf( "[IO] spacetime :: %d \n" , dimensions ) ;
        #endif
      }

      // have a look at the colors
      if( are_equal( pch , "colors" ) ) {
	if( ( dimensions = get_int_tag( pch , "colors" ) ) != 0 ) {
	  if( dimensions != NC ) {
	    printf( "[IO] NC mismatch compiled %d vs. read %d \n" ,
		    NC , dimensions ) ;
	    return GLU_FAILURE ;
	  }
	}
      }

      // have a look at the storage type size
      if( are_equal( pch , "typesize" ) ) {
	if( ( dimensions = get_int_tag( pch , "typesize" ) ) != 0 ) {
	  HEAD_DATA -> config_type = OUTPUT_NCxNC ; // binary file output
	  if( dimensions == 2 * ND * NCNC ) {
	    HEAD_DATA -> precision = FLOAT_PREC ;
	  } else if( dimensions == ( 4 * ND * NCNC ) ) {
	    HEAD_DATA -> precision = DOUBLE_PREC ;
	  } else {
	    fprintf( stderr , "[IO] Storage type not recognised \n" ) ;
	    return GLU_FAILURE ;
	  }
	}
      }

      // get the floating point output precision ...
      if( are_equal( pch , "precision" ) ) {
	if( ( dimensions = get_prec_tag( pch , "precision" ) ) != -1 ) {
	  if( dimensions == FLOAT_PREC ) {
	    #ifdef verbose
	    fprintf( stdout , "[IO] Attempting to read "
		     "single precision data\n" ) ;
	    #endif
	    HEAD_DATA -> precision = FLOAT_PREC ;
	  } else if( dimensions == DOUBLE_PREC ) {
	    #ifdef verbose
	    fprintf( stdout , "[IO] Attempting to read double "
		     "precision data\n" ) ;
	    #endif
	    HEAD_DATA -> precision = DOUBLE_PREC ;
	  } else {
	    fprintf( stderr , "[IO] Precision %d not understood \n" , 
		     dimensions ) ;
	    return GLU_FAILURE ;
	  }
	}
      }

      // grok the lattice dimensions
      if ( are_equal( pch, "dims" ) ) {
	while ( ( pch = strtok( 0 , "<>" ) ) ) {
	  // break up the dimensions ...
	  char *token = strtok( pch , " " ) ;
	  if( token == NULL ) return GLU_FAILURE ;
	  int idx = 0 ;
	  char *pEnd ;
	  Latt.dims[ idx++ ] = strtol( token , &pEnd , 10 ) ;
	  while( ( token = strtok( NULL , " " ) ) != NULL ) {
	    if(  ( are_equal( token , "/dims" ) ) ) break ;
	    Latt.dims[ idx ] = strtol( token , &pEnd , 10 ) ;
	    idx++ ;
	  } 
	  // and break the xml
	  break;
	}
	continue ;
      }

      // I just take the first checksum ...
      if( are_equal( pch , "suma" ) ) {
	while( ( pch = strtok( 0 , "<>" ) ) ) {
	  if( are_equal( pch , "/suma" ) ) break ;
	  sscanf( pch , "%x" , &(HEAD_DATA -> checksum) ) ;
	}
	continue ;
      }

      ////////////////////////  ILDG SPECIFIC TAGS ////////////////////
      // If I were to make up a format it would be exactly the       //
      // same as another one apart from tiny, pointless, differences //

      // geometry, not sure about making this ND-generic much prefer the
      // scidac "dims" array
      int length = 0 ;
      for( mu = 0 ; mu < ND ; mu++ ) {
	if( are_equal( pch , search[mu] ) ) {
	  if( ( length = get_int_tag( pch , search[mu] ) ) != 0 ) {
	    Latt.dims[ mu ] = length ;
	  }
	  continue ;
	}
      }

      // for getting the field ... su3gauge is actually NCxNC by the look of it
      // loop tokens
      if( are_equal( pch , "field" ) ) {
	while( ( pch = strtok( 0 , "<>" ) ) ) {
	  if( are_equal( pch , "/field" ) ) break ;
	  // sometimes there is whitespace around these for some unknown reason
	  char *token = realFront( pch ) ;
	  char compare[10] ;
	  sprintf( compare , "su%dgauge" , NC ) ;
	  if( !strncmp( compare , token , 8 ) ) {
	    HEAD_DATA -> config_type = OUTPUT_NCxNC ;
	  } else {
	    fprintf( stderr , "[ILDG] Expected %s, got \"%s\" \n" , 
		     compare , token ) ;
	    return GLU_FAILURE ;
	  }
	}
	continue ;
      }
      // +any others that may come up ...
    }
    break;
  }
  return GLU_SUCCESS ;
}
Esempio n. 30
0
int main() {
  set<int> A,B,C,Acpy;
  aed::set<int> AA,BB,CC,AAcpy;
  int N=1024*256, m=3, M=100;
  double avdepth = 0.0, avdepthlv=0.0;
  for (int k=0; k<M; k++) {
    AA.clear();
    for (int j=0; j<N; j++) {
      int x = irand(m*N);
      AA.insert(x);
    }
    double ad,adlv;
    avheight(AA.tree(),ad,adlv);
    cout << "ad: " << ad << " ,adlv: " << adlv << endl;
    avdepth += ad;
    avdepthlv += adlv;
  }
  cout << "avrg depth: " << avdepth/double(M) << endl;
  cout << "min. avrg depth: " << log2(double(N))-1 << endl;

  cout << "avrg depth leaves: " << avdepthlv/double(M) << endl;
  cout << "min. avrg depth leaves: " << log2(double(N)) << endl;

#if 0
  cout << "insertando ";
  for (int j=0; j<N; j++) {
    int x = irand(m*N);
    cout << x << endl;
    A.insert(x);
    AA.insert(x);
    x = irand(m*N);
    B.insert(x);
    BB.insert(x);
  }
  cout << endl;
  print_tree(AA.tree());

  assert(are_equal(AA,A));
  assert(are_equal(BB,B));

  set_print(A);
  set_print(AA);

#define VER_ABB(T)					\
  cout << #T " is abb: " << abb_p(T.tree()) << endl;	\
  assert(abb_p(T.tree()))

  VER_ABB(AA);
  VER_ABB(BB);

  for (int j=0; j<m*N; j++) {
    bool inA = (A.find(j)!=A.end());
    bool inAA = (AA.find(j)!=AA.end());
    if (inA != inAA) 
      cout << "in A: " << inA 
	   << "in AA: " << inAA << endl;
  }

  Acpy = A;
  AAcpy = AA;
  assert(are_equal(AAcpy,Acpy));
  VER_ABB(AAcpy);

  for (int j=0; j<m*N; j++) {
    A.erase(2*j);
    AA.erase(2*j);
  }
  assert(are_equal(AA,A));

  cout << "Eliminados los elementos pares\n";
  set_print(A);
  set_print(AA);
  VER_ABB(AA);

  A = Acpy;
  AA = AAcpy;

  cout << "Recupera elementos\n";
  set_print(A);
  set_print(AA);
  assert(are_equal(AA,A));
  VER_ABB(AA);

  cout << "B\n";
  set_print(B);
  set_print(BB);
  VER_ABB(BB);

  aed::set_union(AA,BB,CC);
  C.clear();
  set_union(A.begin(),A.end(),
	    B.begin(),B.end(),inserter(C,C.begin()));
  assert(are_equal(CC,C));
  VER_ABB(CC);

  cout << "C = A union B\n";
  set_print(C);
  set_print(CC);

  aed::set_intersection(AA,BB,CC);
  C.clear();
  set_intersection(A.begin(),A.end(),
		   B.begin(),B.end(),inserter(C,C.begin()));
  assert(are_equal(CC,C));
  VER_ABB(CC);

  cout << "C = A intersection B\n";
  set_print(C);
  set_print(CC);

  aed::set_difference(AA,BB,CC);
  C.clear();
  set_difference(A.begin(),A.end(),
		 B.begin(),B.end(),inserter(C,C.begin()));
  assert(are_equal(CC,C));
  VER_ABB(CC);

  cout << "C = A - B\n";
  set_print(C);
  set_print(CC);

  aed::set_difference(BB,AA,CC);
  C.clear();
  set_difference(B.begin(),B.end(),
		 A.begin(),A.end(),inserter(C,C.begin()));
  assert(are_equal(CC,C));
  VER_ABB(CC);

  cout << "C = B - A \n";
  set_print(C);
  set_print(CC);
#endif
}