/** This is the main header file of the SCS library, which defines the SCS data structure, and the functions that implement arithmetic on it. @file scs.h @author David Defour David.Defour@ens-lyon.fr @author Florent de Dinechin Florent.de.Dinechin@ens-lyon.fr This file is part of the SCS library. Copyright (C) 2002 David Defour and Florent de Dinechin This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* Avoid loading the header twice */ #ifndef INCLUDE_SCS #define INCLUDE_SCS 1 #ifndef DOXYGEN_SHOULD_SKIP_THIS /* because it is not very clean */ #ifdef HAVE_CONFIG_H #include "../crlibm_config.h" #endif #ifdef HAVE_INTTYPES_H #include #endif /* 64 bit arithmetic may be standardised, but people still do want they want */ #ifdef HAVE_INTTYPES_H #define ULL(bits) 0x##bits##uLL #elif defined(WIN32) /* TODO insert Windows garbage there */ /* Default, hoping it works, hopefully less and less relevant */ #else typedef long long int64_t; typedef unsigned long long uint64_t; #define ULL(bits) 0x##bits##uLL #endif #ifndef SCS_DEF_INT64 #define SCS_DEF_INT64 #ifdef SCS_TYPEOS_HPUX #ifndef __LP64__ /* To solve the problem with 64 bits integer */ typedef long long int64_t; typedef unsigned long long uint64_t; #define ULL(bits) 0x##bits##uLL #endif #endif #endif #ifdef HAVE_GMP_H #include #endif #ifdef HAVE_MPFR_H #include #endif #endif /* DOXYGEN_SHOULD_SKIP_THIS */ /** @internal An union to cast floats into doubles or the other way round. For internal purpose only */ typedef union { int32_t i[2]; /* Signed (may be useful) */ int64_t l; /* Signed (may be useful) */ double d; } db_number; /* ****************************************************************** */ /**@name SCS data-types */ /**@{*/ /** @struct scs The SCS data type. An SCS number is a a floating-point number in base 2^32. - Its mantissa is formed of SCS_NB_WORDS digits (currently 32 bits by default) - Its exponent is a 32-bit integer - It also has a sign field, and an exception field used to store and propagate IEEE-754 exceptions. The real number represented by a scs structure is equal to: @f$ \displaystyle \sum_{i=0}^{\mathtt{SCS\_NB\_WORDS}} 2^{(\mathtt{index} -i)\mathtt{SCS\_NB\_BITS}} \times \mathtt{h\_word}[i] @f$ */ /* (verbatim-mode formula for the above eqation:) the number represented by a SCS structure is : i