# Complex structure question

Page 1 of 1

## 2 Replies - 313 Views - Last Post: 17 July 2012 - 11:25 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=286058&amp;s=429ad236cf242d648da02adb348a16de&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 erkant

Reputation: 2
• Posts: 108
• Joined: 26-October 10

# Complex structure question

Posted 17 July 2012 - 06:29 AM

I have a question regarding the Complex structure that I have created, below is a short code and my question:

```typedef struct {
int real, img;
} Complex;

Complex matrix[2][3] = {{9511 + 31356j, 12539 + 30273j, -32610 - 3211j},
{32767, -32768j, 6392 - 32138j}};

```

So this is a small example. In my real code I have 64x64 matrix, for which I have all the values, I will just need to copy and paste them from a file. The point is that the numbers are like in the above example. That said, imaginary parts end with 'j', some numbers have only real part, and some just imaginary part, and of course some both the real and imaginary parts. Therefore, I want to ask if I enter the values to my Complex matrix like in the above example, will everything be okay? I mean it will know which part is imaginary, which part real? And what will happen when the numbers don't have either their real or imaginary parts?

This post has been edited by erkant: 17 July 2012 - 06:29 AM

Is This A Good Question/Topic? 0

## Replies To: Complex structure question

### #2 baavgai

• Dreaming Coder

Reputation: 6608
• Posts: 13,948
• Joined: 16-October 07

## Re: Complex structure question

Posted 17 July 2012 - 06:41 AM

First off, j is meaingless to your code. Just having something like 31356j isn't going to work.

Given your struct, you'd declare your matrix like so:
```Complex matrix[2][3] = {
{ {9511, 31356}, {12539, 30273}, {-32610 , -3211} },
{ {32767, 0}, {0, -32768}, {6392, 32138} },
};

```

### #3 erkant

Reputation: 2
• Posts: 108
• Joined: 26-October 10

## Re: Complex structure question

Posted 17 July 2012 - 11:25 AM

Thanks baavgai!