当前位置: 首页>>代码示例>>C++>>正文


C++ ivec::length方法代码示例

本文整理汇总了C++中ivec::length方法的典型用法代码示例。如果您正苦于以下问题:C++ ivec::length方法的具体用法?C++ ivec::length怎么用?C++ ivec::length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ivec的用法示例。


在下文中一共展示了ivec::length方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: assert_ivec

static
void assert_ivec(const ivec &expected, const ivec &actual)
{
  ASSERT_EQ(expected.length(), actual.length());
  for (int n = 0; n < expected.length(); ++n)
  {
    ASSERT_EQ(expected[n], actual[n]);
  }
}
开发者ID:snikulov,项目名称:mirror.itpp,代码行数:9,代码来源:histogram_test.cpp

示例2: set_data

void cofdm_map::set_data(ivec x)
{
cvec qv;
bvec ce;
int K = x.length();
int i;

	ce.set_length(K); ce.ones();
	#if (DEBUG_LEVEL == 3)
	cout << "***** cofdm_map::set_data *****" << endl;	
	cout << "K=" << K << endl;
	cout << "ce=" << ce << endl;
	cout << "x=" << x << endl;
	cout << "data_carriers=" << data_carriers << endl;
	#endif

	if( K == data_carriers.length() ) {
		qv = qammod.process(ce,x);
		#if (DEBUG_LEVEL == 3)
		cout << "qv=" << qv << endl;
		#endif
		for (i=0; i<K; i++) {
			y0(data_carriers(i))=qv(i);
		}
	}
	else {
		throw sci_exception("cofdm_map::set_data - x.size() <> data_carriers.size()=", data_carriers.length());
	}

	#if (DEBUG_LEVEL == 3)
	cout << "y0(piltos)  y0(zeros) migh have rubbish" << endl;
	cout << "y0=" << y0 << endl;
	cout << "+++++ cofdm_map::set_data +++++" << endl;	
	#endif
}
开发者ID:maki63,项目名称:c_sci,代码行数:35,代码来源:csim_cofdm_map.cpp

示例3: set

void gfx::set(int qvalue, const ivec &invalues)
{
  //    it_assert0(qvalue>0, "gfx::set, out of range");
  degree=invalues.length()-1;
  coeffs.set_size(degree+1);
  for (int i=0;i<degree+1;i++)
	coeffs[i].set(qvalue,invalues[i]);
  q=qvalue;
}
开发者ID:mbillingr,项目名称:tools4bci-unibuild,代码行数:9,代码来源:gfx.cpp

示例4: process

cvec qam_mod::process(bvec ce, ivec x)
{
 cvec y;	
 int N;
 ivec iv;
 cvec cv;

	#if (DEBUG_LEVEL==3)
	cout << "***** qam_mod::process *****" << endl;	
	cout << "ce=" << ce << endl;
	cout << "x=" << x << endl;
	sleep(1000);
	#endif

	iv.set_length(1);
	cv.set_length(1);
	N=ce.length();
	y.set_length(N);
	if (x.length()!=N) {
		throw sci_exception("qam_mod::process - ce.size <> x.size", x.length() );
	}	
	for (int i=0; i<N; i++) {
		if ( bool(ce[i])) {
			iv[0]  = x[i];
			cv = modulate(iv);
			y0 = scale * cv[0];
		}
		y[i]=y0;
	}

	#if (DEBUG_LEVEL==3)
	cout << "y=" << y << endl;
	cout << "+++++ qam_mod::process +++++" << endl;	
	sleep(1000);
	#endif

	return (y);
}
开发者ID:maki63,项目名称:c_sci,代码行数:38,代码来源:csim_qam_mod.cpp

示例5: sci_exception

bmat int2bin::process(bvec ce, ivec x)
{
 bmat y;	
 int N;

	#if (DEBUG_LEVEL==3)
	cout << "***** int2bin::process *****" << endl;	
	cout << "ce=" << ce << endl;
	cout << "x=" << x << endl;
	sleep(1000);
	#endif

	N=ce.length();
	if (x.length()!=N) { 
		throw sci_exception("int2bin::process - ce.size <> x.rows()", x.length() );
	}

	y.set_size(N,symbol_size);
	for (int i=0; i<N; i++) {
		if ( bool(ce[i])) {
			y0 = dec2bin(symbol_size, x[i]);
			if (! msb_first) {
				y0 = reverse(y0);
			}
		}
		y.set_row(i,y0);
	}

	#if (DEBUG_LEVEL==3)
	cout << "y=" << y << endl;
	cout << "+++++ int2bin::process +++++" << endl;	
	sleep(1000);
	#endif

	return (y);
}
开发者ID:maki63,项目名称:c_sci,代码行数:36,代码来源:csim_int2bin.cpp

