/**************************************************************************/
/*                                                                        */
/*                                 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: b_biv2.c,v 1.2 1997/09/25 16:58:21 ae59 Exp $ */
/*
$Log: b_biv2.c,v $
 * Revision 1.2  1997/09/25  16:58:21  ae59
 * Copyright-message
 *
 * Revision 1.1  1994/01/27  13:21:07  ae59
 * Put under RCS control
 *
 */
/****************************************************************/
/*                                                              */
/*      Filename        : b_biv2.c                              */
/*                                                              */
/*      Entries         : a_btyp b_biv2(func,a1,a2,rlb,rub)     */
/*                        int (*func)();                        */
/*                        a_real a1, a2, *rlb, *rub             */
/*                                                              */
/*      Arguments       : func = function to be evaluated for   */
/*                               given real arguments a1,a2     */
/*                        a1,a2= arguments of function          */
/*                        rlb  = lower bound of the result      */
/*                        rub  = upper bound of the result      */
/*                                                              */
/*      Function value  : function dependent return code.       */
/*                                                              */
/*      Description     : evaluate bounds for a function        */
/*                        of two real arguments                 */
/*                                                              */
/*      Date            : 1991-01-08                            */
/*      1991-01-08 : b_rtol() with rounding argument            */
/****************************************************************/

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

#ifdef LINT_ARGS
local a_btyp b_biv2(int (*func)(multiprecision,
                                  multiprecision,multiprecision),
                      a_real a1, a_real a2, a_real *rlb, a_real *rub)
#else
local a_btyp b_biv2(func, a1, a2, rlb, rub)

int (*func)();
a_real a1;
a_real a2;
a_real *rlb;
a_real *rub;
#endif
        {
        a_intg code;
        multiprecision l_a1,l_a2,l_res;
        a_btyp rc;
        a_btyp Oldb_maxl;
        a_intg down = -1, up = 1;

        l_init(&l_a1);
        l_init(&l_a2);
        l_init(&l_res);

        if (b_rtol(a1,&l_a1,down)) return(ALLOCATION);
        if (b_rtol(a2,&l_a2,up)) return(ALLOCATION);

        Oldb_maxl = b_maxl;
        b_maxl = 3;

        code = (*func)(l_a1,l_a2,l_res);

        b_maxl = Oldb_maxl;

        rc = b_ltor(l_res,rlb,down);
        rc += b_ltor(l_res,rub,up);

        l_free(&l_a1);
        l_free(&l_a2);
        l_free(&l_res);

        return((code)?(a_btyp)code:rc);
        }
