# Problem with idft

**URL:** <https://forum.opencv.org/t/problem-with-idft/5937>\
**Category:** C++\
**Created:** [October 28, 2021, 10:12pm UTC](https://forum.opencv.org/t/problem-with-idft/5937 "2021-10-28T22:12:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eugene](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/eugene/32/445_2.png) [@Eugene](https://forum.opencv.org/u/Eugene)\
**Post date:** [October 28, 2021, 10:12pm UTC](https://forum.opencv.org/t/problem-with-idft/5937/1 "2021-10-28T22:12:34Z")

</div>

I’m using idft in my code, see the excerpt below. I tested it many times and it’s been working fine for a long time for many test examples, but all of the sudden if gave me a strange error:

 ![error](https://us1.discourse-cdn.com/flex020/uploads/opencv/original/2X/1/16faf07312375ab170638f917a587dda8955ae9f.jpeg)  
I have no clue what the problem is and what I’m supposed to do to fix it. Any help?

My code:  
Mat PhaseExpRe(1, Nphase, CV\_64F);  
Mat PhaseExpIm(1, Nphase, CV\_64F);  
Mat complexIn, complexOut;

```
for (int i = 0; i < Nphase; i++)
{
	PhaseExpRe.at<double>(0, i) = cos(PhasePolyfit[Nphase - i]);
	PhaseExpIm.at<double>(0, i) = -sin(PhasePolyfit[Nphase - i]);
}
Mat planes[] = { Mat_<double>(PhaseExpRe), Mat_<double>(PhaseExpIm) };
merge(planes, 2, complexIn);         
idft(complexIn, complexOut, DFT_ROWS, DFT_COMPLEX_OUTPUT);
```
