00001 // Interval Wrapper Class -*- C++ -*- 00002 00003 // $Id: interval.h 347 2008-02-06 15:20:01Z schilly $ 00004 // Copyright (C) 2001-2004 Hermann Schichl and Xuan-Ha VU 00005 // 00006 // This file is part of the COCONUT API. This library 00007 // is free software; you can redistribute it and/or modify it under the 00008 // terms of the Library GNU General Public License as published by the 00009 // Free Software Foundation; either version 2, or (at your option) 00010 // any later version. 00011 00012 // This library is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // Library GNU General Public License for more details. 00016 00017 // As a special exception, you may use this file as part of a free software 00018 // library without restriction. Specifically, if other files instantiate 00019 // templates or use macros or inline functions from this file, or you compile 00020 // this file and link it with other files to produce an executable, this 00021 // file does not by itself cause the resulting executable to be covered by 00022 // the Library GNU General Public License. This exception does not however 00023 // invalidate any other reasons why the executable file might be covered by 00024 // the Library GNU General Public License. 00025 00028 #ifndef _COCONUT_INTERVAL_H_ 00029 #define _COCONUT_INTERVAL_H_ 00030 00031 #include <special_val.h> 00032 00033 namespace coco { 00034 00035 #if defined(COCONUT_WINDOWS) 00036 //** This is a replacement for the C99 standard function rint not supported by Visual Studio. 00037 static double rint(double f) 00038 { // the @%&$´-Visual Studio does neither have round nor rint! 00039 if(ceil(f)-f > 0.5) 00040 return (int)floor(f); 00041 else 00042 return (int)ceil(f); 00043 } 00045 static bool is_integer(double f) 00046 { 00047 double b(rint(f)); 00048 return b == f && b < MAXINT && b > -MAXINT; 00049 } 00050 #else 00051 00052 #define is_integer(x) (rint((x)) == (x) && rint((x)) < MAXINT && rint((x)) > -MAXINT) 00053 #endif 00054 00056 #define get_integer(x) ((int) rint((x))) 00057 00058 } // namespace coco 00059 00060 #if COCONUT_INTERVAL_LIBRARY == INTERVAL_LIBRARY_BOOST 00061 #include <interval_boost.h> 00062 #elif COCONUT_INTERVAL_LIBRARY == INTERVAL_LIBRARY_FILIB 00063 #include <interval_filib.h> 00064 #else 00065 #error "No proper interval library selected in ../include/coconut_config.h" 00066 #endif 00067 00068 #endif // _COCONUT_INTERVAL_H_