Main Page   Data Structures   File List   Data Fields   Globals  

scs_private.h

Go to the documentation of this file.
00001 /** Various declarations and macros shared by
00002    several .c files, but useless to users of the library 
00003 
00004  @file scs_private.h
00005 
00006 @author Defour David David.Defour@ens-lyon.fr
00007 @author Florent de Dinechin Florent.de.Dinechin@ens-lyon.fr 
00008 */
00009 
00010 
00011 /*
00012 Copyright (C) 2002  David Defour and Florent de Dinechin
00013 
00014     This library is free software; you can redistribute it and/or
00015     modify it under the terms of the GNU Lesser General Public
00016     License as published by the Free Software Foundation; either
00017     version 2.1 of the License, or (at your option) any later version.
00018 
00019     This library is distributed in the hope that it will be useful,
00020     but WITHOUT ANY WARRANTY; without even the implied warranty of
00021     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00022     Lesser General Public License for more details.
00023 
00024     You should have received a copy of the GNU Lesser General Public
00025     License along with this library; if not, write to the Free Software
00026     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00027 
00028  */
00029 #ifndef SCS_PRIVATE_H
00030 #define SCS_PRIVATE_H 1
00031 
00032 
00033 #define SCS_RADIX   (1<<SCS_NB_BITS)
00034 
00035 #define SCS_MASK_RADIX ((unsigned int)(SCS_RADIX-1))
00036 
00037 #include "scs.h"
00038 
00039 #ifdef WORDS_BIGENDIAN
00040  #define HI_ENDIAN 0
00041  #define LO_ENDIAN 1 
00042 #else
00043  #define HI_ENDIAN 1
00044  #define LO_ENDIAN 0
00045 #endif
00046 
00047 /* An int such that SCS_MAX_RANGE * SCS_NB_BITS < 1024, 
00048    where 1024 is the max of the exponent of a double number.
00049    Used in scs2double.c along with radix_rng_double et al. 
00050    The value of 32 is OK for all practical values of SCS_NB_BITS */       
00051 #define SCS_MAX_RANGE  32
00052 
00053 /*
00054  * DEFINITION OF DOUBLE PRECISION FLOATING POINT NUMBER CONSTANTS 
00055  */
00056 /* In all the following "radix" means 2^(SCS_NB_BITS),
00057    and radix_blah means radix^blah.
00058    (1023 + e)<<20 is the way to cast e into the exponent field of an IEEE-754 double
00059  */
00060  
00061 #ifdef WORDS_BIGENDIAN
00062  static const scs_db_number radix_one_double  = {{((1023+SCS_NB_BITS)<<20) ,               0x00000000 }}; 
00063  static const scs_db_number radix_two_double  = {{((1023+2*SCS_NB_BITS)<<20) ,             0x00000000 }}; 
00064  static const scs_db_number radix_mone_double = {{((1023-SCS_NB_BITS)<<20) ,               0x00000000 }}; 
00065  static const scs_db_number radix_mtwo_double = {{((1023-2*SCS_NB_BITS)<<20) ,             0x00000000 }}; 
00066  static const scs_db_number radix_rng_double  = {{((1023+SCS_NB_BITS*SCS_MAX_RANGE)<<20) , 0x00000000 }}; 
00067  static const scs_db_number radix_mrng_double = {{((1023-SCS_NB_BITS*SCS_MAX_RANGE)<<20) , 0x00000000 }};
00068  static const scs_db_number max_double        = {{0x7FEFFFFF ,                             0xFFFFFFFF }}; 
00069  static const scs_db_number min_double        = {{0x00000000 ,                             0x00000001 }}; 
00070 #else
00071  static const scs_db_number radix_one_double  = {{0x00000000 , ((1023+SCS_NB_BITS)<<20)               }}; 
00072  static const scs_db_number radix_two_double  = {{0x00000000 , ((1023+2*SCS_NB_BITS)<<20)             }}; 
00073  static const scs_db_number radix_mone_double = {{0x00000000 , ((1023-SCS_NB_BITS)<<20)               }}; 
00074  static const scs_db_number radix_mtwo_double = {{0x00000000 , ((1023-2*SCS_NB_BITS)<<20)             }}; 
00075  static const scs_db_number radix_rng_double  = {{0x00000000 , ((1023+SCS_NB_BITS*SCS_MAX_RANGE)<<20) }}; 
00076  static const scs_db_number radix_mrng_double = {{0x00000000 , ((1023-SCS_NB_BITS*SCS_MAX_RANGE)<<20) }}; 
00077  static const scs_db_number max_double        = {{0xFFFFFFFF ,                             0x7FEFFFFF }}; 
00078  static const scs_db_number min_double        = {{0x00000001 ,                             0x00000000 }}; 
00079  #endif
00080 
00081 
00082 #define SCS_RADIX_ONE_DOUBLE     radix_one_double.d   /* 2^(SCS_NB_BITS)           */ 
00083 #define SCS_RADIX_TWO_DOUBLE     radix_two_double.d   /* 2^(2.SCS_NB_BITS)         */
00084 #define SCS_RADIX_MONE_DOUBLE    radix_mone_double.d  /* 2^-(SCS_NB_BITS)          */ 
00085 #define SCS_RADIX_MTWO_DOUBLE    radix_mtwo_double.d  /* 2^-(2.SCS_NB_BITS)        */ 
00086 #define SCS_RADIX_RNG_DOUBLE     radix_rng_double.d   /* 2^(SCS_NB_BITS.SCS_MAX_RANGE) */
00087 #define SCS_RADIX_MRNG_DOUBLE    radix_mrng_double.d  /* 2^-(SCS_NB_BITS.SCS_MAX_RANGE)*/
00088 #define SCS_MAX_DOUBLE           max_double.d         /* 2^1024-1              */
00089 #define SCS_MIN_DOUBLE           min_double.d         /* 2^-1074             */
00090 
00091 
00092 
00093 
00094 
00095 
00096 #define R_HW  result->h_word
00097 #define R_SGN result->sign
00098 #define R_IND result->index
00099 #define R_EXP result->exception.d
00100 
00101 #define X_HW  x->h_word
00102 #define X_SGN x->sign
00103 #define X_IND x->index
00104 #define X_EXP x->exception.d
00105 
00106 #define Y_HW  y->h_word
00107 #define Y_SGN y->sign
00108 #define Y_IND y->index
00109 #define Y_EXP y->exception.d
00110 
00111 #define Z_HW  z->h_word
00112 #define Z_SGN z->sign
00113 #define Z_IND z->index
00114 #define Z_EXP z->exception.d
00115 
00116 #define W_HW  w->h_word
00117 #define W_SGN w->sign
00118 #define W_IND w->index
00119 #define W_EXP w->exception.d
00120 
00121 
00122 
00123 /* A few additional defines for the case when we use floating-point
00124    multiplier */
00125 
00126 #ifdef SCS_USE_FLT_MULT
00127 /* There is a "53" below, which means that these constants won't do
00128    what we expect from them on x86 because of the double extended
00129    precision. We could put more ifdefs, but why care, nobody wants to use the
00130    FP muls on the x86. */
00131 #ifdef WORDS_BIGENDIAN
00132  static const scs_db_number scs_flt_trunc_cst = {{ ((1023+SCS_NB_BITS-1)<<20) ,           0x00000000 }}; 
00133  static const scs_db_number scs_flt_shift_cst = {{ ((1023+SCS_NB_BITS+53)<<20),0x00000000}}; 
00134 #else
00135  static const scs_db_number scs_flt_trunc_cst = {{ 0x00000000, ((1023+SCS_NB_BITS-1)<<20) }}; 
00136  static const scs_db_number scs_flt_shift_cst = {{ 0x00000000 ,((1023+SCS_NB_BITS+53)<<20)}}; 
00137 #endif /*WORDS_BIGENDIAN*/
00138 
00139 #define SCS_FLT_TRUNC_CST  scs_flt_trunc_cst.d    /* 2^(SCS_NB_BITS+53-1) */
00140 #define SCS_FLT_SHIFT_CST  scs_flt_shift_cst.d    /* 2^(SCS_NB_BITS)(1+1/2) */
00141 #endif /* SCS_USE_FLTMULT */
00142 
00143 #endif

Generated on Tue Jun 17 10:15:51 2003 for SCSLib by doxygen1.2.15