fix_functions.cpp
Go to the documentation of this file.
#include <itpp/fixed/fix_functions.h>
namespace itpp
{
vec to_vec(const fixvec &v)
{
vec temp(v.length());
for (int i = 0; i < v.length(); i++) {
temp(i) = v(i).unfix();
}
return temp;
}
cvec to_cvec(const cfixvec &v)
{
cvec temp(v.length());
for (int i = 0; i < v.length(); i++) {
temp(i) = v(i).unfix();
}
return temp;
}
mat to_mat(const fixmat &m)
{
mat temp(m.rows(), m.cols());
for (int i = 0; i < m.rows(); i++) {
for (int j = 0; j < m.cols(); j++) {
temp(i, j) = m(i, j).unfix();
}
}
return temp;
}
cmat to_cmat(const cfixmat &m)
{
cmat temp(m.rows(), m.cols());
for (int i = 0; i < m.rows(); i++) {
for (int j = 0; j < m.cols(); j++) {
temp(i, j) = m(i, j).unfix();
}
}
return temp;
}
Fix abs(const Fix &x)
{
fixrep tmp = x.get_re();
return Fix((tmp >= 0 ? tmp : -tmp), // Risk for overflow!
x.get_shift(),
0, 0);
}
Fix real(const CFix &x)
{
return Fix(x.get_re(),
x.get_shift(),
0, 0);
}
Fix imag(const CFix &x)
{
return Fix(x.get_im(),
x.get_shift(),
0, 0);
}
CFix conj(const CFix &x)
{
return CFix(x.get_re(),
-x.get_im(),
x.get_shift(),
0, 0);
}
} // namespace itpp
itpp::Mat::cols
int cols() const
The number of columns.
Definition: mat.h:235
fix_functions.h
Definitions of a set of functions for Fix, Fixed, CFix and CFixed classes.
itpp::imag
vec imag(const cvec &data)
Imaginary part of complex values.
Definition: elem_math.cpp:180
itpp::Mat::rows
int rows() const
The number of rows.
Definition: mat.h:237
itpp::Mat
Matrix Class (Templated)
Definition: factory.h:41
itpp::conj
cvec conj(const cvec &x)
Conjugate of complex value.
Definition: elem_math.h:226
itpp::to_cmat
cmat to_cmat(const Mat< T > &m)
Converts a Mat<T> to cmat.
Definition: converters.h:232
itpp::to_mat
mat to_mat(const Mat< T > &m)
Converts a Mat<T> to mat.
Definition: converters.h:216
itpp::CFix
Complex fixed-point data type.
Definition: cfix.h:51
itpp::CFix::get_re
fixrep get_re() const
Get data representation for real part (mainly for internal use since it reveals the representation ty...
Definition: cfix.h:138
itpp::to_vec
vec to_vec(const Vec< T > &v)
Converts a Vec<T> to vec.
Definition: converters.h:93
itpp::Fix
Fixed-point data type.
Definition: fix.h:51
itpp::CFix::get_im
fixrep get_im() const
Get data representation for imaginary part (mainly for internal use since it reveals the representati...
Definition: cfix.h:140
itpp::Vec
Vector Class (Templated)
Definition: factory.h:42
itpp::to_cvec
cvec to_cvec(const Vec< T > &v)
Converts a Vec<T> to cvec.
Definition: converters.h:107
itpp::Fix_Base::get_shift
int get_shift() const
Get shift.
Definition: fix_base.h:1001
itpp::abs
bin abs(const bin &inbin)
absolute value of bin
Definition: binary.h:174
itpp::fixrep
int64_t fixrep
Representation for fixed-point data types.
Definition: fix_base.h:884
itpp::Vec::length
int length() const
The size of the vector.
Definition: vec.h:269
itpp::Fix::get_re
fixrep get_re() const
Get data representation (mainly for internal use since it reveals the representation type) ...
Definition: fix.h:116
itpp::real
vec real(const cvec &data)
Real part of complex values.
Definition: elem_math.cpp:157

Generated on Thu Mar 20 2014 12:26:43 for IT++ by Doxygen 1.8.6