Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 10:06:57

0001 #include "SOR.h"
0002 
0003 double SOR_num_flops(int M, int N, int num_iterations) {
0004   double Md = (double)M;
0005   double Nd = (double)N;
0006   double num_iterD = (double)num_iterations;
0007 
0008   return (Md - 1) * (Nd - 1) * num_iterD * 6.0;
0009 }
0010 
0011 void SOR_execute(int M, int N, double omega, double **G, int num_iterations) {
0012   double omega_over_four = omega * 0.25;
0013   double one_minus_omega = 1.0 - omega;
0014 
0015   /* update interior points */
0016 
0017   int Mm1 = M - 1;
0018   int Nm1 = N - 1;
0019   int p;
0020   int i;
0021   int j;
0022   double *Gi;
0023   double *Gim1;
0024   double *Gip1;
0025 
0026   for (p = 0; p < num_iterations; p++) {
0027     for (i = 1; i < Mm1; i++) {
0028       Gi = G[i];
0029       Gim1 = G[i - 1];
0030       Gip1 = G[i + 1];
0031       for (j = 1; j < Nm1; j++)
0032         Gi[j] = omega_over_four * (Gim1[j] + Gip1[j] + Gi[j - 1] + Gi[j + 1]) + one_minus_omega * Gi[j];
0033     }
0034   }
0035 }