Notes for complex self-calculation-Tips

Source: Internet
Author: User

The STL complex template is not used for Recursive Implementation of FFT in image compilation. The real and virtual parts are operated directly, and the results of the spectrum image are different from those of the opencv library, the FFT of the Lena image is like a rough cloth. The left side of the image is generated by opencv and the right side is generated by yourself.

The upper left corner shows that the upper left corner has a frequency band in the lower right corner. However, the lower right corner cannot be seen and an error occurs. It is normal to use the complex template for calculation. It should be because of an error in the complex number operation written by myself. I did not see it carefully. I wrote a few program tests and finally found the problem.

ProgramThere is a self-Multiplication operation w = W * wn. If the complex template is used, it is very simple, but it is ignored when I write the multiplication of the plural.

What?

Incorrect program:

 
W_r = w_r * wn_r-w_ I * wn_ I; w_ I = w_r * wn_ I + w_ I * wn_r;

The correct program:

T t_r = w_r; w_r = t_r * wn_r-w_ I * wn_ I; w_ I = t_r * wn_ I + w_ I * wn_r;

Now we can see at a glance that the original real part is used in the calculation of the virtual part during the self-Multiplication operation, and the wrong program uses the calculated real part...The original value should be saved for temporary storage, and the original value should be used for calculation. The following program calculates the real part first, so you only need to save the real part, if you calculate the virtual part first, it is obvious that it should be saved to the virtual part.

There is no need to worry about the addition and subtraction of the plural because the real imaginary part is not mixed. The division of the plural part also involves the coefficient Hybrid Operation of the real imaginary part. Therefore, you should also pay attention to the temporary storage of the original data during self-division.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.