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

C++ VD类代码示例

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

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



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

示例1: checkRawAccess

 void checkRawAccess() {
     Printf("Raw access+++++++++++++++++++++++++++\n");
     VD data = { 0, 1, 1,
                 2, 3, 2,
                 1, 3, 2,
                 4, 2, 2};
     Matrix m(3, data);
     print(m);
     
     double expected, test;
     size_t rows = data.size() / 3;
     // check read
     for (int i = 0; i < rows; i++) {
         for (int j = 0; j < 3; j++) {
             expected = data[i * 3 + j];
             test = m(i, j);
             unitpp::assert_eq(spf("Expected value not equal to readen at row: %i, col: %i", i, j), test, expected);
         }
     }
     
     // check write
     int val = 0;
     for (int i = 0; i < rows; i++) {
         for (int j = 0; j < 3; j++) {
             m(i, j) = val++;
         }
     }
     VD testVector;
     m.rowPackedCopy(testVector);
     for (int i = 0; i < testVector.size(); i++) {
         test = testVector[i];
         unitpp::assert_eq(spf("Value found: %i, but was expected: %i", test, i), test, i);
     }
 }
开发者ID:yaricom,项目名称:mlib,代码行数:34,代码来源:matrix_unittest.cpp


示例2: doExec

 double doExec() {
     
     if (!loadTestData()) {
         std::cerr << "Failed to load test data" << std::endl;
         return -1;
     }
     
     //
     // Start solution testing
     //
     double score = 0, sse;
     int scenario = 0;
     for (int i = 0; i < subsetsNum; i++) {
         scenario = i % 3;
         generateTestData(scenario, i);
         VD res = test->predict(0, scenario, DTrain, DTest);
         
         Assert(groundTruth.size() == res.size(), "Expected results count not equal to found. Expected: %lu, but found: %lu", groundTruth.size(), res.size());
         sse = 0;
         for (int j = 0; j < res.size(); j++) {
             double e = res[j] - groundTruth[j];
             sse += e * e;
         }
         // calculate score
         double s = 1000000 * fmax(0, 1.0 - sse/sse0);
         Printf("%i.) Score = %f, sse: %f, sse0: %f\n", i, s, sse, sse0);
         score += s;
     }
     return score / subsetsNum;
 }
开发者ID:yaricom,项目名称:childstuntedness5,代码行数:30,代码来源:TestRunner.cpp


示例3: main

int main() {

  const int m = 4;
  const int n = 3;  
  DOUBLE _A[m][n] = {
    { 6, -1, 0 },
    { -1, -5, 0 },
    { 1, 5, 1 },
    { -1, -5, -1 }
  };
  DOUBLE _b[m] = { 10, -4, 5, -5 };
  DOUBLE _c[n] = { 1, -1, 0 };
  
  VVD A(m);
  VD b(_b, _b + m);
  VD c(_c, _c + n);
  for (int i = 0; i < m; i++) A[i] = VD(_A[i], _A[i] + n);

  LPSolver solver(A, b, c);
  VD x;
  DOUBLE value = solver.Solve(x);
  
  cerr << "VALUE: "<< value << endl;
  cerr << "SOLUTION:";
  for (size_t i = 0; i < x.size(); i++) cerr << " " << x[i];
  cerr << endl;
  return 0;
}
开发者ID:juangil,项目名称:programmingContests,代码行数:28,代码来源:simplex.cpp


示例4: LPSolver

 LPSolver(const VVD &A, const VD &b, const VD &c) :
  m(b.size()), n(c.size()),
  N(n + 1), B(m), D(m + 2, VD(n + 2)) {
  for (int i = 0; i < m; i++) for (int j = 0; j < n; j++)
    D[i][j] = A[i][j];
  for (int i = 0; i < m; i++) { B[i] = n + i; D[i][n] = -1;
    D[i][n + 1] = b[i]; }
  for (int j = 0; j < n; j++) { N[j] = j; D[m][j] = -c[j]; }
  N[n] = -1; D[m + 1][n] = 1; }
