36 #define _USE_MATH_DEFINES 76 return 0 <= v && v < max;
80 bool InRange(
double v,
double min,
double max )
82 return min <= v && v <= max;
86 bool InRange(
int n,
double const* v,
double const* min,
double const* max )
88 for (
int i=0; i < n; i++ )
90 if (!
InRange( v[i], min[i], max[i] ))
97 double ToRange(
double v,
double min,
double max )
99 if (v < min)
return min;
100 if (v > max)
return max;
105 void ToRange(
int n,
double* v,
double const* min,
double const* max )
107 for (
int i=0; i < n; i++ )
109 v[i] =
ToRange( v[i], min[i], max[i] );
114 void ToRange( std::vector<double>& v, std::vector<double>
const& min, std::vector<double>
const& max )
116 ToRange(
int(v.size()), &(v[0]), &(min[0]), &(max[0]) );
126 double Approx(
double a,
double b,
double eps )
128 return fabs( a - b ) < eps;
132 bool Approx(
int n,
double* a,
double* b,
double* eps )
134 for (
int i=0; i < n; i++ )
136 if (!
Approx( a[i], b[i], eps[i] ))
158 ::Sleep( static_cast<int>(1000.0*t) );
161 sleeptime.tv_sec = (time_t) floor( t );
162 sleeptime.tv_nsec = (long) ((t - floor( t )) * 1E9);
166 nanosleep( &sleeptime,
NULL );
179 std::vector<int> result;
180 char const* rev_orig = rev;
182 while ( rev !=
NULL && *rev !=
'\0' )
185 int chars_scanned = 0;
187 rc = sscanf( rev,
"%d%n", &r, &chars_scanned );
191 if ( chars_scanned > 0 )
195 rev += chars_scanned;
197 else if ( chars_scanned == 0 &&
'a' <= *rev && *rev <=
'z' )
199 result.push_back( *rev -
'a' + 1 );
202 else if ( chars_scanned == 0 &&
'A' <= *rev && *rev <=
'Z' )
204 result.push_back( *rev -
'A' + 1 );
207 else if ( chars_scanned == 0 && ( *rev ==
'.' || *rev ==
'-' ) )
213 std::cerr <<
"NumerifyRelease( " << rev_orig <<
" ) Could not be handled!\n";
215 assert(
"invalid rev string!" ==
NULL );
238 assert( rev1 !=
NULL );
239 assert( rev2 !=
NULL );
244 std::vector<int>::const_iterator n1 = nums1.begin();
245 std::vector<int>::const_iterator n2 = nums2.begin();
247 for ( ; n1 != nums1.end() && n2 != nums2.end(); n1++, n2++ )
251 else if ( *n1 > *n2 )
256 if ( nums1.size() < nums2.size() )
258 if ( nums1.size() > nums2.size() )
double RadToDeg(double r)
A simple vector implementation.
NAMESPACE_SDH_START bool InIndex(int v, int max)
std::vector< int > NumerifyRelease(char const *rev)
double DegToRad(double d)
bool InRange(double v, double min, double max)
#define NAMESPACE_SDH_START
int CompareReleases(char const *rev1, char const *rev2)
compare release strings
Interface of auxilliary utility functions for SDHLibrary-CPP.
double Approx(double a, double b, double eps)
double ToRange(double v, double min, double max)
#define NAMESPACE_SDH_END
This file contains settings to make the SDHLibrary compile on differen systems:
number of elements in vector