示例6: set_sel_carriers

void cofdm_sel::set_sel_carriers(ivec cindx)
{
	if( cindx.length() < NFFT ) {
		if (itpp::min(cindx) >= 0) {
			if (itpp::max(cindx) < NFFT) {
				sel_carriers = cindx;
			}
			else {
				throw sci_exception("cofdm_sel::set_sel_carriers - max(cindx) > NFFT=", NFFT);
			}
		}
		else {
			throw sci_exception("cofdm_sel::set_sel_carriers - min(cindx) <  0 ");
		}
	}
	else {
		throw sci_exception("cofdm_sel::set_sel_carriers - bad cindx.size() > NFFT=", NFFT);
	}
}
开发者ID:maki63,项目名称:c_sci,代码行数:19,代码来源:csim_cofdm_sel.cpp

示例7: set_pilots_carriers

void cofdm_map::set_pilots_carriers(ivec pcindx)
{
	if( pcindx.length() < NFFT ) {
		if (itpp::min(pcindx) >= 0) {
			if (itpp::max(pcindx) < NFFT) {
				pilots_carriers = pcindx;
			}
			else {
				throw sci_exception("cofdm_map::set_pilots_carriers - max(pcindx) > NFFT=", NFFT);
			}
		}
		else {
			throw sci_exception("cofdm_map::set_pilots_carriers - min(dcindx) <  0 ");
		}
	}
	else {
		throw sci_exception("cofdm_map::set_pilots_carriers - bad pcindx.size() > NFFT=", NFFT);
	}	
}
开发者ID:maki63,项目名称:c_sci,代码行数:19,代码来源:csim_cofdm_map.cpp

示例8: set_zero_carriers

void cofdm_map::set_zero_carriers(ivec zcindx)
{
	if( zcindx.length() < NFFT ) {
		if (itpp::min(zcindx) >= 0) {
			if (itpp::max(zcindx) < NFFT) {
				zero_carriers = zcindx;
			}
			else {
				throw sci_exception("cofdm_map::set_zero_carriers - max(zcindx) > NFFT=", NFFT);
			}
		}
		else {
			throw sci_exception("cofdm_map::set_zero_carriers - min(zcindx) <  0 ");
		}
	}
	else {
		throw sci_exception("cofdm_map::set_zero_carriers - bad zcindx.size() > NFFT=", NFFT);
	}
	
}
开发者ID:maki63,项目名称:c_sci,代码行数:20,代码来源:csim_cofdm_map.cpp

示例9: set_data_carriers

void cofdm_map::set_data_carriers(ivec dcindx)
{
	if( dcindx.length() < NFFT ) {
		if (itpp::min(dcindx) >= 0) {
			if (itpp::max(dcindx) < NFFT) {
				data_carriers = dcindx;
			}
			else {
				throw sci_exception("cofdm_map::set_data_carriers - max(dcindx) > NFFT=", NFFT);
			}
		}
		else {
			throw sci_exception("cofdm_map::set_data_carriers - min(dcindx) <  0 ");
		}
	
	}
	else {
		throw sci_exception("cofdm_map::set_data_carriers - bad dcindx.size() > NFFT=", NFFT);
	}
}
开发者ID:maki63,项目名称:c_sci,代码行数:20,代码来源:csim_cofdm_map.cpp

示例10: decode

