I have been getting this error come up in the for loop when I try to assign values to x\_dev, y\_dev, and pearson. As far as I can see they should all be modifiable. Can anyone see where I have gone wrong?

```
class LoopBody
{  
    double *const x_data;
    double *const y_data;
    double const x_mean;
    double const y_mean;  
    double x_dev;
    double y_dev;
    double pearson; 

public:
    LoopBody(double *x, double *y, double xmean, double ymean, double xdev, double ydev, double pear) 
            : x_data(x), y_data(y), x_mean(xmean), y_mean(ymean), x_dev(xdev), y_dev(ydev), pearson(pear) {}  

    void operator() (const blocked_range<size_t> &r) const {              
        for(size_t i = r.begin(); i != r.end(); i++)
        {
            double x_temp = x_data[i] - x_mean;
            double y_temp = y_data[i] - y_mean;

            x_dev += x_temp * x_temp;
            y_dev += y_temp * y_temp;

            pearson += x_temp * y_temp;

        }
    }
};

```

Having followed @Bathsheba 's advice I have overcome these problems. However When running a parallel\_for the operator is runs but the for loop is never entered.

This is where I call the parallel\_for:

```
parallel_for(blocked_range<size_t>(0,n), LoopBody(x, y, x_mean, y_mean, x_dev, y_dev, pearson), auto_partitioner());

```