• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ VEC类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: integ

double integ(VEC &X,VEC &Y,int n){ // composite nth order Newton-Cotes integral
    int iter = (X.len()-1)/n;
    //printf("iter : %d\n",iter);
    double space = X[X.len()] - X[0];
    double h = space/(X.len()-1);
    double sum = 0.0;
    VEC w(n+1);
    if(n == 1)
	w[0] = w[1] = 0.5;
    else if (n == 2)
	w[0] = w[2] =  1./3. , w[1] = 4./3.;
    else if (n == 3)
	w[0] = w[3] =  3./8. , w[1] = w[2] = 9./8.;
    else if (n == 4)
	w[0] = w[4] =  14./45. , w[1] = w[3] = 64./45. , w[2] = 24./45.;
    else if (n == 5)
	w[0] = w[5] =  95./288. , w[1] = w[4] = 375./288. , w[2] = w[3] = 250./288.;
    else if (n == 6)
	w[0] = w[6] =  41./140. , w[1] = w[5] = 216./140. , w[2] = w[4] = 27./140. , w[3] = 272./140.;
    /*for(int i = 0; i<=n;i++)
	printf("w%d = %f\n",i,w[i]);
	printf("space = %f\n h = %f\n",space,h);*/
    for(int i = 0; i< iter; i++){
	for(int j = 0; j<= n; j++){
	    sum += (w[j] * Y[ n*i + j ]);
	    //printf("%d\n",n*i+j);
	}
    }
    return sum * h;
  
} 
开发者ID:charismaticchiu,项目名称:NumericalAnalysis,代码行数:31,代码来源:MAT.cpp


示例2: writeToFile

//writes file in format:
//x_1   y_m     z_1_m
//x_2   y_m     z_1_m
//x_3   y_m     z_1_m
//      .
//      .
//x_n   y_m     z_1_(m-1)
//x_1   y_(m_1) z_1_(m-1)
//      .
//      .
//x_n   y_1     z_n_1
bool XYZ_Writer::writeToFile(const VEC &x,
                             const VEC &y, 
                             const vector<VEC> &z)
{
    ofstream fhandle(m_fileName.c_str(), ios::out);

    //get size from vectors
    size_t n = x.size();
    size_t m = y.size();

    double xVal, yVal, zVal;
    size_t xIdx, yIdx;
    for(size_t i = 0; i != m*n; ++i)
    {
        //write x value
        xIdx = i % n;
        xVal = x[xIdx];
        fhandle << xVal << " ";

        //write y value
        yIdx = m - 1 - (i - (i%n))/n;
        yVal = y[yIdx];
        fhandle << yVal << " ";

        //write z value
        zVal = isnan(z[yIdx][xIdx]) ? 0.0 : z[yIdx][xIdx];


        fhandle << zVal << endl;
    }

    return true;
}
开发者ID:aasoni,项目名称:wave,代码行数:44,代码来源:xyz_writer.cpp


示例3: test_log1m_exp

void test_log1m_exp(double val) {
  using stan::math::log1m_exp;
  using stan::agrad::log1m_exp;
  using stan::agrad::exp;
  using std::exp;

  AVAR a(val);   
  AVEC x = createAVEC(a);
  AVAR f = log1m_exp(a);
  EXPECT_FLOAT_EQ(log1m_exp(val), f.val());
  VEC g;
  f.grad(x,g);
  double f_val = f.val();
  
  AVAR a2(val);
  AVEC x2 = createAVEC(a2);
  AVAR f2 = log(1.0 - exp(a2));
  VEC g2;
  f2.grad(x2,g2);

  EXPECT_EQ(1U,g.size());
  EXPECT_EQ(1U,g2.size());
  EXPECT_FLOAT_EQ(g2[0],g[0]);
  EXPECT_FLOAT_EQ(g2[0],-1/boost::math::expm1(-val)); // analytic deriv
  EXPECT_FLOAT_EQ(f2.val(),f_val);
}
开发者ID:javaosos,项目名称:stan,代码行数:26,代码来源:log1m_exp_test.cpp


示例4: HTMLGraph

vector<HTML *> HTMLGraph(T * parent) {
  vector<HTML*> result;
  bool border = true;
  typedef vector<T*> VEC;
  VEC V;
  parent->GetGraphChildren(V);
  VEC::const_iterator w = V.begin(), e = V.end();
  HTML * child;
  HTML * aroot;
  while(w!=e) {
    child = *w;
    table = new HTMLTable(border);
    result.push_back(table); 
    table->add(p->HTMLGraphNode(),1,1);
    vector<HTML *> L;
    child->GetGraphChildren(L);
    vector<HTML*>::const_iterator ww = L.begin(), ee = L.end();
    if(ww!=ee) {
      HTMLTable * subtable = new HTMLTable(border);
      table->add(subtable,1,2);
      int i=1;
      while(ww!=ee) {
        subtable->add(*ww,1,i);
        ++ww;++i;
      };
    };
    ++w;
  };
};
开发者ID:lolmid,项目名称:2015-2016,代码行数:29,代码来源:GraphAPI.hpp


