test_mathop_abs.c
Go to the documentation of this file.
00001 /*
00002  *  test_mathop_abs.c
00003  *  vlfeat
00004  *
00005  *  Created by Andrea Vedaldi on 16/07/2009.
00006  *  Copyright 2009 UCLA. All rights reserved.
00007  *
00008  */
00009 
00010 #include <vl/random.h>
00011 #include <vl/mathop.h>
00012 
00013 #include <math.h>
00014 
00015 int
00016 main(int argc VL_UNUSED, char**argv VL_UNUSED)
00017 {
00018   VlRand * rand = vl_get_rand() ;
00019   vl_size numData = 100000000 ;
00020   vl_size i ;
00021   float * X = vl_malloc(sizeof(float) * numData) ;
00022   float * Y = vl_malloc(sizeof(float) * numData) ;
00023   float * X_end = X + numData ;
00024 
00025   for (i = 0 ; i < numData ; ++ i) {
00026     X[i] = vl_rand_real1(rand) - .5 ;
00027     Y[i] = 0 ;
00028   }
00029 
00030   {
00031     float * Xi = X ;
00032     float * Yi = Y ;
00033     vl_tic() ;
00034     while (Xi < X_end) {
00035       *Yi++ = fabsf (*Xi++) ;
00036     }
00037     VL_PRINTF("fabsf: %.3f\n", vl_toc()) ;
00038   }
00039 
00040   for (i = 0 ; i < numData ; ++ i) {
00041     X[i] = vl_rand_real1(rand) - .5 ;
00042     X[i] = 0 ;
00043   }
00044 
00045   {
00046     float * Xi = X ;
00047     float * Yi = Y ;
00048     vl_tic() ;
00049     while (Xi < X_end) {
00050       *Yi++ = vl_abs_f (*Xi++) ;
00051     }
00052     VL_PRINTF("vl_abs_f: %.3f\n", vl_toc()) ;
00053   }
00054 
00055   vl_free (Y) ;
00056   vl_free (X) ;
00057 
00058   return 0 ;
00059 }


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