Example #1
0
int32_t main(void) 
{ 
	uint32_t i;			 /* Loop counter */ 
	float32_t diff;		 /* Difference between reference and test outputs */ 
 
	/* Multiplication of two input buffers */ 
	arm_mult_f32(srcA_buf_f32, srcB_buf_f32, multOutput, MAX_BLOCKSIZE); 
	 
	/* Accumulate the multiplication output values to  
	   get the dot product of the two inputs */ 
	for(i=0; i< MAX_BLOCKSIZE; i++) 
    {          
		arm_add_f32(&testOutput, &multOutput[i], &testOutput, 1);	 
    } 
 
	/* absolute value of difference between ref and test */ 
	diff = fabsf(refDotProdOut - testOutput); 
	 
	/* Comparison of dot product value with reference */ 
	if(diff > DELTA) 
	{ 
		status = ARM_MATH_TEST_FAILURE; 
	} 
		 
	if( status == ARM_MATH_TEST_FAILURE) 
	{ 
	  while(1); 
	} 
} 
int32_t main(void) 
{ 
	float32_t diff; 
	uint32_t i; 
 
	for(i=0; i< blockSize; i++) 
    { 
        cosOutput = arm_cos_f32(testInput_f32[i]); 
		sinOutput = arm_sin_f32(testInput_f32[i]); 
 
		arm_mult_f32(&cosOutput, &cosOutput, &cosSquareOutput, 1); 
		arm_mult_f32(&sinOutput, &sinOutput, &sinSquareOutput, 1); 
 
		arm_add_f32(&cosSquareOutput, &sinSquareOutput, &testOutput, 1);
 
		/* absolute value of difference between ref and test */ 
	    diff = fabsf(testRefOutput_f32 - testOutput); 
	 
	    /* Comparison of sin_cos value with reference */ 
	    if(diff > DELTA) 
	    { 
		   status = ARM_MATH_TEST_FAILURE; 
	    } 
		 
	    if( status == ARM_MATH_TEST_FAILURE) 
	    { 
	       while(1); 
	    } 
 
    } 

    while(1);                             /* main function does not return */
} 
Example #3
0
void vector_add(const vec_3d *a, const vec_3d *b, vec_3d *out)
{
#ifdef LIBQUAT_ARM
  arm_add_f32((float*) a, (float*) b, (float*) out);
#else
  out->x = a->x + b->x;
  out->y = a->y + b->y;
  out->z = a->z + b->z;
#endif
}
Example #4
0
void FloatArray::add(FloatArray operand2, FloatArray destination){ //allows in-place
  ASSERT(operand2.size == size &&  destination.size==size, "Arrays must be same size");
/// @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
  /* despite not explicitely documented in the CMSIS documentation,
      this has been tested to behave properly even when pSrcA==pDst
      void 	arm_add_f32 (float32_t *pSrcA, float32_t *pSrcB, float32_t *pDst, uint32_t blockSize)
  */
  arm_add_f32(data, operand2.data, destination.data, size);
#else
  for(int n=0; n<size; n++){
    destination[n]=data[n]+operand2[n];
  }
#endif /* ARM_CORTEX */
}
int32_t main(void) 
{ 
   float32_t diff; 
   uint32_t i; 

   printf("Starting Test...\n");
   for (i=0; i < blockSize; i++) 
   { 
      cosOutput = arm_cos_f32(testInput_f32[i]); 
      printf("Cos %f = %f\n", testInput_f32[i], cosOutput);
 
      sinOutput = arm_sin_f32(testInput_f32[i]); 
      printf("Sin %f = %f\n", testInput_f32[i], sinOutput);

      arm_mult_f32(&cosOutput, &cosOutput, &cosSquareOutput, 1); 
      printf("Cos squared %f = %f\n", cosOutput, cosSquareOutput);

      arm_mult_f32(&sinOutput, &sinOutput, &sinSquareOutput, 1); 
      printf("Sin squared %f = %f\n", sinOutput, sinSquareOutput);

      arm_add_f32(&cosSquareOutput, &sinSquareOutput, &testOutput, 1);
      printf("Add %f and %f = %f\n", cosSquareOutput, sinSquareOutput, testOutput);
 
      /* absolute value of difference between ref and test */ 
      diff = fabsf(testRefOutput_f32 - testOutput); 
      /* Comparison of sin_cos value with reference */ 
      if (diff > DELTA) 
      { 
         printf("Diff failure %f\n", diff);
         exit(EXIT_FAILURE); /* just for QEMU testing */
         while(1); 
      } 
   } 
   printf("Ending Test...\n");
   exit(EXIT_SUCCESS); /* just for QEMU testing */
   while(1); /* main function does not return */
}