34 #include <itpp/itexports.h>
54 for (
int i = 0; i < v.
length(); ++i) {
55 temp(i) =
static_cast<bin>(v(i));
68 for (
int i = 0; i < v.
length(); ++i) {
69 temp(i) =
static_cast<short>(v(i));
82 for (
int i = 0; i < v.
length(); ++i) {
83 temp(i) =
static_cast<int>(v(i));
96 for (
int i = 0; i < v.
length(); ++i) {
97 temp(i) =
static_cast<double>(v(i));
110 for (
int i = 0; i < v.
length(); ++i) {
111 temp(i) = std::complex<double>(
static_cast<double>(v(i)), 0.0);
132 "to_cvec(): real and imaginary parts must have the same length");
134 for (
int i = 0; i < real.
length(); ++i) {
135 temp(i) = std::complex<double>(
static_cast<double>(
real(i)),
136 static_cast<double>(
imag(i)));
171 for (
int i = 0; i < temp.rows(); ++i) {
172 for (
int j = 0; j < temp.cols(); ++j) {
173 temp(i, j) =
static_cast<bin>(m(i, j));
187 for (
int i = 0; i < temp.rows(); ++i) {
188 for (
int j = 0; j < temp.cols(); ++j) {
189 temp(i, j) =
static_cast<short>(m(i, j));
203 for (
int i = 0; i < temp.rows(); ++i) {
204 for (
int j = 0; j < temp.cols(); ++j) {
205 temp(i, j) =
static_cast<int>(m(i, j));
219 for (
int i = 0; i < temp.rows(); ++i) {
220 for (
int j = 0; j < temp.cols(); ++j) {
221 temp(i, j) =
static_cast<double>(m(i, j));
235 for (
int i = 0; i < temp.rows(); ++i) {
236 for (
int j = 0; j < temp.cols(); ++j) {
237 temp(i, j) = std::complex<double>(
static_cast<double>(m(i, j)), 0.0);
260 "to_cmat(): real and imag part sizes does not match");
261 cmat temp(real.
rows(), real.
cols());
262 for (
int i = 0; i < temp.rows(); ++i) {
263 for (
int j = 0; j < temp.cols(); ++j) {
264 temp(i, j) = std::complex<double>(
static_cast<double>(
real(i, j)),
265 static_cast<double>(
imag(i, j)));
280 ITPP_EXPORT
void dec2bin(
int index, bvec &v);
285 ITPP_EXPORT bvec
dec2bin(
int index,
bool msb_first =
true);
290 ITPP_EXPORT
int bin2dec(
const bvec &inbvec,
bool msb_first =
true);
299 ITPP_EXPORT bvec
oct2bin(
const ivec &octalindex,
short keepzeros = 0);
308 ITPP_EXPORT ivec
bin2oct(
const bvec &inbits);
311 ITPP_EXPORT ivec
bin2pol(
const bvec &inbvec);
314 ITPP_EXPORT bvec
pol2bin(
const ivec &inpol);
322 ITPP_EXPORT
double round(
double x);
324 ITPP_EXPORT vec
round(
const vec &x);
326 ITPP_EXPORT mat
round(
const mat &x);
328 ITPP_EXPORT
int round_i(
double x);
330 ITPP_EXPORT ivec
round_i(
const vec &x);
332 ITPP_EXPORT imat
round_i(
const mat &x);
335 inline vec
ceil(
const vec &x) {
return apply_function<double>(
std::ceil, x); }
337 inline mat
ceil(
const mat &x) {
return apply_function<double>(
std::ceil, x); }
341 ITPP_EXPORT ivec
ceil_i(
const vec &x);
343 ITPP_EXPORT imat
ceil_i(
const mat &x);
352 ITPP_EXPORT ivec
floor_i(
const vec &x);
354 ITPP_EXPORT imat
floor_i(
const mat &x);
360 return ((std::fabs(x) < threshold) ? 0.0 : x);
365 double threshold = 1e-14)
367 return std::complex<double>(
round_to_zero(x.real(), threshold),
384 ITPP_EXPORT cvec
round_to_zero(
const cvec &x,
double threshold = 1e-14);
387 ITPP_EXPORT cmat
round_to_zero(
const cmat &x,
double threshold = 1e-14);
392 return (std::fabs(in)>threshold)?
itpp::round(in):in;
396 inline std::complex<double>
round_to_infty(
const std::complex<double> &in,
const double threshold = 1e9)
415 ITPP_EXPORT cvec
round_to_infty(
const cvec &in,
const double threshold = 1e9);
418 ITPP_EXPORT cmat
round_to_infty(
const cmat &in,
const double threshold = 1e9);
429 template <
typename T>
430 std::string
to_str(
const T &i);
439 ITPP_EXPORT std::string
to_str(
const double &i,
const int precision);
443 template <
typename T>
446 std::ostringstream ss;
448 ss.setf(std::ostringstream::scientific, std::ostringstream::floatfield);
459 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT bvec
to_bvec(
const svec &v);
460 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT bvec
to_bvec(
const ivec &v);
462 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT svec
to_svec(
const bvec &v);
463 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT svec
to_svec(
const ivec &v);
464 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT svec
to_svec(
const vec &v);
466 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT ivec
to_ivec(
const bvec &v);
467 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT ivec
to_ivec(
const svec &v);
468 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT ivec
to_ivec(
const vec &v);
470 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT vec
to_vec(
const bvec &v);
471 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT vec
to_vec(
const svec &v);
472 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT vec
to_vec(
const ivec &v);
474 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cvec
to_cvec(
const bvec &v);
475 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cvec
to_cvec(
const svec &v);
476 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cvec
to_cvec(
const ivec &v);
477 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cvec
to_cvec(
const vec &v);
479 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cvec
to_cvec(
const bvec &
real,
const bvec &
imag);
480 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cvec
to_cvec(
const svec &
real,
const svec &
imag);
481 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cvec
to_cvec(
const ivec &
real,
const ivec &
imag);
482 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cvec
to_cvec(
const vec &
real,
const vec &
imag);
484 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
bmat to_bmat(
const smat &m);
485 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
bmat to_bmat(
const imat &m);
487 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT smat
to_smat(
const bmat &m);
488 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT smat
to_smat(
const imat &m);
489 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT smat
to_smat(
const mat &m);
491 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT imat
to_imat(
const bmat &m);
492 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT imat
to_imat(
const smat &m);
493 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT imat
to_imat(
const mat &m);
495 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT mat
to_mat(
const bmat &m);
496 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT mat
to_mat(
const smat &m);
497 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT mat
to_mat(
const imat &m);
499 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cmat
to_cmat(
const bmat &m);
500 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cmat
to_cmat(
const smat &m);
501 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cmat
to_cmat(
const imat &m);
502 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cmat
to_cmat(
const mat &m);
505 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cmat
to_cmat(
const smat &
real,
const smat &
imag);
506 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cmat
to_cmat(
const imat &
real,
const imat &
imag);
507 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cmat
to_cmat(
const mat &
real,
const mat &
imag);
513 #endif // CONVERTERS_H