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.
Hi,
I am working on a project that uses an array of complex floating point numbers. My C code works fine in other C compilers, but gives me " could not open source file "complex.h" in main.c" error, when I build it in ccs.
Can you please refer me to some material/links that can help me implement complex values in ccsv5?
Thank you for your help and time.
Thanks!
Hi, Ashley.
Ashley said:My C code works fine in other C compilers, but gives me " could not open source file "complex.h" in main.c" error, when I build it in ccs.
at first maybe this link will be useful for you http://processors.wiki.ti.com/index.php/Include_paths_and_options.
Regards,
Igor
Only recent releases of TI compilers support complex.h. Which compiler are you using, and what version? Note the compiler version is different from the CCS version.
Thanks and regards,
-George
Hi Rajasekaran,
Thank you for your reply. Please review the attached C - code at your earliest convenience.
Thank you for your time and I really appreciate your help.
#include <stdio.h> #include <math.h> #include <complex.h> #define SIZE 12 void CircularShift(double complex p[SIZE]); void Print(double complex p[SIZE]); /*-------------------------------------------------------------- Difference between float and double: The maximum value of float is only about 3e38, but double is about 1.7e308, so using float can hit Infinity much easier than double for something simple e.g. computing 60!. ----------------------------------------------------------------*/ int main() { double tau_rms=991e-9; double delta_f = 15e3; //pilot spacing double Tsym=71.7e-6; double fc=2.4e9; double c=3e8; double v = 10.0; //kmp double fd=(v/c)*fc; double pi = 3.142857143; int n,i,j; double Nzc=11.0; double complex primary_seq[SIZE]; double complex p[SIZE]; double complex rs_0[SIZE],rs_1[SIZE],rs_2[SIZE]; double complex pilot_f[3*SIZE]; printf("\n-----------------------------------------------------------\n"); printf("\n Primary sequence is:"); for (n =1; n <=SIZE; n++) { if (n<=SIZE-1) { primary_seq[n] = cos(pi*n*(n-1)/Nzc) - I*sin(pi*n*(n-1)/Nzc); printf("\n primary_seq[%d]: %.15g %+.15gi\n",n,creal(primary_seq[n]),cimag(primary_seq[n])); } else { primary_seq[SIZE] = primary_seq[1]; printf("\n primary_seq[%d]: %.15g %+.15gi\n",n,creal(primary_seq[n]),cimag(primary_seq[n])); } } //Print(primary_seq); - Cannot use this because array starts from 1 printf("\n-----------------------------------------------------------\n"); printf("\n p array is:"); for ( n=0; n<=SIZE-1; n++) { p[n] = primary_seq[n+1]; } Print(p); //Saving the Derived sequence in a temp array printf("\n-----------------------------------------------------------\n"); printf("\nGeneration of reference signals (frequency domain)\n"); printf("\n rs_0 array:"); for ( n=0; n<=SIZE-1; n++) { rs_0[n] = p[n]; } for (j=0;j<=1;j++) { CircularShift(rs_0); } Print(rs_0); printf("\n-----------------------------------------------------------\n"); printf("\n rs_1 array:"); for ( n=0; n<=SIZE-1; n++) { rs_1[n] = p[n]; } for (j=0;j<=2;j++) { CircularShift(rs_1); } Print(rs_1); printf("\n-----------------------------------------------------------\n"); printf("\n rs_2 array:"); for ( n=0; n<=SIZE-1; n++) { rs_2[n] = p[n]; } for (j=0;j<=3;j++) { CircularShift(rs_2); } Print(rs_2); getchar(); return 0; } void CircularShift(double complex p[SIZE]) { double complex temp; temp=p[SIZE-1];//put the last element in the temp variable int i; for(i=SIZE-1;i>0;i--)//shift each value to the next value so that a hole can be created in the beginning p[i]=p[i-1];//shift the values,index 0 is not changed because faida nahi hai p[0]=temp; } void Print(double complex p[SIZE]) { int i; for(i=0;i<SIZE;i++) printf("\n p[%d]: %.15g %+.15gi\n",i,creal(p[i]),cimag(p[i])); }
Hi Igor,
Thank you for your reply. I looked in to the mentioned link earlier, but I am unable to find any files for "complex numbers", that can be included in the path. But, I will go through the link once again to make sure that I am doing it correct.
Thanks for your help once again!
Hi George,
Thank you for your response. I am using C6000 Compiler Tools and 7.3.4 version (I am currently working on TMS320C6678). I am also attaching a screen shot of the window, from which I got the compiler info.
If the above details are not exactly what you are looking for, I would appreciate if you can guide me to provide you with the correct information.
Thanks!
The C6000 compiler introduces support for complex.h in release 7.4.0. You need to upgrade your compiler. You may as well update to the latest 7.4.x release, which is currently 7.4.6. Please see this wiki article to see how to upgrade.
Thanks and regards,
-George
Hello!
As soon as we work with DSPs, getting result is rarely the goal. Instead, we want the result in time, often real-time. Complex data types from complex.h is what may slow down your app. Please refer to http://e2e.ti.com/support/dsp/c6000_multi-core_dsps/f/639/t/273221.aspx. Luckily, __float2_t container and rich set of intrinsics to handle it make life much better.
Hi George,
Thank you very much for your advice. I was able to upgrade the C6000 code generation tool (cgt) to 7.4.6 version. I had some creating output sections errors and memory range overlap existing errors. But, I was able to fix them with the help of other threads on the TI forum. Now I am getting the expected output. Thanks alot!
Hi rrlagic,
Thank you for your response. Yes, its very true that we need the outputs on time in Real time systems. I am a newbie and currently trying to use the available complex.h file in ccs.
I am also looking at the "complex types" link you have provided and will try to implement my code efficiently.
Thank you very much for your guidance.