开发者ID:SuprDewd,项目名称:CompetitiveProgramming,代码行数:9,代码来源:simplex.cpp


示例5: dotProduct_benchmark_vector

void MLComputeTest::dotProduct_benchmark_vector()
{
    VD data;
    data.resize(10000);
    std::iota(data.begin(), data.end(), 1);
    QBENCHMARK
    {
        MLCompute::dotProduct(data, data);
    }
}
开发者ID:magland,项目名称:mountainlab,代码行数:10,代码来源:tst_mlcomputetest.cpp


示例6: correlation_benchmark_parallel

void MLComputeTest::correlation_benchmark_parallel()
{
    VD data;
    data.resize(10000);
    std::iota(data.begin(), data.end(), 1);
    QBENCHMARK
    {
        correlation_parallel(data, data);
    }
}
开发者ID:magland,项目名称:mountainlab,代码行数:10,代码来源:tst_mlcomputetest.cpp


示例7: correlation_benchmark_alternative

void MLComputeTest::correlation_benchmark_alternative()
{
    VD data;
    data.resize(10000);
    std::iota(data.begin(), data.end(), 1);
    QBENCHMARK
    {
        correlation_helper(data, data);
    }
}
开发者ID:magland,项目名称:mountainlab,代码行数:10,代码来源:tst_mlcomputetest.cpp


示例8: stdev_benchmark

void MLComputeTest::stdev_benchmark()
{
    VD data;
    data.resize(10000);
    std::iota(data.begin(), data.end(), 1);
    QBENCHMARK
    {
        MLCompute::stdev(data);
    }
}
开发者ID:magland,项目名称:mountainlab,代码行数:10,代码来源:tst_mlcomputetest.cpp


示例9: LPSolver

 LPSolver(const VD &b, const VD &c) : 
   m(b.size()), n(c.size()), N(n+1), B(m), D(m+2, VD(n+2)) {
   for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) D[i][j] = AA[i][j];
   for (int i = 0; i < m; i++) { B[i] = n+i; D[i][n] = -1; D[i][n+1] = b[i]; }
   for (int j = 0; j < n; j++) { N[j] = j; D[m][j] = -c[j]; }
   N[n] = -1; D[m+1][n] = 1;
   /*for (int i = 0; i < m+2; i++) {
    for (int j = 0; j < n+2; j++){ cout<<D[i][j]<<" ";}
    cout<<endl;
   }*/
 }
开发者ID:HGYN,项目名称:Programming-contest,代码行数:11,代码来源:goats2.cpp


示例10: main

int main() {
  int n;
  cin >> n;
  VD arr(n+1);
  for (int i = 0; i <= n; i++) cin >> arr[i];
  
  VD ans = roots(poly(arr));
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) printf("%.4f\n", ans[i]);
  
  return 0;
}
开发者ID:MO2013,项目名称:practice,代码行数:12,代码来源:rootfind.cpp


示例11: min_benchmark

void MLComputeTest::min_benchmark()
{
    VD data;
    data.reserve(10000);
    for (int i = 0; i < 10000; ++i) {
        data.append(-10000 + qrand());
    }
    QBENCHMARK
    {
        MLCompute::min(data.size(), data.data());
    }
}
开发者ID:magland,项目名称:mountainlab,代码行数:12,代码来源:tst_mlcomputetest.cpp


示例12: generateVoronoi

VD generateVoronoi(int ** setPoints, int numberofPoints){
	VD vd;

	int i = 0;
	for(i = 0; i < numberofPoints * 3; i+=3){
		Site_2 p(Point_2((*setPoints)[i], (*setPoints)[i + 1]));
		vd.insert(p);
	}

	return vd;

}
开发者ID:aggarw13,项目名称:ECE30834_CS334,代码行数:12,代码来源:Voronoi.cpp


示例13: set

 void set(VVD & A, VD & B, VD & C) {
   n = C.size();
   m = A.size();
   left.resize(m);
   up.resize(n);
   pos.resize(n);
   res.resize(n);
   status = -2;
   v = 0;
   a = A;
   b = B;
   c = C;
 }
