Sum of Squared Differences

Hey,

Is there anything in the JUCE lib for doing sum of squared differences?

I tried to add accelerate to my app, but was getting quite a bit of errors including the header

There is a method to calculate the RMS (root mean square) named AudioBuffer::getRMSLevel() https://www.juce.com/doc/classAudioBuffer#af2820a0fc88c4356db579e5831d1fb04
Unfortunately it is not a vector operation, but a small loop which should perform quite fast.
You can experiment with FloatVectorOperations like https://www.juce.com/doc/classFloatVectorOperations#aec850a0a830e6bf7c940c9db38333f0f and give it the same pointer twice, so you get the squares. But you have to calculate the average by summing up, and I don’t see a vector operation for that, so maybe you end up with the same runtime as if you use the loop of getRMSLevel.

Not sure if this fits your use case since you didn’t specify it, but there is a little utility in JUCE called StatisticsAccumulator that could perhaps be useful?

1 Like