This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

CMSIS arm_rms_q15 defect

Note: This was originally posted on 13th July 2012 at http://forums.arm.com

There is a bug in arm_rms_q15 that saturates the sum before dividing for the mean.

00107 /* Truncating and saturating the accumulator to 1.15 format */
00108 sum = __SSAT((q31_t) (sum >> 15), 16);
00109
00110 in1 = (q15_t) (sum / blockSize);
00111
00112 /* Store the result in the destination */
00113 arm_sqrt_q15(in1, pResult);

and
00136 /* Truncating and saturating the accumulator to 1.15 format */
00137 sum = __SSAT((q31_t) (sum >> 15), 16);
00138
00139 in = (q15_t) (sum / blockSize);
00140
00141 /* Store the result in the destination */
00142 arm_sqrt_q15(in, pResult);

should be changed to something like this:
    /* Truncating and saturating the accumulator to 1.15 format */
    in = (q31_t) (sum >> 15);

    in1 = __SSAT((in / blockSize), 16);

    /* Store the result in the destination */
    arm_sqrt_q15(in1, pResult);
Parents
  • Note: This was originally posted on 7th December 2012 at http://forums.arm.com

    Hi,

    I may be wrong but I'm still not satisfied with this fix. I ran this function with small values (1, 2, ... until 181 in q15 format) and got 0 rms. However it works for bigger values. Is this precision loss admitted? I'm investigating...
    I do not understand very well the need to truncate and saturate before dividing and sqrt.
    Please tell me if you see what's wrong.

    --
    Emilien
Reply
  • Note: This was originally posted on 7th December 2012 at http://forums.arm.com

    Hi,

    I may be wrong but I'm still not satisfied with this fix. I ran this function with small values (1, 2, ... until 181 in q15 format) and got 0 rms. However it works for bigger values. Is this precision loss admitted? I'm investigating...
    I do not understand very well the need to truncate and saturate before dividing and sqrt.
    Please tell me if you see what's wrong.

    --
    Emilien
Children
No data