/* Copyright 2001, 2019 IBM Corporation
 *
 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 
 * following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the 
 * following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the 
 * following disclaimer in the documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 
 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
#include <math.h>

#include <BlueMatter/fpexploit.hpp>

#if defined(ARCH_HAS_FSEL)
#include <builtins.h>
#define fsel(a, x, y) __fsel((a),(x),(y))
#else
#define fsel(a, x, y) ( (a) >= 0.0 ? (x) : (y) )
#endif

#include <BlueMatter/fpatrig.hpp>

void tenatrig(double* f, const double* s, const double* c)
{
   QuadWordAligned(f) ;
   QuadWordAligned(c) ;
   QuadWordAligned(s) ;
   double s0 = s[0] ;
   double s1 = s[1] ;
   double s2 = s[2] ;
   double s3 = s[3] ;
   double s4 = s[4] ;
   double s5 = s[5] ;
   double s6 = s[6] ;
   double s7 = s[7] ;
   double s8 = s[8] ;
   double s9 = s[9] ;
   double c0 = c[0] ;
   double c1 = c[1] ;
   double c2 = c[2] ;
   double c3 = c[3] ;
   double c4 = c[4] ;
   double c5 = c[5] ;
   double c6 = c[6] ;
   double c7 = c[7] ;
   double c8 = c[8] ;
   double c9 = c[9] ;
   double f0 = atrig(s0,c0) ;
   double f1 = atrig(s1,c1) ;
   double f2 = atrig(s2,c2) ;
   double f3 = atrig(s3,c3) ;
   double f4 = atrig(s4,c4) ;
   double f5 = atrig(s5,c5) ;
   double f6 = atrig(s6,c6) ;
   double f7 = atrig(s7,c7) ;
   double f8 = atrig(s8,c8) ;
   double f9 = atrig(s9,c9) ;
   f[0] = f0 ;
   f[1] = f1 ;
   f[2] = f2 ;
   f[3] = f3 ;
   f[4] = f4 ;
   f[5] = f5 ;
   f[6] = f6 ;
   f[7] = f7 ;
   f[8] = f8 ;
   f[9] = f9 ;
}

