This site is best viewed in a browser that conforms to web standards.



BOOL ivorix_swma (
vector<double>& ivec, // input vector
vector<double>& ovec, // output vector
unsigned long span) // time period or span of embedding
{
ULONG x = 0;
ULONG y = 0;
ULONG e = ivec.size();
double sum = 0;
double f = PI() / (double) (span + 1);
double d = 0;
double p = 0;
if ( span == 0 || span >= e )
return false;
ovec.resize(ivec.size());
ovec[0] = ivec[0];
for ( x = 1; x < e; x++ )
{
sum = 0;
p = min( x, span );
for ( y = 0; y < p; y++ )
sum += sin((double)(p - y) * f) * ivec[x-y];
if ( x <= span )
{
d = 0;
for ( y = 1; y <= p; y++ )
d += sin((double) y * f);
}
ovec[x] = sum / d;
}
return true;
}