首页 > 编程知识 正文

atan与atan2函数用法,c语言atan2函数用法

时间:2023-05-06 15:55:15 阅读:219619 作者:4929

参考MATLAB函数——atan(x)和atan2(x)的区别

在有的情况下只提供了atan的内置函数而没有atan2,先要判断象限再调整。

import torchimport mathpi = math.pireal = torch.tensor([ 0.12, -1.1, -0.1, 1])imag = torch.tensor([ 0.22, 1.2, -1.2, -1.2])atan = torch.atan(imag/real)print(atan)atan[1] = atan[1] + piatan[2] = atan[2] - piprint(atan)atan2 = torch.atan2(imag,real)print(atan2)

output

tensor([ 1.0714, -0.8288, 1.4877, -0.8761])
tensor([ 1.0714, 2.3127, -1.6539, -0.8761])
tensor([ 1.0714, 2.3127, -1.6539, -0.8761])

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。