0

Hi, below is my code to do a Convolution. I am tryingt o convolute my theoretical data with a Gaussian?

I seem to be getting a number of errors and its killing me

Cheers for any help Gareth

```
#include <iostream>
#include <cmath>
#include <math.h>
using std::cout;
using std::cin;
using std::endl;
double getTheoreticalData(double x);
{
double value;
for (int x = 0; x <= 40; x++){
// For straightforward square root
value = sqrt(x);
return (value);
}
}
int main() {
int mean; // the mean is the mean for the calculation of the Gaussian
double StandardDeviation; // the standard deviation for the calculation of the Gaussian
double PI; // the value PI which will be defined by me as (3.141592654)
double Gauss[41]; // the figure of the Gaussian I am trying to get
double PISQ; // 2PI squared
double exponential; // this will be the exponential side of the Gauss equation
double SDsq; // the 2 time SDsquared
int sampleCount = 40;
int gaussianSize = 40;
StandardDeviation = 1;
mean = 20;
PI = 3.141592654;
PISQ = (2 * PI) * ( 2 * PI );
SDsq = ( StandardDeviation * StandardDeviation) * 2;
// Create Gaussian
for (int x = 0; x <= gaussianSize; ++x )
{
exponential = exp (( x - mean ) * ( x - mean ) * -1 ) / SDsq;
Gauss[x] = ( 1 / (StandardDeviation * PISQ) * exponential );
cout << Gauss[x] << endl;
}
// Now do the convolution
// Loop through all 40 samples
for ( int i = 0; i < sampleCount; ++i )
{
y[i] = 0; // set to zero before sum
// Loop through convolution for this data point and perform sum
for (int j = 0; j < gaussianSize; ++j )
{
y[i] += z[i - j] * Gauss[j]; // convolve: multiply and accumulate
}
cout << i << ": " << y[i] << endl;
}
return 0;
```