自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

太阳升起

万物明亮

  • 博客(65)
  • 收藏
  • 关注

原创 详解Linux下环境变量C_INCLUDE_PATH、CPLUS_INCLUDE_PATH、CPATH以及常见错误

C_INCLUDE_PATH、CPLUS_INCLUDE_PATH以及CPATH常被用于在全局性地添加预处理C/C++时的包含目录,其中C_INCLUDE_PATH仅对预处理C有效,CPLUS_INCLUDE_PATH仅对预处理C++有效,而CPATH对所有语言均有效。下面我们仅以C_INCLUDE_PATH为例来讨论。常用的容易出错的设置方法是在~/.bashrc等文件中简单地使用如下语句:...

2020-04-30 15:07:04 27355 1

原创 Linux使用巨页内存的方法

经测试,1G巨页内存相对于2M巨页内存的性能提升有限,而且由于内存碎片化,除非重启服务器,否则创建较多的1G巨页内存容易失败,而创建大量2M巨页内存则容易成功。在一个进程申请到巨页内存后,另一个进程使用相同的id可以获得对同一块内存的引用,由此可以实现进程间信息传递。注意,巨页内存似乎是无法在运行时回收的,因此x若小于当前已有的巨页内存页数,该命令不会起作用,直到重启设备后才会生效。这里使用的是共享内存的方式申请的巨页内存,首个申请的进程需要管理员权限,后续申请的进程则不需要。向操作系统申请巨页内存,

2024-04-08 13:00:24 753

原创 C++使用i/ostream读写不可打印字符时,一定要使用ios::binary标志

C++使用i/ostream时的一个大坑。

2022-10-06 14:09:32 446

原创 C++20编译时判断大小端序的方法

使用库中的endian枚举类实现编译时判断端序。

2022-10-05 20:37:34 708

原创 C++ Eigen库请慎用auto:避免因重复计算而造成的性能问题

C++ Eigen库请慎用auto:避免因重复计算而造成的性能问题

2022-09-27 16:22:47 816

原创 积化和差公式

积化和差公式

2022-09-20 21:40:24 359

原创 C#创建子进程并用管道进行通信

