热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Dlib库【10】——计算积分,读取xml显示

配置Dlib环境:链接1.计算积分Thecontentsofthisfileareinthepublicdomain.SeeLICENSE_FOR_EXAMPLE_P



配置Dlib环境:  链接


1.计算积分


// The contents of this file are in the public domain. See LICENSE_FOR_EXAMPLE_PROGRAMS.txt
/*This example demonstrates the usage of the numerical quadrature function
integrate_function_adapt_simp(). This function takes as input a single variable
function, the endpoints of a domain over which the function will be integrated, and a
tolerance parameter. It outputs an approximation of the integral of this function over
the specified domain. The algorithm is based on the adaptive Simpson method outlined in:Numerical Integration method based on the adaptive Simpson method in
Gander, W. and W. Gautschi, "Adaptive Quadrature – Revisited,"
BIT, Vol. 40, 2000, pp. 84-101*/#include
#include
#include
#include using namespace std;
using namespace dlib;// Here we the set of functions that we wish to integrate and comment in the domain of
// integration.// x in [0,1]
double gg1(double x)
{return pow(e, x);
}// x in [0,1]
double gg2(double x)
{return x*x;
}// x in [0, pi]
double gg3(double x)
{return 1 / (x*x + cos(x)*cos(x));
}// x in [-pi, pi]
double gg4(double x)
{return sin(x);
}// x in [0,2]
double gg5(double x)
{return 1 / (1 + x*x);
}int main()
{// We first define a tolerance parameter. Roughly speaking, a lower tolerance will// result in a more accurate approximation of the true integral. However, there are // instances where too small of a tolerance may yield a less accurate approximation// than a larger tolerance. We recommend taking the tolerance to be in the// [1e-10, 1e-8] region.double tol &#61; 1e-10;// Here we compute the integrals of the five functions defined above using the same // tolerance level for each.double m1 &#61; integrate_function_adapt_simp(&gg1, 0.0, 1.0, tol);double m2 &#61; integrate_function_adapt_simp(&gg2, 0.0, 1.0, tol);double m3 &#61; integrate_function_adapt_simp(&gg3, 0.0, pi, tol);double m4 &#61; integrate_function_adapt_simp(&gg4, -pi, pi, tol);double m5 &#61; integrate_function_adapt_simp(&gg5, 0.0, 2.0, tol);// We finally print out the values of each of the approximated integrals to ten// significant digits.cout <<"\nThe integral of exp(x) for x in [0,1] is " <}


2.读取XML并显示




// The contents of this file are in the public domain. See LICENSE_FOR_EXAMPLE_PROGRAMS.txt
/*读取XML显示的一个程序
*/#include
#include
#include using namespace std;
using namespace dlib;// ----------------------------------------------------------------------------------------class doc_handler : public document_handler
{/*As the parser runs it generates events when it encounters tags anddata in an XML file. To be able to receive these events all you have todo is make a class that inherits from dlib::document_handler andimplements its virtual methods. Then you simply associate aninstance of your class with the xml_parser.So this class is a simple example document handler that just printsall the events to the screen.*/
public:virtual void start_document(){cout <<"parsing begins" < tag" <" <};// ----------------------------------------------------------------------------------------int main(int argc, char** argv)
{try{// Check if the user entered an argument to this application. if (argc !&#61; 2){cout <<"Please enter an xml file to parse on the command line" <}




先这样了&#xff0c;本来只想看看Dlib的效果追踪咋样的&#xff0c;结果一下子看到这么多有趣的东西……


接着去啃手势识别了…





推荐阅读
  • C++: 实现基于类的四面体体积计算
    本文介绍如何使用C++编程语言,通过定义类和方法来计算由四个三维坐标点构成的四面体体积。文中详细解释了四面体体积的数学公式,并提供了两种不同的实现方式。 ... [详细]
  • 扫描线三巨头 hdu1928hdu 1255  hdu 1542 [POJ 1151]
    学习链接:http:blog.csdn.netlwt36articledetails48908031学习扫描线主要学习的是一种扫描的思想,后期可以求解很 ... [详细]
  • 本文探讨了如何在给定整数N的情况下,找到两个不同的整数a和b,使得它们的和最大,并且满足特定的数学条件。 ... [详细]
  • 题目Link题目学习link1题目学习link2题目学习link3%%%受益匪浅!-----&# ... [详细]
  • 火星商店问题:线段树分治与持久化Trie树的应用
    本题涉及编号为1至n的火星商店,每个商店有一个永久商品价值v。操作包括每天在指定商店增加一个新商品,以及查询某段时间内某些商店中所有商品(含永久商品)与给定密码值的最大异或结果。通过线段树分治和持久化Trie树来高效解决此问题。 ... [详细]
  • 1:有如下一段程序:packagea.b.c;publicclassTest{privatestaticinti0;publicintgetNext(){return ... [详细]
  • 本文基于刘洪波老师的《英文词根词缀精讲》,深入探讨了多个重要词根词缀的起源及其相关词汇,帮助读者更好地理解和记忆英语单词。 ... [详细]
  • 题目描述:给定n个半开区间[a, b),要求使用两个互不重叠的记录器,求最多可以记录多少个区间。解决方案采用贪心算法,通过排序和遍历实现最优解。 ... [详细]
  • 360SRC安全应急响应:从漏洞提交到修复的全过程
    本文详细介绍了360SRC平台处理一起关键安全事件的过程,涵盖从漏洞提交、验证、排查到最终修复的各个环节。通过这一案例,展示了360在安全应急响应方面的专业能力和严谨态度。 ... [详细]
  • 本文探讨了如何在模运算下高效计算组合数C(n, m),并详细介绍了乘法逆元的应用。通过扩展欧几里得算法求解乘法逆元,从而实现除法取余的计算。 ... [详细]
  • This document outlines the recommended naming conventions for HTML attributes in Fast Components, focusing on readability and consistency with existing standards. ... [详细]
  • Splay Tree 区间操作优化
    本文详细介绍了使用Splay Tree进行区间操作的实现方法,包括插入、删除、修改、翻转和求和等操作。通过这些操作,可以高效地处理动态序列问题,并且代码实现具有一定的挑战性,有助于编程能力的提升。 ... [详细]
  • 本文讨论了如何根据特定条件动态显示或隐藏文件上传控件中的默认文本(如“未选择文件”)。通过结合CSS和JavaScript,可以实现更灵活的用户界面。 ... [详细]
  • 本文探讨了 C++ 中普通数组和标准库类型 vector 的初始化方法。普通数组具有固定长度,而 vector 是一种可扩展的容器,允许动态调整大小。文章详细介绍了不同初始化方式及其应用场景,并提供了代码示例以加深理解。 ... [详细]
  • 网络运维工程师负责确保企业IT基础设施的稳定运行,保障业务连续性和数据安全。他们需要具备多种技能,包括搭建和维护网络环境、监控系统性能、处理突发事件等。本文将探讨网络运维工程师的职业前景及其平均薪酬水平。 ... [详细]
author-avatar
hengldkslf
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有