/***************************************************************************** * * SAC demo program * * This SAC demo program implements 2-dimensional relaxation on double * precision floating point numbers applying a 4-point stencil and fixed * boundary conditions. * * The vertical (SIZE1) and the horizontal (SIZE2) array size as well as * the number of iterations to be performed (LOOP) may be set at compile * time. * *****************************************************************************/ #ifndef LOOP #define LOOP 100 #endif #ifndef SIZE1 #define SIZE1 1000 #endif #ifndef SIZE2 #define SIZE2 1000 #endif use Array: all; use StdIO: all; inline double[+] onestep(double[+] B) { A = with { ( . < x < . ) : 0.25*(B[x+[1,0]] + B[x-[1,0]] + B[x+[0,1]] + B[x-[0,1]]); } : modarray( B ); return(A); } inline double[+] relax(double[+] A, int steps) { for (k=0; k