using complex number

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

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?

0 Likes
1 Solution
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

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.

View solution in original post

0 Likes
5 Replies
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

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.

0 Likes
Anonymous
Not applicable

  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.

0 Likes
lock attach
Attachments are accessible only for community members.
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

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

   

typing ?

   

 

   

 

   

Regards, Dana.

Anonymous
Not applicable

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.

0 Likes