Click to See Complete Forum and Search --> : Complex Matrix Multiplication


vioravis
March 20th, 2007, 01:08 AM
I am trying to write a function for matrix multiplication when the two matrices are of type complex.



void MatMultMatCmpx(int q,cmplx **M1, int r,cmplx **M2, int s, cmplx **M)
{
int i,j,k;

for (i=0;i<q;i++)
for (j=0;j<s;j++) {
M[i][j] = 0.0;
for (k=0;k<r;k++)
{
M[i][j] += M1[i][k] * M2[k][j];
}
}
}



I am getting the following errors:

error C2061: syntax error : identifier 'cmplx' matrix.h(125) : error C2061: syntax error : identifier 'cmplx'
matrix.cpp(1326) : error C2061: syntax error : identifier 'cmplx'
matrix.cpp(1331) : error C2065: 's' : undeclared identifier
matrix.cpp(1332) : error C2065: 'M' : undeclared identifier
matrix.cpp(1340) : error C2065: 'M1' : undeclared identifier
matrix.cpp(1340) : error C2065: 'M2' : undeclared identifier
qcorral.cpp(681) : error C2664: 'MatMultMatCmpx' : cannot convert parameter 2 from 'dynamic_2d_array<T>' to 'cmplx **'
1> with
1> [
1> T=cmplx
1> ]
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called


There is already a function in the same .cpp file for multiplying real matrices. Can someone please let me know how do I get this to work for complex matrices? Thanks.

laasunde
March 20th, 2007, 02:13 AM
What type is cmplx? Have you included a reference to the header file that defines it?

Please post all relevant code.

vioravis
March 20th, 2007, 12:34 PM
I have defined cmplx as follows:

typedef complex<double> cmplx;

I have included this in the relevant files.

JVene
March 20th, 2007, 01:40 PM
You'll have to post a more complete code sample, enough that we can post into our compiler and see what's up.

dude_1967
March 20th, 2007, 03:19 PM
Well,

JVene and laasunde are right, we need to see more code.

If I had to guess, I would say the developer forgot (at least) one or more of these three things:

1) #include <complex>

2) typedef std::complex<double> cmplx;
3) And make sure that the typedef is visible to the subroutine through inclusion of it's header. This is definitely missing.

Minor but important items...

Sincerely, Chris.