00001 00006 /* 00007 Copyright (C) 2014 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/mathop.h> 00015 #include <math.h> 00016 #include <stdio.h> 00017 00018 int 00019 main (int argc VL_UNUSED, char** argv VL_UNUSED) 00020 { 00021 vl_index i ; 00022 for (i = 0 ; i < 0xff ; ++i) { 00023 vl_uint8 x = (vl_uint8)i ; 00024 vl_uint8 r = vl_fast_sqrt_ui8(x) ; 00025 vl_uint8 r_ = (vl_uint8) floor(sqrt((double)x)) ; 00026 if (r != r_) abort() ; 00027 /* printf("sqrt(%5d) = %5d -- %5d\n", i, r, r_) ; */ 00028 } 00029 00030 for (i = 0 ; i < 0xffffffff ; ++i) { 00031 vl_uint16 x = (vl_uint16)i ; 00032 vl_uint16 r = vl_fast_sqrt_ui16(x) ; 00033 vl_uint16 r_ = (vl_uint8) floor(sqrt((double)x)) ; 00034 if (r != r_) abort() ; 00035 /* printf("sqrt(%5d) = %5d -- %5d\n", i, r, r_) ; */ 00036 } 00037 00038 return 0 ; 00039 }