cmat operator+(const bmat &a, const cmat &b) { it_assert_debug(a.cols() == b.cols() && a.rows() == b.rows(), "operator+(): sizes does not match"); cmat temp(b); for (int i = 0;i < a.rows();i++) { for (int j = 0;j < a.cols();j++) { temp(i, j) += std::complex<double>(static_cast<double>(a(i, j)), 0.0); } } return temp; }
mat operator+(const bmat &a, const mat &b) { it_assert_debug(a.cols() == b.cols() && a.rows() == b.rows(), "operator+(): sizes does not match"); mat temp(b); for (int i = 0;i < a.rows();i++) { for (int j = 0;j < a.cols();j++) { temp(i, j) += (double)a(i, j); } } return temp; }
vec src::process(bmat ceio, mat xt) { vec y; int K; #if (DEBUG_LEVEL==3) cout << "***** src::process *****" << endl; cout << "ceio=" << ceio << endl; cout << "xt=" << xt << endl; sleep(1000); #endif if (ceio.cols() != 2) { throw sci_exception("src::process - ceio.cols() <> 2 ", ceio.cols() ); } if (xt.cols() != 2) { throw sci_exception("src::process - xt.cols() <> 2 ", xt.cols() ); } if (xt.rows() != ceio.rows() ) { throw sci_exception("src::process - xt.rows() <> ceio.rows() ", xt.rows() ); } K=ceio.rows(); y.set_length(K); for (int i=0; i<K; i++) { // cei - input sample to x_cb if ( bool(ceio(i,0))) { xcb(xt(i,0)); } // ceo - re_samp for tau if ( bool(ceio(i,1))) { y0= re_samp(xt(i,1)); } y(i)=y0; } #if (DEBUG_LEVEL==3) cout << "y=" << y << endl; cout << "+++++ src::process +++++" << endl; sleep(1000); #endif return (y); }
// ceio [cei|ceo] bmat binbuff::process(bmat ceio, bmat x) { bmat y; int K,i; #if (DEBUG_LEVEL==3) cout << "***** binbuff::process *****" << endl; cout << "ceio=" << endl<< ceio << endl; cout << "x=" << endl<< x << endl; sleep(SLEEP_TIME_MS); #endif if (ceio.cols() != 2) { throw sci_exception("binbuff::process - ceio.cols() <> 2 ", ceio.cols() ); } if (x.rows() != ceio.rows() ) { throw sci_exception("binbuff::process - x.rows() <> ceio.rows() ", x.rows() ); } K=ceio.rows(); y.set_size(K,symbol_size); #if (DEBUG_LEVEL==3) cout << "K=" << K << endl; cout << "symbol_size=" << symbol_size << endl; cout << "y0=" << endl <<y0 << endl; sleep(SLEEP_TIME_MS); #endif for ( i=0; i<K; i++) { // cei - input sample to cb if ( bool(ceio(i,0))) { #if (DEBUG_LEVEL==3) cout << "(put x.get_row(" << i << "))=" << x.get_row(i) << endl; #endif put(x.get_row(i)); } // ceo - get sample from cb if ( bool(ceio(i,1))) { try { #if (DEBUG_LEVEL==3) cout << "get (" << i << ") ="; #endif get(y0, symbol_size); #if (DEBUG_LEVEL==3) cout << y0 << endl; #endif } catch (...) { throw sci_exception (" binbuff::process - error for get()"); } } y.set_row(i,y0); } #if (DEBUG_LEVEL==3) cout << "y=" << y << endl; cout << "+++++ binbuff::process +++++" << endl; sleep(SLEEP_TIME_MS); #endif return (y); }
// ceio [cei|ceo] // cmat [xi+%i*xq|t+%i*0] // cvec [yi+%i*yq] cvec tedg_x::process(bmat ceio, cvec x) { cvec y; int K,i; double y0i, y0q; #if (DEBUG_LEVEL==3) cout << "***** tedg_x::process *****" << endl; cout << "ceio=" << ceio << endl; cout << "x=" << x << endl; sleep(1000); #endif if (ceio.cols() != 2) { throw sci_exception("tedg_x::process - ceio.cols() <> 2 ", ceio.cols() ); } if (x.length() != ceio.rows() ) { throw sci_exception("tedg_x::process - x.lenght() <> ceio.rows() ", x.length() ); } K=ceio.rows(); y.set_length(K); for ( i=0; i<K; i++) { // cei - input sample to x_cb if ( bool(ceio(i,0))) { x2=x1; x1=x0; x0=x(i); } // ceo if ( bool(ceio(i,1))) { switch (MODE) { case TEDG_MODE_STD: y0i = (x0.real()-x2.real())*(x1.real()); y0q = (x0.imag()-x2.imag())*(x1.imag()); y0 = complex<double>(y0i,y0q); break; case TEDG_MODE_EDGE: if ((x0.real() > 0.0) && (x2.real() < 0.0)) { y0i = x1.real(); } else if ((x0.real() < 0.0) && (x2.real() > 0.0)) { y0i = - x1.real(); } else { y0i =0.0; }; if ( (x0.imag() > 0.0) && (x2.imag() < 0.0 ) ) { y0q = x1.imag(); } else if ( ( x0.imag() < 0.0 ) && (x2.imag()> 0.0 ) ) { y0q = - x1.imag(); } else { y0q =0.0; }; y0 = complex<double>(y0i,y0q); break; case TEDG_MODE_PUMP: if ((x0.real() > 0.0) && (x2.real() < 0.0)) { y0i = sgn(x1.real()); } else if ((x0.real() < 0.0) && (x2.real() > 0.0)) { y0i = - sgn(x1.real()); } else { y0i =0.0; }; if ( (x0.imag() > 0.0) && (x2.imag() < 0.0 ) ) { y0q = sgn(x1.imag()); } else if ( ( x0.imag() < 0.0 ) && (x2.imag()> 0.0 ) ) { y0q = - sgn(x1.imag()); } else { y0q =0.0; }; y0 = complex<double>(y0i,y0q) * TED_PUMP; break; default: throw sci_exception("tedg_x::process - bad mode", MODE ); break; } } y(i)= y0; } #if (DEBUG_LEVEL==3) cout << "y=" << y << endl; cout << "+++++ tedg_x::process +++++" << endl; sleep(1000); #endif return (y); }