开发者ID:wifai,项目名称:competitive-programming,代码行数:13,代码来源:i.cpp


示例14: roots

VD roots(const poly &p) {
  if (p.is_constant()) return VD(0);
  VD critical_values = roots(p.derivative());
  critical_values.push_back(1e6);
  
  VD ans;
  double lower = -1e6;
  for (int i = 0; i < critical_values.size(); i++) {
    double upper = critical_values[i];
    if (sgn(p.eval(lower)) != sgn(p.eval(upper)))
      ans.push_back(bisect(p, lower, upper));
    
    lower = upper;
  }
  
  return ans;
}
开发者ID:MO2013,项目名称:practice,代码行数:17,代码来源:rootfind.cpp


示例15: init

void init(VD & t, int & n, PDD * p, PDD & a, PDD & b) {
	t.clear();
	double tmp;
	for (int i = 0; i < n; ++i) {
		scanf("%lf", &tmp);
		t.PB(tmp);
	}
	std::sort(t.begin(), t.end());
	t.erase(std::unique(t.begin(), t.end()), t.end());
	n = t.size();
	for (int i = 0; i < n; ++i) {
		p[i] = at(a, b, t[i]);
	}
}
开发者ID:xywy1992,项目名称:ACM-ICPC,代码行数:14,代码来源:Island+Explorer.cpp


示例16: formatFromPixelCoordinate

 virtual QStringList
 formatFromPixelCoordinate( const VD & pix ) override
 {
     CARTA_ASSERT( pix.size() >= 2 );
     QStringList res;
     res.append( QString::number( pix[0] ) );
     res.append( QString::number( pix[1] ) );
     return res;
 }
开发者ID:slovelan,项目名称:NRAODev,代码行数:9,代码来源:QImagePlugin.cpp


示例17: getNextMean

DotNode* GraphKMeans::getNextMean(const vector<DotNode*>& means, ConnectedDotGraph& g)
{
	VD minDist;
	for (int i = 0; i < (int)g.nodes.size(); i++)
	{
		double minD = 123456789.0;
		for (int j = 0; j < (int)means.size(); j++)
		{
			double d = g.getShortestPath(g.nodes[i], means[j], true);
			minD = min(minD, d);
		}

		minDist.push_back(Sqr2(minD));
	}

	int p = randWithProbability(minDist);
	if (minDist[p] < 1e-6) return NULL;

	return g.nodes[p];
}
开发者ID:Grabot,项目名称:gmap,代码行数:20,代码来源:graphkmeans.cpp


示例18: dotProduct_benchmark_arrays

void MLComputeTest::dotProduct_benchmark_arrays()
{
    VD data;
    data.resize(10000);
    std::iota(data.begin(), data.end(), 1);
    QBENCHMARK
    {
        MLCompute::dotProduct(data.size(), data.data(), data.data());
    }
}
开发者ID:magland,项目名称:mountainlab,代码行数:10,代码来源:tst_mlcomputetest.cpp


示例19: dotProduct_benchmark_inner_product

void MLComputeTest::dotProduct_benchmark_inner_product()
{
    VD data;
    data.resize(10000);
    std::iota(data.begin(), data.end(), 1);
    QBENCHMARK
    {
        std::inner_product(data.constBegin(), data.constEnd(), data.constBegin(), 0);
    }
}
开发者ID:magland,项目名称:mountainlab,代码行数:10,代码来源:tst_mlcomputetest.cpp


示例20: mean_benchmark_alternative

void MLComputeTest::mean_benchmark_alternative()
{
    VD data;
    data.resize(10000);
    std::iota(data.begin(), data.end(), 1);
    QBENCHMARK
    {
        (void)(std::accumulate(data.constBegin(), data.constEnd(), 0) / data.size());
    }
}
开发者ID:magland,项目名称:mountainlab,代码行数:10,代码来源:tst_mlcomputetest.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ VDATA类代码示例发布时间:2022-05-31
下一篇:
C++ VCWidget类代码示例发布时间: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