void expr_error_undef (Token t, int w) { if (intfind (undeftree, t)) dothrow (0); union ival i; intadd (&undeftree, t, i); fprintf (errstream, EER"Un%s '%s'\n", w ? "declared function" : "defined object", expand (t)); throw_it (0); }
/* ************************************************************ PROCEDURE partitA INPUT Ajc, Air, m - sparse N x m matrix blkstart, nblk - length nblk integer array of subscripts. iwsize - length of iwork, iwsize = floor(log(1+nblk)/log(2)). OUTPUT Ablkjc - length (nblk+2)*m array. Rows 1+(1:nblk) list 1st nonzero with subscript at or beyond blkstart. WORK cfound - length nblk char work array iwork - length iwsize = floor(log(1+nblk)/log(2)) work array. ************************************************************ */ void partitA(int *Ablkjc, const int *Ajc,const int *Air, const int *blkstart, const int m,const int nblk, const int iwsize, char *cfound, int *iwork) { int j, L; L = nblk+2; for(j = 0; j < m; j++) intmbsearch(Ablkjc + j*L, cfound, Air+Ajc[j], Ajc[j+1]-Ajc[j], blkstart, nblk, iwork, iwsize); for(j = 0; j < m; j++) intadd(Ablkjc + j*L, Ajc[j],L); }
/* ************************************************************ PROCEDURE partitA INPUT Ajc, Air, m - sparse N x m matrix blkstart, nblk - length nblk integer array of subscripts. iwsize - length of iwork, iwsize = floor(log(1+nblk)/log(2)). OUTPUT Ablkjc - length (nblk+1)*m array. Rows 1+(1:nblk) list 1st nonzero with subscript at or beyond blkstart. WORK cfound - length nblk char work array iwork - length iwsize = floor(log(1+nblk)/log(2)) work array. ************************************************************ */ void partitA(mwIndex *Ablkjc, const mwIndex *Ajc,const mwIndex *Air, const mwIndex *blkstart, const mwIndex m,const mwIndex nblk, const mwIndex iwsize, bool *cfound, mwIndex *iwork) { mwIndex j, L; L = nblk+2; for(j = 0; j < m; j++) intmbsearch(Ablkjc + j*L, cfound, Air+Ajc[j], Ajc[j+1]-Ajc[j], blkstart, nblk, iwork, iwsize); for(j = 0; j < m; j++) intadd(Ablkjc + j*L, Ajc[j],L); }
EXTERN_ENV #include <stdio.h> #include <math.h> #include <stdlib.h> #include "decs.h" /* perform multigrid (w cycles) */ void multig(long my_id) { long iter; double wu; double errp; long m; long flag; long k; long my_num; double wmax; double local_err; double red_local_err; double black_local_err; double g_error; flag = 0; iter = 0; m = numlev - 1; wmax = maxwork; my_num = my_id; wu = 0.0; k = m; g_error = 1.0e30; while (!flag) { errp = g_error; iter++; if (my_num == MASTER) { multi->err_multi = 0.0; } /* barrier to make sure all procs have finished intadd or rescal */ /* before proceeding with relaxation */ #if defined(MULTIPLE_BARRIERS) BARRIER(bars->error_barrier, nprocs) #else BARRIER(bars->barrier, nprocs) #endif copy_black(k, my_num); relax(k, &red_local_err, RED_ITER, my_num); /* barrier to make sure all red computations have been performed */ #if defined(MULTIPLE_BARRIERS) BARRIER(bars->error_barrier, nprocs) #else BARRIER(bars->barrier, nprocs) #endif copy_red(k, my_num); relax(k, &black_local_err, BLACK_ITER, my_num); /* compute max local error from red_local_err and black_local_err */ if (red_local_err > black_local_err) { local_err = red_local_err; } else { local_err = black_local_err; } /* update the global error if necessary */ LOCK(locks->error_lock) if (local_err > multi->err_multi) { multi->err_multi = local_err; } UNLOCK(locks->error_lock) /* a single relaxation sweep at the finest level is one unit of */ /* work */ wu += pow((double) 4.0, (double) k - m); /* barrier to make sure all processors have checked local error */ #if defined(MULTIPLE_BARRIERS) BARRIER(bars->error_barrier, nprocs) #else BARRIER(bars->barrier, nprocs) #endif g_error = multi->err_multi; /* barrier to make sure master does not cycle back to top of loop */ /* and reset global->err before we read it and decide what to do */ #if defined(MULTIPLE_BARRIERS) BARRIER(bars->error_barrier, nprocs) #else BARRIER(bars->barrier, nprocs) #endif if (g_error >= lev_tol[k]) { if (wu > wmax) { /* max work exceeded */ fprintf(stderr, "ERROR: Maximum work limit %0.5f exceeded\n", wmax); exit(-1); } else { /* if we have not converged */ if ((k != 0) && (g_error / errp >= 0.6) && (k > minlevel)) { /* if need to go to coarser grid */ copy_borders(k, my_num); copy_rhs_borders(k, my_num); /* This bar is needed because the routine rescal uses the neighbor's border points to compute s4. We must ensure that the neighbor's border points have been written before we try computing the new rescal values */ #if defined(MULTIPLE_BARRIERS) BARRIER(bars->error_barrier, nprocs) #else BARRIER(bars->barrier, nprocs) #endif rescal(k, my_num); /* transfer residual to rhs of coarser grid */ lev_tol[k - 1] = 0.3 * g_error; k = k - 1; putz(k, my_num); /* make initial guess on coarser grid zero */ g_error = 1.0e30; } } } else { /* if we have converged at this level */ if (k == m) { /* if finest grid, we are done */ flag = 1; } else { /* else go to next finest grid */ copy_borders(k, my_num); intadd(k, my_num); /* changes the grid values at the finer level. rhs at finer level */ /* remains what it already is */ k++; g_error = 1.0e30; } } } if (do_output) { if (my_num == MASTER) { printf("iter %ld, level %ld, residual norm %12.8e, work = %7.3f\n", iter, k, multi->err_multi, wu); } } }