由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - 请问STL里有没有类似dot_product的算法
相关主题
STL vector的clear如何强制归还系统?关于C++ STL编译的疑问
stl: How to implement map idea with vector in stl ?如何把文件内容读到2D的vector里?
请问一下怎么把自己写的类转成STL的类?问个土问题:Why iterator instead of array index for vector?
关于std::vector的一个很简单的问题Question about vector as a class member
一道C++ STL面试题 (转载)C++的一个问题
Interview question - use a STL vector object as an argument of function.vector析构的时候怎么办?
STL/vector引用成员变量。C++ vector 到底能多大
In STL, how big is the initial size for a vector?question on reserve() in vector container.
相关话题的讨论汇总
话题: product话题: dot话题: transform话题: stl话题: vector
进入Programming版参与讨论
1 (共1页)
c****6
发帖数: 22
1
既然有inner_product,很自然应该有个dot_product啊,但是
查了半天没看到。比如我有两个vector A, B,如果算他们的
dot_product,是不是只能通过transform来做,
transform(A.begin(),A.end(),B.begin(),res.begin(),binary_function)?
有其他更有效的方法吗?
p***o
发帖数: 1252
2
这不挺有效么,一个多余的参数都没有。

【在 c****6 的大作中提到】
: 既然有inner_product,很自然应该有个dot_product啊,但是
: 查了半天没看到。比如我有两个vector A, B,如果算他们的
: dot_product,是不是只能通过transform来做,
: transform(A.begin(),A.end(),B.begin(),res.begin(),binary_function)?
: 有其他更有效的方法吗?

c****6
发帖数: 22
3
单就两个vector来看,是没什么不好,但要是我有要对很多个
vector一起处理,类似 \sum V_i,(当然我这里的sum不一定
就是plus) 我还要手写一个dot_product,
然后用accumulate。因为上面用的那个transform不好直接转
成binary_function。

【在 p***o 的大作中提到】
: 这不挺有效么,一个多余的参数都没有。
p***o
发帖数: 1252
4
手写把 ... 多个的范型接口不好写,估计要用expression template。

【在 c****6 的大作中提到】
: 单就两个vector来看,是没什么不好,但要是我有要对很多个
: vector一起处理,类似 \sum V_i,(当然我这里的sum不一定
: 就是plus) 我还要手写一个dot_product,
: 然后用accumulate。因为上面用的那个transform不好直接转
: 成binary_function。

1 (共1页)
进入Programming版参与讨论
相关主题
question on reserve() in vector container.一道C++ STL面试题 (转载)
C++ vector 一边遍历一边删Interview question - use a STL vector object as an argument of function.
stl的一个问题STL/vector引用成员变量。
CodeBlocks cannot display vector in WatchesIn STL, how big is the initial size for a vector?
STL vector的clear如何强制归还系统?关于C++ STL编译的疑问
stl: How to implement map idea with vector in stl ?如何把文件内容读到2D的vector里?
请问一下怎么把自己写的类转成STL的类?问个土问题:Why iterator instead of array index for vector?
关于std::vector的一个很简单的问题Question about vector as a class member
相关话题的讨论汇总
话题: product话题: dot话题: transform话题: stl话题: vector