sqrt()双重麻烦 [英] sqrt() double trouble

查看:113
本文介绍了sqrt()双重麻烦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个使用sqrt()的程序。一个历史上非常慢的

函数,但我读取了具有SSE支持的CPU,这实际上很快。问题:

C'的sqrt()(与C ++ sqrt()不同)被定义为仅适用于双打,而且早期
版本的SSE不支持双精度。 CPU要求

至少具有第一代SEE支持的东西 (一切从

P3 / Athlon XP及以上版本)对我来说是可以接受的。但是,要求一个支持双精度SSE的CPU太多了。

这个问题有什么解决方法吗? (切换到C ++除外)


对于那些肯定会抱怨讨论使用CPU的人来说,具体说明是OT在这里 - 我说这个问题是关于这里的主题

,因为我的问题是由C标准造成的,它只有双精度
精度sqrt(),因此不允许我利用

目标CPU。

I am writing a program which uses sqrt() a lot. A historically very slow
function but I read on CPUs with SSE support this is actually fast. Problem:
C''s sqrt() (unlike C++ sqrt()) is defined to work on doubles only, and early
versions of SSE did not support double precision. The CPU requirement
"something with at least first generation SEE support" (everything from
P3/Athlon XP and up) is acceptable for me. However, requiring a CPU which
supports double precision SSE is too much.
Is there any work around for this problem? (except for switching to C++)

For those who will certainly complain that discussing the use of CPU
specific instructions is OT here - I say this question is on topic here
because my problem is caused by the C standard which only features double
precision sqrt() and thus does not allow me to exploit the capabilities of
the target CPUs.

推荐答案

文章< g2 ********** @ inews.gazeta。 pl>,copx< co ** @ gazeta.plwrote:
In article <g2**********@inews.gazeta.pl>, copx <co**@gazeta.plwrote:

>对于那些肯定会抱怨讨论使用CPU
具体说明的人是OT在这里 - 我说这个问题是关于这里的主题
因为我的问题是由C标准引起的,它只有双精度sqrt(),因此不允许我利用
>For those who will certainly complain that discussing the use of CPU
specific instructions is OT here - I say this question is on topic here
because my problem is caused by the C standard which only features double
precision sqrt() and thus does not allow me to exploit the capabilities of
the target CPUs.



如果您对C标准有疑问并希望更改,那么

会在comp.std.c中解决问题。


但就个人而言,我不会这样做:我只会使用

标准规定的浮点平方根函数,


#include< math.h>


浮动sqrtf(浮动x)


你将在C99标准的第7.12.7.5节中找到这个。

-

罗马人认为每个人都有他的天才,而且每个人都有。 $ b女人她的朱诺。 - Thomas Bulfinch

If you have a problem with the C standard and want it changed, then
take the issue up in comp.std.c .

Personally, though, I wouldn''t bother doing that: I''d just use
the standard-mandated float square root function,

#include <math.h>

float sqrtf(float x)

You will find this in section 7.12.7.5 of the C99 standard.
--
"The Romans believed that every man had his Genius, and every
woman her Juno." -- Thomas Bulfinch




" Walter Roberson" < ro ****** @ ibd.nrc-cnrc.gc.caschrieb im Newsbeitrag

news:g2 ********** @ canopus.cc.umanitoba.ca ...

"Walter Roberson" <ro******@ibd.nrc-cnrc.gc.caschrieb im Newsbeitrag
news:g2**********@canopus.cc.umanitoba.ca...

文章< g2 ********** @ inews.gazeta.pl> ;,copx< co ** @ gazeta .plwrote:
In article <g2**********@inews.gazeta.pl>, copx <co**@gazeta.plwrote:

>>对于那些肯定会抱怨讨论使用CPU
具体说明的人来说,OT就在这里 - 我说这个问题是关于这里的主题
因为我的问题是由C标准引起的,它只有双精度sqrt(),因此不允许我利用目标CPU的功能。
>>For those who will certainly complain that discussing the use of CPU
specific instructions is OT here - I say this question is on topic here
because my problem is caused by the C standard which only features double
precision sqrt() and thus does not allow me to exploit the capabilities of
the target CPUs.



如果您对C标准有疑问并希望更改,那么

会在comp.std.c中解决问题。


但就个人而言,我不会这样做:我只会使用

标准规定的浮点平方根函数,


#include< math.h>


浮动sqrtf(浮动x)


你将在C99标准的7.12.7.5节中找到了这一点。


If you have a problem with the C standard and want it changed, then
take the issue up in comp.std.c .

Personally, though, I wouldn''t bother doing that: I''d just use
the standard-mandated float square root function,

#include <math.h>

float sqrtf(float x)

You will find this in section 7.12.7.5 of the C99 standard.



这是C99的新功能还是C89的一部分?

Is this a new function of C99 or is it also part of C89?




" copx" < co ** @ gazeta.plschrieb im Newsbeitrag

news:g2 ********** @ inews.gazeta.pl ...

"copx" <co**@gazeta.plschrieb im Newsbeitrag
news:g2**********@inews.gazeta.pl...

>

" Walter Roberson" < ro ****** @ ibd.nrc-cnrc.gc.caschrieb im Newsbeitrag

news:g2 ********** @ canopus.cc.umanitoba.ca ...
>
"Walter Roberson" <ro******@ibd.nrc-cnrc.gc.caschrieb im Newsbeitrag
news:g2**********@canopus.cc.umanitoba.ca...

>在文章< g2 ********** @ inews.gazeta.pl>中,copx< co ** @gazeta.plwrote:
>In article <g2**********@inews.gazeta.pl>, copx <co**@gazeta.plwrote:

>>>对于那些肯定会抱怨讨论CPU使用的具体说明的人来说,这就是OT--我说这个问题是关于这里的话题
因为我的问题是由C标准引起的,它只有双精度sqrt(),因此不允许我利用
目标CPU。
>>>For those who will certainly complain that discussing the use of CPU
specific instructions is OT here - I say this question is on topic here
because my problem is caused by the C standard which only features double
precision sqrt() and thus does not allow me to exploit the capabilities
of
the target CPUs.


如果您对C标准有疑问并希望更改,那么请在comp.std.c中解决问题。

但就个人而言,我不会这样做:我只会使用
标准规定的浮点平方根函数,

#include< math.h>

浮动sqrtf(浮点x)

您可以在C99标准的7.12.7.5节中找到它。


If you have a problem with the C standard and want it changed, then
take the issue up in comp.std.c .

Personally, though, I wouldn''t bother doing that: I''d just use
the standard-mandated float square root function,

#include <math.h>

float sqrtf(float x)

You will find this in section 7.12.7.5 of the C99 standard.



这是C99的新功能还是它也是C89的一部分?


Is this a new function of C99 or is it also part of C89?



我在3个不同的C标准库引用中看了这个,而

结果表明这是C99唯一的东西。好吧,至少它似乎是标准委员会的某个人知道这个问题。

I have looked this up in 3 different C standard library references and the
result suggests that this is a C99-only thing. Well, at least it seems
someone on the standard comitee was aware of the issue.


这篇关于sqrt()双重麻烦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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