"SfR Fresh" - the SfR Freeware/Shareware Archive

Member "ocre-0.029/ocre/src/aplica.c" of archive ocre_v0_029.tgz:


As a special service "SfR Fresh" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. That can be also achieved for any archive member file by clicking within an archive contents listing on the first character of the file(path) respectively on the according byte size field.
    1 
    2 #include <stdlib.h>
    3 
    4 #include "imag.h"
    5 
    6 /* Aplica f sobre un entorno de tamaņo d del vector me
    7  * y deja el resultado en el vector ms
    8  * En los extremos repite el valor limpio
    9  */
   10 void aplicaVv (int me[], int ms[], int d, int vs, int fn(int *, int))
   11 {
   12   int i;
   13   for (i=vs; i<d-vs; i++)
   14     ms[i] = fn(& me[i-vs], 2*vs+1);
   15   for (i=0; i<vs; i++)
   16     ms[i] = ms[vs] ;
   17   for (i=d-vs; i<d; i++)
   18     ms[i] = ms[d-vs-1] ;
   19 }
   20 
   21 /* Aplica f sobre un entorno de tamaņo d del vector me
   22  * y deja el resultado en el vector ms
   23  * Amplia me con vs valores por la izquierda y derecha
   24  * repitiendo primer y ultimo valor.
   25  */
   26 void aplicaV (int me[], int ms[], int d, int vs, int fn(int *, int))
   27 {
   28   int i;
   29   int * mt;
   30   mt = (int *) malloc ((d + 2*vs) * sizeof (int)) ;
   31   for (i=0; i<vs; i++)
   32     mt[i] = me[0];
   33   for (i=0; i<d; i++)
   34     mt[i+vs] = me[i];
   35   for (i=0; i<vs; i++)
   36     mt[vs+d+i] = me[d-1];
   37   for (i=0; i<d; i++)
   38     ms[i] = fn(& mt[i], 2*vs+1);
   39   free (mt);
   40 }
   41 
   42 void aplicaVvents (tvvents vvents, void fn(tvent))
   43 {
   44   int i, n;
   45   n = vvents->n;
   46   for (i=0; i<n; i++)
   47     fn (vvents->ventanas[i]);
   48 }
   49 
   50 void aplicaLvents (lista lvint, void fn(tvent))
   51 {
   52   tnodol nodol;
   53   for (nodol = lvint->primero; nodol != (tnodol)0L; nodol = nodol->siguiente)
   54     fn ((tvent) nodol->aitem);
   55 }
   56 
   57 void aplicaLventsHojRecurN (tvent vent, int n, void fn(tvent))
   58 {
   59   if ( vent->lvint == (lista) 0L)
   60     fn (vent);
   61   else
   62     if (n > 0) {
   63       tnodol nodol;
   64       for (nodol = vent->lvint->primero; nodol != (tnodol)0L; nodol = nodol->siguiente)
   65         aplicaLventsHojRecurN ((tvent) nodol->aitem, n-1, fn );
   66       }
   67 }
   68 
   69 void aplicaLventsRecurN (tvent vent, int n, void fn(tvent))
   70 {
   71   fn (vent);
   72   if ( vent->lvint != (lista) 0L )
   73     if (n > 0) {
   74       tnodol nodol;
   75       for (nodol = vent->lvint->primero; nodol != (tnodol)0L; nodol = nodol->siguiente)
   76         aplicaLventsRecurN ((tvent) nodol->aitem, n-1, fn );
   77       }
   78 }
   79