算法POW(浮动,浮动) [英] Algorithm for pow(float, float)

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

问题描述

我需要一个efficent算法做两浮筒之间的数学::幂函数, 你有什么想法如何做到这一点,(我需要的算法,不使用函数本身)

I need an efficent algorithm to do math::power function between two floats, do you have any idea how to do this, (i need the algorithm not to use the function itself)

推荐答案

的一般算法趋于计算浮子功率作为所述整数幂的剩余根的组合。该整数次幂是相当简单的,根可使用或者牛顿计算 - 迭代法或的Taylor系列。在C中 IIRC 数值的食谱有一些这方面的文字。还有其他的(潜在的更好)的方法这样做太,但这将做出合理的起点的是一个令人惊讶的复杂的问题来实现。还要注意,一些实现使用查找表和一些技巧来减少所需的计算。

The general algorithm tends to be computing the float power as the combination of the integer power and the remaining root. The integer power is fairly straightforward, the root can be computed using either Newton - Raphson method or Taylor series. IIRC numerical recipes in C has some text on this. There are other (potentially better) methods for doing this too, but this would make a reasonable starting point for what is a surprisingly complex problem to implement. Note also that some implementations use lookup tables and a number of tricks to reduce the computation required.

这篇关于算法POW(浮动,浮动)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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