4 Replies - 1568 Views - Last Post: 20 February 2012 - 08:56 AM Rate Topic: -----

#1 [email protected]  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 20-January 11

How to find the transpose of the complex 2d matrix

Posted 20 February 2012 - 06:26 AM

How to find the transpose of the complex 2d matrix
Is This A Good Question/Topic? 0
  • +

Replies To: How to find the transpose of the complex 2d matrix

#2 Karel-Lodewijk  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 454
  • View blog
  • Posts: 864
  • Joined: 17-March 11

Re: How to find the transpose of the complex 2d matrix

Posted 20 February 2012 - 06:30 AM

The same way you would take the transpose of an ordinary matrix, only with a matrix that has complex entries.
Was This Post Helpful? 0
  • +
  • -

#3 [email protected]  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 20-January 11

Re: How to find the transpose of the complex 2d matrix

Posted 20 February 2012 - 07:42 AM

Actually, i have to construct my complex matrix by using struct, so there will be a real part and imag part to it
So, i suppose its transpose wont be similar to a normal matrix transpose.
If you can guide me along, it would be nice of you.
thanks
Was This Post Helpful? 0
  • +
  • -

#4 ishkabible  Icon User is offline

  • spelling expret
  • member icon





Reputation: 1739
  • View blog
  • Posts: 5,895
  • Joined: 03-August 09

Re: How to find the transpose of the complex 2d matrix

Posted 20 February 2012 - 07:49 AM

it's the same thing so long as you define the arithmetic behavior of the complex number(add, sub, multiply, divide, etc...)

also, C++ has a complex number library. double and complex<double> can do all the same things but complex<double> defines an imaginary part.

This post has been edited by ishkabible: 20 February 2012 - 07:51 AM

Was This Post Helpful? 0
  • +
  • -

#5 Karel-Lodewijk  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 454
  • View blog
  • Posts: 864
  • Joined: 17-March 11

Re: How to find the transpose of the complex 2d matrix

Posted 20 February 2012 - 08:56 AM

An algorithm for a simple square matrix implemented using a 2D array could look something like this:

#include <complex>
#include <algorithm>
#include <iostream>

const size_t DIM = 3;

int main() {
    std::complex<double> matrix[DIM][DIM] = {{1+1i,2,3},{4,5+3i,6},{7,8,9}};

    for (size_t i = 0; i < DIM-1; ++i)
        for (size_t j = i+1; j < DIM; j++) 
            std::swap(matrix[i][j], matrix[j][i]);

    for (size_t i = 0; i < DIM; ++i) {
        for (size_t j = 0; j < DIM; ++j)
            std::cout << matrix[i][j] << " ";
        std::cout << std::endl;
    }
}



edit: [] used for array indices
edit2: tested it, posted running version, works ok

This post has been edited by Karel-Lodewijk: 20 February 2012 - 09:08 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1