
C++
Storming2011
熟练掌握图形算法、PC桌面软件、三维显示及动画、大数据与并行运算,能独立高效的完成前后端完整开发任务,有多项自己的创新算法。
展开
-
log4cpp C++
原创 2020-07-28 16:28:20 · 118 阅读 · 0 评论 -
C++ 知识点和问题
1.基类为什么要声明为析构函数基类指针可以指向派生类的对象(多态性),如果删除该指针delete []p;就会调用该指针指向的派生类析构函数,而派生类的析构函数又自动调用基类的析构函数,这样整个派生类的对象完全被释放。如果析构函数不被声明成虚函数,则编译器实施静态绑定,在删除基类指针时,只会调用基类的析构函数而不调用派生类析构函数,这样就会造成派生类对象析构不完全。所以,将析构函数声明为虚函数是十分必要的。...原创 2020-07-01 17:50:32 · 436 阅读 · 0 评论 -
log4cpp C++ demo代码
#include<iostream>#include<log4cpp/Category.hh>#include<log4cpp/OstreamAppender.hh>#include<log4cpp/Priority.hh>#include<log4cpp/PatternLayout.hh>using namespace std;int main(int argc,char* argv[]){log4cpp::OstreamApp.原创 2020-06-23 17:28:49 · 238 阅读 · 0 评论 -
C++ std::cout 非科学计数法输出
cout.setf(ios::fixed);cout.precision(3); // 精度为输出小数点后3位原创 2020-06-22 17:35:04 · 2134 阅读 · 0 评论 -
C语言求解0~2*PI(0~360度)弧度值
#include float Actan_0_2PI(float y, float x){// 说明:-PI ~ PI [10/22/2016 ZOSH];float fRad = atan2( y, x);if (y {fRad = (float)PI - fRad;}return fRad;}原创 2016-10-23 17:37:15 · 2596 阅读 · 1 评论 -
std::wstring 与std::string 转换
#include string>#include // 需包含locale、string头文件、使用setlocale函数。std::wstring StringToWstring(const std::string str){// string转wstring unsigned len = str.size() * 2;// 预留字节数 setlocale(LC_CT转载 2016-11-30 09:22:45 · 1191 阅读 · 0 评论 -
算法导论之寻找最大子数组
bool FindMaxmumSubArray(float A[], int low, int high, float &fMaxmumSum, int &iFrom, int &iTo){ // 判断输入条件 if (low high) { return false; } if (low == high) { iFrom = iTo = low; return t原创 2016-11-12 14:04:27 · 397 阅读 · 0 评论 -
MemoryPool 内存池 仿std::allocator 实现
#pragma once#include #include template class MemoryPool { public: /* Member types */ typedef T value_type; // T 的 value 类型 typedef T*转载 2016-10-30 16:03:50 · 1190 阅读 · 0 评论 -
C++迭代器模拟
#include "stdafx.h"#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include原创 2016-10-30 11:19:02 · 300 阅读 · 0 评论 -
排序算法之归并排序(模板类)
#includeusing namespace std;template class element{public:element() { key = T(0);}~element() {};public:T key;};#pragma onceclass merge_sort{public:merge_sort(void);~m原创 2016-08-15 21:50:52 · 1012 阅读 · 0 评论 -
有价值的C语言开源库
- 1. WebbenchWebbench是一个在linux下使用的非常简单的网站压测工具。它使用fork()模拟多个客户端同时访问我们设定的URL,测试网站在压力下工作的性能,最多可以模拟3万个并发连接去测试网站的负载能力。Webbench使用C语言编写, 代码实在太简洁,源码加起来不到600行。下载链接:http://home.tiscali.cz/~cz210552/webb转载 2016-08-15 15:39:55 · 2224 阅读 · 1 评论 -
typedef typename 是什么?
template class A {public:typedef T a_type;};templateclass B {public://typedef A::a_type b_type;typedef typename A::a_type b_type;};int main() {B> b;return 0;}注意:如果把注释转载 2016-08-15 16:14:26 · 372 阅读 · 0 评论 -
C++矩阵库 Eigen
最近需要用 C++ 做一些数值计算,之前一直采用Matlab 混合编程的方式处理矩阵运算,非常麻烦,直到发现了 Eigen 库,简直相见恨晚,好用哭了。 Eigen 是一个基于C++模板的线性代数库,直接将库下载后放在项目目录下,然后包含头文件就能使用,非常方便。此外,Eigen的接口清晰,稳定高效。唯一的问题是之前一直用 Matlab,对 Eigen 的 API 接口不太熟悉,如果能有 Ei转载 2016-08-16 18:17:35 · 1434 阅读 · 0 评论 -
牛顿法(Newton's Method)
牛顿迭代法(简称牛顿法)由英国著名的数学家牛顿爵士最早提出。1. 原理:将目标函数f(x) 在x(k)处展开,:若忽略二次项以上,得到:导数:2. 应用,求解平方根下面介绍使用牛顿迭代法求方根的例子。牛顿迭代法是已知的实现求方根最快的方法之一,只需要迭代几次后就能得到相当精确的结果。以math.h中sqrt(x)求平方根为例,将m =转载 2016-08-16 21:08:18 · 824 阅读 · 0 评论 -
求解非线性最小二乘法 Eigen
// 利用Eigen 求解非线性最小二乘;// 示例:y = 10*(x0+3)^2 + (x1-5)^2#include "math.h"#include "iostream"#include "vector"#include "list"using namespace std;#include "Eigen/Dense"#include "Eigen/Core"#inc原创 2016-08-17 11:37:41 · 6539 阅读 · 2 评论 -
牛顿法(newton's method)求解函数极值
// 目标函数:f(x1, x2, x3, x4) = (x1 + 10*x2)^2 + 5*(x3 - x4)^2 + (x2 - 2*x3)^4 + 10.0*(x1 - x4)^4; 求取输入向量x?// 牛顿法: x(k+1) = x(k) - inv(F(x(k))) * g(x(k)), F是黑塞矩阵,g是导数;double CPowell::ComputePowellFunc(f原创 2016-08-17 11:52:17 · 6015 阅读 · 0 评论 -
求解线性方程最小二乘解
#include "math.h"#include "iostream"#include "vector"#include "list"using namespace std;#include "Eigen/Dense"#include "Eigen/Core"#include "Eigen/QR"#include "Eigen/SVD"#include "Eigen/Ge原创 2016-08-17 12:51:47 · 4487 阅读 · 1 评论 -
寻找最近点(快速算法))
问题: 寻找n >=2 个平面点集中两个最近点。应用:交通控制中寻找两个最近的交通工具。传统蛮力搜索算法中,需要O(n*n)次搜索,本文介绍一种分治算法,运动时间为O(nlgn);算法步骤如下:1. 输入P(原始点集), X(P按x坐标递增), Y(P按y坐标递增) 三个点集,点集个数为n. 若有 n否则进行Step2;2. 将P 沿垂直线l(即横坐标)原创 2016-08-15 21:10:39 · 16933 阅读 · 2 评论 -
排序算法之插入排序(模板类)
#includeusing namespace std;template class element{public:element() { key = T(0);}~element() {};public:T key;};class insert_sort{public:template void Sort(element list[原创 2016-08-15 21:53:05 · 395 阅读 · 0 评论 -
CString-〉char*
方法1: //// 路径字符串。CString strPathName == L“1q221“;char szPathName[MAX_PATH]="";int len = WideCharToMultiByte(CP_ACP,0,strPathName,strPathName.GetLength(),NULL,0,NULL,NULL);WideCharTo原创 2016-03-24 11:02:36 · 373 阅读 · 0 评论