04.11.2011 - adjust for Windows & QNX, multiprotocol, repeater, signals, process, codec, console input

This commit is contained in:
peri4
2011-11-04 15:33:15 +03:00
parent 39ec9cac5c
commit e25553b97b
32 changed files with 468 additions and 294 deletions

View File

@@ -21,7 +21,7 @@ using std::complex;
typedef complex<int> complexi;
typedef complex<float> complexf;
typedef complex<double> complexd;
typedef complex<long double> complexld;
typedef complex<ldouble> complexld;
const complexld complexld_i(0., 1.);
const complexld complexld_0(0.);
const complexld complexld_1(1.);
@@ -32,7 +32,7 @@ const complexd complexd_1(1.);
const double deg2rad = atan(1.) / 45.;
const double rad2deg = 45. / atan(1.);
inline int pow2(int p) {return 1 << p;}
inline int pow2(const int p) {return 1 << p;}
inline double sqr(const double & v) {return v * v;}
inline double sinc(const double & v) {double t = M_PI * v; return sin(t) / t;}
inline complexd atanc(const complexd & c) {return -complexd(-0.5, 1.) * log((complexd_1 + complexd_i * c) / (complexd_1 - complexd_i * c));}
@@ -306,7 +306,7 @@ inline std::ostream & operator <<(std::ostream & s, const PIMathMatrixT<Cols, Ro
/// Multiply matrices {CR x Rows0} on {Cols1 x CR}, result is {Cols1 x Rows0}
template<uint CR, uint Rows0, uint Cols1, typename Type>
inline PIMathMatrixT<Cols1, Rows0, Type> operator *(const PIMathMatrixT<CR, Rows0, Type> & fm,
const PIMathMatrixT<Cols1, CR, Type> & sm) {
const PIMathMatrixT<Cols1, CR, Type> & sm) {
PIMathMatrixT<Cols1, Rows0, Type> tm;
Type t;
for (uint j = 0; j < Rows0; ++j) {
@@ -323,7 +323,7 @@ inline PIMathMatrixT<Cols1, Rows0, Type> operator *(const PIMathMatrixT<CR, Rows
/// Multiply matrix {Cols x Rows} on vector {Cols}, result is vector {Rows}
template<uint Cols, uint Rows, typename Type>
inline PIMathVectorT<Rows, Type> operator *(const PIMathMatrixT<Cols, Rows, Type> & fm,
const PIMathVectorT<Cols, Type> & sv) {
const PIMathVectorT<Cols, Type> & sv) {
PIMathVectorT<Rows, Type> tv;
Type t;
for (uint i = 0; i < Rows; ++i) {
@@ -459,8 +459,8 @@ public:
inline _CMatrix & resize(const uint cols, const uint rows, const Type & new_value = Type()) {cols_ = cols; rows_ = rows; m.resize(cols); PIMM_FOR_C(i) m[i].resize(rows, new_value); return *this;}
inline _CMatrix & setCol(uint index, const _CMCol & v) {PIMM_FOR_R(i) m[index][i] = v[i]; return *this;}
inline _CMatrix & setRow(uint index, const _CMRow & v) {PIMM_FOR_C(i) m[i][index] = v[i]; return *this;}
inline _CMatrix & swaprows_(uint r0, uint r1) {Type t; PIMM_FOR_C(i) {t = m[i][r0]; m[i][r0] = m[i][r1]; m[i][r1] = t;} return *this;}
inline _CMatrix & swapcols_(uint c0, uint c1) {Type t; PIMM_FOR_R(i) {t = m[c0][i]; m[c0][i] = m[c1][i]; m[c1][i] = t;} return *this;}
inline _CMatrix & swapRows(uint r0, uint r1) {Type t; PIMM_FOR_C(i) {t = m[i][r0]; m[i][r0] = m[i][r1]; m[i][r1] = t;} return *this;}
inline _CMatrix & swapCols(uint c0, uint c1) {Type t; PIMM_FOR_R(i) {t = m[c0][i]; m[c0][i] = m[c1][i]; m[c1][i] = t;} return *this;}
inline _CMatrix & fill(const Type & v) {PIMM_FOR_WB(c, r) m[c][r] = v; return *this;}
//inline _CMatrix & set(Type fval, ...) {m[0] = fval; va_list vl; va_start(vl, fval); PIMV_FOR(i, 1) m[i] = va_arg(vl, Type); va_end(vl); return *this;}
//inline void normalize() {Type tv = length(); if (tv == Type(1)) return; PIMV_FOR(i, 0) m[i] /= tv;}
@@ -510,7 +510,7 @@ public:
for (uint i = 0; i < cols_; ++i) {
crow = i;
while (smat.m[i][i] == Type(0))
smat.swaprows_(i, ++crow);
smat.swapRows(i, ++crow);
for (uint j = i + 1; j < rows_; ++j) {
mul = smat.m[i][j] / smat.m[i][i];
for (uint k = i; k < cols_; ++k) smat.m[k][j] -= mul * smat.m[k][i];
@@ -553,8 +553,8 @@ public:
crow = i;
while (smat.m[i][i] == Type(0)) {
++crow;
smat.swaprows_(i, crow);
mtmp.swaprows_(i, crow);
smat.swapRows(i, crow);
mtmp.swapRows(i, crow);
if (sv != 0) sv->swap(i, crow);
}
for (uint j = i + 1; j < rows_; ++j) {