numerix_doc 0.4
|
00001 00002 /****************************************************************************** 00003 * MODULE : numerix.cpp 00004 * DESCRIPTION: Basic inclusions, definitions and routines 00005 * COPYRIGHT : (C) 2003 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 #include <numerix/rational.hpp> 00014 #include <basix/glue.hpp> 00015 namespace mmx { 00016 00017 gmp_randstate_t gmp_randstate; 00018 extern string (*as_string_hook) (double); 00019 string mpfr_double_as_string (double x); 00020 00021 generic 00022 simple_construct_integer (const integer& i) { 00023 return generic (as_string (i)); 00024 } 00025 00026 generic 00027 simple_construct_rational (const rational& x) { 00028 if (denominator (x) == 1) return generic (as_string (numerator (x))); 00029 return generic (as_string (numerator (x))) / 00030 generic (as_string (denominator (x))); 00031 } 00032 00033 /* 00034 void* 00035 numerix_malloc (size_t new_size) { 00036 mmout << "[+" << new_size << "]" << flush_now; 00037 return mmx_malloc (new_size); 00038 } 00039 00040 void* 00041 numerix_realloc (void* ptr, size_t old_size, size_t new_size) { 00042 mmout << "[" << old_size << "->" << new_size << "]" << flush_now; 00043 return mmx_realloc (ptr, old_size, new_size); 00044 } 00045 00046 void 00047 numerix_free (void* ptr, size_t old_size) { 00048 mmout << "[-" << old_size << "]" << flush_now; 00049 mmx_free (ptr, old_size); 00050 } 00051 */ 00052 00053 struct numerix_instance { 00054 numerix_instance () { 00055 mp_set_memory_functions (mmx_malloc, mmx_realloc, mmx_free); 00056 //mp_set_memory_functions (numerix_malloc, numerix_realloc, numerix_free); 00057 gmp_randinit_default (gmp_randstate); 00058 as_string_hook= mpfr_double_as_string; 00059 } 00060 ~numerix_instance () {} 00061 }; 00062 00063 numerix_instance numerix_inst; 00064 00065 } // namespace mmx