主要内容

cordicabs

基于 CORDIC 的绝对值

说明

r = cordicabs(c) 返回 c 的复数元素的量级。

示例

r = cordicabs(c,niters) 执行 niters 指定的 CORDIC 算法迭代次数。

r = cordicabs(___,'ScaleOutput',b) 指定是否按逆 CORDIC 增益因子缩放输出。

示例

全部折叠

将使用双精度输入值计算的绝对值与 cordicabsabs 函数进行比较。

dblValues = complex(rand(5,4),rand(5,4))
dblValues = 5×4 complex

   0.8147 + 0.6557i   0.0975 + 0.7577i   0.1576 + 0.7060i   0.1419 + 0.8235i
   0.9058 + 0.0357i   0.2785 + 0.7431i   0.9706 + 0.0318i   0.4218 + 0.6948i
   0.1270 + 0.8491i   0.5469 + 0.3922i   0.9572 + 0.2769i   0.9157 + 0.3171i
   0.9134 + 0.9340i   0.9575 + 0.6555i   0.4854 + 0.0462i   0.7922 + 0.9502i
   0.6324 + 0.6787i   0.9649 + 0.1712i   0.8003 + 0.0971i   0.9595 + 0.0344i

r_dbl_ref = abs(dblValues)
r_dbl_ref = 5×4

    1.0458    0.7640    0.7234    0.8356
    0.9065    0.7936    0.9711    0.8128
    0.8586    0.6730    0.9964    0.9691
    1.3064    1.1604    0.4876    1.2371
    0.9277    0.9800    0.8062    0.9601

r_dbl_cdc = cordicabs(dblValues)
r_dbl_cdc = 5×4

    1.0458    0.7640    0.7234    0.8356
    0.9065    0.7936    0.9711    0.8128
    0.8586    0.6730    0.9964    0.9691
    1.3064    1.1604    0.4876    1.2371
    0.9277    0.9800    0.8062    0.9601

计算定点输入的绝对值。

fxpValues = fi(dblValues)
fxpValues = 
   0.8147 + 0.6557i   0.0975 + 0.7578i   0.1576 + 0.7061i   0.1419 + 0.8235i
   0.9058 + 0.0357i   0.2785 + 0.7431i   0.9706 + 0.0318i   0.4218 + 0.6948i
   0.1270 + 0.8491i   0.5469 + 0.3922i   0.9572 + 0.2769i   0.9157 + 0.3171i
   0.9134 + 0.9340i   0.9575 + 0.6555i   0.4854 + 0.0462i   0.7922 + 0.9502i
   0.6324 + 0.6787i   0.9649 + 0.1712i   0.8003 + 0.0971i   0.9595 + 0.0345i

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 16
        FractionLength: 15
r_fxp_cdc = cordicabs(fxpValues)
r_fxp_cdc = 
    1.0458    0.7640    0.7234    0.8356
    0.9066    0.7935    0.9712    0.8128
    0.8586    0.6730    0.9965    0.9691
    1.3064    1.1604    0.4876    1.2371
    0.9277    0.9799    0.8062    0.9601

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 18
        FractionLength: 15

输入参数

全部折叠

复数输入数组,指定为标量、向量、矩阵或多维数组。所有输入值必须具有相同的数据类型。

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

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

如果未指定 niters 或指定的值太大,算法将使用最大值。对于定点运算,最大迭代次数为 c 的字长减 1。对于浮点运算,最大值为 52(双精度)或 23(单精度)。

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

是否按逆 CORDIC 增益因子缩放输出,指定为数值或逻辑值 1 (true) 或 0 (false)。

数据类型: logical

输出参量

全部折叠

复数输入值的幅值,以标量、向量、矩阵或多维数组形式返回。如果输入 c 是定点,则 r 以使用二进制小数点定标的有符号定点数据类型形式返回。如果输入是有符号输入,则 r 的字长为输入字长 + 2。如果输入是无符号输入,则 r 的字长为输入字长 + 3。r 的小数长度始终与输入 c 的小数长度相同。

算法

全部折叠

参考

[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 中推出