basics.cppGo to the documentation of this file.00001 00002 // $Revision: 1.1 $ 00003 // $Date: 2001/08/23 16:45:44 $ 00004 // $Source: /usr/local/cvs/OpenSees/SRC/nDarray/basics.cpp,v $ 00005 00006 00007 //############################################################################ 00008 //# # 00009 //# /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/~~\ # 00010 //# | |____| # 00011 //# | | # 00012 //# | | # 00013 //# | B A S E | # 00014 //# | | # 00015 //# | | # 00016 //# | C L A S S E S | # 00017 //# | | # 00018 //# | | # 00019 //# | C + + S O U R C E | # 00020 //# | | # 00021 //# | | # 00022 //# | | # 00023 //# | | # 00024 //# | | # 00025 //# /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/ | # 00026 //# | | | # 00027 //# \_________________________________________\__/ # 00028 //# # 00029 //# # 00030 //############################################################################ 00031 // 00032 // "C makes it easy to shoot yourself in the foot, C++ makes it harder, 00033 // but when you do, it blows away your whole leg" -- Bjarne Stroustrup 00034 // 00035 //############################################################################# 00036 00037 // 00038 //################################################################################ 00039 //# COPY-YES (C): :-)) # 00040 //# PROJECT: Object Oriented Finite Element Program # 00041 //# PURPOSE: # 00042 //# CLASS: # 00043 //# # 00044 //# VERSION: # 00045 //# LANGUAGE: C++.ver >= 2.0 ( Borland C++ ver=3.10, SUN C++ ver=2.1 ) # 00046 //# TARGET OS: DOS || UNIX || . . . # 00047 //# DESIGNER(S): Boris Jeremic # 00048 //# PROGRAMMER(S): Boris Jeremic # 00049 //# # # 00050 //# DATE: November '92 # 00051 //# UPDATE HISTORY: 05 - __ avgust '93. redefined as derived class from # 00052 //# nDarray class # 00053 //# january 06 '93 added Matrix2BJtensor_1, Matrix2BJtensor_2 # 00054 //# Matrix2BJtensor_3 # 00055 //# August 22-29 '94 choped to separate files and worked on # 00056 //# const and & issues # 00057 //# August 30-31 '94 added use_def_dim to full the CC # 00058 //# resolved problem with temoraries for # 00059 //# operators + and - ( +=, -= ) # 00060 //# # 00061 //# # 00062 //################################################################################ 00063 // 00064 #ifndef BASICS_CC 00065 #define BASICS_CC 00066 00067 00068 #include "basics.h" 00069 00070 00071 //############################################################################## 00072 //DEBUGheap // heap checking function 00073 //DEBUGheap void heap(char *message) 00074 //DEBUGheap { 00075 //DEBUGheap struct heapinfo hi; 00076 //DEBUGheap 00077 //DEBUGheap if (*message) ::printf("%s",message); 00078 //DEBUGheap 00079 //DEBUGheap int counter = 0; 00080 //DEBUGheap hi.ptr = NULL; 00081 //DEBUGheap ::printf( "\n counter Pointer Size Status\n" ); 00082 //DEBUGheap 00083 //DEBUGheap unsigned int size = 0; 00084 //DEBUGheap char use[10]; 00085 //DEBUGheap while( heapwalk( &hi ) == _HEAPOK ) 00086 //DEBUGheap { 00087 //DEBUGheap counter++; 00088 //DEBUGheap size = hi.size; 00089 //DEBUGheap 00090 //DEBUGheap if(hi.in_use == 0 ) strcpy(use," free"); 00091 //DEBUGheap if(hi.in_use == 1 ) strcpy(use,"USED"); 00092 //DEBUGheap printf( " %7d %p %7u %s\n", counter,hi.ptr,size, use ); 00093 //DEBUGheap } 00094 //DEBUGheap } 00095 00096 00097 //############################################################################## 00098 // find out the machine epsilon of the runing platform ! 00099 //############################################################################## 00100 float f_macheps() 00101 { 00102 float eps = 1.0; 00103 int counter = 1; 00104 float one = 1.0; 00105 while ( (one + eps) > one ) 00106 { 00107 eps = eps/2.0; 00108 counter++; 00109 // ::printf("eps = %.20e counter = %7d \n",eps,counter); 00110 } 00111 eps = eps*2.0; 00112 counter--; 00113 00114 // ::printf("\n flota macheps = %.20e at counter = %d \n",eps,counter); 00115 00116 return eps; 00117 } 00118 00119 //############################################################################## 00120 double d_macheps() 00121 { 00122 double eps = 1.0; 00123 int counter = 1; 00124 while ( ((double) 1.0 + eps) > ((double) 1.0) ) 00125 { 00126 eps = eps/2.0; 00127 counter++; 00128 // ::printf("eps = %.16e counter = %7d \n",eps,counter); 00129 } 00130 eps = eps*2.0; 00131 counter--; 00132 // ::printf("\n double macheps = %.20e at counter = %d \n",eps,counter); 00133 00134 return eps; 00135 } 00136 00137 //############################################################################## 00138 long double ld_macheps() 00139 { 00140 long double eps = 1.0; 00141 int counter = 1; 00142 while ( ((long double) 1.0 + eps) > ((long double) 1.0) ) 00143 { 00144 eps = eps/2.0; 00145 counter++; 00146 // ::printf("eps = %.16le counter = %7d \n",eps,counter); 00147 } 00148 eps = eps*2.0; 00149 counter--; 00150 // ::printf("\n long double macheps = %.20le at counter = %d \n",eps,counter); 00151 00152 return eps; 00153 } 00154 00155 00156 double min(double a, double b) 00157 { 00158 double ret=0; 00159 ret=(a<b) ? a : b; 00160 return ret; 00161 } 00162 00163 double max(double a, double b) 00164 { 00165 double ret=0; 00166 ret=(a>b) ? a : b; 00167 return ret; 00168 } 00169 00170 int min(int a, int b) 00171 { 00172 int ret=0; 00173 ret=(a<b) ? a : b; 00174 return ret; 00175 } 00176 00177 int max(int a, int b) 00178 { 00179 int ret=0; 00180 ret=(a>b) ? a : b; 00181 return ret; 00182 } 00183 00184 #endif 00185 |