Questions tagged [complex.h]

8 questions
4
votes
1 answer

Tilde '~' operator on _Complex, what does it do? Is it an extension?

In C99, it looks like the '~' operator on a _Complex performs a complex conjugate. The following code: #include #include int main() { double _Complex a = 2 + 3 * I; printf("%f,%f\n", creal(~a), cimag(~a)); } Gives the…
Derek Ross
  • 75
  • 5
0
votes
2 answers

How to read imaginary data from text file, with C

I am unable to read imaginary data from text file. Here is my .txt file abc.txt 0.2e-3+0.3*I 0.1+0.1*I 0.3+0.1*I 0.1+0.4*I I want to read this data into a matrix and print it. I found the solutions using C++ here and here. I don't know how…
user19013072
0
votes
1 answer

Passing pointer to complex double in C (using complex.h)

I am trying to run a function, int testfn below, which should assign a complex number to the pointer (to a complex number), double _Complex *foo below, that it is fed. The minimal (non-working) example .c file is test.c below. When I call testfn…
calgopher
  • 23
  • 5
0
votes
0 answers

typedef for C complex type results in compilation error on IAR compiler, but works on GCC and ARMCC

I have some C code for an ARM-based microcontroller that already compiles with GCC and the ARM compiler. However, when compiling with IAR V8.42.1, there is a problem with the following typedef float _Complex f_complex; The error message is expected…
dandan78
  • 13,328
  • 13
  • 64
  • 78
0
votes
2 answers

How GCC understand complex arithmetics?

I am bit new to C language and I have a question in some basic principles about C. I'm on the way of implementing a custom complex library that deals with fixed point arithmetic. We can use a library called complex.h in C. using that library we can…
BMTC
  • 3
  • 2
0
votes
2 answers

In C, How can I compare Complex Numbers as with <, >, et cetera

I keep receiving this error message when compiling a simplified mandelbrot function. main.c:86:43: error: invalid operands to binary > (have ‘complex double’ and ‘complex float’) else if(f2r > 1000 || f2i > 1000 * I) { ........^ There are other…
0
votes
2 answers

How to read complex number using complex.h in C?

I want to read from a file two complex numbers (1.1,2) (1.7,3.14) In the beginning I do this struct Num { double Re; double Im; }; typedef struct Num zesp; zesp readZ(FILE *wp) { char c; zesp z; …
Jakub
  • 679
  • 5
  • 16
0
votes
0 answers

Why is this complex.h typedef not working?

I've been referencing published C++ code from MIT here. I'm trying to compile the code using the provided Makefile. Note I'm using Ubuntu version 20.04 and installed g++. From a previous question I posted here, the code seems to be tripping up over…
Izzo
  • 4,461
  • 13
  • 45
  • 82