STL学习笔记----16.STL算法之 (数值算法)
来源:互联网 发布:内网映射软件 编辑:程序博客网 时间:2024/05/16 00:45
一. 概述
用来处理数值的算法,需要加上头文件 #include<numberic>
1. 对序列进行某种运算
- //计算initValue和区间[beg, end)内所有元素的总和
- //也就是: initValue + a1 + a2 + a3 +...
- T
- accumulate (InputIterator beg, InputIterator end,
- T initValue)
- //也就是:initValue op a1 op a2 ...
- //比如 op 是 乘,则为:initValue * a1 * a2 * a3...
- T
- accumulate (InputIterator beg. InputIterator end,
- T initValue, BinaryFunc op)
//计算initValue和区间[beg, end)内所有元素的总和//也就是: initValue + a1 + a2 + a3 +...Taccumulate (InputIterator beg, InputIterator end, T initValue)//也就是:initValue op a1 op a2 ...//比如 op 是 乘,则为:initValue * a1 * a2 * a3...Taccumulate (InputIterator beg. InputIterator end, T initValue, BinaryFunc op)2. 计算两序列内积
- //返回[beg, end)区间和beg2为起始的区间的对应元素组的内积
- //initValue + (a1*b1) + (a2*b2) + (a3*b3) + ...
- T
- inner_product (InputIterator1 beg1, InputIterator1 end1,
- InputIterator2 beg2,
- T initValue)
- //initValue op1 (a1 op2 b1) op1 (a2 op2 b2) op1 ...
- T
- inner_product (InputIterator1 beg1. InputIterator1 end1,
- InputIterator2 beg2,
- T initValue,
- BinaryFunc op1, BinaryFunc op2)
//返回[beg, end)区间和beg2为起始的区间的对应元素组的内积//initValue + (a1*b1) + (a2*b2) + (a3*b3) + ...Tinner_product (InputIterator1 beg1, InputIterator1 end1, InputIterator2 beg2, T initValue)//initValue op1 (a1 op2 b1) op1 (a2 op2 b2) op1 ...Tinner_product (InputIterator1 beg1. InputIterator1 end1, InputIterator2 beg2, T initValue, BinaryFunc op1, BinaryFunc op2)三. 相对值和绝对值之间的转换
1. 将相对值转换成绝对值
- //计算区间[sourceBeg, sourceEnd)中每个元素的部分和,然后写入destBeg
- //a1, a1+a2, a1+a2+a3, ...
- OutputIterator
- partial_sum (InputIterator sourceBeg, InputIterator sourceEnd,
- OutputIterator destBeg)
- //a1, a1 op a2, a1 op a2 op a3, ...
- OutputIterator
- partial_sum (InputIterator sourceBeg, InputIterator sourceEnd,
- OutputIterator destBeg, BinaryFunc op)
//计算区间[sourceBeg, sourceEnd)中每个元素的部分和,然后写入destBeg//a1, a1+a2, a1+a2+a3, ...OutputIteratorpartial_sum (InputIterator sourceBeg, InputIterator sourceEnd, OutputIterator destBeg)//a1, a1 op a2, a1 op a2 op a3, ...OutputIteratorpartial_sum (InputIterator sourceBeg, InputIterator sourceEnd, OutputIterator destBeg, BinaryFunc op)2. 将绝对值转换成相对值
- //计算区间[sourceBeg, sourceEnd)中每一个元素前趋差,然后写destBeg
- //a1, a2-a1, a3-a2, a4-a3, ...
- OutputIterator
- adjacent_difference (InputIterator sourceBeg,
- InputIterator sourceEnd,
- OutputIterator destBeg)
- //a1, a2 op a1, a3 op a2, a4 op a3, ...
- OutputIterator
- adjacent_difference (InputIterator sourceBeg,
- InputIterator sourceEnd,
- OutputIterator destBeg,
- BinaryFunc op)
//计算区间[sourceBeg, sourceEnd)中每一个元素前趋差,然后写destBeg//a1, a2-a1, a3-a2, a4-a3, ...OutputIteratoradjacent_difference (InputIterator sourceBeg, InputIterator sourceEnd, OutputIterator destBeg)//a1, a2 op a1, a3 op a2, a4 op a3, ...OutputIteratoradjacent_difference (InputIterator sourceBeg, InputIterator sourceEnd, OutputIterator destBeg, BinaryFunc op)
- STL学习笔记----16.STL算法之 (数值算法)
- STL学习笔记----16.STL算法之 (数值算法)
- STL之数值算法
- STL算法之数值算法
- STL源码剖析学习之数值算法
- STL学习笔记----11.STL算法之 (变动性算法)
- STL学习笔记----13.STL算法之 (变序性算法)
- STL学习笔记----14.STL算法之 (排序算法)
- STL学习笔记----14.STL算法之 (排序算法)
- STL学习笔记----13.STL算法之 (变序性算法)
- STL学习笔记----11.STL算法之 (变动性算法)
- STL常用数值算法
- STL学习笔记----9.STL算法之 for_each()
- STL学习笔记----9.STL算法之 for_each()
- SGI-STL学习笔记之heap算法
- STL学习笔记之sort算法
- STL学习笔记之算法--algorithmn
- STL学习笔记--排序算法
- mysql 找不到或无法加载已注册的 .Net Framework Data Provider
- Memcahce和Redis比较
- Lightoj 1017 DP
- Android调用jni全过程,方便以后操作。
- 品味人生
- STL学习笔记----16.STL算法之 (数值算法)
- iOS 视图滚动到某一个位置做某一件事
- 【Android开发那点破事】Android判断SD卡状态
- Could not initialize class sun.awt.X11GraphicsEnvironment
- moonseo-占座:网站关键词多怎么做优化?
- tomcat虚拟目录配置
- 网警找人流程
- Servlet以及HttpServlet的源码分析
- STL学习笔记----15.STL算法之 (已序区间算法)