46 lines
866 B
C++
46 lines
866 B
C++
/*
|
|
* utility.h
|
|
*
|
|
* Created on: Mar 22, 2011
|
|
* Author: ditlevsen
|
|
*/
|
|
|
|
#ifndef UTILITY_H_
|
|
#define UTILITY_H_
|
|
|
|
/**********************************************************************************/
|
|
/* functions, etc. for handling different data types in mathematical expressions */
|
|
/**********************************************************************************/
|
|
|
|
// overloaded versions of conj() and real() for scalar values...
|
|
// (not needed when compiled with gcc and -std_c++0x)
|
|
|
|
template <class Type>
|
|
inline Type conj(Type f) {
|
|
return f;
|
|
}
|
|
|
|
template<class Type>
|
|
inline Type real(Type f) {
|
|
return f;
|
|
}
|
|
|
|
template<class Type>
|
|
inline Type imag(Type f) {
|
|
return 0;
|
|
}
|
|
|
|
|
|
// sign function
|
|
|
|
template<class T_comp, class T_scal>
|
|
inline T_comp sign(T_comp x) {
|
|
T_scal ax = std::abs(x);
|
|
if(ax > 0)
|
|
return x/ax;
|
|
else
|
|
return 0;
|
|
}
|
|
|
|
#endif /* UTILITY_H_ */
|