"Fossies" - the Fresh Open Source Software Archive

Member "laspack/examples/vectopt/testproc.c" (10 Feb 1995, 4522 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 /*                                testproc.c                                */
    3 /****************************************************************************/
    4 /*                                                                          */
    5 /* TEST PROCedures for vector operation optimization for laspack            */
    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/errhandl.h>
   19 #include <laspack/copyrght.h>
   20 
   21 #include "testproc.h"
   22 
   23 Vector *Test1_VV(Vector *V1, Vector *V2)
   24 /* VRes = V1 += V2 ... implementation like laspack version 0.06 */
   25 {
   26     Vector *VRes;
   27     
   28     size_t Dim, Ind;
   29 
   30     if (LASResult() == LASOK) {
   31         if (V1->Instance == Normal && V1->Dim == V2->Dim) {
   32             Dim = V1->Dim;
   33             for(Ind = 1; Ind <= Dim; Ind++)
   34                 V1->Cmp[Ind] += V2->Cmp[Ind];
   35             VRes = V1;
   36         } else {
   37             LASBreak();
   38             VRes = NULL;
   39         }
   40     } else {
   41         VRes = NULL;
   42     }
   43     return(VRes);
   44 }
   45 
   46 Vector *Test2_VV(Vector *V1, Vector *V2)
   47 /* VRes = V1 += V2 ... implementation using local variables,
   48                        ascended counting of vector components */
   49 {
   50     Vector *VRes;
   51     
   52     Real *V1Cmp, *V2Cmp;
   53     size_t Dim, Ind;
   54 
   55     if (LASResult() == LASOK) {
   56         if (V1->Instance == Normal && V1->Dim == V2->Dim) {
   57             Dim = V1->Dim;
   58             V1Cmp = V1->Cmp;
   59             V2Cmp = V2->Cmp;
   60             for(Ind = 1; Ind <= Dim; Ind++)
   61                 V1Cmp[Ind] += V2Cmp[Ind];
   62             VRes = V1;
   63         } else {
   64             LASBreak();
   65             VRes = NULL;
   66         }
   67     } else {
   68         VRes = NULL;
   69     }
   70     return(VRes);
   71 }
   72 
   73 Vector *Test3_VV(Vector *V1, Vector *V2)
   74 /* VRes = V1 += V2 ... implementation using local variables,
   75                        descended counting of vector components */
   76 {
   77     Vector *VRes;
   78     
   79     Real *V1Cmp, *V2Cmp;
   80     size_t Dim, Ind;
   81 
   82     if (LASResult() == LASOK) {
   83         if (V1->Instance == Normal && V1->Dim == V2->Dim) {
   84             Dim = V1->Dim;
   85             V1Cmp = V1->Cmp;
   86             V2Cmp = V2->Cmp;
   87             for(Ind = Dim; Ind > 0; Ind--)
   88                 V1Cmp[Ind] += V2Cmp[Ind];
   89             VRes = V1;
   90         } else {
   91             LASBreak();
   92             VRes = NULL;
   93         }
   94     } else {
   95         VRes = NULL;
   96     }
   97     return(VRes);
   98 }
   99 
  100 Vector *Test4_VV(Vector *V1, Vector *V2)
  101 /* VRes = V1 += V2 ... implementation using pointers,
  102                        ascended counting of vector components */
  103 {
  104     Vector *VRes;
  105     
  106     Real *PtrV1Cmp, *PtrV2Cmp;
  107     size_t Dim, Ind;
  108 
  109     if (LASResult() == LASOK) {
  110         if (V1->Instance == Normal && V1->Dim == V2->Dim) {
  111             Dim = V1->Dim;
  112             PtrV1Cmp = V1->Cmp + 1;
  113             PtrV2Cmp = V2->Cmp + 1;
  114             for(Ind = 1; Ind <= Dim; Ind++) {
  115                 *PtrV1Cmp += *PtrV2Cmp;
  116                 PtrV1Cmp++;
  117                 PtrV2Cmp++;
  118         }
  119             VRes = V1;
  120         } else {
  121             LASBreak();
  122             VRes = NULL;
  123         }
  124     } else {
  125         VRes = NULL;
  126     }
  127     return(VRes);
  128 }
  129 
  130 Vector *Test5_VV(Vector *V1, Vector *V2)
  131 /* VRes = V1 += V2 ... implementation using pointers,
  132                        descended counting of vector components */
  133 {
  134     Vector *VRes;
  135     
  136     Real *PtrV1Cmp, *PtrV2Cmp;
  137     size_t Dim, Ind;
  138 
  139     if (LASResult() == LASOK) {
  140         if (V1->Instance == Normal && V1->Dim == V2->Dim) {
  141             Dim = V1->Dim;
  142             PtrV1Cmp = V1->Cmp + 1;
  143             PtrV2Cmp = V2->Cmp + 1;
  144             for(Ind = Dim; Ind > 0; Ind--) {
  145                 *PtrV1Cmp += *PtrV2Cmp;
  146         PtrV1Cmp++;
  147                 PtrV2Cmp++;
  148         }
  149             VRes = V1;
  150         } else {
  151             LASBreak();
  152             VRes = NULL;
  153         }
  154     } else {
  155         VRes = NULL;
  156     }
  157     return(VRes);
  158 }
  159