seperate_complex_mat_to_real_and_imag_mat

 

Description

This function will take care of the complex data matrix and sperate it into two double matrix, and then according to nRowProcess and nColProcess, do neccessory padding with zero or truncting for the two result double matrix.

Syntax

int seperate_complex_mat_to_real_and_imag_mat( matrix<complex> & matSource, matrix & matReal, matrix & matImag, int nRowProcess, int nColProcess )

Parameters

matSource
[input]The source matrix
matReal
[output]The real part matrix
matImag
[output]The imaginary part matrix
nRowProcess
[input]The number of rows, which will be processed, where is result matrix row number
nColProcess
[input]The number of cols, which will be processed, where is result matrix colum number

Return

Returns 0 on successful exit

Examples

EX1

int seperate_complex_mat_to_real_and_imag_mat_ex1()
{
   matrix<complex> matSource = {{1+3i, 2+4i, 3+2i},{5+8i, 6+9i, 7+10i},{9+12i, 10+1i, 11+3i}};
   printf("The source complex matrix:\n");
   int ii, jj;
   int nNumCols = matSource.GetNumCols();
   int nNumRows = matSource.GetNumRows();
   for(ii = 0; ii < nNumRows; ii++)
   {
       for(jj = 0; jj < nNumCols; jj++)
           out_complex("", matSource[ii][jj]);
       printf("\n");    
   }
   int nRowProcess = nNumRows + 3;
   int nColProcess = nNumCols - 1;
   matrix matReal, matImag; 
   int nRet = seperate_complex_mat_to_real_and_imag_mat(matSource, matReal, matImag, nRowProcess, nColProcess);
   if(nRet != 0)
   {
       printf("seperate_complex_mat_to_real_and_imag_mat failed!");
       return -1;
   }
   printf("The result two matrices are:\n");
   printf("Real part:\n");
   for(ii = 0; ii < nRowProcess; ii++)
   {
       for(jj = 0; jj < nColProcess; jj++)
           printf("%f  ",matReal[ii][jj]);
       printf("\n");    
   }
   
   printf("Imaginary part:\n");
   for(ii = 0; ii < nRowProcess; ii++)
   {
       for(jj = 0; jj < nColProcess; jj++)
           printf("%f  ",matImag[ii][jj]);
       printf("\n");    
   }
   return 0;    
}

Remark

See Also

set_matrix_with_padding_truncting

Header to Include

origin.h

Reference