示例5: generateMatrix

MTRX generateMatrix(Mnd mnd) {
  MTRX output;
  int mn = mnd.m * mnd.n;
  int m = mnd.m;
  
  for (int mn1 = 0; mn1 < mn; mn1++) {
    int m1 = mn1 / m;
    int n1 = mn1 % m;
    VEC v;
    for (int mn2 = 0; mn2 < mn; mn2++) {
      int m2 = mn2 / m;
      int n2 = mn2 % m;
      if (mn1 == mn2 || abs(m1 - m2) + abs(n1 - n2) == mnd.d) {
        v.push_back(1);
      } else {
        v.push_back(0);
      }
    }
    for (int mn3 = 0; mn3 < mn; mn3++) {
      v.push_back(mn1 == mn3 ? 1 : 0);
    }
    output.push_back(v);
  }
  return output;
}
开发者ID:mayah,项目名称:ICPC,代码行数:25,代码来源:d_reorder.cpp


示例6: choose_next

 static std::size_t choose_next(VEC const& weights, std::size_t present, RNG& rng){
   double sum = *(std::max_element(weights.begin(), weights.end()));
   sum -= weights[present] * rng();
   for (int i = 0; i < weights.size(); ++i) {
     int j = (present + i + 1) % weights.size();
     if (sum <= weights[j]) return j;
     sum -= weights[j];
   }
   return present;
 }
开发者ID:cmsi,项目名称:bcl,代码行数:10,代码来源:st2010.hpp


示例7: TestSslowlog

void TestSslowlog(){
    CRedisClient redis;
    redis.connect( "127.0.0.1", 6379 );
    cout << "------test slowlog------" << endl;
    VEC vec;
    vec.push_back("GET");
    CResult res;
    redis.slowlog(vec,res);
    cout<<res<<endl;
}
开发者ID:RedisCppTeam,项目名称:redis-client,代码行数:10,代码来源:testServer.cpp


示例8: TEST

TEST(AgradRev,asin_out_of_bounds2) {
  AVAR a = -1.0 - stan::math::EPSILON;
  AVAR f = asin(a);
  AVEC x = createAVEC(a);
  VEC g;
  f.grad(x,g);
  EXPECT_TRUE(std::isnan(asin(a)));
  EXPECT_TRUE(g.size() == 1);
  EXPECT_TRUE(std::isnan(g[0]));
}
开发者ID:stan-dev,项目名称:math,代码行数:10,代码来源:asin_test.cpp


示例9: TEST

TEST(AgradRev,abs_var_3) {
  AVAR a = 0.0;
  AVAR f = abs(a);
  EXPECT_FLOAT_EQ(0.0, f.val());

  AVEC x = createAVEC(a);
  VEC g;
  f.grad(x,g);
  EXPECT_EQ(1,g.size());
  EXPECT_FLOAT_EQ(0.0, g[0]);
}
开发者ID:frenchjl,项目名称:stan,代码行数:11,代码来源:abs_test.cpp


示例10: TestServerPrint

void TestServerPrint(const string& cmd,VEC& vec)
{
    cout<<cmd<<":"<<endl;
    VEC::const_iterator it = vec.begin();
    VEC::const_iterator end = vec.end();
    for ( ; it != end; ++it )
    {
        cout<<*it<<endl;
    }
    cout<<endl;
}
开发者ID:RedisCppTeam,项目名称:redis-client,代码行数:11,代码来源:testServer.cpp


示例11: multiply

VEC multiply(const MTRX &matrix, const VEC &row) {
  VEC output;
  for (int i = 0; i < matrix.size(); i++) {
    int sum = 0;
    for (int j = 0; j < matrix[i].size(); j++) {
      sum += matrix[i][j] * row[j];
    }
    output.push_back(sum % 2);
  }
  return output;
}
开发者ID:mayah,项目名称:ICPC,代码行数:11,代码来源:d_reorder.cpp


示例12: glRotate

/** @brief rotate in the given direction
 * @tparam VEC point type including POINT::Scalar as coord type
 * @param _direction vector which points in the desired direction
 */
template<class VEC> void glRotate(const VEC& _direction)
{
  // get coordinate type from vector type
  typedef typename VEC::scalar_type Scalar;
  // pre-calculate vector length
  Scalar length = _direction.length();
  // calculate phi and theta (@link http://de.wikipedia.org/wiki/Kugelkoordinaten#.C3.9Cbliche_Konvention)
  Scalar phi = tomo::rad2deg( atan2(_direction.y(), _direction.x()) );
  Scalar theta = (0.0 != length) ? tomo::rad2deg(acos( (_direction.z() / length) )) : 0.0;
  // rotate GL world
  glRotate(phi,theta);
}
开发者ID:aeickho,项目名称:Tomo,代码行数:16,代码来源:render.hpp


示例13: assert

