int32_t main() 
{ 
 
#ifndef  USE_STATIC_INIT 
 
  	arm_matrix_instance_f32 srcA; 
  	arm_matrix_instance_f32 srcB; 
  	arm_matrix_instance_f32 dstC;  
 
	/* Input and output matrices initializations */  
	arm_mat_init_f32(&srcA, numStudents, numSubjects, (float32_t *)testMarks_f32);  
	arm_mat_init_f32(&srcB, numSubjects, 1, (float32_t *)testUnity_f32);  
	arm_mat_init_f32(&dstC, numStudents, 1, testOutput);  
 
#else 
 
	/* Static Initializations of Input and output matrix sizes and array */ 
	arm_matrix_instance_f32 srcA = {NUMSTUDENTS, NUMSUBJECTS, (float32_t *)testMarks_f32}; 
	arm_matrix_instance_f32 srcB = {NUMSUBJECTS, 1, (float32_t *)testUnity_f32}; 
	arm_matrix_instance_f32 dstC = {NUMSTUDENTS, 1, testOutput}; 
 
#endif 
 
	 
	/* ---------------------------------------------------------------------- 
	*Call the Matrix multiplication process function   
	* ------------------------------------------------------------------- */ 
	arm_mat_mult_f32(&srcA, &srcB, &dstC); 
	 
	/* ---------------------------------------------------------------------- 
	** Call the Max function to calculate max marks among numStudents 
	** ------------------------------------------------------------------- */ 
	arm_max_f32(testOutput, numStudents, &max_marks, &student_num);  
 
	/* ---------------------------------------------------------------------- 
	** Call the Min function to calculate min marks among numStudents 
	** ------------------------------------------------------------------- */ 
	arm_min_f32(testOutput, numStudents, &min_marks, &student_num);  
 
	/* ---------------------------------------------------------------------- 
	** Call the Mean function to calculate mean 
	** ------------------------------------------------------------------- */ 
	arm_mean_f32(testOutput, numStudents, &mean); 
 
	/* ---------------------------------------------------------------------- 
	** Call the std function to calculate standard deviation 
	** ------------------------------------------------------------------- */ 
	arm_std_f32(testOutput, numStudents, &std); 
 
	/* ---------------------------------------------------------------------- 
	** Call the var function to calculate variance 
	** ------------------------------------------------------------------- */ 
	arm_var_f32(testOutput, numStudents, &var); 
 
    while(1);                             /* main function does not return */
} 
Пример #2
0
void FloatArray::getMin(float* value, int* index){
/// @note When built for ARM Cortex-M processor series, this method uses the optimized <a href="http://www.keil.com/pack/doc/CMSIS/General/html/index.html">CMSIS library</a>
#ifdef ARM_CORTEX
  unsigned long idx;
  arm_min_f32(data, size, value, &idx);
  *index = (int)idx;
#else
  *value=data[0];
  *index=0;
  for(int n=1; n<size; n++){
    float currentValue=data[n];
    if(currentValue<*value){
      *value=currentValue;
      *index=n;
    }
  }
#endif
}
int32_t main(void) 
{ 
  uint32_t i; 
  arm_status status; 
  uint32_t index; 
  float32_t minValue; 
 
  /* Initialize the LMSNorm data structure */ 
  arm_lms_norm_init_f32(&lmsNorm_instance, NUMTAPS, lmsNormCoeff_f32, lmsStateF32, MU, BLOCKSIZE); 
 
  /* Initialize the FIR data structure */ 
  arm_fir_init_f32(&LPF_instance, NUMTAPS, (float32_t *)FIRCoeff_f32, firStateF32, BLOCKSIZE); 
 
  /* ---------------------------------------------------------------------- 
  * Loop over the frames of data and execute each of the processing 
  * functions in the system. 
  * ------------------------------------------------------------------- */ 
 
  for(i=0; i < NUMFRAMES; i++)  
    { 
      /* Read the input data - uniformly distributed random noise - into wire1 */  
      arm_copy_f32(testInput_f32 + (i * BLOCKSIZE), wire1, BLOCKSIZE); 
 
      /* Execute the FIR processing function.  Input wire1 and output wire2 */  
      arm_fir_f32(&LPF_instance, wire1, wire2, BLOCKSIZE); 
       
      /* Execute the LMS Norm processing function*/  
 
      arm_lms_norm_f32(&lmsNorm_instance, /* LMSNorm instance */ 
		       wire1,                     /* Input signal */  
		       wire2,			          /* Reference Signal */ 
		       wire3, 			          /* Converged Signal */ 
		       err_signal, 		          /* Error Signal, this will become small as the signal converges */ 
		       BLOCKSIZE);		          /* BlockSize */ 
 
      /* apply overall gain */  
      arm_scale_f32(wire3, 5, wire3, BLOCKSIZE);	 /* in-place buffer */  
    } 
 
  status = ARM_MATH_SUCCESS; 
 
  /* ------------------------------------------------------------------------------- 
  * Test whether the error signal has reached towards 0. 
  * ----------------------------------------------------------------------------- */ 
 
  arm_abs_f32(err_signal, err_signal, BLOCKSIZE); 
  arm_min_f32(err_signal, BLOCKSIZE, &minValue, &index); 
 
  if (minValue > DELTA_ERROR) 
  { 
      status = ARM_MATH_TEST_FAILURE; 
  } 
 
  /* ---------------------------------------------------------------------- 
  * Test whether the filter coefficients have converged. 
  * ------------------------------------------------------------------- */ 
 
  arm_sub_f32((float32_t *)FIRCoeff_f32, lmsNormCoeff_f32, lmsNormCoeff_f32, NUMTAPS); 
 
  arm_abs_f32(lmsNormCoeff_f32, lmsNormCoeff_f32, NUMTAPS); 
  arm_min_f32(lmsNormCoeff_f32, NUMTAPS, &minValue, &index); 
 
  if (minValue > DELTA_COEFF) 
  { 
      status = ARM_MATH_TEST_FAILURE; 
  } 
 
  /* ---------------------------------------------------------------------- 
  * Loop here if the signals did not pass the convergence check. 
  * This denotes a test failure 
  * ------------------------------------------------------------------- */ 
 
  if( status != ARM_MATH_SUCCESS) 
  { 
      while(1); 
  } 
}