16

私はarmv7、Android アプリケーション用に、一度に 4 ピクセルで画像を処理しています。

float32x4_tベクトルを別のベクトルで除算したいのですが、その中の数値は から までさまざまです。除算0.7する3.85唯一の方法は右シフトを使用することですが、それは数値 です2^n

また、私はこれが初めてなので、建設的な助けやコメントを歓迎します。

例:

これらの操作を NEON 組み込み関数で実行するにはどうすればよいですか?

float32x4_t a = {25.3,34.1,11.0,25.1};
float32x4_t b = {1.2,3.5,2.5,2.0};
//    somthing like this
float32x4 resultado = a/b; // {21.08,9.74,4.4,12.55}
4

1 に答える 1

25

NEON 命令セットには浮動小数点除算がありません。

値が適切にスケーリングされておらず、正確な丸めを必要としないことがアプリオリにわかっている場合 (これは、画像処理を行っている場合にほぼ確実に当てはまります)、代わりに逆数推定、改良ステップ、および乗算を使用できます。分割の:

// get an initial estimate of 1/b.
float32x4_t reciprocal = vrecpeq_f32(b);

// use a couple Newton-Raphson steps to refine the estimate.  Depending on your
// application's accuracy requirements, you may be able to get away with only
// one refinement (instead of the two used here).  Be sure to test!
reciprocal = vmulq_f32(vrecpsq_f32(b, reciprocal), reciprocal);
reciprocal = vmulq_f32(vrecpsq_f32(b, reciprocal), reciprocal);

// and finally, compute a/b = a*(1/b)
float32x4_t result = vmulq_f32(a,reciprocal);
于 2011-07-25T21:10:23.717 に答える