34 #include <itpp/itexports.h>
47 inline double logb(
double b,
double x)
53 inline int pow2i(
int x) {
return ((x < 0) ? 0 : (1 << x)); }
63 return std::ldexp(1.0,x);
78 it_assert(n >= 0,
"int2bits(): Improper argument value");
94 it_assert(n > 0,
"levels2bits(): Improper argument value");
117 if (std::numeric_limits<double>::is_iec559) {
118 if (x == std::numeric_limits<double>::infinity())
139 if (std::numeric_limits<double>::is_iec559
147 ITPP_EXPORT
double log_add(
double log_a,
double log_b);
155 inline vec
exp(
const vec &x)
157 return apply_function<double>(
std::exp, x);
160 inline cvec
exp(
const cvec &x)
162 return apply_function<std::complex<double> >(
std::exp, x);
165 inline mat
exp(
const mat &m)
167 return apply_function<double>(
std::exp, m);
170 inline cmat
exp(
const cmat &m)
172 return apply_function<std::complex<double> >(
std::exp, m);
176 inline vec
pow(
const double x,
const vec &y)
178 return apply_function<double>(
std::pow, x, y);
181 inline mat
pow(
const double x,
const mat &y)
183 return apply_function<double>(
std::pow, x, y);
186 inline vec
pow(
const vec &x,
const double y)
188 return apply_function<double>(
std::pow, x, y);
191 inline mat
pow(
const mat &x,
const double y)
193 return apply_function<double>(
std::pow, x, y);
199 return apply_function<double>(
pow2, x);
206 for(
int i = 0; i < x.length(); i++)
214 return apply_function<double>(
pow2, x);
220 mat out(x.rows(), x.cols());
221 for(
int i = 0; i < x.rows(); i++) {
222 for(
int j = 0; j < x.cols(); j++) {
223 out(i, j) =
pow2(x(i, j));
232 return apply_function<double>(
pow10, x);
237 return apply_function<double>(
pow10, x);
241 inline vec
log(
const vec &x)
243 return apply_function<double>(
std::log, x);
246 inline mat
log(
const mat &x)
248 return apply_function<double>(
std::log, x);
251 inline cvec
log(
const cvec &x)
253 return apply_function<std::complex<double> >(
std::log, x);
256 inline cmat
log(
const cmat &x)
258 return apply_function<std::complex<double> >(
std::log, x);
266 ITPP_EXPORT vec
log2(
const vec &x);
268 ITPP_EXPORT mat
log2(
const mat &x);
282 inline vec
logb(
double b,
const vec &x)
284 return apply_function<double>(
itpp::logb, b, x);
287 inline mat
logb(
double b,
const mat &x)
289 return apply_function<double>(
itpp::logb, b, x);
293 inline vec
dB(
const vec &x)
295 return apply_function<double>(
dB, x);
298 inline mat
dB(
const mat &x)
300 return apply_function<double>(
dB, x);
306 return apply_function<double>(
inv_dB, x);
311 return apply_function<double>(
inv_dB, x);
317 return apply_function<int>(
int2bits, v);
330 #endif // #ifndef LOG_EXP_H