test_vec_comp.c
Go to the documentation of this file.
00001 
00006 /*
00007 Copyright (C) 2008-11 Andrea Vedaldi.
00008 All rights reserved.
00009 
00010 This file is part of the VLFeat library and is made available under
00011 the terms of the BSD license (see the COPYING file).
00012 */
00013 
00014 #include <vl/random.h>
00015 #include <vl/mathop.h>
00016 
00017 void
00018 init_data (vl_size numDimensions, vl_size numSamples, float ** X, float ** Y)
00019 {
00020   VlRand * rand = vl_get_rand() ;
00021   vl_uindex i ;
00022   float * Xi = *X = vl_malloc(sizeof(float) * numDimensions * numSamples) ;
00023   float * Yi = *Y = vl_malloc(sizeof(float) * numDimensions * numSamples) ;
00024   for (i = 0 ; i < numDimensions * numSamples ; ++ i) {
00025     *Xi++ = vl_rand_real1(rand) ;
00026     *Yi++ = vl_rand_real1(rand) ;
00027   }
00028 }
00029 
00030 int
00031 main (int argc VL_UNUSED, char** argv VL_UNUSED)
00032 {
00033   float * X ;
00034   float * Y ;
00035   vl_size numDimensions = 1000 ;
00036   vl_size numSamples    = 2000 ;
00037   float * result = vl_malloc (sizeof(float) * numSamples * numSamples) ;
00038   VlFloatVectorComparisonFunction f ;
00039 
00040   init_data (numDimensions, numSamples, &X, &Y) ;
00041 
00042   X+=1 ;
00043   Y+=1 ;
00044 
00045   vl_set_simd_enabled (VL_FALSE) ;
00046   f = vl_get_vector_comparison_function_f (VlDistanceL2) ;
00047   vl_tic () ;
00048   vl_eval_vector_comparison_on_all_pairs_f (result, numDimensions, X, numSamples, Y, numSamples, f) ;
00049   VL_PRINTF("Float L2 distnace: %.3f s\n", vl_toc ()) ;
00050 
00051   vl_set_simd_enabled (VL_TRUE) ;
00052   f = vl_get_vector_comparison_function_f (VlDistanceL2) ;
00053   vl_tic () ;
00054   vl_eval_vector_comparison_on_all_pairs_f (result, numDimensions, X, numSamples, Y, numSamples, f) ;
00055   VL_PRINTF("Float L2 distance (SIMD): %.3f s\n", vl_toc ()) ;
00056 
00057   X-- ;
00058   Y-- ;
00059 
00060   vl_free (X) ;
00061   vl_free (Y) ;
00062   vl_free (result) ;
00063 
00064   return 0 ;
00065 }


libvlfeat
Author(s): Andrea Vedaldi
autogenerated on Thu Jun 6 2019 20:25:51