16 #ifndef INCLUDED_numeric_trig_functions_hh
17 #define INCLUDED_numeric_trig_functions_hh
41 template<
typename T >
46 return (
T( 1.0 ) / std::cos( x ) );
51 template<
typename T >
56 return (
T( 1.0 ) / std::sin( x ) );
61 template<
typename T >
66 return (
T( 1.0 ) / std::tan( x ) );
71 template<
typename T >
76 assert(
tol >=
T( 0.0 ) );
77 return ( ( x >= -(
T( 1.0 ) +
tol ) ) && ( x <=
T( 1.0 ) +
tol ) );
92 template<
typename T >
100 using std::setprecision;
101 using std::showpoint;
103 assert(
tol >=
T( 0.0 ) );
104 if ( ( x >=
T( -1.0 ) ) && ( x <=
T( 1.0 ) ) ) {
106 }
else if ( ( x <=
T( -1.0 ) ) && ( x >= -(
T( 1.0 ) +
tol ) ) ) {
108 }
else if ( ( x >=
T( 1.0 ) ) && ( x <=
T( 1.0 ) +
tol ) ) {
111 cout <<
"sin_cos_range ERROR: " << setprecision( 8 ) << showpoint << x <<
" is outside of [-1,+1] sin and cos value legal range" << endl;
112 cerr <<
"sin_cos_range ERROR: " << setprecision( 8 ) << showpoint << x <<
" is outside of [-1,+1] sin and cos value legal range" << endl;
118 return ( x >=
T( 0.0 ) ?
T( 1.0 ) :
T( -1.0 ) );
121 std::string
const warning(
"NANs occured in sin_cos_range!" );
130 template<
typename T >
142 #endif // INCLUDED_numeric_trig_functions_HH
ocstream cerr(std::cerr)
Wrapper around std::cerr.
T cot(T const &x)
Cotangent.
bool in_sin_cos_range(T const &x, T const &tol=T(.001))
Is a sine or cosine value within a specified tolerance of the valid [-1,1] range? ...
common derived classes for thrown exceptions
T sin_cos_range(T const &x, T const &tol=T(.001))
Adjust a sine or cosine value to the valid [-1,1] range if within a specified tolerance or exit with ...
Program exit functions and macros.
#define utility_exit()
Macro function wrappers for utility::exit.
T csc(T const &x)
Cosecant.
ocstream cout(std::cout)
Wrapper around std::cout.
T arccos(T const x)
like std::acos but with range checking