/*

-Procedure sumad_c ( Sum of a double precision array )

-Abstract
 
    Return the sum of the elements of a double precision array. 
 
-Disclaimer

   THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
   CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
   GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
   ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
   PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
   TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
   WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
   PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
   SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
   SOFTWARE AND RELATED MATERIALS, HOWEVER USED.

   IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
   BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
   LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
   INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
   REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
   REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.

   RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
   THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
   CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
   ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.

-Required_Reading
 
   None. 
 
-Keywords
 
    ARRAY,  MATH,  UTILITY 
 
*/

   #include "SpiceUsr.h"
   #undef    sumad_c
   
   
   SpiceDouble sumad_c ( ConstSpiceDouble   * array,
                         SpiceInt             n     ) 

/*

-Brief_I/O
 
    VARIABLE  I/O  DESCRIPTION 
    --------  ---  -------------------------------------------------- 
    array      I   Input array. 
    n          I   Number of elements in the array. 

    The function returns the sum of the elements of the input array. 
 
-Detailed_Input
 
    array       is the input array. 
 
    n           is the number of elements in the array. 
 
-Detailed_Output
 
    The function returns the sum of the elements of the input array. 
    That is, 
 
       sumad_c ( array, n )  =  array[0] + array[1] + ... + array[n-1] 
 
    If n is zero or negative, sumad_c returns zero. 
 
-Parameters
 
   None. 
 
-Particulars
 
    The value of the function is initially set to zero. The elements 
    of the array are then added. If the number of elements is 
    zero or negative, sumad_c is zero. 
 
-Examples
 
    Let array contain the following elements. 
 
          array[0] = 12. 
          array[1] =  1. 
          array[2] =  4. 
          array[3] = 75. 
          array[4] = 18. 
 
    Then 
 
          sumad_c ( array,   -3 )       =   0. 
          sumad_c ( array,    0 )       =   0. 
          sumad_c ( array,    1 )       =  12. 
          sumad_c ( array,    2 )       =  13. 
          sumad_c ( array,    5 )       = 110. 
          sumad_c ( array+2,  3 )       =  97. 
 
 
-Restrictions
 
    sumad_c does not check for overflow. 
 
-Exceptions
 
    Error free. 
 
-Files
 
    None. 
 
-Author_and_Institution
 
    N.J. Bachman    (JPL) 
    I.M. Underwood  (JPL) 
 
-Literature_References
 
    None. 
 
-Version
 
   -CSPICE Version 1.0.0, 24-MAR-1999 (IMU) (NJB)

-Index_Entries
 
   sum of a d.p. array 
 
-&
*/

{ /* Begin sumad_c */

   /*
   Local variables
   */
   SpiceDouble             retval;
   
   SpiceInt                i;



   retval = 0.;
   
   for ( i = 0;  i < n;  i++  )
   {
      retval += array[i];
   }

   return ( retval );
   
   
} /* End sumad_c */
