Make a Complex matrix from two Real matrices.
int MakeComplex( matrixbase & mbReal, matrixbase & mbImag )
Returns 0 on success and -1 on failure.
EX1
// Make a complex matrix from teo matrices void matrixbase_MakeComplex_ex1() { matrix<double> mR = { {2, 2, 2, 0}, {0, 1, 99, 99} }; mR[1][2]=NANUM; mR[1][3]=NANUM; matrix<double> mI = { {3, -3, 0, 3}, {0, 99, 1, 99} }; mI[1][1]=NANUM; mI[1][3]=NANUM; matrix<complex> mC; // Input matrix is: // {2, 2, 2, 0} // {0, 1, --, --} // and // {3, -3, 0, 3} // {0, --, 1, --} // Result matrix is: // {2+3i, 2-3i, 2, 3i} // {0, --, --, --} MatrixPage MatPg1; MatPg1.Create("Origin"); MatrixLayer MatLy1 = MatPg1.Layers(0); Matrix<double> Mat1(MatLy1); Mat1 = mR; printf(" Input matrix for the real part is %s.\n",Mat1.GetName()); MatrixPage MatPg2; MatPg2.Create("Origin"); MatrixLayer MatLy2 = MatPg2.Layers(0); Matrix<double> Mat2(MatLy2); Mat2 = mI; printf(" Input matrix for the imaginary part is %s.\n",Mat2.GetName()); MatrixPage MatPg3; MatPg3.Create("Origin"); MatrixLayer MatLy3 = MatPg3.Layers(0); MatLy3.SetInternalData(FSI_COMPLEX); // Set the internal data type to complex Matrix<complex> Mat3(MatLy3); int rc=mC.MakeComplex(mR,mI); //Create a complex matrix mC from mR and mI if(rc!=0) printf(" Error: MakeComplex failed.\n"); else { Mat3 = mC; printf(" Created complex matrix is %s.\n",Mat3.GetName()); printf(" Observe that if either the real or imaginary input is a NANUM, the result is also a NANUM.\n"); } }
Make a Complex matrix from two Real matrices (which must have the same dimensions).
matrixbase::CastToInteger, matrixbase::CastToDouble, matrixbase::GetReal, matrixbase::GetImaginary, matrixbase::GetPhase, matrixbase::GetAmplitude, matrixbase::Conjugate, matrixbase::Cross, matrixbase::Inverse
origin.h