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 void dec2bin(
int index, bvec &v);
285 bvec
dec2bin(
int index,
bool msb_first =
true);
290 int bin2dec(
const bvec &inbvec,
bool msb_first =
true);
299 bvec
oct2bin(
const ivec &octalindex,
short keepzeros = 0);
308 ivec
bin2oct(
const bvec &inbits);
311 ivec
bin2pol(
const bvec &inbvec);
314 bvec
pol2bin(
const ivec &inpol);
322 double round(
double x);
324 vec
round(
const vec &x);
326 mat
round(
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 ivec
ceil_i(
const vec &x);
343 imat
ceil_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),
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 cvec
round_to_infty(
const cvec &in,
const double threshold = 1e9);
418 cmat
round_to_infty(
const cmat &in,
const double threshold = 1e9);
429 template <
typename T>
430 std::string
to_str(
const T &i);
439 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);
461 extern template bvec
to_bvec(
const svec &v);
462 extern template bvec
to_bvec(
const ivec &v);
464 extern template svec
to_svec(
const bvec &v);
465 extern template svec
to_svec(
const ivec &v);
466 extern template svec
to_svec(
const vec &v);
468 extern template ivec
to_ivec(
const bvec &v);
469 extern template ivec
to_ivec(
const svec &v);
470 extern template ivec
to_ivec(
const vec &v);
472 extern template vec
to_vec(
const bvec &v);
473 extern template vec
to_vec(
const svec &v);
474 extern template vec
to_vec(
const ivec &v);
476 extern template cvec
to_cvec(
const bvec &v);
477 extern template cvec
to_cvec(
const svec &v);
478 extern template cvec
to_cvec(
const ivec &v);
479 extern template cvec
to_cvec(
const vec &v);
490 extern template smat
to_smat(
const imat &m);
491 extern template smat
to_smat(
const mat &m);
494 extern template imat
to_imat(
const smat &m);
495 extern template imat
to_imat(
const mat &m);
498 extern template mat
to_mat(
const smat &m);
499 extern template mat
to_mat(
const imat &m);
502 extern template cmat
to_cmat(
const smat &m);
503 extern template cmat
to_cmat(
const imat &m);
504 extern template cmat
to_cmat(
const mat &m);
517 #endif // CONVERTERS_H