/**************************************************************************/
/*                                                                        */
/*                                 Sources                                */
/*                                from  the                               */
/*                           XSC SOFTWARE PACKAGE                         */
/*                                                                        */
/*                Copyright (c) 1997 University of Karlsruhe              */
/*                     Institute for Appl. Mathematics                    */
/*                                                                        */
/* This program is free software for non-commercial use. For details, see */
/* the file LICENSE.XSC, distributed with this software package.          */
/*                                                                        */
/* This program is distributed WITHOUT ANY WARRANTY. For details, see the */
/* file LICENSE.XSC, distributed with this software package.              */
/*                                                                        */
/**************************************************************************/

/* RCS $Id: r_scps.c,v 1.2 1997/09/25 17:50:09 ae59 Exp $ */
/*
$Log: r_scps.c,v $
 * Revision 1.2  1997/09/25  17:50:09  ae59
 * Copyright-message
 *
 * Revision 1.1  1994/01/27  13:24:11  ae59
 * Put under RCS control
 *
 */
/****************************************************************/
/*                                                              */
/*      Filename        : r_scps.c                              */
/*                                                              */
/*      Entries         : a_real r_scps(r,s,n,rnd)              */
/*                        a_real r[];                           */
/*                        a_real s[];                           */
/*                        a_intg n;                             */
/*                        a_intg rnd;                           */
/*                                                              */
/*      Arguments       : n   = size of arrays r and s          */
/*                        r   = real vector                     */
/*                        s   = real vector                     */
/*                        rnd = rounding mode                   */
/*                              +1 rounding upwards             */
/*                               0 round to nearest             */
/*                              -1 rounding downwards           */
/*                          addition of 4 does not clear accu   */
/*                                                              */
/*      Function value  : Rounded real dotproduct               */
/*                                                              */
/*      Description     : Dotproduct for static real arrays     */
/*                        with directed rounding                */
/*                                                              */
/*      Date            : 1991-01-22                            */
/*      1991-01-22 : VAX_VMS_C considered                       */
/*      1990-11-22 : E_TPUSH+E_TPOPP                            */
/*      1990-10-31 : force linkage of global variables          */
/*      1990-07-16 : LINT_ARGS prototype                        */
/****************************************************************/

#ifndef ALL_IN_ONE
#ifdef AIX
#include "/u/p88c/runtime/o_defs.h"
#else
#include "o_defs.h"
#endif
#define local
extern dotprecision b_acrl;
#endif

#ifdef LINT_ARGS
local a_real r_scps(a_real r[],a_real s[],a_intg n,a_intg rnd)
#else
local a_real r_scps(r,s,n,rnd)

a_real r[];
a_real s[];
a_intg n;
a_intg rnd;
#endif
        {
        a_intg i;
        a_real res;

        E_TPUSH("r_scps")

        /* force linkage of module containing global variables only */
#if VAX_VMS_C
        b_accu();
#endif

        if (rnd<3)
           {
           d_clr(&b_acrl);
           }

        for (i=0;i<n;i++)
           d_padd(&b_acrl,r[i],s[i]);

        if (rnd==0)     res = d_stan(b_acrl);
        else if (rnd>0) res = d_stau(b_acrl);
        else            res = d_stad(b_acrl);

        E_TPOPP("r_scps")
        return(res);
        }

