Complex matrix

I have a exercise, i can't do it.Please help me:
"Multiply 2 complex matrix"
Thank alot!
...Where is your code?
i haven't had any ideas yet.
can you give me a idea?Please
Thank alot
What is justified as a complex matrix?
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.
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.
closed account (D80DSL3A)
Check out this thread for help with creating your arrays:
http://www.cplusplus.com/forum/general/40240/
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.
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
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.
This is a really strange idiot.
Last edited on
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
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.
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.)
chucthanh Please do not do his homework.
thanks everyone, now i can do my homework by myself
Thank you very much!
Topic archived. No new replies allowed.