geomath.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:qgis-shapetools-plugin 作者: NationalSecurityAgency 项目源码 文件源码
def log1p(x):
    """log(1 + x) accurate for small x (missing from python 2.5.2)"""

    if sys.version_info > (2, 6):
      return math.log1p(x)

    y = 1 + x
    z = y - 1
    # Here's the explanation for this magic: y = 1 + z, exactly, and z
    # approx x, thus log(y)/z (which is nearly constant near z = 0) returns
    # a good approximation to the true log(1 + x)/x.  The multiplication x *
    # (log(y)/z) introduces little additional error.
    return x if z == 0 else x * math.log(y) / z
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号