How to find the transpose of the complex 2d matrix

## 4 Replies - 1698 Views - Last Post: 20 February 2012 - 08:56 AM

### #1

# How to find the transpose of the complex 2d matrix

Posted 20 February 2012 - 06:26 AM

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

### #2

## 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.

### #3

## 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

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

### #4

## 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.

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

### #5

## 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:

edit: [] used for array indices

edit2: tested it, posted running version, works ok

#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

Page 1 of 1