33 #include <itpp/itexports.h>
46 inline double logb(
double b,
double x)
52 inline int pow2i(
int x) {
return ((x < 0) ? 0 : (1 << x)); }
54 inline double pow2(
double x) {
return pow(2.0, x); }
57 inline double pow10(
double x) {
return pow(10.0, x); }
60 inline double dB(
double x) {
return 10.0 *
log10(x); }
62 inline double inv_dB(
double x) {
return pow(10.0, 0.1 * x); }
67 it_assert(n >= 0,
"int2bits(): Improper argument value");
83 it_assert(n > 0,
"levels2bits(): Improper argument value");
106 if (std::numeric_limits<double>::is_iec559) {
107 if (x == std::numeric_limits<double>::infinity())
128 if (std::numeric_limits<double>::is_iec559
136 ITPP_EXPORT
double log_add(
double log_a,
double log_b);
144 inline vec
exp(
const vec &x)
146 return apply_function<double>(
std::exp, x);
149 inline cvec
exp(
const cvec &x)
151 return apply_function<std::complex<double> >(
std::exp, x);
154 inline mat
exp(
const mat &m)
156 return apply_function<double>(
std::exp, m);
159 inline cmat
exp(
const cmat &m)
161 return apply_function<std::complex<double> >(
std::exp, m);
165 inline vec
pow(
const double x,
const vec &y)
167 return apply_function<double>(
std::pow, x, y);
170 inline mat
pow(
const double x,
const mat &y)
172 return apply_function<double>(
std::pow, x, y);
175 inline vec
pow(
const vec &x,
const double y)
177 return apply_function<double>(
std::pow, x, y);
180 inline mat
pow(
const mat &x,
const double y)
182 return apply_function<double>(
std::pow, x, y);
188 return apply_function<double>(
pow2, x);
193 return apply_function<double>(
pow2, x);
199 return apply_function<double>(
pow10, x);
204 return apply_function<double>(
pow10, x);
208 inline vec
log(
const vec &x)
210 return apply_function<double>(
std::log, x);
213 inline mat
log(
const mat &x)
215 return apply_function<double>(
std::log, x);
218 inline cvec
log(
const cvec &x)
220 return apply_function<std::complex<double> >(
std::log, x);
223 inline cmat
log(
const cmat &x)
225 return apply_function<std::complex<double> >(
std::log, x);
233 ITPP_EXPORT vec
log2(
const vec &x);
235 ITPP_EXPORT mat
log2(
const mat &x);
249 inline vec
logb(
double b,
const vec &x)
251 return apply_function<double>(
itpp::logb, b, x);
254 inline mat
logb(
double b,
const mat &x)
256 return apply_function<double>(
itpp::logb, b, x);
260 inline vec
dB(
const vec &x)
262 return apply_function<double>(
dB, x);
265 inline mat
dB(
const mat &x)
267 return apply_function<double>(
dB, x);
273 return apply_function<double>(
inv_dB, x);
278 return apply_function<double>(
inv_dB, x);
284 return apply_function<int>(
int2bits, v);
297 #endif // #ifndef LOG_EXP_H