Macros | Functions
util.cpp File Reference

Implementation of auxilliary utility functions for SDHLibrary-CPP. More...

#include "sdhlibrary_settings.h"
#include <math.h>
#include <time.h>
#include <assert.h>
#include <iostream>
#include "util.h"
Include dependency graph for util.cpp:

Go to the source code of this file.

Macros

#define _USE_MATH_DEFINES
 

Functions

double Approx (double a, double b, double eps)
 
bool Approx (int n, double *a, double *b, double *eps)
 
int CompareReleases (char const *rev1, char const *rev2)
 compare release strings More...
 
double DegToRad (double d)
 
NAMESPACE_SDH_START bool InIndex (int v, int max)
 
bool InRange (double v, double min, double max)
 
bool InRange (int n, double const *v, double const *min, double const *max)
 
std::vector< int > NumerifyRelease (char const *rev)
 
double RadToDeg (double r)
 
void SleepSec (double t)
 
double ToRange (double v, double min, double max)
 
void ToRange (int n, double *v, double const *min, double const *max)
 
void ToRange (std::vector< double > &v, std::vector< double > const &min, std::vector< double > const &max)
 
void ToRange (cSimpleVector &v, std::vector< double > const &min, std::vector< double > const &max)
 

Detailed Description

Implementation of auxilliary utility functions for SDHLibrary-CPP.

General file information

Author
Dirk Osswald
Date
2007-02-19

Copyright


Definition in file util.cpp.

Macro Definition Documentation

◆ _USE_MATH_DEFINES

#define _USE_MATH_DEFINES

Definition at line 36 of file util.cpp.

Function Documentation

◆ Approx() [1/2]

double Approx ( double  a,
double  b,
double  eps 
)

Return True if a is approximately the same as b. I.E. |a-b| < eps

Definition at line 126 of file util.cpp.

◆ Approx() [2/2]

bool Approx ( int  n,
double *  a,
double *  b,
double *  eps 
)

Return True if list/tuple/array a=(a1,a2,...) is approximately the same as b=(b1,b2,...). I.E. |a_i-b_i| < eps[i]

Definition at line 132 of file util.cpp.

◆ CompareReleases()

int CompareReleases ( char const *  rev1,
char const *  rev2 
)

compare release strings

compare release strings rev1 and rev2.

Returns
-1,0, or 1 if rev1 is older, equal or newer than rev2
Parameters
rev1- a release string like "0.0.1.5" or "0.0.1.11-a"
rev2- another release string

Example:

  • CompareReleases( "0.0.1.5", "0.0.1.5" ) ==> 0
  • CompareReleases( "0.0.1.5", "0.0.1.4" ) ==> 1
  • CompareReleases( "0.0.1.5", "0.0.2.1" ) ==> -1
  • CompareReleases( "0.0.1.5", "0.0.1.5-a" ) ==> -1

Definition at line 236 of file util.cpp.

◆ DegToRad()

double DegToRad ( double  d)

Return d in deg converted to rad

Definition at line 143 of file util.cpp.

◆ InIndex()

NAMESPACE_SDH_START bool InIndex ( int  v,
int  max 
)

Return True if v is in range [0 .. max[

Definition at line 74 of file util.cpp.

◆ InRange() [1/2]

bool InRange ( double  v,
double  min,
double  max 
)

Return True if v is in range [min .. max]

Definition at line 80 of file util.cpp.

◆ InRange() [2/2]

bool InRange ( int  n,
double const *  v,
double const *  min,
double const *  max 
)

Return True if in list/tuple/array v=(v1,v2,...) each v_i is in range [min_i..max_i] with min = (min1, min2,...) max = (max1, max2, ..)

Definition at line 86 of file util.cpp.

◆ NumerifyRelease()

std::vector<int> NumerifyRelease ( char const *  rev)

return a vector of integer numbers for a release string rev

Parameters
revrelease string like "0.0.1.11-a"
Returns
a vector of integer numbers like [0,0,1,11,1]

Definition at line 177 of file util.cpp.

◆ RadToDeg()

double RadToDeg ( double  r)

Return r in rad converted to deg

Definition at line 149 of file util.cpp.

◆ SleepSec()

void SleepSec ( double  t)

Sleep for t seconds. (t is a double!)

Definition at line 155 of file util.cpp.

◆ ToRange() [1/4]

double ToRange ( double  v,
double  min,
double  max 
)

Return v limited to range [min .. max]. I.e. if v is < min then min is returned, or if v > max then max is returned, else v is returned

Definition at line 97 of file util.cpp.

◆ ToRange() [2/4]

void ToRange ( int  n,
double *  v,
double const *  min,
double const *  max 
)

Limit each v_i in v to range [min_i..max_i] with min = (min1, min2,...) max = (max1, max2, ..) This modifies *v!

Definition at line 105 of file util.cpp.

◆ ToRange() [3/4]

void ToRange ( std::vector< double > &  v,
std::vector< double > const &  min,
std::vector< double > const &  max 
)

Limit each v_i in v to range [min_i..max_i] with min = (min1, min2,...) max = (max1, max2, ..) This modifies v!

Definition at line 114 of file util.cpp.

◆ ToRange() [4/4]

void ToRange ( cSimpleVector v,
std::vector< double > const &  min,
std::vector< double > const &  max 
)

Limit each v_i in v to range [min_i..max_i] with min = (min1, min2,...) max = (max1, max2, ..) This modifies v!

Definition at line 120 of file util.cpp.



sdhlibrary_cpp
Author(s): Dirk Osswald
autogenerated on Mon Feb 28 2022 23:41:52