Beispiel #1
0
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;
}
Beispiel #2
0
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;
}
void Rec_Syst_Conv_Code::encode_tail(const bvec &input, bvec &tail, bmat &parity_bits)
{
  int i, j, length = input.size(), target_state;
  parity_bits.set_size(length+m, n-1, false);
  tail.set_size(m, false);
  
  encoder_state = 0;
  for (i=0; i<length; i++) {
    for (j=0; j<(n-1); j++) {
      parity_bits(i,j) = output_parity(encoder_state,2*j+int(input(i)));
    }
    encoder_state = state_trans(encoder_state,int(input(i)));
  }
  
  // add tail of m=K-1 zeros
  for (i=0; i<m; i++) {
    target_state = (encoder_state<<1) & ((1<<m)-1);
    if (state_trans(encoder_state,0)==target_state) { tail(i) = bin(0); } else { tail(i) = bin(1); }
    for (j=0; j<(n-1); j++) {
      parity_bits(length+i,j) = output_parity(encoder_state,2*j+int(tail(i)));
    }
    encoder_state = target_state;
  }
  terminated = true;
}
Beispiel #4
0
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);
}
void Rec_Syst_Conv_Code::encode(const bvec &input, bmat &parity_bits)
{
  int i, j, length = input.size();
  parity_bits.set_size(length, n-1, false);
  
  encoder_state = 0;
  for (i=0; i<length; i++) {
    for (j=0; j<(n-1); j++) {
      parity_bits(i,j) = output_parity(encoder_state,2*j+int(input(i)));
    }
    encoder_state = state_trans(encoder_state,int(input(i)));
  }
  terminated = false;
}
Beispiel #6
0
// 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);
}
Beispiel #7
0
// 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);
}