5 Replies Latest reply on Nov 5, 2012 12:36 PM by user_95857601

    using complex number

    user_95857601

      Hello,

         

      I want use the Psoc5 in a new design. In this design I want use complex number. Is it possible in psoc creator 2.1?

        • 1. Re: using complex number
          user_14586677

          Yes, any processor can handle a complex number, but you might

             

          have to keep track of the real and imaginary components, depending

             

          on what you are doing. Also the available GNU library has transcendental

             

          functions if you want to work in complex polar. But again, you have to do the

             

          simple math coding. Example., you want RMS of complex power, that is

             

          very straighforward knowing the Re and Im parts of the number.

             

           

             

          In fact you could easily write macros to implement your own specific

             

          library of complex number calculations.

             

           

             

          Regards. Dana.

          • 3. Re: using complex number
            user_95857601

              Thank danaaknight for your answer
              I know that I can make my library for complex (it not complex !!!).
              But I want use the C99 library.
              For the compiler I add the command line "-std=gnu99"
              When I write
               #include "complex.h"
               the gcc compiler from PSoC Creator 2.1  give an error : 
                .\main.c:14: fatal error: complex.h: No such file or directory
                
                the other include are Ok  .
                
                
                 ....
            25 :        _Complex float a=1.3+2.5i;    
            26 :        sprintf(strtmp, "a = %g + %gi\n", creal(a), cimag(a));
                ...

               
                This small  program is working but with warning because compiler dont know "complex.h"  and the linker is Ok
            .\main.c:26: warning: implicit declaration of function 'creal'
            .\main.c:26: warning: incompatible implicit declaration of built-in function 'creal'
            .\main.c:26: warning: implicit declaration of function 'cimag'
            .\main.c:26: warning: incompatible implicit declaration of built-in function 'cimag'

               


             My question is why it dont find complex.h  . I see it in the folder :
               C:\Program Files\Cypress\PSoC Creator\2.1\PSoC Creator\import\gnu_cs\arm\4.4.1\arm-none-eabi\include\c++\4.4.1
                
              ( May be it's working only with a Cpp file not in C file?)
             

               

             

               

            Thank for your answers and may be a working example in PSoC creator.

            • 4. Re: using complex number
              user_14586677

              You are meeting the rules of file location per the attached for your

                 

              typing ?

                 

               

                 

               

                 

              Regards, Dana.

              1 of 1 people found this helpful
              • 5. Re: using complex number
                user_95857601

                I think that I can't use <complex.h> in  C program but only in Cpp program, but PSoC creator don't support Cpp program.

                   

                Can you confirm or have you a simple example with <complex.h> use ?

                   

                Thank for you very good job for the support.

                   

                Best regards

                   

                Jack.