misc.h
Go to the documentation of this file.
#ifndef MISC_H
#define MISC_H
#include <complex>
#include <string>
#include <limits>
#include <itpp/itexports.h>
namespace std
{
template <class T>
std::ostream& operator<<(std::ostream &os, const std::complex<T> &x)
{
os << x.real();
ios::fmtflags saved_format = os.setf(ios::showpos);
os << x.imag();
os.setf(saved_format, ios::showpos);
return os << 'i';
}
template <class T>
std::istream& operator>>(std::istream &is, std::complex<T> &x)
{
T re, im;
char c;
is >> c;
if (c == '(') {
is >> re >> c;
if (c == ',') {
is >> im >> c;
if (c == ')') {
x = complex<T>(re, im);
}
else {
is.setstate(ios_base::failbit);
}
}
else if (c == ')') {
x = complex<T>(re, T(0));
}
else {
is.setstate(ios_base::failbit);
}
}
else {
is.putback(c);
is >> re;
if (!is.eof() && ((c = static_cast<char>(is.peek())) == '+' || c == '-')) {
is >> im >> c;
if (c == 'i') {
x = complex<T>(re, im);
}
else {
is.setstate(ios_base::failbit);
}
}
else {
x = complex<T>(re, T(0));
}
}
return is;
}
} // namespace std
namespace itpp
{
const double pi = 3.14159265358979323846;
const double m_2pi = 2 * pi;
const double eps = std::numeric_limits<double>::epsilon();
inline bool is_int(double x)
{
double dummy;
return (modf(x, &dummy) == 0.0);
}
inline bool is_even(int x) { return ((x&1) == 0); }
ITPP_EXPORT std::string itpp_version();
ITPP_EXPORT bool is_bigendian();
inline bool check_big_endianness() { return is_bigendian(); }
} //namespace itpp
#endif // #ifndef MISC_H
itpp::Array
General array class.
Definition array.h:105
itpp::is_bigendian
bool is_bigendian()
Returns true if machine endianness is BIG_ENDIAN.
Definition misc.cpp:50
itpp::itpp_version
std::string itpp_version(void)
Returns IT++ library version number, e.g. "3.7.1".
Definition misc.cpp:41
itpp::is_even
bool is_even(int x)
Return true if x is an even integer.
Definition misc.h:122
itpp::check_big_endianness
bool check_big_endianness()
This function is deprecated. Please use is_bigendian() instead.
Definition misc.h:131
itpp::is_int
bool is_int(double x)
Return true if x is an integer.
Definition misc.h:115
itpp
itpp namespace
Definition itmex.h:37
itpp::m_2pi
const double m_2pi
Constant 2*Pi.
Definition misc.h:106
itpp::pi
const double pi
Constant Pi.
Definition misc.h:103
itpp::eps
const double eps
Constant eps.
Definition misc.h:109
std
STL namespace.
std::operator<<
std::ostream & operator<<(std::ostream &os, const std::complex< T > &x)
Output stream operator for complex numbers.
Definition misc.h:42
std::operator>>
std::istream & operator>>(std::istream &is, std::complex< T > &x)
Input stream operator for complex numbers.
Definition misc.h:53

Generated on Mon Jun 10 2024 11:49:18 for IT++ by Doxygen 1.9.8