• AVR Freaks

Hot!Complex numbers

Author
Evgeny
Senior Member
  • Total Posts : 138
  • Reward points : 0
  • Joined: 2003/11/07 12:39:19
  • Location: Toronto, Canada
  • Status: offline
2011/10/23 15:12:56 (permalink)
0

Complex numbers

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
#1

10 Replies Related Threads

    Evgeny
    Senior Member
    • Total Posts : 138
    • Reward points : 0
    • Joined: 2003/11/07 12:39:19
    • Location: Toronto, Canada
    • Status: offline
    Re:Complex numbers 2011/11/08 11:45:01 (permalink)
    0
    I have to rephrase my question:

    Does C32 support Complex Number arithmetic?

    #2
    NKurzman
    A Guy on the Net
    • Total Posts : 18976
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re:Complex numbers 2011/11/08 14:51:57 (permalink)
    0
    The silence may be your answer. 
    Or put in a support ticket and ask Microchip.
    #3
    Evgeny
    Senior Member
    • Total Posts : 138
    • Reward points : 0
    • Joined: 2003/11/07 12:39:19
    • Location: Toronto, Canada
    • Status: offline
    Re:Complex numbers 2011/11/09 11:58:53 (permalink)
    0
    I did submit a ticket to Technical Support.
    They also silent so far...
    #4
    Evgeny
    Senior Member
    • Total Posts : 138
    • Reward points : 0
    • Joined: 2003/11/07 12:39:19
    • Location: Toronto, Canada
    • Status: offline
    Re:Complex numbers 2011/11/11 19:46:38 (permalink)
    0
    OK, it is clear now that MPLAB C32 does NOT support complex data types.
    Have to explore other resources.
    #5
    DarioG
    Allmächtig.
    • Total Posts : 54081
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: Oesterreich
    • Status: offline
    Re:Complex numbers 2011/11/12 04:01:25 (permalink)
    0
    It wuold be an easy C++ class, or a struct in C with helper functions...

    GENOVA :D :D ! GODO
    #6
    Evgeny
    Senior Member
    • Total Posts : 138
    • Reward points : 0
    • Joined: 2003/11/07 12:39:19
    • Location: Toronto, Canada
    • Status: offline
    Re:Complex numbers 2011/12/06 08:04:16 (permalink)
    0

    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.
    #7
    charlyduru
    New Member
    • Total Posts : 2
    • Reward points : 0
    • Joined: 2019/04/01 20:54:23
    • Location: 0
    • Status: offline
    Re:Complex numbers 2020/09/05 14:08:19 (permalink)
    0
    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
    post edited by charlyduru - 2020/09/05 14:09:26
    #8
    ric
    Super Member
    • Total Posts : 28671
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re:Complex numbers 2020/09/05 16:07:34 (permalink)
    0
    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.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #9
    vexorg
    Senior Member
    • Total Posts : 156
    • Reward points : 0
    • Joined: 2019/09/27 10:59:40
    • Location: 0
    • Status: offline
    Re:Complex numbers 2020/09/06 04:08:20 (permalink)
    +1 (1)
    Not exactly difficult to have your own complex functions and structures in a small module.
    #10
    crosland
    Super Member
    • Total Posts : 2057
    • Reward points : 0
    • Joined: 2005/05/10 10:55:05
    • Location: Warks, UK
    • Status: offline
    Re:Complex numbers 2020/09/06 09:34:26 (permalink)
    +1 (1)
    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.
    #11
    Jump to:
    © 2020 APG vNext Commercial Version 4.5