using System;namespace main{ internal class Program { static void Main(string[] args) { Console.WriteLine("Hello World!"); System.Diagnostics.Process pro=new System.Diagnostics.Process(); pro.

2022-03-14 23:05:50 2068 1

原创 PAT顶级1003 - 最大网络流

// PAT top 1003// https://pintia.cn/problem-sets/994805148990160896/problems/994805155688464384#include <algorithm>#include <iostream>#include <string>#include <unordered_map>using namespace std;using cap_type = int;const

2021-09-08 19:17:08 232

原创 二维随机变量的函数的概率密度公式的曲线积分形式

二维随机变量的函数的概率密度公式设连续型随机变量X,YX,YX,Y的联合概率密度为f(x,y)f\left(x,y\right)f(x,y),设Z=ϕ(X,Y)Z=\phi\left(X,Y\right)Z=ϕ(X,Y)为随机变量X,YX,YX,Y的函数且ZZZ可微,则ZZZ的分布函数FZ(z)=∬Df(x,y)dσF_Z\left(z\right)=\underset{D}{\iint}f\left(x,y\right)\mathrm{d}\sigmaFZ​(z)=D∬​f(x,y)dσ其中,积分区

2021-09-08 14:44:16 4429

原创 PAT顶级1002 - 动态规划

#include <algorithm>#include <iostream>using namespace std;const int MAX_N = 6008;struct Proj{ int P; int L; int D; bool operator<(const Proj &r) const { return D < r.D; }} proj[MAX_N];int dp[

2021-09-08 14:32:15 178

原创 HTML+CSS+JavaScript实现贪吃蛇

<!DOCTYPE html><html><head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link rel="icon" href="https://img-blog.csdnimg.cn/abe2b87251a64ea0a45075491e893a71.jpg" type="image/x-icon"> &lt

2021-08-19 21:35:42 200

原创 扩展域GF(2^m)在特定不可约多项式下取余运算的C++实现

// c++ standard : c++20#include <bit>#include <type_traits>template <typename T1, typename T2, typename RT = std::make_unsigned_t< std::conditional_t<sizeof(T1) >= sizeof(T2), T1, T2>>>RT GF2_mo

2021-06-29 20:51:17 534 1

原创 不要在C++中使用带有引用捕获的静态局部lambda函数

#include <iostream>using namespace std;void foo(){ int x[4] = {}; static const auto lbd = [&]() { x[0] = 10; cout << &x << endl; }; cout << &x << ' '; lbd();}void bar(){

2020-12-27 23:26:57 969

转载 OpenCV中图像评价算法PSNR与MSSID的C++实现

OpenCV版本:4.5.0文件路径:$OPENCV_PATH/sources/samples/cpp/tutorial_code/videoio/video-input-psnr-ssim/video-input-psnr-ssim.cppdouble getPSNR(const Mat& I1, const Mat& I2){ Mat s1; absdiff(I1, I2, s1); // |I1 - I2| s1.convertTo(s1, C

2020-11-23 00:13:44 1081

原创 CUDA编程:GPU并行与CPU并行的效率对比

#include <algorithm>#include <chrono>#include <cuda.h>#include <cuda_runtime.h>#include <functional>#include <iostream>#include <memory>#include <ra...

2020-11-16 14:45:02 802

原创 并行计算实验报告:使用Hadoop进行WordCount

并行计算实验报告:使用Hadoop进行WorldCount实验环境宿主机:操作系统:Manjaro 20.0.3 Lysia内核:x86_64 Linux 5.7.0-3-MANJAROCPU:Intel Core i5-8400 @ 6x 4GHzGPU:GeForce GTX 1080 Ti内存:16GB虚拟机1:操作系统:Manjaro 20.0.3 Lysia内核:x86_64 Linux 5.6.15-1-MANJAROCPU:Intel Core i5-8

2020-09-11 16:15:32 2795

原创 MIT 6.S081 / Fall 2020 - Xv6 Labs - System calls

Xv6 Labs - System callsSystem call tracingLab要求In this assignment you will add a system call tracing feature that may help you when debugging later labs. You’ll create a new trace system call that will control tracing. It should take one argument, an

2020-09-06 14:05:46 1311

原创 MIT 6.S081 / Fall 2020 - Xv6 Labs - Utilities

Xv6 Labs - UtilitiessleepLab要求Implement the UNIX program sleep for xv6; your sleep should pause for a user-specified number of ticks. A tick is a notion of time defined by the xv6 kernel, namely the time between two interrupts from the timer chip. Yo

2020-09-06 14:03:48 394

原创 C++中使用<chrono>和<thread>实现秒表

#include <chrono>#include <iostream>#include <thread>int main(){ auto t0 = std::chrono::steady_clock::now(); for (size_t cnt = 1;; ++cnt) { std::cout << cnt << std::endl; std::this_thread::slee

2020-08-10 15:21:34 387

原创 POJ1912-计算几何-凸包+极角二分

A highway and the seven dwarfsTime Limit: 8000MSMemory Limit: 30000KTotal Submissions: 3240Accepted: 659Case Time Limit: 3000MSDescriptionOnce upon a time, there was a land where several families of dwarfs were living. This land was called Dwarfland

2020-07-23 10:56:30 376

原创 C++二叉树模板类的实现

#ifndef BINARY_TREE_H#define BINARY_TREE_H#include <array>#include <memory>#include <type_traits>template <typename T> class _binary_tree_node;template <typename NodeType> class _binary_tree_baseIterator;template <

2020-06-01 19:12:12 744

原创 异或、与、加法恒等式

a+b=a⊕b+2(a&b)a+b−2(a&b)=a⊕ba+b=a\oplus b+2(a\&b)\\a+b-2(a\&b)=a\oplus ba+b=a⊕b+2(a&b)a+b−2(a&b)=a⊕b

2020-05-24 17:19:21 1821

原创 C语言中rand()不是线程安全的函数-多线程应使用rand_r()

这是glibc中的rand_r的实现:/* This algorithm is mentioned in the ISO C standard, here extended for 32 bits. */intrand_r (unsigned int *seed){ unsigned int next = *seed; int result; next *= 1103...

2020-05-04 01:03:26 3574

原创 C/C++求出最低比特位的位置的宏

#define HASLOWBITS(x, y) ((x) & ((1ull << (y)) - 1))#define CONDSHR(x, y) (HASLOWBITS(x, y) ? (x) : (x) >> (y))#define CONDADD(x, y) (HASLOWBITS(x, y) ? 0 : (y))#define CONDSHR32(x...

2020-05-03 14:34:32 829

原创 C++中使用OpenMP并行计算圆周率

源代码:#include <iostream>#include <omp.h>static constexpr long MAX_N = 1000000000;double calc_pi(const long N);int main(){ std::cout.precision(20); std::cout << calc_p...

2020-04-24 22:07:26 1780

原创 C++中读取std::istream全部内容至std::string的方法

初始化时读取:std::ifstream input_stream("file", std::ios::in);std::string file_string(std::istream_iterator<char>{input_stream}, std::istream_iterator<char>{});直接读取:std::string file_string...

2020-04-10 14:34:00 4505

原创 c++使用未命名对象作为构造函数的实参的歧义问题

问题发生在使用c++随机数生成器时,如下代码:#include <iostream>#include <random>int main(){ std::default_random_engine x(std::random_device()());// Error std::uniform_int_distribution<int> u...

2020-03-26 14:13:39 629

原创 C++中对多线程任务计时

#include <algorithm>#include <chrono>#include <iostream>#include <memory>#include <thread>using ll = long long;static constexpr ll Task = 5000000000;// 循环数void ...

2020-03-26 01:03:09 2773

原创 c++使用std::chrono计算任务的执行时间

通过指定std::chrono::duration_cast的模板参数来设定精度,该函数的第一个模板参数指定转换后的duration精度,后两个模板参数直接由实参类型推倒出。其中所谓的精度影响的是std::chrono::duration的成员函数count()的返回值类型与返回值,最终duration所代表的时间段长度为 count()×单位时间count()×单位时间count()×单位时间...

2020-03-26 00:21:33 2098

原创 c++多线程传递引用参数的问题

在多线程之间传递参数时,不能简单地把线程创建当作函数调用,在进行子函数调用时,父函数的局部变量不会被销毁,而在创建线程时,若没有join该线程,那么局部变量可能会被销毁,致使引用或指针失效。下面的代码是不安全的引用传递例子:#include <chrono>#include <functional>#include <iostream>#include...

2020-03-25 21:48:42 3069

原创 搜索的基本方法

问题的形式化定义Agent的初始状态描述Agent的可能行动转移模型目标测试路径耗散形式化分类增量形式化完整状态形式化搜索策略经典搜索无信息搜索策略宽度优先搜索一致代价搜索深度优先搜索、回溯搜索深度受限搜索迭代加深的深度优先搜索双向搜索有信息(启发式)搜索策略贪婪最佳优先搜索A*搜索存储受限的启发式搜索迭代加深...

2020-03-12 16:09:32 493

原创 基于std::vector的循环旋转数组

在提供随机访问的同时实现 O(1)O(1)O(1) 的 rotate 操作。circular_array.h:#include <algorithm>#include <memory>#include <type_traits>#include <vector>template <typename T, typename _All...

2020-03-06 18:58:25 413

原创 vscode(linux)中让一个task的输出作为另一个task的输入的方法

完整命令是用pkg-config输出opencv4的包含和链接信息,并且作为g++的参数进行编译:pkg-config --cflags --libs --static opencv4 | xargs g++ -g example.cpp -o example方法:在tasks.json中删掉掉原本的args项,并将完整命令直接赋值给command项,最终完整的tasks.json文件为:...

2020-02-26 00:02:36 769

原创 机器学习的基本分类和基本问题

机器学习的基本分类按映射类型分类归纳(induction)演绎(deduction)类比(analogy)转导(transduction)按反馈类型分类有监督学习(supervised learning)分类(classification)回归(regression)无监督学习(unsupervised learning)聚类...

2020-02-24 21:12:57 1017 1

原创 ubuntu19.10(GNOME)中隐藏已挂载的卷和设备图标的方法

输入如下命令安装GNOME及相关组件:sudo apt install gnome gnome-tweaks gnome-tweak-tool gnome-shell gnome-shell-extension-dashtodock其中最后一项——gnome-shell-extension-dashtodock,是最重要的插件。输入如下命令重启:reboot在选择账户时点击...

2020-02-21 01:01:02 1469

原创 简单计算器的C++实现——表达式的解析与计算

实现的功能:运算符的优先级, {!}>{∧}>{∗,/,%}>{+,−}\{!\}>\{\wedge\}>\{*,/,\%\}>\{+,-\}{!}>{∧}>{∗,/,%}>{+,−} .括号有最高的优先级。可以使用部分一元数学函数,如 sin⁡,exp⁡,log⁡\sin,\exp,\logsin,exp,log .其他:可以...

2020-02-18 15:10:17 1512

原创 HDU6656 Kejin Player - 动态规划DP - 数学期望

Kejin PlayerTime Limit: 10000/5000 MS (Java/Others)   Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 342   Accepted Submission(s): 115Problem DescriptionCuber QQ al...

2019-08-12 21:10:54 358 2

原创 HDU6651 Final Exam - 贪心法

Final ExamTime Limit: 4000/2000 MS (Java/Others)   Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 462   Accepted Submission(s): 199Problem DescriptionFinal Exam is...

2019-08-12 20:22:20 718

原创 HDU6638 Snowy Smile - 稀疏矩阵的最大子矩阵和 - 坐标离散化 - 线段树 - 最大子段和

Snowy SmileTime Limit: 4000/4000 MS (Java/Others)   Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 525   Accepted Submission(s): 165Problem DescriptionThere are n p...

2019-08-07 21:51:49 456

原创 POJ2482 Stars in Your Window - 平面扫描 - 坐标离散化 - 区间更新的线段树

Stars in Your WindowTime Limit: 1000MS   Memory Limit: 65536KTotal Submissions: 15614   Accepted: 4210DescriptionHere comes the problem: Assume the sky is a flat plane. All the stars lie...

2019-08-07 20:44:05 197

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除