00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00071 #include <math.h>
00072 #include "arm_math.h"
00073
00074
00075
00076
00077 #define MAX_BLOCKSIZE 32
00078 #define DELTA (0.000001f)
00079
00080
00081
00082
00083
00084 float32_t wire1[MAX_BLOCKSIZE];
00085 float32_t wire2[MAX_BLOCKSIZE];
00086 float32_t wire3[MAX_BLOCKSIZE];
00087
00088
00089
00090
00091
00092
00093 float32_t testInput_f32[32] =
00094 {
00095 -0.432564811528221, -1.665584378238097, 0.125332306474831, 0.287676420358549,
00096 -1.146471350681464, 1.190915465642999, 1.189164201652103, -0.037633276593318,
00097 0.327292361408654, 0.174639142820925, -0.186708577681439, 0.725790548293303,
00098 -0.588316543014189, 2.183185818197101, -0.136395883086596, 0.113931313520810,
00099 1.066768211359189, 0.059281460523605, -0.095648405483669, -0.832349463650022,
00100 0.294410816392640, -1.336181857937804, 0.714324551818952, 1.623562064446271,
00101 -0.691775701702287, 0.857996672828263, 1.254001421602532, -1.593729576447477,
00102 -1.440964431901020, 0.571147623658178, -0.399885577715363, 0.689997375464345
00103
00104 };
00105
00106
00107
00108
00109 uint32_t blockSize = 32;
00110 float32_t refVarianceOut = 0.903941793931839;
00111
00112
00113
00114
00115
00116 int32_t main(void)
00117 {
00118 arm_status status;
00119 float32_t mean, oneByBlockSize;
00120 float32_t variance;
00121 float32_t diff;
00122
00123 status = ARM_MATH_SUCCESS;
00124
00125
00126
00127
00128
00129
00130 arm_fill_f32(1.0, wire1, blockSize);
00131
00132
00133
00134 arm_dot_prod_f32(testInput_f32, wire1, blockSize, &mean);
00135
00136
00137 oneByBlockSize = 1.0 / (blockSize);
00138
00139
00140 arm_mult_f32(&mean, &oneByBlockSize, &mean, 1);
00141
00142
00143
00144
00145
00146
00147
00148 arm_fill_f32(mean, wire2, blockSize);
00149
00150
00151 arm_sub_f32(testInput_f32, wire2, wire3, blockSize);
00152
00153
00154 arm_copy_f32(wire3, wire2, blockSize);
00155
00156
00157 arm_dot_prod_f32(wire2, wire3, blockSize, &variance);
00158
00159
00160 oneByBlockSize = 1.0 / (blockSize - 1);
00161
00162
00163 arm_mult_f32(&variance, &oneByBlockSize, &variance, 1);
00164
00165
00166 diff = fabsf(refVarianceOut - variance);
00167
00168
00169 if(diff > DELTA)
00170 {
00171 status = ARM_MATH_TEST_FAILURE;
00172 }
00173
00174 if( status != ARM_MATH_SUCCESS)
00175 {
00176 while(1);
00177 }
00178 }
00179