1 #include "arm_vec_math.h" 2 3 #include "FastMathF64.h" 4 #include <stdio.h> 5 6 #include "Error.h" 7 #include "Test.h" 8 9 10 #define SNR_THRESHOLD 310 11 /* 12 13 Reference patterns are generated with 14 a double precision computation. 15 16 */ 17 #define REL_ERROR (2.0e-16) 18 #define ABS_ERROR (2.0e-16) 19 20 /* 21 void FastMathF64::test_cos_f64() 22 { 23 const float64_t *inp = input.ptr(); 24 float64_t *outp = output.ptr(); 25 unsigned long i; 26 27 for(i=0; i < ref.nbSamples(); i++) 28 { 29 outp[i]=arm_cos_f64(inp[i]); 30 } 31 32 ASSERT_SNR(ref,output,(float64_t)SNR_THRESHOLD); 33 ASSERT_CLOSE_ERROR(ref,output,ABS_ERROR,REL_ERROR); 34 35 } 36 37 void FastMathF64::test_sin_f64() 38 { 39 const float64_t *inp = input.ptr(); 40 float64_t *outp = output.ptr(); 41 unsigned long i; 42 43 for(i=0; i < ref.nbSamples(); i++) 44 { 45 outp[i]=arm_sin_f64(inp[i]); 46 } 47 48 ASSERT_SNR(ref,output,(float64_t)SNR_THRESHOLD); 49 ASSERT_CLOSE_ERROR(ref,output,ABS_ERROR,REL_ERROR); 50 51 } 52 53 void FastMathF64::test_sqrt_f64() 54 { 55 const float64_t *inp = input.ptr(); 56 float64_t *outp = output.ptr(); 57 arm_status status; 58 unsigned long i; 59 60 for(i=0; i < ref.nbSamples(); i++) 61 { 62 status=arm_sqrt_f64(inp[i],&outp[i]); 63 ASSERT_TRUE((status == ARM_MATH_SUCCESS) || ((inp[i] < 0.0f) && (status == ARM_MATH_ARGUMENT_ERROR))); 64 } 65 66 67 ASSERT_SNR(ref,output,(float64_t)SNR_THRESHOLD); 68 ASSERT_CLOSE_ERROR(ref,output,ABS_ERROR,REL_ERROR); 69 70 71 } 72 73 */ test_vlog_f64()74 void FastMathF64::test_vlog_f64() 75 { 76 const float64_t *inp = input.ptr(); 77 float64_t *outp = output.ptr(); 78 79 arm_vlog_f64(inp,outp,ref.nbSamples()); 80 81 ASSERT_SNR(ref,output,(float64_t)SNR_THRESHOLD); 82 ASSERT_CLOSE_ERROR(ref,output,ABS_ERROR,REL_ERROR); 83 ASSERT_EMPTY_TAIL(output); 84 85 } 86 test_vexp_f64()87 void FastMathF64::test_vexp_f64() 88 { 89 const float64_t *inp = input.ptr(); 90 float64_t *outp = output.ptr(); 91 92 arm_vexp_f64(inp,outp,ref.nbSamples()); 93 94 ASSERT_SNR(ref,output,(float64_t)SNR_THRESHOLD); 95 ASSERT_CLOSE_ERROR(ref,output,ABS_ERROR,REL_ERROR); 96 ASSERT_EMPTY_TAIL(output); 97 98 } 99 100 setUp(Testing::testID_t id,std::vector<Testing::param_t> & paramsArgs,Client::PatternMgr * mgr)101 void FastMathF64::setUp(Testing::testID_t id,std::vector<Testing::param_t>& paramsArgs,Client::PatternMgr *mgr) 102 { 103 (void)paramsArgs; 104 switch(id) 105 { 106 case FastMathF64::TEST_COS_F64_1: 107 { 108 input.reload(FastMathF64::ANGLES1_F64_ID,mgr); 109 ref.reload(FastMathF64::COS1_F64_ID,mgr); 110 output.create(ref.nbSamples(),FastMathF64::OUT_F64_ID,mgr); 111 112 } 113 break; 114 115 case FastMathF64::TEST_SIN_F64_2: 116 { 117 input.reload(FastMathF64::ANGLES1_F64_ID,mgr); 118 ref.reload(FastMathF64::SIN1_F64_ID,mgr); 119 output.create(ref.nbSamples(),FastMathF64::OUT_F64_ID,mgr); 120 121 } 122 break; 123 124 case FastMathF64::TEST_SQRT_F64_3: 125 { 126 input.reload(FastMathF64::SQRTINPUT1_F64_ID,mgr); 127 ref.reload(FastMathF64::SQRT1_F64_ID,mgr); 128 output.create(ref.nbSamples(),FastMathF64::OUT_F64_ID,mgr); 129 130 } 131 break; 132 133 case FastMathF64::TEST_VLOG_F64_4: 134 { 135 input.reload(FastMathF64::LOGINPUT1_F64_ID,mgr); 136 ref.reload(FastMathF64::LOG1_F64_ID,mgr); 137 output.create(ref.nbSamples(),FastMathF64::OUT_F64_ID,mgr); 138 139 } 140 break; 141 142 case FastMathF64::TEST_VLOG_F64_5: 143 { 144 /* 145 If only one sample was taken here, the SNR 146 computation would give 0 / 0 because the 147 first value (1.0) has a log of 0. 148 149 */ 150 input.reload(FastMathF64::LOGINPUT1_F64_ID,mgr,2); 151 ref.reload(FastMathF64::LOG1_F64_ID,mgr,2); 152 output.create(ref.nbSamples(),FastMathF64::OUT_F64_ID,mgr); 153 154 } 155 break; 156 157 case FastMathF64::TEST_VLOG_F64_6: 158 { 159 input.reload(FastMathF64::LOGINPUT1_F64_ID,mgr,4); 160 ref.reload(FastMathF64::LOG1_F64_ID,mgr,4); 161 output.create(ref.nbSamples(),FastMathF64::OUT_F64_ID,mgr); 162 163 } 164 break; 165 166 case FastMathF64::TEST_VLOG_F64_7: 167 { 168 input.reload(FastMathF64::LOGINPUT1_F64_ID,mgr,5); 169 ref.reload(FastMathF64::LOG1_F64_ID,mgr,5); 170 output.create(ref.nbSamples(),FastMathF64::OUT_F64_ID,mgr); 171 172 } 173 break; 174 175 case FastMathF64::TEST_VEXP_F64_8: 176 { 177 input.reload(FastMathF64::EXPINPUT1_F64_ID,mgr); 178 ref.reload(FastMathF64::EXP1_F64_ID,mgr); 179 output.create(ref.nbSamples(),FastMathF64::OUT_F64_ID,mgr); 180 181 } 182 break; 183 184 case FastMathF64::TEST_VEXP_F64_9: 185 { 186 input.reload(FastMathF64::EXPINPUT1_F64_ID,mgr,2); 187 ref.reload(FastMathF64::EXP1_F64_ID,mgr,2); 188 output.create(ref.nbSamples(),FastMathF64::OUT_F64_ID,mgr); 189 190 } 191 break; 192 193 case FastMathF64::TEST_VEXP_F64_10: 194 { 195 input.reload(FastMathF64::EXPINPUT1_F64_ID,mgr,4); 196 ref.reload(FastMathF64::EXP1_F64_ID,mgr,4); 197 output.create(ref.nbSamples(),FastMathF64::OUT_F64_ID,mgr); 198 199 } 200 break; 201 202 case FastMathF64::TEST_VEXP_F64_11: 203 { 204 input.reload(FastMathF64::EXPINPUT1_F64_ID,mgr,5); 205 ref.reload(FastMathF64::EXP1_F64_ID,mgr,5); 206 output.create(ref.nbSamples(),FastMathF64::OUT_F64_ID,mgr); 207 208 } 209 break; 210 } 211 212 } 213 tearDown(Testing::testID_t id,Client::PatternMgr * mgr)214 void FastMathF64::tearDown(Testing::testID_t id,Client::PatternMgr *mgr) 215 { 216 (void)id; 217 output.dump(mgr); 218 219 } 220