Hello Guys,

I am completely new to Chapel. I want to write a program for doing the
gauss-seidal iteration. I have two issues.
1) I want to have a temporally variable not an array to hold the new value
and calculate delta based on that, then replace the array element with
that.
2) Delta is again not an array so I think I should define it as atomic so
everyone has access to it, then I have to synchronise it for finding the
maximum value in each iteration. I could not find a way to do so.
Below you can find the code that wrote so far.

proc gauss_seidal(D: domain(2), x: [D] real, epsilon: real){
  const ID = D.expand(-1,-1); // domain for interior points
  var a: real=0;           // temporary variable for elements
  var delta: real; // measure of convergence,
  var cnt = 0;

do {
  forall ij in ID do {
  a=(x(ij+(0,1)) + x(ij+(0,-1))
                   + x(ij+(1,0)) + x(ij+(-1,0))) / 4.0;
  delta = abs(a- x[ij]);     //I should find the maximum value in each
iteration for the main array
  x[ij] = a;}
  cnt +=1;

  if (verbose) {
      writeln("Iter: ", cnt, " (delta=", delta, ")\n");
      writeln(x);
    }
} while (delta > epsilon);
  return cnt;
  }

I would be grateful if you can help me.
Sepideh
------------------------------------------------------------------------------
_______________________________________________
Chapel-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-users

Reply via email to