"Fossies" - the Fresh Open Source Software Archive

Member "laspack/examples/lastest/lastest.c" (8 Aug 1995, 24171 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 /*                                lastest.c                                 */
    3 /****************************************************************************/
    4 /*                                                                          */
    5 /* LASpack - a TEST program                                                 */
    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 <stdio.h>
   17 #include <stdlib.h>
   18 #include <string.h>
   19 #include <time.h>
   20 #include <math.h>
   21 
   22 #include <laspack/errhandl.h>
   23 #include <laspack/vector.h>
   24 #include <laspack/qmatrix.h>
   25 #include <laspack/operats.h>
   26 #include <laspack/version.h>
   27 #include <laspack/copyrght.h>
   28 
   29 #include <xc/getopts.h>
   30 
   31 #define MAX_TEST_NR 20
   32 
   33 static void GenMatr(QMatrix *Q);
   34 static Vector *SimpleMul_QV(QMatrix *Q, Vector *V);
   35 static void PrintHelp(void);
   36 
   37 int main(int argc, char **argv)
   38 {
   39     char Descr[MAX_TEST_NR + 1][32];
   40     double Factor, Clock[MAX_TEST_NR + 1], InlineClock[MAX_TEST_NR + 1];
   41     double s, si;
   42     int TestNo, NoCycles, Test, Cycle;
   43     clock_t BegClock, EndClock;
   44     size_t Dim, Ind;
   45     Boolean Help;
   46     QMatrix L;
   47     Real *aCmp, *bCmp, *cCmp;
   48     Vector a, b, c;
   49 
   50     OptTabType OptTab;
   51 
   52     /* initial message */
   53     fprintf(stderr, "lastest             Version %s\n", LASPACK_VERSION);
   54     fprintf(stderr, "                    (C) 1992-1995 Tomas Skalicky\n");
   55     fprintf(stderr, "                    Use option -h for help.\n");
   56 
   57     /* generate options table */
   58     OptTab.No = 3;
   59     OptTab.Descr = (OptDescrType *)malloc(OptTab.No * sizeof(OptDescrType));
   60     if (OptTab.Descr != NULL) {
   61         /* boolean option */
   62         OptTab.Descr[0].KeyChar = 'd';
   63         OptTab.Descr[0].Type = SizeOptType;
   64         OptTab.Descr[0].Variable = (void *)&Dim;
   65 
   66         /* int option */
   67         OptTab.Descr[1].KeyChar = 'c';
   68         OptTab.Descr[1].Type = IntOptType;
   69         OptTab.Descr[1].Variable = (void *)&NoCycles;
   70 
   71         /* option for help */
   72         OptTab.Descr[2].KeyChar = 'h';
   73         OptTab.Descr[2].Type = BoolOptType;
   74         OptTab.Descr[2].Variable = (void *)&Help;
   75 
   76         /* initialize variables with default values */
   77 #if defined(__MSDOS__) || defined(MSDOS)
   78         /* the most MS-DOS compilers use size_t of 16 bits size, which rescricts
   79        arrays to maximal 65536 / 8 = 8192 double elements */
   80     Dim = 1000;
   81 #else
   82         Dim = 10000;
   83 #endif      
   84         NoCycles = 10;
   85         Help = False;
   86 
   87         /* analyse options in the command line */
   88         GetOpts(&argc, argv, &OptTab);
   89         if (OptResult() == OptOK && !Help) {
   90             /* construction of vectors and matrix */
   91             V_Constr(&a, "a", Dim, Normal, True);
   92             V_Constr(&b, "b", Dim, Normal, True);
   93             V_Constr(&c, "c", Dim, Normal, True);
   94             Q_Constr(&L, "L", Dim, True, Rowws, Normal, True);
   95 
   96             printf("\n");
   97             printf("This program tests efficiency of basic operations implemented in LASPack.\n");
   98         fprintf(stderr, "\n");
   99 
  100             Factor = 1.0 / CLOCKS_PER_SEC / NoCycles;
  101             
  102             /* initialization random-number generator */
  103             srand(1);
  104 
  105             Test = 0;
  106 
  107             /* Test: vector constructor & dectructor */
  108 
  109             Test++;
  110             strncpy(Descr[Test], "vector constr. & destr.", 32);
  111             if (LASResult() == LASOK) {
  112             fprintf(stderr, ".");
  113 
  114                 BegClock = clock();
  115                 for(Cycle = 1; Cycle <= NoCycles; Cycle++) {
  116                     V_Destr(&a);
  117                     V_Constr(&a, "a", Dim, Normal, True);
  118                 }
  119                 EndClock = clock();
  120                 Clock[Test] = (double)(EndClock - BegClock) * Factor;
  121 
  122                 InlineClock[Test] = 0.0;
  123             }
  124 
  125             /* Test: generation of a vector */
  126 
  127             Test++;
  128             strncpy(Descr[Test], "vector generation", 32);
  129             if (LASResult() == LASOK) {
  130             fprintf(stderr, ".");
  131 
  132                 BegClock = clock();
  133                 for(Cycle = 1; Cycle <= NoCycles; Cycle++)
  134                     V_SetAllCmp(&a, 1.0);
  135                 EndClock = clock();
  136                 Clock[Test] = (double)(EndClock - BegClock) * Factor;
  137 
  138                 InlineClock[Test] = 0.0;
  139             }
  140 
  141             /* Test: matrix constructor & dectructor */
  142 
  143             Test++;
  144             strncpy(Descr[Test], "matrix constr. & destr.", 32);
  145             if (LASResult() == LASOK) {
  146             fprintf(stderr, ".");
  147     
  148                 BegClock = clock();
  149                 for(Cycle = 1; Cycle <= NoCycles; Cycle++) {
  150                     Q_Destr(&L);
  151                     Q_Constr(&L, "L", Dim, True, Rowws, Normal, True);
  152                 }
  153                 EndClock = clock();
  154                 Clock[Test] = (double)(EndClock - BegClock) * Factor;
  155 
  156                 InlineClock[Test] = 0.0;
  157             }
  158 
  159             /* Test: generating of L as a symmetric seven diagonal matrix */
  160 
  161             Test++;
  162             strncpy(Descr[Test], "matrix generation", 32);
  163             if (LASResult() == LASOK) {
  164             fprintf(stderr, ".");
  165 
  166                 BegClock = clock();
  167                 for(Cycle = 1; Cycle <= NoCycles; Cycle++)
  168                     GenMatr(&L);
  169                 EndClock = clock();
  170                 Clock[Test] = (double)(EndClock - BegClock) * Factor;
  171 
  172                 InlineClock[Test] = 0.0;
  173             }
  174 
  175             /* Test: a = b */
  176 
  177             Test++;
  178             strncpy(Descr[Test], "a = b", 32);
  179             if (LASResult() == LASOK) {
  180             fprintf(stderr, ".");
  181                 V_SetRndCmp(&b);
  182 
  183                 BegClock = clock();
  184                 for(Cycle = 1; Cycle <= NoCycles; Cycle++)
  185                     Asgn_VV(&a, &b);
  186                 EndClock = clock();
  187                 Clock[Test] = (double)(EndClock - BegClock) * Factor;
  188 
  189                 BegClock = clock();
  190                 for(Cycle = 1; Cycle <= NoCycles; Cycle++) {
  191                     aCmp = a.Cmp;
  192                     bCmp = b.Cmp;
  193                     for(Ind = 1; Ind <= Dim; Ind++) 
  194                         aCmp[Ind] = bCmp[Ind];
  195                 }
  196                 EndClock = clock();
  197                 InlineClock[Test] = (double)(EndClock - BegClock) * Factor;
  198             }
  199 
  200             /* Test: a = b + c */
  201 
  202             Test++;
  203             strncpy(Descr[Test], "a = b + c", 32);
  204             if (LASResult() == LASOK) {
  205             fprintf(stderr, ".");
  206                 V_SetRndCmp(&b);
  207                 V_SetRndCmp(&c);
  208 
  209                 BegClock = clock();
  210                 for(Cycle = 1; Cycle <= NoCycles; Cycle++)
  211                     Asgn_VV(&a, Add_VV(&b, &c));
  212                 EndClock = clock();
  213                 Clock[Test] = (double)(EndClock - BegClock) * Factor;
  214 
  215                 BegClock = clock();
  216                 for(Cycle = 1; Cycle <= NoCycles; Cycle++) {
  217                     aCmp = a.Cmp;
  218                     bCmp = b.Cmp;
  219                     cCmp = c.Cmp;
  220                     for(Ind = 1; Ind <= Dim; Ind++)
  221                         aCmp[Ind] = bCmp[Ind] + cCmp[Ind];
  222                 }
  223                 EndClock = clock();
  224                 InlineClock[Test] = (double)(EndClock - BegClock) * Factor;
  225             }
  226 
  227             /* Test: a = s * b */
  228 
  229             Test++;
  230             strncpy(Descr[Test], "a = s * b", 32);
  231             if (LASResult() == LASOK) {
  232             fprintf(stderr, ".");
  233                 V_SetRndCmp(&b);
  234                 s = 3.141592;
  235 
  236                 BegClock = clock();
  237                 for(Cycle = 1; Cycle <= NoCycles; Cycle++)
  238                     Asgn_VV(&a, Mul_SV(s, &b));
  239                 EndClock = clock();
  240                 Clock[Test] = (double)(EndClock - BegClock) * Factor;
  241 
  242                 BegClock = clock();
  243                 for(Cycle = 1; Cycle <= NoCycles; Cycle++) {
  244                     aCmp = a.Cmp;
  245                     bCmp = b.Cmp;
  246                     for(Ind = 1; Ind <= Dim; Ind++)
  247                         aCmp[Ind] = s * bCmp[Ind];
  248                 }    
  249                 EndClock = clock();
  250                 InlineClock[Test] = (double)(EndClock - BegClock) * Factor;
  251             }
  252 
  253             /* Test: s = b * c */
  254 
  255             Test++;
  256             strncpy(Descr[Test], "s = b * c", 32);
  257             if (LASResult() == LASOK) {
  258             fprintf(stderr, ".");
  259                 V_SetRndCmp(&b);
  260                 V_SetRndCmp(&c);
  261 
  262                 BegClock = clock();
  263                 for(Cycle = 1; Cycle <= NoCycles; Cycle++) 
  264                     s = Mul_VV(&b, &c);
  265                 EndClock = clock();
  266                 Clock[Test] = (double)(EndClock - BegClock) * Factor;
  267 
  268                 BegClock = clock();
  269                 for(Cycle = 1; Cycle <= NoCycles; Cycle++) {
  270                     bCmp = b.Cmp;
  271                     cCmp = c.Cmp;
  272                     s = 0.0;
  273                     for(Ind = 1; Ind <= Dim; Ind++)
  274                         s += bCmp[Ind] * cCmp[Ind];
  275                     /* to avoid undesirable optimization */
  276                     sqrt(s);
  277                 }
  278                 EndClock = clock();
  279                 InlineClock[Test] = (double)(EndClock - BegClock) * Factor;
  280             }
  281 
  282             /* Test: a = L * b */
  283 
  284             Test++;
  285             strncpy(Descr[Test], "a = L * b", 32);
  286             if (LASResult() == LASOK) {
  287             fprintf(stderr, ".");
  288                 V_SetRndCmp(&b);
  289                 /* first operation of this type causes the allocation
  290                    of diagonal elements */
  291                 Asgn_VV(&a, Mul_QV(&L, &b)); 
  292 
  293                 BegClock = clock();
  294                 for(Cycle = 1; Cycle <= NoCycles; Cycle++)
  295                     Asgn_VV(&a, Mul_QV(&L, &b));
  296                 EndClock = clock();
  297                 Clock[Test] = (double)(EndClock - BegClock) * Factor;
  298 
  299                 BegClock = clock();
  300                 for(Cycle = 1; Cycle <= NoCycles; Cycle++) 
  301                     Asgn_VV(&a, SimpleMul_QV(&L, &b));
  302                 EndClock = clock();
  303                 InlineClock[Test] = (double)(EndClock - BegClock) * Factor;
  304             }
  305 
  306             /* Test: a += b */
  307 
  308             Test++;
  309             strncpy(Descr[Test], "a = a + b", 32);
  310             if (LASResult() == LASOK) {
  311             fprintf(stderr, ".");
  312                 V_SetRndCmp(&a);
  313                 V_SetRndCmp(&b);
  314 
  315                 BegClock = clock();
  316                 for(Cycle = 1; Cycle <= NoCycles; Cycle++)
  317                     AddAsgn_VV(&a, &b);
  318                 EndClock = clock();
  319                 Clock[Test] = (double)(EndClock - BegClock) * Factor;
  320 
  321                 BegClock = clock();
  322                 for(Cycle = 1; Cycle <= NoCycles; Cycle++) {
  323                     aCmp = a.Cmp;
  324                     bCmp = b.Cmp;
  325                     for(Ind = 1; Ind <= Dim; Ind++)
  326                          aCmp[Ind] += bCmp[Ind];
  327                 }
  328                 EndClock = clock();
  329                 InlineClock[Test] = (double)(EndClock - BegClock) * Factor;
  330             }
  331 
  332             /* Test: a *= s */
  333 
  334             Test++;
  335             strncpy(Descr[Test], "a = s * a", 32);
  336             if (LASResult() == LASOK) {
  337             fprintf(stderr, ".");
  338                 V_SetRndCmp(&a);
  339                 s = 3.141592;
  340                 si = 1.0 / s;
  341 
  342                 BegClock = clock();
  343                 for(Cycle = 1; Cycle <= NoCycles; Cycle++)
  344             if (Cycle % 2 == 0)
  345                         MulAsgn_VS(&a, s);
  346             else
  347                         MulAsgn_VS(&a, si);
  348                 EndClock = clock();
  349                 Clock[Test] = (double)(EndClock - BegClock) * Factor;
  350 
  351                 BegClock = clock();
  352                 for(Cycle = 1; Cycle <= NoCycles; Cycle++) {
  353                     aCmp = a.Cmp;
  354             if (Cycle % 2 == 0)
  355                         for(Ind = 1; Ind <= Dim; Ind++)
  356                             aCmp[Ind] *= s;
  357             else
  358                         for(Ind = 1; Ind <= Dim; Ind++)
  359                             aCmp[Ind] *= si;
  360                 }
  361                 EndClock = clock();
  362                 InlineClock[Test] = (double)(EndClock - BegClock) * Factor;
  363             }
  364 
  365             /* Test: a = b + s * c */
  366     
  367             Test++;
  368             strncpy(Descr[Test], "a = b + s * c", 32);
  369             if (LASResult() == LASOK) {
  370             fprintf(stderr, ".");
  371                 V_SetRndCmp(&a);
  372                 V_SetRndCmp(&b);
  373                 V_SetRndCmp(&c);
  374                 s = 3.141592;
  375 
  376                 BegClock = clock();
  377                 for(Cycle = 1; Cycle <= NoCycles; Cycle++)
  378                     Asgn_VV(&a, Add_VV(&b, Mul_SV(s, &c)));
  379                 EndClock = clock();
  380                 Clock[Test] = (double)(EndClock - BegClock) * Factor;
  381 
  382                 BegClock = clock();
  383                 for(Cycle = 1; Cycle <= NoCycles; Cycle++) {
  384                     aCmp = a.Cmp;
  385                     bCmp = b.Cmp;
  386                     cCmp = c.Cmp;
  387                     for(Ind = 1; Ind <= Dim; Ind++)
  388                          aCmp[Ind] = bCmp[Ind] + s * cCmp[Ind];
  389                 }
  390                 EndClock = clock();
  391                 InlineClock[Test] = (double)(EndClock - BegClock) * Factor;
  392             }
  393 
  394             /* Test: a += s * b */
  395 
  396             Test++;
  397             strncpy(Descr[Test], "a = a + s * b", 32);
  398             if (LASResult() == LASOK) {
  399             fprintf(stderr, ".");
  400                 V_SetRndCmp(&a);
  401                 V_SetRndCmp(&b);
  402                 s = 3.141592;
  403 
  404                 BegClock = clock();
  405                 for(Cycle = 1; Cycle <= NoCycles; Cycle++)
  406                     AddAsgn_VV(&a, Mul_SV(s, &b));
  407                 EndClock = clock();
  408                 Clock[Test] = (double)(EndClock - BegClock) * Factor;
  409 
  410                 BegClock = clock();
  411                 for(Cycle = 1; Cycle <= NoCycles; Cycle++) {
  412                     aCmp = a.Cmp;
  413                     bCmp = b.Cmp;
  414                     for(Ind = 1; Ind <= Dim; Ind++)
  415                         aCmp[Ind] += s * bCmp[Ind];
  416                 }
  417                 EndClock = clock();
  418                 InlineClock[Test] = (double)(EndClock - BegClock) * Factor;
  419             }
  420 
  421             fprintf(stderr, "\n");
  422             TestNo = Test;
  423 
  424             /* output of results */
  425 
  426             if (LASResult() == LASOK) {
  427                 printf("\n");
  428                 printf("Results:    (for dimension %lu, cycles %d)\n",
  429                     (unsigned long)Dim, NoCycles);
  430                 printf("--------\n\n");
  431                 printf("   #    with LASPack  in-line code  efficiency     ");
  432                 printf("description\n");
  433                 printf("---------------------------------------------------");
  434                 printf("-----------------------\n");
  435                 for (Test = 1; Test <= TestNo; Test++) {
  436                     if (Clock[Test] > 1e-5 && InlineClock[Test] > 1e-5)
  437                         printf("  %2d  %10.5f s   %10.5f s    %6.2f %%    ",
  438                                Test, Clock[Test], InlineClock[Test],
  439                                100.0 * InlineClock[Test] / Clock[Test]);
  440                     if (Clock[Test] <= 1e-5 && InlineClock[Test] > 1e-5)
  441                         printf("  %2d       ---       %10.5f s      ---       ",
  442                                Test, InlineClock[Test]);
  443                     if (Clock[Test] > 1e-5 && InlineClock[Test] <= 1e-5)
  444                         printf("  %2d  %10.5f s        ---          ---       ",
  445                                Test, Clock[Test]);
  446                     if (Clock[Test] <= 1e-5 && InlineClock[Test] <= 1e-5)
  447                         printf("  %2d       ---            ---          ---       ",
  448                                Test);
  449                     printf("%s\n", Descr[Test]);
  450                 }
  451                 printf("---------------------------------------------------");
  452                 printf("-----------------------\n\n");
  453                 printf("where s is a scalar, a, b, c are vectors, and L is a matrix.\n");
  454         printf("The inline routines are in comparison with LASPack simplified and\n");
  455         printf("can be therefore a little faster.\n");
  456             }
  457 
  458             /* LASPack error messages */
  459             if (LASResult() != LASOK) {
  460                 fprintf(stderr, "\n");
  461                 fprintf(stderr, "LASPack error: ");
  462                 WriteLASErrDescr(stderr);     
  463             }
  464 
  465             /* destruction of vectors and matrix */
  466             V_Destr(&a);
  467             V_Destr(&b);
  468             V_Destr(&c);
  469             Q_Destr(&L);
  470         } else {
  471             /* error messages */
  472             if (OptResult() == OptNotDefErr || OptResult() == OptSyntaxErr || Help) {
  473                 fprintf(stderr, "\n");
  474                 PrintHelp();
  475             }
  476             if (OptResult() == OptDescrErr) {
  477                 fprintf(stderr, "\n");
  478                 fprintf(stderr, "Description of an option faulty.\n");
  479             }
  480         }
  481         
  482         if (OptTab.Descr != NULL)
  483             free(OptTab.Descr);
  484     } else {
  485         /* error message */
  486         fprintf(stderr, "\n");
  487         fprintf(stderr, "Not enought memory for analysis of command line options.\n");
  488     }
  489     
  490     return(0);
  491 }
  492 
  493 static void GenMatr(QMatrix *Q)
  494 /* generate matrix Q with a given number of subdiagonals 
  495    for both triangular parts of the matrix */
  496 {
  497     size_t NoSubdiag = 3;
  498 
  499     size_t Dim, RoC, Len1, Len2, Entry, Subdiag, Pos;
  500     Boolean Symmetry;
  501     ElOrderType ElOrder;
  502 
  503     if (LASResult() == LASOK) {
  504         Dim = Q_GetDim(Q);
  505     Symmetry = Q_GetSymmetry(Q);
  506     ElOrder = Q_GetElOrder(Q);
  507         for (RoC = 1; RoC <= Dim; RoC++) {
  508             if (RoC + NoSubdiag <= Dim)
  509             Len1 = NoSubdiag;
  510         else
  511             Len1 = Dim - RoC;
  512         if (RoC > NoSubdiag)
  513             Len2 = NoSubdiag;
  514         else
  515             Len2 = RoC - 1;
  516         if (Symmetry) {
  517             if (ElOrder == Rowws)
  518             Q_SetLen(Q, RoC, Len1 + 1);
  519             if (ElOrder == Clmws)
  520             Q_SetLen(Q, RoC, Len2 + 1);
  521         } else {
  522             Q_SetLen(Q, RoC, Len1 + Len2 + 1);
  523         }
  524             if (LASResult() == LASOK) {
  525             /* main diagonal entry */
  526             Entry = 0;
  527         Q__SetEntry(Q, RoC, Entry, RoC, 1.0);
  528         /* entries for subdiagonals in both triagonal parts */
  529             for (Subdiag = 1; Subdiag <= NoSubdiag ; Subdiag++) {
  530             Pos = RoC + Subdiag;
  531                 if ((!Symmetry || (ElOrder == Rowws)) && Pos <= Dim) {
  532                 Entry++;
  533                     Q__SetEntry(Q, RoC, Entry, Pos, 1.0);
  534             }
  535                 if ((!Symmetry || (ElOrder == Clmws)) && RoC > Subdiag) {
  536                 Pos = RoC - Subdiag;
  537                     Entry++;
  538                         Q__SetEntry(Q, RoC, Entry, Pos, 1.0);
  539                 }
  540         }
  541         }
  542     }
  543     }
  544 }
  545 
  546 static Vector *SimpleMul_QV(QMatrix *Q, Vector *V)
  547 /* simple multiplikation matrix by vector, multipliers are not used.
  548    VRes = Q * V */
  549 {
  550     Vector *VRes;
  551 
  552     char *VResName;
  553     size_t Dim, Row, Clm, Len, ElCount;
  554     size_t *QLen;
  555     ElType *PtrEl, **QEl,**QDiagEl;
  556     Real *VCmp, *VResCmp;
  557     Real El;
  558 
  559     if (LASResult() == LASOK) {
  560     if (Q->Dim == V->Dim) {
  561         Dim = V->Dim;
  562         VRes = (Vector *)malloc(sizeof(Vector));
  563         VResName = (char *)malloc((strlen(Q_GetName(Q)) + strlen(V_GetName(V)) + 10)
  564                    * sizeof(char));
  565             if (VRes != NULL && VResName != NULL) {
  566             sprintf(VResName, "(%s) * (%s)", Q_GetName(Q), V_GetName(V));
  567         V_Constr(VRes, VResName, Dim, Tempor, True);
  568                 
  569                 /* allocation of diagonal elements of matrix Q */
  570                 Q_SortEl(Q);
  571                 Q_AllocInvDiagEl(Q);
  572 
  573         if (LASResult() == LASOK) {
  574                     /* initialisation of vector VRes */
  575                     V_SetAllCmp(VRes, 0.0);
  576                     
  577                     /* seting local variables */
  578                     VCmp = V->Cmp;
  579                     VResCmp = VRes->Cmp;
  580                     QLen = Q->Len;
  581                     QEl = Q->El;
  582                     QDiagEl = Q->DiagEl;
  583                     
  584                     /* multiplikation matrix Q by vector V */
  585                     if (Q->Symmetry && Q->ElOrder == Rowws) {
  586                         for (Row = 1; Row <= Dim; Row++) {
  587                             VResCmp[Row] += (*QDiagEl[Row]).Val * VCmp[Row];
  588                             Len = QLen[Row];
  589                             PtrEl = QEl[Row] + 1;
  590                             for (ElCount = Len - 1; ElCount > 0; ElCount--) {
  591                                 El = (*PtrEl).Val;
  592                                 Clm = (*PtrEl).Pos;
  593                                 VResCmp[Row] += El * VCmp[Clm];
  594                                 VResCmp[Clm] += El * VCmp[Row];
  595                                 PtrEl++;
  596                             }
  597                         }
  598             }
  599                     if (Q->Symmetry && Q->ElOrder == Clmws) {
  600             for (Clm = 1; Clm <= Dim; Clm++) {
  601                             VResCmp[Clm] += (*QDiagEl[Clm]).Val * VCmp[Clm];
  602                             Len = QLen[Clm];
  603                             PtrEl = QEl[Clm];
  604                             for (ElCount = Len - 1; ElCount > 0; ElCount--) {
  605                                 El = (*PtrEl).Val;
  606                                 Row = (*PtrEl).Pos;
  607                                 VResCmp[Row] += El * VCmp[Clm];
  608                                 VResCmp[Clm] += El * VCmp[Row];
  609                                 PtrEl++;
  610                             }
  611                         }
  612                     }
  613                     if (!Q->Symmetry && Q->ElOrder == Rowws) {
  614             for (Row = 1; Row <= Dim; Row++) {
  615                             Len = QLen[Row];
  616                             PtrEl = QEl[Row];
  617                             for (ElCount = Len; ElCount > 0; ElCount--) {
  618                                 El = (*PtrEl).Val;
  619                                 Clm = (*PtrEl).Pos;
  620                                 VResCmp[Row] += El * VCmp[Clm];
  621                                 PtrEl++;
  622                             }
  623                         }
  624             }
  625                     if (!Q->Symmetry && Q->ElOrder == Clmws) {
  626             for (Clm = 1; Clm <= Dim; Clm++) {
  627                             Len = QLen[Clm];
  628                             PtrEl = QEl[Clm];
  629                             for (ElCount = Len; ElCount > 0; ElCount--) {
  630                                 El = (*PtrEl).Val;
  631                                 Row = (*PtrEl).Pos;
  632                                 VResCmp[Row] += El * VCmp[Clm];
  633                                 PtrEl++;
  634                             }
  635             }
  636             }
  637                 }
  638         } else {
  639         LASError(LASMemAllocErr, "SimpleMul_QV", Q_GetName(Q), V_GetName(V), NULL);
  640         if (VRes != NULL)
  641             free(VRes);
  642         if (VResName != NULL)
  643             free(VResName);
  644             }
  645     } else {
  646         LASError(LASDimErr, "SimpleMul_QV", Q_GetName(Q), V_GetName(V), NULL);
  647         VRes = NULL;
  648     }
  649     } else {
  650         VRes = NULL;
  651     }
  652     /* DestrFree4Tempor_Q(Q) */
  653     if (Q != NULL) {
  654     if (Q->Instance == Tempor) {
  655         Q_Destr(Q);
  656         free(Q);
  657     }
  658     }
  659     /* DestrFree4Tempor_V(V) */
  660     if (V != NULL) {
  661     if (V->Instance == Tempor) {
  662         V_Destr(V);
  663         free(V);
  664     }
  665     }
  666     return(VRes);
  667 }
  668 
  669 static void PrintHelp(void)
  670 /* print help for syntax and avaible options */
  671 {
  672     fprintf(stderr, "Syntax:\n");
  673     fprintf(stderr, "  lastest [-d<dim>] [-c<cycles>] [-h]\n\n");
  674     fprintf(stderr, "Options:\n");
  675     fprintf(stderr, "  -d  set vector and matrix dimensions to <dim>, default is %lu\n",
  676 #if defined(__MSDOS__) || defined(MSDOS)
  677         (unsigned long)1000);
  678 #else
  679             (unsigned long)10000);
  680 #endif      
  681     fprintf(stderr, "  -c  set number of cycles to <cycles>, default is 10\n");
  682     fprintf(stderr, "  -h  print this help\n");
  683 }