Main Page   Class Hierarchy   Data Structures   File List   Data Fields   Globals  

util_math.C

Go to the documentation of this file.
00001 
00002 #include "stdinc.h"
00003 
00004 bool twiddles(real a, real b,
00005               real eps)         // default = 1.e-12
00006 {
00007     if (a == b || 2*abs(a-b) <= eps*(abs(a)+abs(b)))
00008         return true;
00009     else
00010         return false;
00011 }
00012 
00013 real adjust_number_to_power(real newstep, real max_step_size)
00014 {
00015     real tmp = 1.0;
00016     real limit = max_step_size;
00017     if(newstep < limit) limit = newstep;
00018     while(tmp < limit) tmp *= 4.0;
00019     while(tmp > limit) tmp *= 0.5;
00020     return tmp;
00021 }
00022 
00023 int sign(real x)
00024 {
00025     if (x > 0)
00026       return 1;
00027     else if (x < 0)
00028       return -1;
00029     else
00030       return 0;
00031 }
00032 
00033 #if !defined(linux)     // already defined un Linux/math.h
00034 
00035 real acosh(real x)  // inverse of cosh()
00036 {
00037     return log( x + sqrt( x * x - 1 ) );
00038 }
00039 
00040 real asinh(real x)  // inverse of sinh()
00041 {
00042     return sign(x) * log( abs(x) + sqrt( x * x + 1 ) );
00043 }
00044 
00045 #endif

Generated at Sun Feb 24 09:57:20 2002 for STARLAB by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001