Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Crosscorrel.cpp
- Committer:
- gunarthon
- Date:
- 2018-05-03
- Revision:
- 0:61544337ff5e
File content as of revision 0:61544337ff5e:
#include "Crosscorrel.h"
#include "mbed.h"
Crosscorrel::Crosscorrel()
{
this->tau = 50;
}
float Crosscorrel::GetMax(SignalBuf &buf, unsigned chA, unsigned chB)
{
float max = 0;
for(int j = -tau; j <= tau; j++)
{
float correl = 0;
for(unsigned t = 0; t < buf.size(); t++)
{
correl += buf[t][chA] * GetValue(buf, t+j, chB);
}
printf("%i\n", int(correl));
max = correl > max ? correl : max;
}
return max;
}
Crosscorrel::~Crosscorrel()
{
}
float Crosscorrel::GetValue(SignalBuf &buf, int index, unsigned ch)
{
if(index < 0 || index >= buf.size())
return 0;
return buf[index][ch];
}
