/**************************************************************************/
/*                                                                        */
/*                                 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: t_tnct.c,v 1.2 1997/09/25 18:24:21 ae59 Exp $ */
/*
$Log: t_tnct.c,v $
 * Revision 1.2  1997/09/25  18:24:21  ae59
 * Copyright-message
 *
 * Revision 1.1  1994/01/27  13:25:52  ae59
 * Put under RCS control
 *
 */
#ifdef AIX
#include "/u/p88c/runtime/tbyte/t_defs.h"
#else
#include "t_defs.h"
#endif

/*--------------------------------------------------------------*/
/* tancot                                                       */
/*--------------------------------------------------------------*/
#ifdef ANSI_C
#ifdef LINT_ARGS
int tancot(const ExtReal *arg, int jmod4, ExtReal *res)
#else
int tancot(arg, jmod4, res)
const ExtReal  *arg;    /* reduziertes Argument                 */
      int      jmod4;   /* j modulo 4                           */
      ExtReal  *res;    /* Ergebnis                             */
#endif /* LINT_ARGS */
#else  /* NOT ANSI_C */
#ifdef LINT_ARGS
int tancot(ExtReal *arg, int jmod4, ExtReal *res)
#else
int tancot(arg, jmod4, res)
ExtReal  *arg;          /* reduziertes Argument                 */
int      jmod4;         /* j modulo 4                           */
ExtReal  *res;          /* Ergebnis                             */
#endif /* LINT_ARGS */
#endif /* ANSI_C */
{
   ExtReal     t;       /* -pi/4 <= Argument t <= pi/4          */
   ExtReal     rn;      /* Ergebnis Numerator                   */
   ExtReal     rd;      /* Ergebnis Denominator                 */
   int         rnd;     /* RundungsMode                         */
   int         ret;     /* Rueckgabe                            */

   /* --- RundungsMode sichern, NEAR setzen --- */
   rnd  = getrndmode();
   setrndmode(NEAR);

   /* --- arg*Pi/4 --- */
   mulee(arg, &PiQuart, &t);
   ret = _s_tan(&t, &rn, &rd);

   /* --- cot = rd/rn --- */
   if(jmod4==1||jmod4==2)
      divee(&rd, &rn, res);
   /* --- tan = rn/rd --- */
   else
      divee(&rn, &rd, res);

   /* --- RundungsMode zuruecksetzen --- */
   setrndmode(rnd);

   return ret;
} /* tancot() */
