2011/10/23 15:12:56
Evgeny
Do appreciate of someone couild advice how to handle Complex numbers in C32.
 
In C30 where I declared them like this:
__complex__ float Zo = 50.0+0.0I;
 
It looks like it has to be done differently in C32.
 
Evgeny
2011/11/08 11:45:01
Evgeny
I have to rephrase my question:

Does C32 support Complex Number arithmetic?

2011/11/08 14:51:57
NKurzman
The silence may be your answer. 
Or put in a support ticket and ask Microchip.
2011/11/09 11:58:53
Evgeny
I did submit a ticket to Technical Support.
They also silent so far...
2011/11/11 19:46:38
Evgeny
OK, it is clear now that MPLAB C32 does NOT support complex data types.
Have to explore other resources.
2011/11/12 04:01:25
DarioG
It wuold be an easy C++ class, or a struct in C with helper functions...
2011/12/06 08:04:16
Evgeny

Hello All, 
After weeks of waiting I received a nice response from Technical support.
This is a way the Complex numbers handled by C32:



#include <stdio.h>
#include "p32xxxx.h"

#define COMPLEX _Complex

int main(argc, argv)
int argc;
char *argv[];
{
    COMPLEX double z1, z2, z3, z4;
    double creal(), cimag();
    
    __C32_UART = 1;
    
    z1 = 1 + 1i;
    z2 = 1 - 1i;
    z3 = z1*z2;
    z4 = z3/z1;

    printf("%g + %gi\n", creal(z4), cimag(z4));
      
    return 0;
}

//----------------------------------------------------------------


This program demonstrates the use of complex numbers, as per the GNU C C30 manuals, and it works correctly on both C30 and C32. You can use either the __complex__ or _Complex keywords, both work the same.

The creal() and cimag() functions are normally defined in the C99 complex.h header file. Neither C30 nor C32 instalations include this header file, but declaring them manually in the program works.
2020/09/05 14:08:19
charlyduru
Hey @ever , your complex number code description doesn't seems to compile i am running a XC32 compiler. please any further clarification will be appreciated. Any special headers to add? it basically doesn't understand the data definitions of the
''double complex".
 
Thanks,
Charles
2020/09/05 16:07:34
ric
charlyduru
Hey @ever , your complex number code description doesn't seems to compile i am running a XC32 compiler.

He stated several times that he is using C32, and specifically mentions how XC32 is different.
 
He does specifically mention a header file called "complex.h" used with XC32.
 
2020/09/06 09:34:26
crosland
charlyduru
Hey @ever , your complex number code description doesn't seems to compile


That was 9 (NINE) years ago and he hasn't posted for 6 (SIX) years.
12
© 2021 APG vNext Commercial Version 4.5

Use My Existing Forum Account