correlation/correlation.cpp
// sets out to A * in (matrix multiplication)
sets out to A * in (matrix multiplication)
sets out to A * in ( matrix multiplication )
void C_matrix::av_no_C(int n, double *in, int nin, double *out, int nout)
{
  int nrow = this->nrow;
  int ncol = this->ncol;
  double Lx = this->Lx;
  double Ly = this->Ly;
  #pragma omp parallel
  {
    double x1[2];
    double x2[2];
    double val;
    int i,j;
    int N = n;
    #pragma omp for
    for (int k = 0; k < N; ++k)
    {
      out[k] = 0;
    }
    #pragma omp barrier
    #pragma omp for
    for (int row1 = 0; row1 < nrow; row1++)
    {
      for (int col1 = 0; col1 < ncol; col1++)
      {
        for (int row2 = 0; row2 < nrow; row2++)
        {
          for (int col2 = 0; col2 < ncol; col2++)
          {
            i = row1*ncol+col1;
            j = row2*ncol+col2;
              x1[0] = (row1+0.5)*Lx;
              x1[1] = (col1+0.5)*Ly;
              x2[0] = (row2+0.5)*Lx;
              x2[1] = (col2+0.5)*Ly;
              val = correlation(x1, 2, x2, 2);
              out[i] += in[j]*val;
          }
        }
      }
    }
  }
}
void C_matrix :: av_no_C ( int n , double * in , int nin , double * out , int nout ) { int nrow = this -> nrow ; int ncol = this -> ncol ; double Lx = this -> Lx ; double Ly = this -> Ly ; #pragma  omp parallel { double x1 [ 2 ] ; double x2 [ 2 ] ; double val ; int i , j ; int N = n ; #pragma  omp for for ( int k = 0 ; k < N ; ++ k ) { out [ k ] = 0 ; } #pragma  omp barrier #pragma  omp for for ( int row1 = 0 ; row1 < nrow ; row1 ++ ) { for ( int col1 = 0 ; col1 < ncol ; col1 ++ ) { for ( int row2 = 0 ; row2 < nrow ; row2 ++ ) { for ( int col2 = 0 ; col2 < ncol ; col2 ++ ) { i = row1 * ncol + col1 ; j = row2 * ncol + col2 ; x1 [ 0 ] = ( row1 + 0.5 ) * Lx ; x1 [ 1 ] = ( col1 + 0.5 ) * Ly ; x2 [ 0 ] = ( row2 + 0.5 ) * Lx ; x2 [ 1 ] = ( col2 + 0.5 ) * Ly ; val = correlation ( x1 , 2 , x2 , 2 ) ; out [ i ] += in [ j ] * val ; } } } } } }
sets out to A * in (matrix multiplication)
sets out to A * in ( matrix multiplication )
// private(x1,x2,val,i,j, k row1, row2,col1, col2) // C_matrix has N=nrow*col rows and columns // C_matrix is symmetric // out[row1*ncol+col1] = 0; // the if statement won't work with default openMP // if on or above the diagonal // if (j >= i){ // if above diagonal set reflection // if (j > i){ // out[j] += in[i]*val; // } // } // cout << "calling av" << endl;