Dot products of vectors to perform 1D convolution

This seems working but I am not sure if it will slow down the calculation

  for(i in 2:lxy){
    int asc[i] = 1:i;
    cvxy[i] = dot_product(x[asc], y[sort_desc(asc)]);
  }

What confuses me is the following also works even if asc is not used,

  for(i in 2:lxy){
    int asc[i] = 1:i;
    cvxy[i] = dot_product(x[1:i], y[sort_desc(1:i)]);
  }

but as long as I comment out line int asc[i] = 1:i;, I start having syntax error. I guess I am doing a silly mistake here, but could not find why…

1 Like