numerix_doc 0.4
|
00001 00002 /****************************************************************************** 00003 * MODULE : string_scnot.hpp 00004 * DESCRIPTION: Scientific notation for intervals 00005 * COPYRIGHT : (C) 2004 Joris van der Hoeven 00006 ******************************************************************************* 00007 * This software falls under the GNU general public license and comes WITHOUT 00008 * ANY WARRANTY WHATSOEVER. See the file $TEXMACS_PATH/LICENSE for more details. 00009 * If you don't have this file, write to the Free Software Foundation, Inc., 00010 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00011 ******************************************************************************/ 00012 00013 #ifndef __STRING_SCNOT_HPP 00014 #define __STRING_SCNOT_HPP 00015 #include <basix/string.hpp> 00016 #include <numerix/mmx_mpfr.hpp> 00017 namespace mmx { 00018 00019 string make_range (const string& l, const string& r); 00020 void decompose_range (const string& s, string& l, string& r); 00021 string trunc_digits (const string& s, xnat dd); 00022 syntactic flatten_number (const string& s); 00023 string flatten_as_mmx (const generic& g); 00024 00025 template<typename C> string 00026 flatten_as_string (const C& x) { 00027 return flatten_as_mmx (as_generic (x)); 00028 } 00029 00030 template<typename C> string 00031 as_string (const C& x, xnat dd) { 00032 if (dd == 0) return flatten_as_string (x); 00033 else return trunc_digits (flatten_as_string (x), dd); 00034 } 00035 00036 template<typename C> syntactic 00037 flatten_range (const C& x, const C& y) { 00038 const string s= make_range (flatten_as_string (x), flatten_as_string (y)); 00039 return flatten_number (s); 00040 } 00041 00042 template<typename C> syntactic 00043 flatten_range (const C& x, const C& y, xnat dd) { 00044 xnat old= mmx_significant_digits; 00045 mmx_significant_digits= 0; 00046 const string s= make_range (flatten_as_string (x), flatten_as_string (y)); 00047 mmx_significant_digits= old; 00048 return flatten_number (trunc_digits (s, dd)); 00049 } 00050 00051 } // namespace mmx 00052 #endif // __STRING_SCNOT_HPP