メインページ   クラス階層   構成   ファイル一覧   構成メンバ   ファイルメンバ  

lo-cieee.c

解説を見る。
00001 /*
00002 
00003 Copyright (C) 2002 John W. Eaton
00004 
00005 This file is part of Octave.
00006 
00007 Octave is free software; you can redistribute it and/or modify it
00008 under the terms of the GNU General Public License as published by the
00009 Free Software Foundation; either version 2, or (at your option) any
00010 later version.
00011 
00012 Octave is distributed in the hope that it will be useful, but WITHOUT
00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00015 for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Octave; see the file COPYING.  If not, write to the Free
00019 Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00020 
00021 */
00022 
00023 #ifdef HAVE_CONFIG_H
00024 #include <config.h>
00025 #endif
00026 
00027 #include <float.h>
00028 #include <math.h>
00029 
00030 #if defined (HAVE_FLOATINGPOINT_H)
00031 #include <floatingpoint.h>
00032 #endif
00033 
00034 #if defined (HAVE_IEEEFP_H)
00035 #include <ieeefp.h>
00036 #endif
00037 
00038 #if defined (HAVE_NAN_H)
00039 #if defined (SCO)
00040 #define _IEEE 1
00041 #endif
00042 #include <nan.h>
00043 #if defined (SCO)
00044 #undef _IEEE
00045 #endif
00046 #endif
00047 
00048 #include "lo-ieee.h"
00049 
00050 #if defined (_AIX) && defined (__GNUG__)
00051 #undef finite
00052 #define finite(x) ((x) < DBL_MAX && (x) > -DBL_MAX)
00053 #endif
00054 
00055 /* Octave's idea of infinity.  */
00056 double octave_Inf;
00057 
00058 /* Octave's idea of a missing value.  */
00059 double octave_NA;
00060 
00061 /* Octave's idea of not a number.  */
00062 double octave_NaN;
00063 
00064 int lo_ieee_hw;
00065 int lo_ieee_lw;
00066 
00067 #if defined (SCO)
00068 
00069 int
00070 isnan (double x)
00071 {
00072   return (IsNANorINF (x) && NaN (x) && ! IsINF (x)) ? 1 : 0;
00073 }
00074 
00075 int
00076 isinf (double x)
00077 {
00078   return (IsNANorINF (x) && IsINF (x)) ? 1 : 0;
00079 }
00080 
00081 #endif
00082 
00083 int
00084 lo_ieee_isnan (double x)
00085 {
00086 #if defined (HAVE_ISNAN)
00087   return isnan (x) ? ! lo_ieee_is_NA (x) : 0;
00088 #else
00089   return 0;
00090 #endif
00091 }
00092 
00093 int
00094 lo_ieee_finite (double x)
00095 {
00096 #if defined (HAVE_FINITE)
00097   return finite (x) != 0 && ! lo_ieee_is_NaN_or_NA (x);
00098 #elif defined (HAVE_ISINF)
00099   return (! isinf (x) && ! lo_ieee_is_NaN_or_NA (x));
00100 #else
00101   return ! lo_ieee_is_NaN_or_NA (x);
00102 #endif
00103 }
00104 
00105 int
00106 lo_ieee_isinf (double x)
00107 {
00108 #if defined (HAVE_ISINF)
00109   return isinf (x);
00110 #elif defined (HAVE_FINITE)
00111   return (! (finite (x) || lo_ieee_is_NaN_or_NA (x)));
00112 #else
00113   return 0;
00114 #endif
00115 }
00116 
00117 int
00118 lo_ieee_is_NA (double x)
00119 {
00120 #if defined HAVE_ISNAN
00121   lo_ieee_double t;
00122   t.value = x;
00123   return (isnan (x) && t.word[lo_ieee_lw] == LO_IEEE_NA_LW) ? 1 : 0;
00124 #else
00125   return 0;
00126 #endif
00127 }
00128 
00129 int
00130 lo_ieee_is_NaN_or_NA (double x)
00131 {
00132   /* Although NA really is an IEEE NaN value, lo_ieee_isnan pretends
00133      it is not, so we much check both...  */
00134 
00135   return lo_ieee_isnan (x) || lo_ieee_is_NA (x);
00136 }
00137 
00138 double
00139 lo_ieee_inf_value (void)
00140 {
00141   return octave_Inf;
00142 }
00143 
00144 double
00145 lo_ieee_na_value (void)
00146 {
00147   return octave_NA;
00148 }
00149 
00150 double
00151 lo_ieee_nan_value (void)
00152 {
00153   return octave_NaN;
00154 }
00155 
00156 /*
00157 ;;; Local Variables: ***
00158 ;;; mode: C++ ***
00159 ;;; End: ***
00160 */

Wed Dec 29 11:51:39 2004に生成されました。 doxygen1.2.18
SEO [PR] 爆速!無料ブログ 無料ホームページ開設 無料ライブ放送