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::Array
General array class.
Definition array.h:105
itpp::Array::length
int length() const
Returns the number of data elements in the array object.
Definition array.h:157
itpp::CFix
Complex fixed-point data type.
Definition cfix.h:52
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::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::Fix_Base::get_shift
int get_shift() const
Get shift.
Definition fix_base.h:1001
itpp::Fix
Fixed-point data type.
Definition fix.h:52
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::Mat
Matrix Class (Templated)
Definition mat.h:202
itpp::Mat::rows
int rows() const
The number of rows.
Definition mat.h:237
itpp::Mat::cols
int cols() const
The number of columns.
Definition mat.h:235
itpp::Vec
Vector Class (Templated)
Definition vec.h:245
fix_functions.h
Definitions of a set of functions for Fix, Fixed, CFix and CFixed classes.
itpp::fixrep
int64_t fixrep
Representation for fixed-point data types.
Definition fix_base.h:884
itpp::imag
vec imag(const cvec &data)
Imaginary part of complex values.
Definition elem_math.cpp:180
itpp::real
vec real(const cvec &data)
Real part of complex values.
Definition elem_math.cpp:157
itpp::conj
cvec conj(const cvec &x)
Conjugate of complex value.
Definition elem_math.h:226
itpp
itpp namespace
Definition itmex.h:37
itpp::to_cvec
cvec to_cvec(const Vec< T > &v)
Converts a Vec<T> to cvec.
Definition converters.h:107
itpp::to_cmat
cmat to_cmat(const Mat< T > &m)
Converts a Mat<T> to cmat.
Definition converters.h:232
itpp::to_vec
vec to_vec(const Vec< T > &v)
Converts a Vec<T> to vec.
Definition converters.h:93
itpp::to_mat
mat to_mat(const Mat< T > &m)
Converts a Mat<T> to mat.
Definition converters.h:216
itpp::abs
bin abs(const bin &inbin)
absolute value of bin
Definition binary.h:174

Generated on Mon Jun 10 2024 11:49:23 for IT++ by Doxygen 1.9.8