STL - 矢量 - 标准化? [英] STL - Vector - Normalization ?

查看:61
本文介绍了STL - 矢量 - 标准化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



是否有一个函数可以帮助我规范化给定的向量

(属于C ++ STL)范围内的''double'' 0.0 - 1.0

即。给定一组''double',每个元素''ele''将被替换为

elenew =(ele - min)/(max - min),其中max和min是

给定向量的最大值和最小值。


或者,aliter - 有没有办法,我可以指定一个函数(这里,在
中)
这种情况​​,我可以指定我的规范化函数)应用于每个

和向量的每个元素并获得一个由

值组成的新向量由函数返回。


-

Rakesh Kumar

**从我的电子邮件地址中删除nospamplz以获取我的真实电子邮件* *

Hi,
Is there a function that can help me to normalize the given vector
(belonging to C++ STL) of ''double''s in the range 0.0 - 1.0

i.e . given a set of ''double''s, each element ''ele'' would be replaced by
elenew = (ele - min) / (max - min) , where max and min are the
maximum and minimum of the given vector.

Or, aliter - is there a way , I can specify a function (here, in
this case, I could specify my normalize function) to be applied to each
and every element of a vector and get a new vector consisting of the
value returned by the function.

--
Rakesh Kumar
** Remove nospamplz from my email address for my real email **

推荐答案

" Rakesh Kumar" <博士****************** @ yahoo.com>写道...
"Rakesh Kumar" <dr******************@yahoo.com> wrote...

是否有一个函数可以帮助我规范化给定的矢量
(属于C ++ STL)的''double'的范围0.0 - 1.0

即。给定一组''double',每个元素''ele''将被替换为
elenew =(ele - min)/(max - min),其中max和min是
给定矢量的最大值和最小值。

或者,aliter - 有一种方法,我可以指定一个函数(这里,在这种情况下,我可以指定我的规范化函数)是应用于每个
和向量的每个元素,并获得一个由函数返回的
值组成的新向量。
Hi,
Is there a function that can help me to normalize the given vector
(belonging to C++ STL) of ''double''s in the range 0.0 - 1.0

i.e . given a set of ''double''s, each element ''ele'' would be replaced by
elenew = (ele - min) / (max - min) , where max and min are the
maximum and minimum of the given vector.

Or, aliter - is there a way , I can specify a function (here, in
this case, I could specify my normalize function) to be applied to each
and every element of a vector and get a new vector consisting of the
value returned by the function.




噢,来吧在......程序员的骄傲发生了什么?如果你需要的话,你不能写一个吗?



Aw, come on... What happened to the programmer''s pride? Couldn''t
you write one if you just needed it?


2004年4月21日星期三17:25:51 -0700 comp.lang.c ++,Rakesh Kumar

< dr ****************** @ yahoo.com>写道,
On Wed, 21 Apr 2004 17:25:51 -0700 in comp.lang.c++, Rakesh Kumar
<dr******************@yahoo.com> wrote,
即。给定一组''double',每个元素''ele''将被替换为
elenew =(ele - min)/(max - min),其中max和min是
给定向量的最大值和最小值。
i.e . given a set of ''double''s, each element ''ele'' would be replaced by
elenew = (ele - min) / (max - min) , where max and min are the
maximum and minimum of the given vector.




请参阅std :: min_element<> ;,std :: max_element<>和std :: transform<> ;.

Stroustrup第18.9节,18.6.2。



See std::min_element<>, std::max_element<>, and std::transform<>.
Stroustrup section 18.9, 18.6.2.


" Victor Bazarov" <五******** @ comAcast.net>写道:
"Victor Bazarov" <v.********@comAcast.net> wrote:
噢,加油......程序员的骄傲发生了什么?如果你需要的话,你不能写一个吗?
Aw, come on... What happened to the programmer''s pride? Couldn''t
you write one if you just needed it?




实际上,我认为有一个相当广泛的算法是有意义的>
库可以覆盖,包括其他东西,也包括许多典型的

数值算法。

-

<的mailto:二*********** @ yahoo.com> < http://www.dietmar-kuehl.de/>

< http://www.contendix.com> - 软件开发&咨询



Actually, I think it would make sense to have a quite extensive algorithms
library which would cover, amoung other things, also many of the typical
numerical algorithms.
--
<mailto:di***********@yahoo.com> <http://www.dietmar-kuehl.de/>
<http://www.contendix.com> - Software Development & Consulting


这篇关于STL - 矢量 - 标准化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