-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Speed-up Klopfenstein taper and ABCD matrix calculations #3
Conversation
Implemented the simple recursive formula from Grossberg, Proc. IEEE 1968, pp.1629-1630 to compute the phi(x, A) function needed for the Klopfenstein taper calculations. Changed the ABCD matrix to use a constant number of sections, instead of using constant fraction of wavelength sections, since the number of sections needed depends mainly on the impedance change across the section, not on its length. Corrected the ABCD matrix to Y-parameters conversion (had a missing negative sign). Now using the a Qucs function to set the S-matrix.
Speed-up Klopfenstein taper and ABCD matrix calculations
Wow!! Your Klopfenstein taper implementation is miracle-working :-) I've just compared your code with the paper you've cited and it is correct. Thank you!! On the other hand, I've removed the line 75 (previously commented) because it is no longer useful. I've also remembered that float divisions take more CPU cycles than float multiplications so I have also converted x/2 expressions into .5*x. That's not a significant improvement, but every little helps... Besides this, I've already added the GPL license + my name. I would like to add yours there. May I do it? |
yep, the recursive As said in a previous comments, the ABCD matrix will be exact with 1 section only if the actual line was uniform, i.e. with a constant impedance, the need to divide it in section comes from the impedance variations, not from the line delay, which is modeled already by the section ABCD matrix. ok, for line 75, it was a leftover from previous mods. I usually do not pay much attention to the simple math operations, I expect the compiler to understand that Thanks for asking to add my name to the code authors, I won't say no 😁, it was an interesting work but took quite some time here. Name and contact details you can fine e.g. here Thanks again for all the work! |
Ok, thank you for your explanation. Since the sampling rate of the impedance profile does not depend on the frequency, now it is possible to precalculate it in initSP() :-) Concerning the product/division issue, I did a quick test and I can confirm that g++ does not optimize that kind of operations. Indeed, if you take a look to the assembly code you can see that the division is performed by using a 'divsd' instruction whereas the product uses 'mulsd'. Unfortunately, I couldn't find further information in the instruction set of Intel. However, the test above evidences that 'divsd' requires more time than 'mulsd' (roughly about a 14% more). Anyway, this is absolutely insignificant because we were using a just few x/2... |
thanks for doing some actual testing on the math operations; honestly I'm surprised the compiler didn't choose the same (faster) method for both cases. Did you complie with optimizaton enabled ( |
Yes, you win. |
ok, this agrees with some experiments I did lot of time ago, my conclusions were that for simple operation is better to let the compiler decide what to do and prefer to optimize code readability. |
Here is an update to greatly speed-up the tapers calculations, especially the Klopfenstein.
The two main points are:
Enjoy! and thanks again for all the work!