# Modify loop for faster execution

Hello,

Here's the code which works well for analysis while performing discrete wavelet transform. I've been wondering if this loop could be modified to make the execution faster? Any help would be appreciated.

```
int rows = signal.size();
int cols = signal[0].size();
int cols_lp1 =(int) ceil( (double) cols / 2);
vector<vector<double> > lp_dn1(rows, vector<double>( cols_lp1));
// Implementing row filtering and column downsampling in each branch.
for (int i =0; i < rows; i++) {
vector<double> temp_row;
for (int j=0;j < cols;j++) {
double temp = signal[i][j];
temp_row.push_back(temp);
}
vector<double> oup;
branch_lp_dn(name,temp_row,oup);
temp_row.clear();
for (int j=0;j < (int) oup.size();j++) {
lp_dn1[i][j] = oup[j];
}
}
```

start with using preallocated vectors/arrays. don't do push_back/clear in inner loops.

(but again, all of it unrelated to opencv..)