メインコンテンツ

cordicatan2

CORDIC ベースの 4 象限逆正接

説明

theta = cordicatan2(y,x) は、CORDIC アルゴリズム近似を使用して、y および x の 4 象限逆正接を計算します。

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 を指定しない場合や指定した値が大きすぎた場合は、アルゴリズムでは最大値が使用されます。

  • 固定小数点の演算では、反復の最大回数は y または x の語長よりも 1 回少なくなります。

  • 浮動小数点の演算では、最大値は double で 52、single で 23 です。

データ型: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fi

出力引数

すべて折りたたむ

範囲 [-pi, pi] の逆正接の値 (ラジアン)。スカラー、ベクトル、行列、または多次元配列として返されます。

y および x が浮動小数点数の場合、thetayx と同じデータ型になります。それ以外の場合、theta は固定小数点データ型となり、語長は y および x と同じで、小数部の長さは -pi から pi の値に対して最高精度となります。

アルゴリズム

すべて折りたたむ

参照

[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 で導入