Blame sysdeps/ieee754/dbl-64/mpatan2.c

Packit 6c4009
/*
Packit 6c4009
 * IBM Accurate Mathematical Library
Packit 6c4009
 * written by International Business Machines Corp.
Packit 6c4009
 * Copyright (C) 2001-2018 Free Software Foundation, Inc.
Packit 6c4009
 *
Packit 6c4009
 * This program is free software; you can redistribute it and/or modify
Packit 6c4009
 * it under the terms of the GNU Lesser General Public License as published by
Packit 6c4009
 * the Free Software Foundation; either version 2.1 of the License, or
Packit 6c4009
 * (at your option) any later version.
Packit 6c4009
 *
Packit 6c4009
 * This program is distributed in the hope that it will be useful,
Packit 6c4009
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 6c4009
 * GNU Lesser General Public License for more details.
Packit 6c4009
 *
Packit 6c4009
 * You should have received a copy of the GNU Lesser General Public License
Packit 6c4009
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
Packit 6c4009
 */
Packit 6c4009
/******************************************************************/
Packit 6c4009
/*  MODULE_NAME: mpatan2.c                                        */
Packit 6c4009
/*                                                                */
Packit 6c4009
/*  FUNCTIONS:mpatan2                                             */
Packit 6c4009
/*                                                                */
Packit 6c4009
/*  FILES NEEDED: mpa.h                                           */
Packit 6c4009
/*                mpa.c mpatan.c mpsqrt.c                         */
Packit 6c4009
/*                                                                */
Packit 6c4009
/* Multi-Precision Atan2(y,x) function subroutine,                */
Packit 6c4009
/* for precision p >= 4.                                          */
Packit 6c4009
/* y=0 is not permitted if x<=0. No error messages are given.     */
Packit 6c4009
/* The relative error of the result is bounded by 44.84*r**(1-p)  */
Packit 6c4009
/* if x <= 0,  y != 0 and by 37.33*r**(1-p) if x>0. here r=2**24. */
Packit 6c4009
/*                                                                */
Packit 6c4009
/******************************************************************/
Packit 6c4009
Packit 6c4009
#include "mpa.h"
Packit 6c4009
Packit 6c4009
#ifndef SECTION
Packit 6c4009
# define SECTION
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
/* Multi-Precision Atan2 (y, x) function subroutine, for p >= 4.
Packit 6c4009
   y = 0 is not permitted if x <= 0. No error messages are given.  */
Packit 6c4009
void
Packit 6c4009
SECTION
Packit 6c4009
__mpatan2 (mp_no *y, mp_no *x, mp_no *z, int p)
Packit 6c4009
{
Packit 6c4009
  mp_no mpt1, mpt2, mpt3;
Packit 6c4009
Packit 6c4009
  if (X[0] <= 0)
Packit 6c4009
    {
Packit 6c4009
      __dvd (x, y, &mpt1, p);
Packit 6c4009
      __mul (&mpt1, &mpt1, &mpt2, p);
Packit 6c4009
      if (mpt1.d[0] != 0)
Packit 6c4009
	mpt1.d[0] = 1;
Packit 6c4009
      __add (&mpt2, &__mpone, &mpt3, p);
Packit 6c4009
      __mpsqrt (&mpt3, &mpt2, p);
Packit 6c4009
      __add (&mpt1, &mpt2, &mpt3, p);
Packit 6c4009
      mpt3.d[0] = Y[0];
Packit 6c4009
      __mpatan (&mpt3, &mpt1, p);
Packit 6c4009
      __add (&mpt1, &mpt1, z, p);
Packit 6c4009
    }
Packit 6c4009
  else
Packit 6c4009
    {
Packit 6c4009
      __dvd (y, x, &mpt1, p);
Packit 6c4009
      __mpatan (&mpt1, z, p);
Packit 6c4009
    }
Packit 6c4009
}