Main Page   Data Structures   File List   Data Fields   Globals  

divser.c

Go to the documentation of this file.
00001 /*******************************************************************************
00002  RTN DIVSER: Divide one series by another; subtract if one goes negative
00003 
00004   Programmed copyright (C) AUG 1982 by
00005   Richard L Holmes, Lab. de Dendrocronologia, CRICYT - Mendoza - Argentina
00006   Modified copyright (C) 18 JUN 1998
00007 
00008   Divides array RM by array CV, both of length N, to produce array RZ.
00009   If RM has negative values or CV is not entirely positive,
00010   CV is subtracted from RM and a constant of 1.0 is added.
00011 
00012 ********************************************************************************/
00013 
00014 void DIVSER(int N, float *RM, float *CV, float *RZ)
00015 {
00016     int i;
00017     float BRM, BCV, AV;
00018 
00019     /* Find minimum values in RM and CV arrays */
00020     BRM = 1.0;
00021     BCV = 1.0;
00022     for(i = 0; i < N; i++)
00023     {
00024         BRM = (RM[i] < BRM? RM[i]: BRM);
00025         BCV = (CV[i] < BCV? CV[i]: BCV);
00026     }
00027 
00028     /* Subtract if minimum in RM is negative or minimum in CV is zero or negative */
00029     if (BRM < 0.0 || BCV <= 0.0)
00030     {
00031         BRM = 0.0;
00032         AV = 0.0;
00033         for(i = 0; i < N; i++)
00034         {
00035             RZ[i] = RM[i] - CV[i] + 1.0;
00036             AV = AV + RZ[i];
00037             BRM = (RZ[i] < BRM? RZ[i]: BRM);
00038         }
00039         AV = AV/(float)N;
00040         
00041         if (BRM < 0.0)
00042         {
00043             AV = 0.0;
00044             for(i = 0; i < N; i++)
00045             {
00046                 RZ[i] = RZ[i] - BRM;
00047                 AV = AV + RZ[i];
00048             }
00049             AV = AV/(float)N;
00050         }
00051         
00052         for(i = 0; i < N; i++)
00053             RZ[i] = RZ[i]/AV;
00054     }
00055     else /* Divide series RM by CV to yield RZ */
00056     {
00057         for(i = 0; i < N; i++)
00058             RZ[i] = RM[i]/CV[i];
00059     }
00060 
00061     return;
00062 }

Generated on Wed Apr 9 08:56:05 2003 for TREES by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002