Marsyas
0.6.0-alpha
|
00001 // Header file of basis.cpp 00002 00003 /*********************************************************************** 00004 * * 00005 * Basic functions: Declarations file (with types and macros) * 00006 * ---------------------------------------------------------- * 00007 * * 00008 * Programming language: ANSI C * 00009 * Compiler: Turbo C 2.0 * 00010 * Computer: IBM PS/2 70 with 80387 * 00011 * Author: Juergen Dietel, Computer Center, RWTH Aachen * 00012 * Date: 9.30.1992 * 00013 * * 00014 ***********************************************************************/ 00015 00016 00017 00018 /*********************************************************************** 00019 * Make preparations in case this declarations file is included more * 00020 * than once in a source code * 00021 ***********************************************************************/ 00022 00023 #ifndef BASIS_H_INCLUDED 00024 #define BASIS_H_INCLUDED 00025 00026 /*********************************************************************** 00027 * Include a few other declarations file here. * 00028 * We include the standard declarations files here mainly so that only * 00029 * this file needs to be included in the C modules of the Numerical * 00030 * Library in order to have access to all standard names and variables. * 00031 * Moreover modifications for nonstandard compilers may then be limited * 00032 * to this file only. * 00033 ***********************************************************************/ 00034 00035 #ifdef __EMX__ /* emx 0.9b with GNU CC 2.7.2? */ 00036 #if __GNUC__ == 2 /* To prevent a compiler crash in */ 00037 #if __GNUC_MINOR__ == 7 /* `15\gax.c' while compiling with LDOUBLE, */ 00038 #define EMX09B /* by defining the macro _WITH_UNDERSCORE */ 00039 #define _WITH_UNDERSCORE /* the special variants of the mathematical */ 00040 #define fabsl _fabsl /* functions for `long double' in `math.h' */ 00041 #define sqrtl _sqrtl /* are activated and their use further */ 00042 #define powl _powl /* below in shape of the macros FABS, SQRT, */ 00043 #define sinl _sinl /* ... is prepared here; which seems quite */ 00044 #define cosl _cosl /* useful even without the affair with the */ 00045 #define expl _expl /* crashing compiler. */ 00046 #define logl _logl 00047 #define atanl _atanl 00048 #define acosl _acosl 00049 #define coshl _coshl 00050 #endif 00051 #endif 00052 #endif 00053 00054 #include <stdlib.h> 00055 #include <stdio.h> 00056 #include <math.h> /* for fabs, sqrt, pow, exp, sin, cos, log, */ 00057 /* atan, acos */ 00058 #include <float.h> /* for DBL_EPSILON, DBL_MAX */ 00059 #include <string.h> 00060 00061 #ifdef sun /* for GNU CC under SunOS */ 00062 #include <unistd.h> /* for SEEK_END */ 00063 #else 00064 #ifdef amigados /* for GNU CC on an Amiga */ 00065 #include <unistd.h> /* for SEEK_END */ 00066 #endif 00067 #endif 00068 #ifndef SEEK_END /* SEEK_END not yet defined (such as for */ 00069 /* GNU CC 2.1 for an i386 MS-DOS computer)? */ 00070 #endif 00071 00072 00073 00074 /*********************************************************************** 00075 * Predefine the desired precision for floating point arithmetic: * 00076 * If the macro FLOAT has been defined, we compute in single precision * 00077 * (data type float), for LDOUBLE we compute in maximal precision * 00078 * (data type long double), otherwise we use double precision (data type* 00079 * double). LDOUBLE only adds precision on those compilers for which * 00080 * long double is different from double such as on Turbo C, but not on * 00081 * QuickC compilers for example. * 00082 * For input and output of floating numbers the macros LZS (length * 00083 * prefix for scanf()) and LZP (length prefix for printf()) should be * 00084 * used (obviously two different ones), since according to the ANSI C * 00085 * Standard the output of double values should be done without the * 00086 * length declaration "l" in contrast to the input where this "l" is * 00087 * needed. * 00088 * NOTE: If the compiler used does not know the macros FLT_MAX, * 00089 * ==== LDBL_MAX, DBL_MAX or FLT_MAX_EXP, LDBL_MAX_EXP, DBL_MAX_EXP * 00090 * (which can usually be found in float.h), the user must * 00091 * insert suitable values at the locations marked with !!!!. * 00092 ***********************************************************************/ 00093 00094 #ifdef FLOAT /* single precision ? ...............*/ 00095 00096 typedef float REAL; /* Standard floating point type float*/ 00097 /*.IX{REAL}*/ 00098 typedef double LONG_REAL; /* more precise floating point type */ 00099 /*.IX{LONG\unt REAL}*/ 00100 00101 #ifdef FLT_EPSILON /* ANSI C compiler ? ................*/ 00102 #define MACH_EPS (REAL)FLT_EPSILON 00103 /*.IX{MACH\unt EPS}*/ 00104 #else /* not an ANSI C compiler ? .........*/ 00105 #define MACH_EPS mach_eps() /* machine constant .................*/ 00106 #endif 00107 00108 #ifdef FLT_MAX_EXP /* ANSI C compiler? .................*/ 00109 #define MAX_EXP FLT_MAX_EXP /* Binary exponent of POSMAX ........*/ 00110 /*.IX{MAX\unt EXP}*/ 00111 #else /* not an ANSI C compiler ? .........*/ 00112 #define MAX_EXP 128 /* make adjustments here !!!! .......*/ 00113 #endif 00114 00115 #ifdef FLT_MAX /* ANSI C compiler? ................ */ 00116 #define POSMAX (REAL)FLT_MAX /* largest floating point number ... */ 00117 /*.IX{POS\unt MAX}*/ 00118 #else /* not an ANSI C compiler ? ........ */ 00119 #define POSMAX 1e38f /* adjust here !!!! ................ */ 00120 #endif 00121 00122 #ifdef FLT_MIN /* ANSI C compiler? .................*/ 00123 #define POSMIN (REAL)FLT_MIN /* smallest positive floating point */ 00124 /*.IX{POS\unt MIN}*/ 00125 /* number ...........................*/ 00126 #else /* not an ANSI C compiler ? .........*/ 00127 #define POSMIN posmin() 00128 #endif 00129 00130 #define LZS "" /* length prefix for formatted */ 00131 /*.IX{LZS}*/ 00132 /* input of floating point numbers ..*/ 00133 #define LZP "" /* length prefix for formatted */ 00134 /*.IX{LZP}*/ 00135 /* output of floating point numbers .*/ 00136 00137 00138 #else 00139 #ifdef LDOUBLE /* maximal precision ? ..............*/ 00140 00141 typedef long double REAL; /* Standard floating point type */ 00142 /* long double */ 00143 /*.IX{REAL}*/ 00144 typedef long double LONG_REAL; /* "more precise" floating point type*/ 00145 /*.IX{LONG\unt REAL}*/ 00146 #define LONG_DOUBLE_USED 00147 00148 #ifdef LDBL_EPSILON /* ANSI C compiler? .................*/ 00149 #define MACH_EPS (REAL)LDBL_EPSILON 00150 /*.IX{MACH\unt EPS}*/ 00151 #else /* not an ANSI C compiler ? .........*/ 00152 #define MACH_EPS mach_eps() /* machine constant .................*/ 00153 #endif 00154 00155 #ifdef LDBL_MAX_EXP /* ANSI C compiler? .................*/ 00156 #define MAX_EXP LDBL_MAX_EXP /* Binary exponent of POSMAX ........*/ 00157 /*.IX{MAX\unt EXP}*/ 00158 #else /* not an ANSI C compiler ? .........*/ 00159 #define MAX_EXP 1023 /* adjust here !!!! .................*/ 00160 #endif 00161 00162 #ifdef LDBL_MAX /* ANSI C compiler? .................*/ 00163 #define POSMAX (REAL)LDBL_MAX /* largest floating point number ....*/ 00164 /*.IX{POS\unt MAX}*/ 00165 #else /* not an ANSI C compiler ? .........*/ 00166 #define POSMAX 1e100l /* adjust here !!!! .................*/ 00167 #endif 00168 00169 #ifdef LDBL_MIN /* ANSI C compiler? .................*/ 00170 #define POSMIN (REAL)LDBL_MIN /* smallest positive floating point */ 00171 /*.IX{POS\unt MIN}*/ /* number ...........................*/ 00172 #else /* not an ANSI C compiler ? ........*/ 00173 #define POSMIN posmin() 00174 #endif 00175 00176 #define LZS "L" /* length prefix for formatted */ 00177 /*.IX{LZS}*/ 00178 /* input of floating point numbers ..*/ 00179 #define LZP "L" /* length prefix for formatted */ 00180 /*.IX{LZP}*/ 00181 /* output of floating point numbers .*/ 00182 00183 00184 #else /* double precision ? ...............*/ 00185 00186 typedef double REAL; /* Standard floating point type */ 00187 /* double */ 00188 /*.IX{REAL}*/ 00189 typedef long double LONG_REAL; /* more precise floating point type */ 00190 /*.IX{LONG\unt REAL}*/ 00191 00192 #ifdef DBL_EPSILON /* ANSI C compiler? .................*/ 00193 #define MACH_EPS (REAL)DBL_EPSILON 00194 /*.IX{MACH\unt EPS}*/ 00195 #else /* not an ANSI C compiler ? .........*/ 00196 #define MACH_EPS mach_eps() /* machine constant .................*/ 00197 #endif 00198 00199 #ifdef DBL_MAX_EXP /* ANSI C compiler? .................*/ 00200 #define MAX_EXP DBL_MAX_EXP /* Binary exponent of POSMAX ........*/ 00201 /*.IX{MAX\unt EXP}*/ 00202 #else /* not an ANSI C compiler ? .........*/ 00203 #define MAX_EXP 1023 /* adjust here !!!! .................*/ 00204 #endif 00205 00206 #ifdef DBL_MAX /* ANSI C compiler? .................*/ 00207 #define POSMAX (REAL)DBL_MAX /* largest floating point number ....*/ 00208 /*.IX{POS\unt MAX}*/ 00209 #else /* not an ANSI C compiler ? .........*/ 00210 #define POSMAX 1e100 /* adjust here !!!! .................*/ 00211 #endif 00212 00213 #ifdef DBL_MIN /* ANSI C compiler? .................*/ 00214 #ifdef __BORLANDC__ 00215 #if __BORLANDC__ <= 0x0200 /* Borland C++ 2.0 for DOS? .........*/ 00216 /* because the value */ 00217 #define POSMIN 2.2250738585072017E-308 /* 2.2250738585072014E-308 */ 00218 #else /* from `float.h' is */ 00219 /* regarded as zero! */ 00220 #define POSMIN DBL_MIN /* smallest positive floating point */ 00221 #endif /* number ...........................*/ 00222 #else 00223 #define POSMIN DBL_MIN /* smallest positive floating point */ 00224 #endif 00225 /*.IX{POS\unt MIN}*/ /* number ...........................*/ 00226 #else /* not an ANSI C compiler ? .........*/ 00227 #define POSMIN posmin() 00228 #endif 00229 00230 #define LZS "l" /* length prefix for formatted */ 00231 /*.IX{LZS}*/ 00232 /* input of floating point numbers ..*/ 00233 #define LZP "" /* length prefix for formatted */ 00234 /*.IX{LZP}*/ 00235 /* output of floating point numbers .*/ 00236 #endif 00237 #endif 00238 00239 00240 00241 /*********************************************************************** 00242 * declare several important data types * 00243 ***********************************************************************/ 00244 00245 // this appears to work, but I'm not too happy about it. -gp 00246 //#undef boolean 00247 //#undef FALSE 00248 //#undef TRUE 00249 #ifndef TRUE 00250 #ifndef boolean 00251 typedef enum {FALSE, TRUE} boolean; 00252 #endif 00253 #endif 00254 /*.IX{FALSE}*/ 00255 /*.IX{TRUE}*/ 00256 /*.IX{boolean}*/ 00257 00258 /* function pointer types for approximation in chapter 8 .............*/ 00259 typedef REAL (*ansatzfnk) (int i, REAL x); 00260 /*.IX{ansatzfnk}*/ 00261 typedef REAL (*approxfnk) (REAL c[], REAL x); 00262 /*.IX{approxfnk}*/ 00263 typedef void (*ableitfnk) (REAL x, REAL c[], REAL *d); 00264 /*.IX{ableitfnk}*/ 00265 00266 /* Type of function, which evaluates the right hand side of an .......*/ 00267 /* explicit ordinary differential equation y' = f(x,y) .......*/ 00268 typedef REAL (*dglfnk)(REAL x, REAL y); 00269 /*.IX{dglfnk}*/ 00270 00271 00272 /* Type of function, which evaluates the right hand side .............*/ 00273 /* of a system of differential equations y' = f(x,y) .............*/ 00274 typedef void (*dglsysfnk)(REAL x, REAL y[], REAL f[]); 00275 /*.IX{dglsysfnk}*/ 00276 00277 /* Type of function, which computes the boundary value r(ya, yb) .....*/ 00278 /* of a two-point first order boundary value problem .....*/ 00279 typedef void (*rndbedfnk)(REAL ya[], REAL yb[], REAL r[]); 00280 /*.IX{rndbedfnk}*/ 00281 00282 /* enumeration type for classification of error codes that are ......*/ 00283 /* returned from most of the functions that realize a numerical ......*/ 00284 /* method ......*/ 00285 typedef enum { KEIN_FEHLER, WARNUNG, UNBEKANNT, FATAL } fehler_t; 00286 /*.IX{KEIN\unt FEHLER}*/ 00287 /*.IX{WARNUNG}*/ 00288 /*.IX{UNBEKANNT}*/ 00289 /*.IX{FATAL}*/ 00290 /*.IX{fehler\unt t}*/ 00291 00292 typedef REAL abl_mat1[4][2]; /* used to evaluate splinefunctions */ 00293 /*.IX{abl\unt mat1}*/ 00294 typedef REAL abl_mat2[6][2]; /* in spliwert ......................*/ 00295 /*.IX{abl\unt mat2}*/ 00296 00297 typedef REAL mat4x4[4][4]; /* type for bicubic splines */ 00298 00299 /*--------------------------------------------------------------------* 00300 * Type declarations by Albert Becker * 00301 *--------------------------------------------------------------------*/ 00302 00303 /* Real functions ...................................................*/ 00304 typedef REAL (* REALFCT) (REAL); 00305 /*.IX{REALFCT}*/ 00306 00307 /* Real multi-dimensional functions .................................*/ 00308 typedef int (* FNFCT) (int, REAL [], REAL []); 00309 /*.IX{FNFCT}*/ 00310 00311 /* Functions for finding the Jacobi matrix ..........................*/ 00312 typedef int (* JACOFCT) (int, REAL [], REAL * []); 00313 /*.IX{JACOFCT}*/ 00314 00315 00316 00317 /*********************************************************************** 00318 * define sevaral important macros * 00319 * NOTE: Borland C++ offers floating point standard functions * 00320 * suitable for long double type from version 3.0 on such as * 00321 * expl() instead of exp(), sinl() instead of sin() etc. But * 00322 * Borland C++ 3.0 does not seem to define a macro that lets * 00323 * the user differentiate it from Borland C++ 2.0 and below, * 00324 * the user is forced to do so himself: If using Borland C++ * 00325 * 3.0 and long double the user should define the macro BC3 * 00326 * before compiling. Only in this case will the new maximally * 00327 * precise floating point functions be used. * 00328 ***********************************************************************/ 00329 00330 #define BASIS 2 /* Basis of number representation */ 00331 /*.IX{BASIS}*/ 00332 #define EPSROOT epsroot() /* square root of MACH_EPS */ 00333 /*.IX{EPSROOT}*/ 00334 #define EPSQUAD epsquad() /* square of MACH_EPS */ 00335 /*.IX{EPSQUAD}*/ 00336 #define MAXROOT maxroot() /* square root of the largest */ 00337 /*.IX{MAXROOT}*/ 00338 /* floating point number */ 00339 #ifndef PI 00340 #define PI pi() /* pi = 3.14... */ 00341 /*.IX{PI}*/ 00342 #endif 00343 #define EXP_1 exp_1() /* e = 2.71... */ 00344 /*.IX{EXP\unt 1}*/ 00345 00346 #define ZERO (REAL)0.0 /* declare names for recurring */ 00347 /*.IX{ZERO}*/ 00348 #define ONE (REAL)1.0 /* floating point numbers */ 00349 /*.IX{ONE}*/ 00350 #define TWO (REAL)2.0 00351 /*.IX{TWO}*/ 00352 #define THREE (REAL)3.0 00353 /*.IX{THREE}*/ 00354 #define FOUR (REAL)4.0 00355 /*.IX{FOUR}*/ 00356 #define FIVE (REAL)5.0 00357 /*.IX{FIVE}*/ 00358 #define SIX (REAL)6.0 00359 /*.IX{SIX}*/ 00360 #define EIGHT (REAL)8.0 00361 /*.IX{EIGHT}*/ 00362 #define NINE (REAL)9.0 00363 /*.IX{NINE}*/ 00364 #define TEN (REAL)10.0 00365 /*.IX{TEN}*/ 00366 #define HALF (REAL)0.5 00367 /*.IX{HALF}*/ 00368 00369 #ifdef __BORLANDC__ 00370 #if __BORLANDC__ >= 0x0400 /* a BC distinguishable from BC2 */ 00371 /* and with long double functions */ 00372 /* (at least Borland C++ 3.1 or */ 00373 /* Borland C++ 1.00 for OS/2)? */ 00374 #define BC3 /* define `BC3' automatically */ 00375 #endif 00376 #endif 00377 00378 #ifdef _MSC_VER 00379 #if _MSC_VER >= 0x0258 /* a MC distinguishable from QC2 */ 00380 /* and with long double functions */ 00381 /* (at least Microsoft C 6.00A)? */ 00382 #define MC6 /* define MC6 automatically */ 00383 #endif 00384 #endif 00385 00386 #if defined(LDOUBLE) && /* Borland C++ 3.0 or */\ 00387 (defined(BC3) || defined(MC6) || /* Microsoft C 6.0 or */\ 00388 defined(EMX09B)) /* emx 0.9b (GCC272) with */ 00389 /* maximal precision? */ 00390 #define FABS(x) fabsl((x)) /* use the long double */ 00391 /*.IX{FABS}*/ 00392 #define SQRT(x) sqrtl((x)) /* versions of the basic */ 00393 /*.IX{SQRT}*/ 00394 #define POW(x, y) powl((x), (y)) /* floating point */ 00395 /*.IX{POW}*/ 00396 #define SIN(x) sinl((x)) /* functions */ 00397 /*.IX{SIN}*/ 00398 #define COS(x) cosl((x)) 00399 /*.IX{COS}*/ 00400 #define EXP(x) expl((x)) 00401 /*.IX{EXP}*/ 00402 #define LOG(x) logl((x)) 00403 /*.IX{LOG}*/ 00404 #define ATAN(x) atanl((x)) 00405 /*.IX{ATAN}*/ 00406 #define ACOS(x) acosl((x)) 00407 /*.IX{ACOS}*/ 00408 #define COSH(x) coshl((x)) 00409 /*.IX{COSH}*/ 00410 00411 #else /* less precision or not a*/ 00412 /* BC3 and not a MC6 ? */ 00413 #define FABS(x) (REAL)fabs((double)(x)) /* declare names of basic */ 00414 #ifdef LONG_DOUBLE_USED /* floating point */ 00415 #define SQRT(x) sqrtlong((x)) /* functions that can be */ 00416 /*.IX{SQRT}*/ 00417 #else /* used in each of the */ 00418 #define SQRT(x) (REAL)sqrt((double)(x)) /* three precisions */ 00419 #endif 00420 #define POW(x, y) (REAL)pow((double)(x), \ 00421 /*.IX{POW}*/ \ 00422 (double)(y)) 00423 #define SIN(x) (REAL)sin((double)(x)) 00424 /*.IX{SIN}*/ 00425 #define COS(x) (REAL)cos((double)(x)) 00426 /*.IX{COS}*/ 00427 #define EXP(x) (REAL)exp((double)(x)) 00428 /*.IX{EXP}*/ 00429 #define LOG(x) (REAL)log((double)(x)) 00430 /*.IX{LOG}*/ 00431 #define ATAN(x) (REAL)atan((double)(x)) 00432 /*.IX{ATAN}*/ 00433 #define ACOS(x) (REAL)acos((double)(x)) 00434 /*.IX{ACOS}*/ 00435 #define COSH(x) (REAL)cosh((double)(x)) 00436 /*.IX{COSH}*/ 00437 #endif 00438 00439 #undef sign 00440 //lmartins: #undef min 00441 //lmartins: #undef max 00442 #define sign(x, y) (((y) < ZERO) ? -FABS(x) : /* |x| times */ \ 00443 /*.IX{sign}*/ \ 00444 FABS(x)) /* sign of y */ 00445 #define min_basis(a, b) (((a) < (b)) ? (a) : (b)) 00446 /*.IX{min}*/ 00447 #define max_basis(a, b) (((a) > (b)) ? (a) : (b)) 00448 /*.IX{max}*/ 00449 #define SWAP(typ, a, b) /* swap two objects of */ \ 00450 /*.IX{SWAP}*/ \ 00451 { typ temp; temp = a; a = b; b = temp; } /* arbitrary type */ 00452 00453 /* ------------------ Macros by Albert Becker ----------------------- */ 00454 #define ABS(X) (((X) >= ZERO) ? (X) : -(X)) /* Absolute value of X */ 00455 /*.IX{ABS}*/ 00456 #define SIGN(X,Y) \ 00457 /*.IX{SIGN}*/ \ 00458 (((Y) < ZERO) ? -ABS(X) : ABS(X)) /* sign of Y times */ 00459 /* ABS(X) */ 00460 #define SQR(X) ((X) * (X)) /* square of X */ 00461 /*.IX{SQR}*/ 00462 00463 #define FORMAT_IN "%lg" /* Input format for REAL */ 00464 /*.IX{FORMAT\unt IN}*/ 00465 #define FORMAT_LF "% " LZP "f " /* Format l for REAL */ 00466 /*.IX{FORMAT\unt LF}*/ 00467 #define FORMAT_126LF "% 12.6" LZP "f " /* Format 12.6f for REAL */ 00468 /*.IX{FORMAT\unt 126LF}*/ 00469 #define FORMAT_2010LF "% 20.10" LZP "f " /* Format 20.10f for REAL */ 00470 /*.IX{FORMAT\unt 2010LF}*/ 00471 #define FORMAT_2016LF "% 20.16" LZP "f " /* Format 20.16f for REAL */ 00472 /*.IX{FORMAT\unt 2016LF}*/ 00473 #define FORMAT_LE "% " LZP "e " /* Format e for REAL */ 00474 /*.IX{FORMAT\unt LE}*/ 00475 #define FORMAT_2016LE "% 20.16" LZP "e " /* Format 20.16e for REAL */ 00476 /*.IX{FORMAT\unt 2016LE}*/ 00477 00478 00479 00480 /*********************************************************************** 00481 * declare all external functions defined in basis.c * 00482 ***********************************************************************/ 00483 00484 int basis(void); /* find basis for number representation */ 00485 00486 REAL mach_eps(void); /* find machine constant */ 00487 00488 REAL epsroot(void); /* find square root of machine constant */ 00489 00490 REAL epsquad(void); /* find square of machine constant */ 00491 00492 REAL maxroot(void); /* Root of the largest representable number ....*/ 00493 00494 REAL posmin(void); /* find smallst positive floating point */ 00495 /* number */ 00496 00497 REAL pi(void); /* find pi */ 00498 00499 REAL exp_1(void); /* find e */ 00500 00501 REAL sqr(REAL x); /* square a floating point number */ 00502 00503 void fehler_melden /* Write error messages to stdout and stderr ....*/ 00504 ( 00505 char text[], /* error description ........*/ 00506 int fehlernummer, /* Number of error ..........*/ 00507 char dateiname[], /* file with error .........*/ 00508 int zeilennummer /* file name, row number ....*/ 00509 ); 00510 00511 int umleiten /* Perhaps redirect stdin or stdout to a file */ 00512 ( 00513 int argc, /* number of arguments in command line ..*/ 00514 char *argv[] /* Vector of arguments ..................*/ 00515 ); /* error code ...........................*/ 00516 00517 void readln(void); /* Skip the remainder of line in stdin */ 00518 00519 void getline /* Read one line from stdin ....................*/ 00520 ( 00521 char kette[], /* Vector with the read text ...........*/ 00522 int limit /* maximal length of kette .............*/ 00523 ); 00524 00525 int intervall /* Find the number for a value inside a partition ...*/ 00526 ( 00527 int n, /* lenght of partition ..................*/ 00528 REAL xwert, /* number whose interval index is wanted */ 00529 REAL x[] /* partition ............................*/ 00530 ); /* Index for xwert ......................*/ 00531 00532 REAL horner /* Horner scheme for polynomial evaluations .......*/ 00533 ( 00534 int n, /* Polynomial degree ......*/ 00535 REAL a[], /* Polynomial coefficients */ 00536 REAL x /* place of evaluation ....*/ 00537 ); /* Polynomial value at x ..*/ 00538 00539 REAL norm_max /* Find the maximum norm of a REAL vector .........*/ 00540 ( 00541 REAL vektor[], /* vector .................*/ 00542 int n /* length of vector .......*/ 00543 ); /* Maximum norm ...........*/ 00544 00545 REAL skalprod /* standard scalar product of two REAL vectors*/ 00546 ( 00547 REAL v[], /* 1st vector .....................*/ 00548 REAL w[], /* 2nd vector .....................*/ 00549 int n /* vector length...................*/ 00550 ); /* scalar product .................*/ 00551 00552 void copy_vector /* copy a REAL vector ........................*/ 00553 ( 00554 REAL ziel[], /* copied vector ............*/ 00555 REAL quelle[], /* original vector ..........*/ 00556 int n /* length of vector .........*/ 00557 ); 00558 00559 00560 /*--------------------------------------------------------------------* 00561 * Basic functions chapter 1 (by Albert Becker) ......................* 00562 *--------------------------------------------------------------------*/ 00563 00564 long double sqrtlong (long double x); 00565 00566 int comdiv /* Complex division ..........................*/ 00567 ( 00568 REAL ar, /* Real part of numerator ..........*/ 00569 REAL ai, /* Imaginary part of numerator .....*/ 00570 REAL br, /* Real part of denominator ........*/ 00571 REAL bi, /* Imaginary part of denominator ...*/ 00572 REAL * cr, /* Real part of quotient ...........*/ 00573 REAL * ci /* Imaginary part of quotient ......*/ 00574 ); 00575 00576 REAL comabs /* Complex absolute value ....................*/ 00577 ( 00578 REAL ar, /* Real part .......................*/ 00579 REAL ai /* Imaginary part ..................*/ 00580 ); 00581 00582 void quadsolv /* Complex quadratic equation ................*/ 00583 ( 00584 REAL ar, /* second degree coefficient .......*/ 00585 REAL ai, 00586 REAL br, /* linear coefficient ..............*/ 00587 REAL bi, 00588 REAL cr, /* polynomial constant .............*/ 00589 REAL ci, 00590 REAL * tr, /* solution ........................*/ 00591 REAL * ti 00592 ); 00593 00594 void SetVec /* initialize vector .........................*/ 00595 (int n, REAL x[], REAL val); 00596 00597 void CopyVec /* copy vector ...............................*/ 00598 (int n, REAL source[], REAL dest[]); 00599 00600 int ReadVec /* read vector from input index starts at zero*/ 00601 (FILE *fp, int n, REAL x[]); 00602 00603 int ReadVec1 /* read vector from input index starts at one */ 00604 (FILE *fp, int n, REAL x[]); 00605 00606 int WriteVec /* write vector to output index starts at zero*/ 00607 (FILE *fp, int n, REAL x[]); 00608 00609 int WriteVec1 /* write vector to output index starts at one */ 00610 (FILE *fp, int n, REAL x[]); 00611 00612 void SetMat /* initialize matrix .........................*/ 00613 (int m, int n, REAL * a[], REAL val); 00614 00615 void CopyMat /* copy matrix ...............................*/ 00616 (int m, int n, REAL * source[], REAL * dest[]); 00617 00618 int ReadMat /* read matrix from input index starts at zero*/ 00619 (FILE *fp, int m, int n, REAL * a[]); 00620 int ReadMat1 /* read matrix from input index starts at one */ 00621 (FILE *fp, int m, int n, REAL * a[]); 00622 00623 int WriteMat /* write matrix to output index starts at zero*/ 00624 (FILE *fp, int m, int n, REAL * mat[]); 00625 int WriteMat1 /* write matrix to output index starts at one */ 00626 (FILE *fp, int m, int n, REAL * mat[]); 00627 00628 int WriteHead (FILE *fp, char *s); /* write header to file ........*/ 00629 00630 int WriteEnd (FILE *fp); /* write separator to file .......*/ 00631 00632 void LogError /* write error message to stdout .............*/ 00633 (char *s, int rc, char *file, int line); 00634 00635 00636 00637 #endif 00638 00639 /* -------------------------- END basis.h --------------------------- */