主要内容

cordicatan2

基于 CORDIC 的四象限反正切

说明

theta = cordicatan2(y,x) 使用 CORDIC 算法逼近计算 yx 的四象限反正切。

示例

theta = cordicatan2(y,x,niters) 执行 niters 次算法迭代。

示例

全部折叠

定义浮点笛卡尔坐标。

y = 0.5;
x = -0.5;

使用 cordicatan2 计算浮点 CORDIC 反正切。将结果与使用 atan2 计算的反正切进行比较。

theta_cdat2_float = cordicatan2(y,x)
theta_cdat2_float = 
2.3562
theta_atan2_float = atan2(y,x)
theta_atan2_float = 
2.3562

定义定点笛卡尔坐标。

y = fi(0.5,1,16,15);
x = fi(-0.5,1,16,15);

使用 cordicatan2 计算定点 CORDIC 反正切。将结果与使用 atan2 计算的反正切进行比较。

theta_cdat2_fixpt = cordicatan2(y,x)
theta_cdat2_fixpt = 
    2.3562

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 16
        FractionLength: 13
theta_atan2_fixpt = atan2(y,x)
theta_atan2_fixpt = 
    2.3562

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 16
        FractionLength: 13

输入参数

全部折叠

笛卡尔 y 坐标,指定为标量、向量、矩阵或多维数组。

yx 的大小必须相同。如果其大小不同,则其中至少一个值必须为标量值。yx 必须具有相同的数据类型。

数据类型: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fi
复数支持:

笛卡尔 x 坐标,指定为标量、向量、矩阵或多维数组。

yx 的大小必须相同。如果其大小不同,则其中至少一个值必须为标量值。yx 必须具有相同的数据类型。

数据类型: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fi
复数支持:

CORDIC 算法的迭代次数,指定为正整数值标量。

增加迭代次数可以得出更准确的结果,但会增加计算开销和延迟。

如果未指定 niters,或指定的值太大,算法将使用最大值:

  • 对于定点运算,最大迭代次数为 yx 的字长减 1。

  • 对于浮点运算,最大值是 52(双精度)或 23(单精度)。

数据类型: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fi

输出参量

全部折叠

在范围 [-π, π] 弧度内的反正切值,以标量、向量、矩阵或多维数组形式返回。

如果 yx 是浮点数,则 theta 具有与 yx 相同的数据类型。否则,theta 的数据类型是与 yx 具有相同字长的定点数据类型,并具有在 [-π, π] 范围内的最佳精度小数长度。

算法

全部折叠

参考

[1] Volder, Jack E. “The CORDIC Trigonometric Computing Technique.” IRE Transactions on Electronic Computers. EC-8, no. 3 (Sept. 1959): 330–334.

[2] Andraka, Ray. “A Survey of CORDIC Algorithm for FPGA Based Computers.” In Proceedings of the 1998 ACM/SIGDA Sixth International Symposium on Field Programmable Gate Arrays, 191–200. https://dl.acm.org/doi/10.1145/275107.275139.

[3] Walther, J.S. “A Unified Algorithm for Elementary Functions.” In Proceedings of the May 18-20, 1971 Spring Joint Computer Conference, 379–386. https://dl.acm.org/doi/10.1145/1478786.1478840.

[4] Schelin, Charles W. “Calculator Function Approximation.” The American Mathematical Monthly, no. 5 (May 1983): 317–325. https://doi.org/10.2307/2975781.

扩展功能

全部展开

版本历史记录

在 R2011b 中推出