Complex matrix

Apr 7, 2011 at 2:04am
I have a exercise, i can't do it.Please help me:
"Multiply 2 complex matrix"
Thank alot!
Apr 7, 2011 at 2:29am
...Where is your code?
Apr 7, 2011 at 3:45am
i haven't had any ideas yet.
can you give me a idea?Please
Thank alot
Apr 7, 2011 at 4:08am
What is justified as a complex matrix?
Apr 7, 2011 at 5:29am
closed account (D80DSL3A)
IDEA: First step. Create the 2 matrices. Can you do this part?
I assume you want 2 dimensional arrays of complex numbers.

There is a complex number library available.
to use it #include<complex> in your program. It is in the namespace std.
Here's a link to the reference section on the library: http://www.cplusplus.com/reference/std/complex/
Here's a link to this sites tutorial on arrays: http://www.cplusplus.com/doc/tutorial/arrays/
There is info about multidimensional arrays also in that tutorial.

Here is a sample program showing some basic uses of complex numbers
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <complex>
using namespace std;

int main()
{
	// declare 2 complex numbers. Assign values through a constructor
	complex<double> z1(1.0, 1.0), z2(1.0, -1.0);

	cout << "z1 = " << z1 << endl;// display a complex number.
	complex<double> z3 = z1*z2;// multiply two complex numbers
	cout << "z1*z2 = " << z3 << endl;// display the product

	// change the values of the components of a complex number
	z3.real(3.0);
	z3.imag(4.0);
	// find the magnitude and display it
	cout << "|z3| = " << abs(z3) << endl;

	cout << endl;
	return 0;
}

See if you can create the arrays then check back about multiplying them. I'll help you if you get that far.
Apr 7, 2011 at 8:23am
Thank "fun2code" very much.About complex class and array i understand, but to create a complex matrix is very difficult to me.
Please help me.
Apr 7, 2011 at 7:17pm
closed account (D80DSL3A)
Check out this thread for help with creating your arrays:
http://www.cplusplus.com/forum/general/40240/
Apr 7, 2011 at 9:00pm
What fun2code is dancing around: We will help you provided that you will give us something to help with. (almost) No one wants to do your homework for you. We will help take any code you have that is not working, or is lacking, and help finish it, but we won't give you a completed solution.
Apr 8, 2011 at 1:11am
ok.thank "fun2code and Intrexa" very much.i need only a idea to complete, and i don't want to have full code.
Please Help me if you can.
Thanks alot
Last edited on Apr 8, 2011 at 1:13am
Apr 8, 2011 at 1:17am
What exactly is the problem? You can't declare matrices, initialize matrices or multiply them?
Or is thinking of an application for multiplying 2 matrices?????
Be a bit more specific and we can help.
Apr 8, 2011 at 2:10am
This is a really strange idiot.
Last edited on Apr 8, 2011 at 2:11am
Apr 8, 2011 at 8:07am
ok.i am idiot.My english is very bad so i can't explain fluently.sorry.
How to enter a complex number in (a,bi) trong VS2008?
please help me
Apr 8, 2011 at 8:16am
This is a duplicate of http://www.cplusplus.com/forum/general/40164/

I was rather hoping that you'd realise that multiplying a matrix of double is the same algorithm as multiplying a matrix of int and by induction, multiplying a matirx of complex.

C++ templates allow you to write a general matrix then plug in the type.

So far you've not managed to get these two points, which are the answer to your question. Short of actually doing the assignment for you (which someone appears to have already done), I really don't know how else to help.
Apr 8, 2011 at 8:18am
Does this help?

1
2
3
	
// declare 2 complex numbers. Assign values through a constructor
complex<double> z1(1.0, 1.0), z2(1.0, -1.0);


(From fun2code above.)
Apr 8, 2011 at 8:22am
chucthanh Please do not do his homework.
Apr 8, 2011 at 4:01pm
thanks everyone, now i can do my homework by myself
Thank you very much!
Topic archived. No new replies allowed.