bool Reed_Solomon::decode(const bvec &coded_bits, const ivec &erasure_positions, bvec &decoded_message, bvec &cw_isvalid)
{
  bool decoderfailure, no_dec_failure;
  int j, i, kk, l, L, foundzeros, iterations = floor_i(static_cast<double>(coded_bits.length()) / (n * m));
  bvec mbit(m * k);
  decoded_message.set_size(iterations * k * m, false);
  cw_isvalid.set_length(iterations);

  GFX rx(q, n - 1), cx(q, n - 1), mx(q, k - 1), ex(q, n - 1), S(q, 2 * t), Xi(q, 2 * t), Gamma(q), Lambda(q),
      Psiprime(q), OldLambda(q), T(q), Omega(q);
  GFX dummy(q), One(q, (char*)"0"), Omegatemp(q);
  GF delta(q), tempsum(q), rtemp(q), temp(q), Xk(q), Xkinv(q);
  ivec errorpos;

  if ( erasure_positions.length() ) {
    it_assert(max(erasure_positions) < iterations*n, "Reed_Solomon::decode: erasure position is invalid.");
  }
  
  no_dec_failure = true;
  for (i = 0; i < iterations; i++) {
    decoderfailure = false;
    //Fix the received polynomial r(x)
    for (j = 0; j < n; j++) {
      rtemp.set(q, coded_bits.mid(i * n * m + j * m, m));
      rx[j] = rtemp;
    }
    // Fix the Erasure polynomial Gamma(x)
    // and replace erased coordinates with zeros
    rtemp.set(q, -1);
    ivec alphapow = - ones_i(2);
    Gamma = One;
    for (j = 0; j < erasure_positions.length(); j++) {
      rx[erasure_positions(j)] = rtemp;
      alphapow(1) = erasure_positions(j);
      Gamma *= (One - GFX(q, alphapow));
    }
    //Fix the syndrome polynomial S(x).
    S.clear();
    for (j = 1; j <= 2 * t; j++) {
      S[j] = rx(GF(q, b + j - 1));
    }
    // calculate the modified syndrome polynomial Xi(x) = Gamma * (1+S) - 1
    Xi = Gamma * (One + S) - One;
    // Apply Berlekam-Massey algorithm
    if (Xi.get_true_degree() >= 1) { //Errors in the received word
      // Iterate to find Lambda(x), which hold all error locations
      kk = 0;
      Lambda = One;
      L = 0;
      T = GFX(q, (char*)"-1 0");
      while (kk < 2 * t) {
        kk = kk + 1;
        tempsum = GF(q, -1);
        for (l = 1; l <= L; l++) {
          tempsum += Lambda[l] * Xi[kk - l];
        }
        delta = Xi[kk] - tempsum;
        if (delta != GF(q, -1)) {
          OldLambda = Lambda;
          Lambda -= delta * T;
          if (2 * L < kk) {
            L = kk - L;
            T = OldLambda / delta;
          }
        }
        T = GFX(q, (char*)"-1 0") * T;
      }
      // Find the zeros to Lambda(x)
      errorpos.set_size(Lambda.get_true_degree());
      foundzeros = 0;
      for (j = q - 2; j >= 0; j--) {
        if (Lambda(GF(q, j)) == GF(q, -1)) {
          errorpos(foundzeros) = (n - j) % n;
          foundzeros += 1;
          if (foundzeros >= Lambda.get_true_degree()) {
            break;
          }
        }
      }
      if (foundzeros != Lambda.get_true_degree()) {
        decoderfailure = true;
      }
      else { // Forney algorithm...
        //Compute Omega(x) using the key equation for RS-decoding
        Omega.set_degree(2 * t);
        Omegatemp = Lambda * (One + Xi);
        for (j = 0; j <= 2 * t; j++) {
          Omega[j] = Omegatemp[j];
        }
        //Find the error/erasure magnitude polynomial by treating them the same
        Psiprime = formal_derivate(Lambda*Gamma);
        errorpos = concat(errorpos, erasure_positions);
        ex.clear();
        for (j = 0; j < errorpos.length(); j++) {
          Xk = GF(q, errorpos(j));
          Xkinv = GF(q, 0) / Xk;
          // we calculate ex = - error polynomial, in order to avoid the 
          // subtraction when recunstructing the corrected codeword
          ex[errorpos(j)] = (Xk * Omega(Xkinv)) / Psiprime(Xkinv);
          if (b != 1) { // non-narrow-sense code needs corrected error magnitudes
//.........这里部分代码省略.........
开发者ID:c304728539,项目名称:itpp-fastica,代码行数:101,代码来源:reedsolomon.cpp

示例11: mean

/*
  Return the mean value of the elements in the vector
*/
double mean(const ivec& v)
{
    return (double)sum(v)/v.length();
}
开发者ID:mbillingr,项目名称:tools4bci-unibuild,代码行数:7,代码来源:array1d_functions.cpp


注:本文中的ivec::length方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。