"Fossies" - the Fresh Open Source Software Archive

Member "laspack/rtc.c" (14 Jun 1995, 2688 Bytes) of package /linux/privat/old/laspack.tgz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /****************************************************************************/
    2 /*                                  rtc.c                                   */
    3 /****************************************************************************/
    4 /*                                                                          */
    5 /* Residual Termination Control                                             */
    6 /*                                                                          */
    7 /* Copyright (C) 1992-1995 Tomas Skalicky. All rights reserved.             */
    8 /*                                                                          */
    9 /****************************************************************************/
   10 /*                                                                          */
   11 /*        ANY USE OF THIS CODE CONSTITUTES ACCEPTANCE OF THE TERMS          */
   12 /*              OF THE COPYRIGHT NOTICE (SEE FILE COPYRGHT.H)               */
   13 /*                                                                          */
   14 /****************************************************************************/
   15 
   16 #include <stddef.h>
   17 
   18 #include "laspack/rtc.h"
   19 #include "laspack/errhandl.h"
   20 #include "laspack/elcmp.h"
   21 #include "laspack/operats.h"
   22 #include "laspack/copyrght.h"
   23 
   24 /* accuracy for Residual Termination Control */
   25 static double RTCEps = 1e-8;
   26 
   27 /* auxiliary procedure to be performed by Residual Termination Control */
   28 static RTCAuxProcType RTCAuxProc = NULL;
   29 
   30 /* number of iterations performed during last call of a iteration method */
   31 static int LastNoIter = 0;
   32 
   33 /* accuracy reached during last call of a iteration method */
   34 static double LastAcc = 0.0;
   35 
   36 void SetRTCAccuracy(double Eps)
   37 /* set accuracy for the RTC */
   38 {
   39     RTCEps = Eps;
   40 }
   41 
   42 void SetRTCAuxProc(RTCAuxProcType AuxProc)
   43 /* set auxiliary procedure of RTC */
   44 {
   45     RTCAuxProc = AuxProc;
   46 }
   47 
   48 Boolean RTCResult(int Iter, double rNorm, double bNorm, IterIdType IterId)
   49 /* get result of RTC */
   50 {
   51     Boolean Result;
   52 
   53     if (LASResult() == LASOK) {
   54         if (rNorm < RTCEps * bNorm || (IsZero(bNorm) && IsOne(1.0 + rNorm)))
   55             Result = True;
   56         else
   57             Result = False;
   58 
   59         LastNoIter = Iter;
   60         if (!IsZero(bNorm))
   61             LastAcc = rNorm / bNorm;
   62         else
   63             LastAcc = 1.0;
   64 
   65         if (RTCAuxProc != NULL)
   66             (*RTCAuxProc)(Iter, rNorm, bNorm, IterId);
   67     } else {
   68         Result = True;
   69     }
   70 
   71     return(Result);
   72 }
   73 
   74 int GetLastNoIter()
   75 /* get number of iterations performed during last call of a iteration method */
   76 {
   77     return(LastNoIter);
   78 }
   79 
   80 double GetLastAccuracy()
   81 /* get accuracy reached during last call of a iteration method */
   82 {
   83     return(LastAcc);
   84 }