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.

C6713b --- Cosine of 0.0 yields 0.0 ! Why???

Hi everyone,

My program for C6713b has not be working as expected.

After debugging, I finally found the cause to be that it yields 0.0 after computing cosine(0.0)! (when cos(0.0) should be 1.0!)

The program included the C6713 and C6713e libraries.

It compiled and runs without any complaint relating to this function.

Can anybody guess why this might be the case???

Any help would be greatly appreciated.

C. M.

  • CM,

    Can you elaborate what you mean by C6713 and C6713e libraries. The cosine function is part of the standard rts library part of C6000 compiler and the C67x fastMath library. Can you provide us a snippet of your code so that we can use to replicate this issue. You may also want to repost the query on the compiler forum to see if they can give you some pointers to resolve this issue.

    Regards,

    Rahul

  • Hi Rahul,

                Thanks for replying. I meant I’ve included the csl6713.lib, csl6713e.lib, and in fact the rts6700.lib has been included also. Here is a snippet of my program.

    void xform(misalignment m, matrix_ptr P)
    {
       int i, j;

       float theta_x = d_to_r * m[0];  // Convert angle in degree into radian
       float theta_y = d_to_r * m[1];
       float theta_z = d_to_r * m[2];
       float sin_theta_x = sin(theta_x);  // Compute sin(angle_x)
       float sin_theta_y = sin(theta_y);  // Compute sin(angle_y)
       float sin_theta_z = sin(theta_z);  // Compute sin(angle_z)
       float cos_theta_x = cos(theta_x);  // Compute cos(angle_x)
       float cos_theta_y = cos(theta_y);  // Compute cos(angle_y)
       float cos_theta_z = cos(theta_z);  // Compute cos(angle_z)

       matrix rx = {{1.,0.,0.},{0.,1.,0.},{0.,0.,1.}};
       matrix ry = {{1.,0.,0.},{0.,1.,0.},{0.,0.,1.}};
       matrix rz = {{1.,0.,0.},{0.,1.,0.},{0.,0.,1.}};
      
       matrix rotatetotal, xformtempmatrix;
       matrix_ptr result;

       rx[1][1] = cos_theta_x; rx[2][2] = cos_theta_x; // Compute Rx -- rotation matrix around x-axis
       rx[1][2] = -sin_theta_x; rx[2][1] = sin_theta_x;

     ......

    }

    The lines that don’t yield correct results are: 

       float cos_theta_x = cos(theta_x);             // Compute cos(angle_x)

       float cos_theta_y = cos(theta_y);             // Compute cos(angle_y)

       float cos_theta_z = cos(theta_z);             // Compute cos(angle_z)

     Can you see anything wrong?

     C.M.

  • Hi Everyone,

    I've fixed the problem. It turned out that I commented out the "include <math.h>" line.

    Once I removed the comment mark, the result is correct now.

    It's amazing why such error does not get picked up by the compiler, nor generate any error at run time!

    Anyway, thanks everyone!

    C.M.