CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2007
    Posts
    80

    Complex Matrix Multiplication

    I am trying to write a function for matrix multiplication when the two matrices are of type complex.

    Code:
    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.

  2. #2
    Join Date
    Jan 2003
    Posts
    615

    Re: Complex Matrix Multiplication

    What type is cmplx? Have you included a reference to the header file that defines it?

    Please post all relevant code.
    Before post, make an effort yourself, try googling or search here.

    When posting, give a proper description of your problem, include code* and error messages.

    *All code should include code tags

  3. #3
    Join Date
    Feb 2007
    Posts
    80

    Re: Complex Matrix Multiplication

    I have defined cmplx as follows:

    typedef complex<double> cmplx;

    I have included this in the relevant files.

  4. #4
    Join Date
    Nov 2006
    Posts
    1,611

    Re: Complex Matrix Multiplication

    You'll have to post a more complete code sample, enough that we can post into our compiler and see what's up.

  5. #5
    Join Date
    Jun 2002
    Location
    Germany
    Posts
    1,557

    Re: Complex Matrix Multiplication

    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:
    Code:
    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.
    Last edited by dude_1967; March 20th, 2007 at 03:21 PM. Reason: clarity
    You're gonna go blind staring into that box all day.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured