I have found that piece of code on blackfin533, which has fract32 which is from -1, 1, its in the format 1.31.
I can't get why the pre-shifting is required for calculating the amplitude of a complex number (re, img). I know if you want to multiply 1.31 by 1.31 fractional format then you need to shift right 31 bits.
GO_coil_D[0].re, and GO_coil_D[0].im are two fract32.
I can't get what the following code is doing :
norm[0] = norm_fr1x32(GO_coil_D[0].re);
norm[1] = norm_fr1x32(GO_coil_D[0].im);
shift = (norm[0] < norm[1]) ? (norm[0] - 1) : (norm[1] - 1);
vectorFundamentalStored.im = shl_fr1x32(GO_coil_D[0].im,shift);
vectorFundamentalStored.re = shl_fr1x32(GO_coil_D[0].re,shift);
vectorFundamentalStored.im = mult_fr1x32x32(vectorFundamentalStored.im, vectorFundamentalStored.im);
vectorFundamentalStored.re = mult_fr1x32x32(vectorFundamentalStored.re, vectorFundamentalStored.re);
amplitudeFundamentalStored = sqrt_fr16(round_fr1x32(add_fr1x32(vectorFundamentalStored.re,vectorFundamentalStored.im))) << 16;
amplitudeFundamentalStored = shr_fr1x32(amplitudeFundamentalStored,shift);
round_
fr1x32` (fract32 f1) fract16 Rounds the 32-bit fract to a 16-bit fract using biased rounding.
norm_fr1x32
norm_fr1x32 (fract32) int Returns the number of left shifts required to normalize the input variable so that it is either in the interval 0x40000000 to 0x7fffffff, or in the interval 0x80000000 to 0xc0000000. In other words, fract32 x; shl_fr1x32(x,norm_fr1x32(x)); returns a value in the range 0x40000000 to 0x7fffffff, or in the range 0x80000000 to 0xc0000000