Rotate input using CORDIC-based approximation
v = cordicrotate(theta,u)
v = cordicrotate(theta,u,niters)
v = cordicrotate(theta,u,Name,Value)
v = cordicrotate(theta,u,niters,Name,Value)
rotates the input v
= cordicrotate(theta
,u
)u
by theta
using a CORDIC
algorithm approximation. The function returns the result of u
.*
e^(j*theta
).
performs v
= cordicrotate(theta
,u
,niters
)niters
iterations
of the algorithm.
scales
the output depending on the Boolean value, v
= cordicrotate(theta
,u
,Name,Value
)b
.
specifies
both the number of iterations and the v
= cordicrotate(theta
,u
,niters
,Name,Value
)Name,Value
pair
for whether to scale the output.
|
|
|
|
|
|
Optional comma-separated pairs of Name,Value
arguments,
where Name
is the argument name and Value
is
the corresponding value. Name
must appear inside
single quotes (''
).
|
Default: true |
|
When the input When the input u is an unsigned integer
or fixed point, the output |
Run the following code, and evaluate the accuracy of the CORDIC-based complex rotation.
wrdLn = 16; theta = fi(-pi/3, 1, wrdLn); u = fi(0.25 - 7.1i, 1, wrdLn); uTeTh = double(u) .* exp(1i * double(theta)); fprintf('\n\nNITERS\tReal\t ERROR\t LSBs\t\tImag\tERROR\tLSBs\n'); fprintf('------\t-------\t ------\t ----\t\t-------\t------\t----\n'); for niters = 1:(wrdLn - 1) v_fi = cordicrotate(theta, u, niters); v_dbl = double(v_fi); x_err = abs(real(v_dbl) - real(uTeTh)); y_err = abs(imag(v_dbl) - imag(uTeTh)); fprintf('%d\t%1.4f\t %1.4f\t %1.1f\t\t%1.4f\t %1.4f\t %1.1f\n',... niters, real(v_dbl),x_err,(x_err * pow2(v_fi.FractionLength)), ... imag(v_dbl),y_err, (y_err * pow2(v_fi.FractionLength))); end fprintf('\n');
The output table appears as follows:
NITERS Real ERROR LSBs Imag ERROR LSBs ------ ------- ------ ---- ------- ------ ------ 1 -4.8438 1.1800 4833.5 -5.1973 1.4306 5859.8 2 -6.6567 0.6329 2592.5 -2.4824 1.2842 5260.2 3 -5.8560 0.1678 687.5 -4.0227 0.2560 1048.8 4 -6.3098 0.2860 1171.5 -3.2649 0.5018 2055.2 5 -6.0935 0.0697 285.5 -3.6528 0.1138 466.2 6 -5.9766 0.0472 193.5 -3.8413 0.0746 305.8 7 -6.0359 0.0121 49.5 -3.7476 0.0191 78.2 8 -6.0061 0.0177 72.5 -3.7947 0.0280 114.8 9 -6.0210 0.0028 11.5 -3.7710 0.0043 17.8 10 -6.0286 0.0048 19.5 -3.7590 0.0076 31.2 11 -6.0247 0.0009 3.5 -3.7651 0.0015 6.2 12 -6.0227 0.0011 4.5 -3.7683 0.0017 6.8 13 -6.0237 0.0001 0.5 -3.7666 0.0001 0.2 14 -6.0242 0.0004 1.5 -3.7656 0.0010 4.2 15 -6.0239 0.0001 0.5 -3.7661 0.0005 2.2
[1] Volder, JE. “The CORDIC Trigonometric Computing Technique.” IRE Transactions on Electronic Computers. Vol. EC-8, September 1959, pp. 330–334.
[2] Andraka, R. “A survey of CORDIC algorithm for FPGA based computers.” Proceedings of the 1998 ACM/SIGDA sixth international symposium on Field programmable gate arrays. Feb. 22–24, 1998, pp. 191–200.
[3] Walther, J.S. “A Unified Algorithm for Elementary Functions.” Hewlett-Packard Company, Palo Alto. Spring Joint Computer Conference, 1971, pp. 379–386. (from the collection of the Computer History Museum). www.computer.org/csdl/proceedings/afips/1971/5077/00/50770379.pdf
[4] Schelin, Charles W. “Calculator Function Approximation.” The American Mathematical Monthly. Vol. 90, No. 5, May 1983, pp. 317–325.