1 2 /* 3 * M_APM - m_apm_lc.h 4 * 5 * Copyright (C) 1999 - 2007 Michael C. Ring 6 * 7 * Permission to use, copy, and distribute this software and its 8 * documentation for any purpose with or without fee is hereby granted, 9 * provided that the above copyright notice appear in all copies and 10 * that both that copyright notice and this permission notice appear 11 * in supporting documentation. 12 * 13 * Permission to modify the software is granted. Permission to distribute 14 * the modified code is granted. Modifications are to be distributed by 15 * using the file 'license.txt' as a template to modify the file header. 16 * 'license.txt' is available in the official MAPM distribution. 17 * 18 * This software is provided "as is" without express or implied warranty. 19 */ 20 21 /* 22 * This is the local header file needed to build the library 23 * 24 * $Log: m_apm_lc.h,v $ 25 * Revision 1.45 2007/12/04 01:26:02 mike 26 * add support for Digital Mars compiler 27 * 28 * Revision 1.44 2007/12/03 01:23:54 mike 29 * Update license 30 * 31 * Revision 1.43 2004/05/28 19:30:16 mike 32 * add new prototype 33 * 34 * Revision 1.42 2003/10/25 22:36:01 mike 35 * add support for National Instruments CVI 36 * 37 * Revision 1.41 2003/07/21 19:42:50 mike 38 * rename M_APM_EXIT to M_APM_FATAL 39 * change M_APM_RETURN to 0, set M_APM_FATAL to 1 40 * 41 * Revision 1.40 2003/07/21 19:14:29 mike 42 * add new prototype 43 * 44 * Revision 1.39 2003/05/04 20:09:10 mike 45 * add support for Open Watcom 1.0 46 * 47 * Revision 1.38 2003/05/01 21:54:04 mike 48 * add math.h, add new prototype 49 * 50 * Revision 1.37 2003/04/01 23:19:01 mike 51 * add new log constants and prototypes 52 * 53 * Revision 1.36 2003/03/30 23:02:49 mike 54 * add new log constants and new prototypes 55 * 56 * Revision 1.35 2002/11/03 23:21:28 mike 57 * add new prototype, M_set_to_zero 58 * 59 * Revision 1.34 2002/05/18 15:38:52 mike 60 * add MINGW compiler #define 61 * 62 * Revision 1.33 2002/02/14 19:42:59 mike 63 * add conditional compiler stuff for Metrowerks Codewarrior compiler 64 * 65 * Revision 1.32 2001/08/25 16:45:40 mike 66 * add new prototype 67 * 68 * Revision 1.31 2001/07/24 18:13:31 mike 69 * add new prototype 70 * 71 * Revision 1.30 2001/07/16 18:38:04 mike 72 * add 'free_all' prototypes 73 * 74 * Revision 1.29 2001/02/07 19:13:27 mike 75 * eliminate MM_skip_limit_PI_check 76 * 77 * Revision 1.28 2001/01/23 21:10:24 mike 78 * add new prototype for M_long_2_ascii 79 * 80 * Revision 1.27 2000/12/10 14:30:52 mike 81 * added ifdef for LCC-WIN32 compiler 82 * 83 * Revision 1.26 2000/12/02 19:41:45 mike 84 * add arc functions near 0 85 * 86 * Revision 1.25 2000/11/14 22:48:29 mike 87 * add BORLANDC to pre-processor stuff 88 * 89 * Revision 1.24 2000/10/22 21:17:56 mike 90 * add _MSC_VER check for VC++ compilers 91 * 92 * Revision 1.23 2000/10/18 23:09:27 mike 93 * add new prototype 94 * 95 * Revision 1.22 2000/09/23 18:55:30 mike 96 * add new prototype fpr M_apm_sdivide 97 * 98 * Revision 1.21 2000/08/01 22:21:55 mike 99 * add prototype 100 * 101 * Revision 1.20 2000/07/19 17:21:26 mike 102 * add ifdef for older Borland compilers 103 * 104 * Revision 1.19 2000/07/11 20:09:30 mike 105 * add new prototype 106 * 107 * Revision 1.18 2000/05/19 17:09:57 mike 108 * add local copies for PI variables 109 * 110 * Revision 1.17 2000/05/04 23:21:56 mike 111 * change/add new global internal MAPM values 112 * 113 * Revision 1.16 2000/04/11 18:44:43 mike 114 * no longer need the constant 'Fifteen' 115 * 116 * Revision 1.15 2000/04/03 17:27:08 mike 117 * added cbrt prototype 118 * 119 * Revision 1.14 2000/02/03 22:41:34 mike 120 * add MAPM_* memory function defines 121 * 122 * Revision 1.13 1999/07/09 22:46:10 mike 123 * add skip limit integer 124 * 125 * Revision 1.12 1999/07/08 23:35:20 mike 126 * change constant 127 * 128 * Revision 1.11 1999/07/08 22:55:38 mike 129 * add new constant 130 * 131 * Revision 1.10 1999/06/23 01:08:11 mike 132 * added constant '15' 133 * 134 * Revision 1.9 1999/06/20 23:38:11 mike 135 * updated for new prototypes 136 * 137 * Revision 1.8 1999/06/20 23:30:03 mike 138 * added new constants 139 * 140 * Revision 1.7 1999/06/20 19:23:12 mike 141 * delete constants no longer needed 142 * 143 * Revision 1.6 1999/06/20 18:50:21 mike 144 * added more constants 145 * 146 * Revision 1.5 1999/06/19 20:37:30 mike 147 * add stack prototypes 148 * 149 * Revision 1.4 1999/05/31 23:01:38 mike 150 * delete some unneeded constants 151 * 152 * Revision 1.3 1999/05/15 02:23:28 mike 153 * fix define for M_COS 154 * 155 * Revision 1.2 1999/05/15 02:16:56 mike 156 * add check for number of decimal places 157 * 158 * Revision 1.1 1999/05/12 20:51:22 mike 159 * Initial revision 160 * 161 * $Id: m_apm_lc.h,v 1.45 2007/12/04 01:26:02 mike Exp $ 162 */ 163 164 #ifndef M__APM_LOCAL_INC 165 #define M__APM_LOCAL_INC 166 167 #include <stdio.h> 168 #include <stdlib.h> 169 #include <string.h> 170 #include <math.h> 171 #include "m_apm.h" 172 173 /* 174 * this supports older (and maybe newer?) Borland compilers. 175 * these Borland compilers define __MSDOS__ 176 */ 177 178 #ifndef MSDOS 179 #ifdef __MSDOS__ 180 #define MSDOS 181 #endif 182 #endif 183 184 /* 185 * this supports some newer Borland compilers (i.e., v5.5). 186 */ 187 188 #ifndef MSDOS 189 #ifdef __BORLANDC__ 190 #define MSDOS 191 #endif 192 #endif 193 194 /* 195 * this supports the LCC-WIN32 compiler 196 */ 197 198 #ifndef MSDOS 199 #ifdef __LCC__ 200 #define MSDOS 201 #endif 202 #endif 203 204 /* 205 * this supports Micro$oft Visual C++ and also possibly older 206 * straight C compilers as well. 207 */ 208 209 #ifndef MSDOS 210 #ifdef _MSC_VER 211 #define MSDOS 212 #endif 213 #endif 214 215 /* 216 * this supports the Metrowerks CodeWarrior 7.0 compiler (I think...) 217 */ 218 219 #ifndef MSDOS 220 #ifdef __MWERKS__ 221 #define MSDOS 222 #endif 223 #endif 224 225 /* 226 * this supports the MINGW 32 compiler 227 */ 228 229 #ifndef MSDOS 230 #ifdef __MINGW_H 231 #define MSDOS 232 #endif 233 #endif 234 235 /* 236 * this supports the Open Watcom 1.0 compiler 237 */ 238 239 #ifndef MSDOS 240 #ifdef __WATCOMC__ 241 #define MSDOS 242 #endif 243 #endif 244 245 /* 246 * this supports the Digital Mars compiler 247 */ 248 249 #ifndef MSDOS 250 #ifdef __DMC__ 251 #define MSDOS 252 #endif 253 #endif 254 255 /* 256 * this supports National Instruments LabWindows CVI 257 */ 258 259 #ifndef _HAVE_NI_LABWIN_CVI_ 260 #ifdef _CVI_ 261 #define _HAVE_NI_LABWIN_CVI_ 262 #endif 263 #endif 264 265 /* 266 * If for some reason (RAM limitations, slow floating point, whatever) 267 * you do NOT want to use the FFT multiply algorithm, un-comment the 268 * #define below, delete mapm_fft.c and remove mapm_fft from the build. 269 */ 270 271 /* #define NO_FFT_MULTIPLY */ 272 273 /* 274 * use your own memory management functions if desired. 275 * re-define MAPM_* below to point to your functions. 276 * an example is shown below. 277 */ 278 279 /* 280 extern void *memory_allocate(unsigned int); 281 extern void *memory_reallocate(void *, unsigned int); 282 extern void memory_free(void *); 283 284 #define MAPM_MALLOC memory_allocate 285 #define MAPM_REALLOC memory_reallocate 286 #define MAPM_FREE memory_free 287 */ 288 289 /* default: use the standard C library memory functions ... */ 290 291 #define MAPM_MALLOC malloc 292 #define MAPM_REALLOC realloc 293 #define MAPM_FREE free 294 295 #ifndef TRUE 296 #define TRUE 1 297 #endif 298 299 #ifndef FALSE 300 #define FALSE 0 301 #endif 302 303 #define M_APM_IDENT 0x6BCC9AE5 304 #define M_APM_RETURN 0 305 #define M_APM_FATAL 1 306 307 /* number of digits in the global constants, PI, E, etc */ 308 309 #define VALID_DECIMAL_PLACES 128 310 311 extern int MM_lc_PI_digits; 312 extern int MM_lc_log_digits; 313 314 /* 315 * constants not in m_apm.h 316 */ 317 318 extern M_APM MM_0_5; 319 extern M_APM MM_0_85; 320 extern M_APM MM_5x_125R; 321 extern M_APM MM_5x_64R; 322 extern M_APM MM_5x_256R; 323 extern M_APM MM_5x_Eight; 324 extern M_APM MM_5x_Sixteen; 325 extern M_APM MM_5x_Twenty; 326 extern M_APM MM_lc_PI; 327 extern M_APM MM_lc_HALF_PI; 328 extern M_APM MM_lc_2_PI; 329 extern M_APM MM_lc_log2; 330 extern M_APM MM_lc_log10; 331 extern M_APM MM_lc_log10R; 332 333 /* 334 * prototypes for internal functions 335 */ 336 337 #ifndef NO_FFT_MULTIPLY 338 extern void M_free_all_fft(void); 339 #endif 340 341 extern void M_init_trig_globals(void); 342 extern void M_free_all_add(void); 343 extern void M_free_all_div(void); 344 extern void M_free_all_exp(void); 345 extern void M_free_all_pow(void); 346 extern void M_free_all_rnd(void); 347 extern void M_free_all_set(void); 348 extern void M_free_all_cnst(void); 349 extern void M_free_all_fmul(void); 350 extern void M_free_all_stck(void); 351 extern void M_free_all_util(void); 352 353 extern int M_exp_compute_nn(int *, M_APM, M_APM); 354 extern void M_raw_exp(M_APM, int, M_APM); 355 extern void M_raw_sin(M_APM, int, M_APM); 356 extern void M_raw_cos(M_APM, int, M_APM); 357 extern void M_5x_sin(M_APM, int, M_APM); 358 extern void M_4x_cos(M_APM, int, M_APM); 359 extern void M_5x_do_it(M_APM, int, M_APM); 360 extern void M_4x_do_it(M_APM, int, M_APM); 361 362 extern M_APM M_get_stack_var(void); 363 extern void M_restore_stack(int); 364 extern int M_get_sizeof_int(void); 365 366 extern void M_apm_sdivide(M_APM, int, M_APM, M_APM); 367 extern void M_cos_to_sin(M_APM, int, M_APM); 368 extern void M_limit_angle_to_pi(M_APM, int, M_APM); 369 extern void M_log_near_1(M_APM, int, M_APM); 370 extern void M_get_sqrt_guess(M_APM, M_APM); 371 extern void M_get_cbrt_guess(M_APM, M_APM); 372 extern void M_get_log_guess(M_APM, M_APM); 373 extern void M_get_asin_guess(M_APM, M_APM); 374 extern void M_get_acos_guess(M_APM, M_APM); 375 extern void M_arcsin_near_0(M_APM, int, M_APM); 376 extern void M_arccos_near_0(M_APM, int, M_APM); 377 extern void M_arctan_near_0(M_APM, int, M_APM); 378 extern void M_arctan_large_input(M_APM, int, M_APM); 379 extern void M_log_basic_iteration(M_APM, int, M_APM); 380 extern void M_log_solve_cubic(M_APM, int, M_APM); 381 extern void M_check_log_places(int); 382 extern void M_log_AGM_R_func(M_APM, int, M_APM, M_APM); 383 extern void M_init_util_data(void); 384 extern void M_get_div_rem_addr(UCHAR **, UCHAR **); 385 extern void M_get_div_rem(int,UCHAR *, UCHAR *); 386 extern void M_get_div_rem_10(int, UCHAR *, UCHAR *); 387 extern void M_apm_normalize(M_APM); 388 extern void M_apm_scale(M_APM, int); 389 extern void M_apm_pad(M_APM, int); 390 extern void M_long_2_ascii(char *, long); 391 extern void M_check_PI_places(int); 392 extern void M_calculate_PI_AGM(M_APM, int); 393 extern void M_set_to_zero(M_APM); 394 extern int M_strposition(char *, char *); 395 extern char *M_lowercase(char *); 396 extern void M_apm_log_error_msg(int, char *); 397 extern void M_apm_round_fixpt(M_APM, int, M_APM); 398 399 #endif 400 401