This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Absolute value of a complex number

Other Parts Discussed in Thread: MATHLIB

Please suggest me how to calculate absolute value of a complex number in C66x dsp. Is there any function in DSP lib to do this?

  • Hi Ranjit,

    I will check with our experts and get back to you as soon as possible. Thank you for your patience.
  • Ranjit Kumar said:
    Please suggest me how to calculate absolute value of a complex number in C66x dsp. Is there any function in DSP lib to do this?


    For complex numbers, you can use "fabs() function in math.h. i.e., "double fabs (double x);"

    For more details, please refer to this example which uses the fabs().

    ~:\ti\dsplib_c66x_3_4_0_0\packages\ti\dsplib\src\DSPF_sp_cholesky_cmplx\c66\DSPF_sp_cholesky_cmplx_66_LE_ELF
  • fabs() is not for absolute value of complex number but absolute value of a floating point number which can be either real or imaginary. What i need is if x=a+b*i then abs(x)= sqrt(a^2+b^2) where a and b are fixed point 16 bit values
  • Hi,

    In my knowledge, there is c64x+ IQ math library in which there are functions to compute absolute value of a IQ number and other than this, we do not find functions directly which does the absolute value of complex number. May be, there are functions to compute square root and also magnitude square functions (Magnitude square: sqrt(A2 + B2))

    To download IQmath, please go to:

    http://focus.ti.com/docs/toolsw/folders/print/sprc542.html

    See Table 3-5 for the mathematical functions available from the c64x+ IQ math library user guide below:

    http://www.ti.com/lit/ug/sprugg9/sprugg9.pdf

    Also, check the below wiki for MATHLIB and IQMATHLIB:

    http://processors.wiki.ti.com/index.php/Software_libraries#MathLIB

    Thanks & regards,

    Sivaraj K

    ----------------------------------------------------------------------------------------------------------

    Please click the Verify Answer button on this post if it answers your question.

    ----------------------------------------------------------------------------------------------------------

  • I assume you are looking for square root function.
    finding a^2 + b^2 is easy and I will not get to it here unless you ask.

    To find square root of a number I like to use Newton Raphsom iteration method for 1/square root.
    If you need you can find tons of information about Newton Raphson on the Web. C66X has an intrinsic function
    that gives the 1/square seed for single precision and double precision.
    Look at RSQRSP and RSQRDP for single precision and double precision 8-bit accuracy seed intrinsic in the optimized compiler document.
    So if your value is fixed point convert it to floating point, and do 2 iterations for single precision (the first iteration takes you from
    8 bit accuracy to 16, and the second from 16 to 24- the number of mantissa bits for floating point single precision) ,
    or three iterations for double precision (8, 16, 32, and 48 bits)

    Do you need more information? I am sure you can figure the code out yourself

    Best Regards

    Ran