void BoundingBox<VEC>::fusion(const BoundingBox<VEC>& bb)
{
	assert(m_initialized || !"Bounding box not initialized");
	VEC bbmin = bb.min() ;
	VEC bbmax = bb.max() ;
	for(unsigned int i = 0; i < bbmin.dimension(); ++i)
	{
		if(bbmin[i] < m_pMin[i])
			m_pMin[i] = bbmin[i] ;
		if(bbmax[i] > m_pMax[i])
			m_pMax[i] = bbmax[i] ;
	}
}
开发者ID:sujithvg,项目名称:CGoGN,代码行数:13,代码来源:bounding_box.hpp


示例14: preSolve

MTRX preSolve(Mnd mnd) {
  MTRX matrix = generateMatrix(mnd);
  int rank = gaussianElimination(matrix);
  MTRX output;
  for (int i = rank; i < matrix.size(); i++) {
    VEC v;
    for (int j = matrix[0].size()/2; j < matrix[0].size(); j++) {
      v.push_back(matrix[i][j]);
    }
    output.push_back(v);
  }
  return output;
}
开发者ID:mayah,项目名称:ICPC,代码行数:13,代码来源:d_reorder.cpp


示例15: findLocalMinima

static void findLocalMinima ( const VEC& intData, vector<mz_uint>& minIndexes) {
    for (size_t i = 0; i < intData.size(); ++i) {
        if ( i == 0) {
            if (intData[i + 1] > intData[i])
                minIndexes.push_back(i);
        } else if ( i == intData.size() - 1) {
            if ( intData[i - 1] > intData[i] )
                minIndexes.push_back(i);
        } else {
            if (intData[i - 1] > intData[i] && intData[i + 1] > intData[i])
                minIndexes.push_back(i);
        }
    }
}
开发者ID:AlexandreBurel,项目名称:pwiz-mzdb,代码行数:14,代码来源:peak_finder_utils.hpp


示例16: findLocalMaxima

static void findLocalMaxima ( const VEC& intData, vector<mz_uint>& maxIndexes, float threshold) {
    for (size_t i = 0; i < intData.size(); ++i) {
        if ( i == 0) {
            if (intData[i + 1] < intData[i] && intData[i] > threshold)
                maxIndexes.push_back(i);
        } else if ( i == intData.size() - 1 && intData[i] > threshold) {
            if ( intData[i - 1] < intData[i] )
                maxIndexes.push_back(i);
        } else {
            if (intData[i - 1] < intData[i] && intData[i + 1] < intData[i] && intData[i] > threshold)
                maxIndexes.push_back(i);
        }
    }
}
开发者ID:AlexandreBurel,项目名称:pwiz-mzdb,代码行数:14,代码来源:peak_finder_utils.hpp


示例17: polyRoots

VEC polyRoots(double x,VEC &A,int maxiter, double eps){
	int n = A.leng()-1;
	double err,f,df,B_i,C_i;
	VEC Z(n);
	int k;
	VEC B(n+1);
	VEC C(n+1);
	while(n>=1){
		err = 1+eps;
		k = 0;
		while((err>=eps)&&(k<maxiter)){
			B[n-1] = A[n];
			C[n-1] = B[n-1];
			for(int j=n-2;j>=0;j--)
				B[j] = A[j+1]+x*B[j+1];
			for(int j=n-3;j>=0;j--)
				C[j] = B[j+1]+x*C[j+1];
			B_i = A[0]+x*B[0];
			C_i = B[0]+x*C[0];
			f = B_i;
			df = C_i;
			x = x - f/df;
			err = fabs(f);
			k++;
		}
		Z[n-1] = x;
		for(int j=0;j<n;j++)
			A[j] = B[j];
		x = Z[n-1];
		n--;
	}
	return Z;
}
开发者ID:charismaticchiu,项目名称:NumericalAnalysis,代码行数:33,代码来源:MAT.cpp


示例18: TEST

TEST(AgradRevMatrix, dot_product_dv_vec) {
  VEC a;
  AVEC b;
  AVAR c;
  for (int i = -1; i < 2; i++) { // a = (-1, 0, 1), b = (1, 2, 3)
    a.push_back(i);
    b.push_back(i + 2);
  }
  c = dot_product(a, b);
  EXPECT_EQ(2, c);
  VEC grad;
  c.grad(b, grad);
  EXPECT_EQ(grad[0], -1);
  EXPECT_EQ(grad[1], 0);
  EXPECT_EQ(grad[2], 1);
}
开发者ID:javaosos,项目名称:stan,代码行数:16,代码来源:dot_product2_test.cpp


示例19: Tools

//----------------------------------------------------------------------
EEMD::EEMD( const VEC& input_array ) {

    signal_length = input_array.size();
    input_signal = input_array;

    tools = new Tools();
}   
开发者ID:Open-IOT,项目名称:EEMD,代码行数:8,代码来源:eemd.cpp


示例20: l1norm

double l1norm(VEC x){
    double sum = 0.0;
    for (int i = 0; i < x.len(); i++){
	sum += std::abs(x[i]);
    }
    return sum;
}
开发者ID:charismaticchiu,项目名称:NumericalAnalysis,代码行数:7,代码来源:MAT.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ VECADDONS类代码示例发布时间:2022-05-31
下一篇:
C++ VDynamicMesh类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap