2.2.3.9.43 matrixbase::IFFTShiftIFFTShift
Description
Inverse FFTShift.
Syntax
int IFFTShift( matrixbase & mbShifted, int nDim = -1 )
Parameters
- mbShifted
- [output] The output matrix in which the un-shifted matrix is returned
- nDim
- [input] Inverse FFTShifts can occur row wise (relative to the first dimension when nDim=1), column wise (relative to the second dimension when nDim=2), or relative to both or the first dimension and then the second dimension (when nDim=-1 default)
Return
Returns 0 on success and a non-zero error code on failure:
-1=nDim is not -1, 1, or 2
-2=Internal casting error
Examples
EX1
void matrixbase_IFFTShift_ex1()
{
matrix mSource = {
{1,2,3},
{4,5,6},
{7,8,9}
};
int rc = mSource.IFFTShift( mSource );
if(rc!=0)
printf("Error: IFFTShift failed. rc=%d\n", rc);
else{
printf("The matrix is:\n");
for(int ii=0; ii< mSource.GetNumRows(); ii++){
for(int jj=0; jj< mSource.GetNumCols(); jj++)
printf("%g ", mSource[ii][jj]);
printf("\r\n");
}
}
}
EX2
// Inverse-shifting matrix rows or columns
void matrixbase_IFFTShift_ex2()
{
matrix mSource = {
{1,2,3},
{4,5,6},
{7,8,9}
};
matrix mShifted, mIShifted;
int ii, jj;
MatrixPage MatPg1;
MatPg1.Create("Origin");
MatrixLayer MatLy1 = MatPg1.Layers(0);
Matrix Mat1(MatLy1);
Mat1 = mSource;
printf(" The original matrix is %s.\n",Mat1.GetName());
MatrixPage MatPg2;
MatPg2.Create("Origin");
MatrixLayer MatLy2 = MatPg2.Layers(0);
Matrix Mat2(MatLy2);
int rc=mSource.FFTShift(mShifted);
if(rc!=0)
printf(" Error: FFTShift failed.\n");
else {
Mat2 = mShifted;
printf(" %s is a shifted matrix relative to both 1st and 2nd dimensions.\n",Mat2.GetName());
}
MatrixPage MatPg3;
MatPg3.Create("Origin");
MatrixLayer MatLy3 = MatPg3.Layers(0);
Matrix Mat3(MatLy3);
rc=mShifted.IFFTShift(mIShifted);
if(rc!=0)
printf(" Error: IFFTShift failed.\n");
else {
Mat3 = mIShifted;
printf(" %s is the invert-sfifted matrix from %s, made the original recovered.\n",Mat3.GetName(),Mat2.GetName());
}
}
Remark
Inverse FFTShift. Inverse FFTShifts can occur row wise or relative to the first dimension (nDim=1), column wise or relative to the second dimension(nDim=2), or relative to both or the first dimension and then the second dimension (nDim=-1 default). The result matrix and this matrix can be the same (i.e m1.IFFTShift(m1);).
See Also
matrixbase::FFTShift
Header to Include
origin.h
|