Am a beginner in C programme.
How do I define two vectors of complex
numbers with random valuee of size N.
appling this code
complexvector=(complex) malloc(sizeof(complex)*N)
Am a beginner in C programme.
How do I define two vectors of complex
numbers with random valuee of size N.
appling this code
complexvector=(complex) malloc(sizeof(complex)*N)
A complex number is expressed as a number with 2 parts, the real part, and the imaginary part. Usually both are notated as either floats or doubles. This means that the complex number is a structure, and your allocation is actually more or less correct in that you need to multiply the size of the complex structure by the number of elements in order to get the appropriate array allocated. Hoever, do remember if you are using a 64-bit architecture, and noting that floats are 32-bit values, your allocated space will be twice the size that you expect, in that each element will be 128 bits, not 64 as expected (due to padding required for word alignment in the structure).