1

I need some conceptual help for my Qt application.

I have a program that receives image data from 12 Analog Digital Converters (ADCs - they digitize the signal of 12 detectors in an electron microscope). I display these images live in my app. Now I want to give the user the opportunity to apply mathematical operations on the signals in a very flexible manner, while maintaining the live display.

Therefore, I consider to implement the shunting yard algorithm. My idea is that the user enters/mixes the signals in a textBox as he/she likes. For example, if a sum of four ADC signals is needed, the user just enters

"ADC01 + ADC02 + ADC03 + ADC04"

I understand how to apply the algorithm to get the Polish Postfix Notation and also how to evaluate such an expression. However, this approach seems to be too slow to be applied on currently 8x256x256 values (eight square images, all values need to be refreshed at the same time unfortunately). Surely, the Postfix conversion only needs to be done once, but the insert of my variables and the evaluation seems to me much more costly than just writing

uint valToDisp = ADC[1]+ADC[2]+ADC[3]+ADC[4];

in code.

Can you think of any way to do such a thing with good performance? What I thought of is to create some kind of dynamic function out of the postfix, but I am not sure how to realize something like this in C++.

phuclv
  • 37,963
  • 15
  • 156
  • 475
kleinpoe
  • 11
  • 2
  • Dynamic code generation would be complicated, but perhaps you could sidestep the entire issue by operating on entire vectors of data, rather then scalars. Then interpretation overhead should be relatively small. – zch Oct 21 '18 at 21:39
  • shunting yard is unnecessary if you just use the same operations for all elements, like `ADC[1]+ADC[2]+ADC[3]+ADC[4]` or `ADC[1]*ADC[2]*ADC[3]*ADC[4]` – phuclv Oct 22 '18 at 02:23
  • @zch This is a very good idea! I will do that, thank you! – kleinpoe Oct 24 '18 at 10:52
  • @phuclv Sorry I did not explain this enough: I want the user to be able to enter any operation, also e.g. `(ADC[1]-ADC[2])/(ADC[1]+ADC[2])`. And also e.g. `ADC[1]+ADC[4]` – kleinpoe Oct 24 '18 at 10:54
  • Dear @zch I used vectorization and it worked great, thank you very much! – kleinpoe Oct 22 '19 at 21:46

0 Answers0