我当时正在处理四个像素的图像,这是在armv7
对于 Android 应用程序。
我想分一个float32x4_t
向量由另一个向量组成,但其中的数字与大约不同0.7
to 3.85
,在我看来,除法的唯一方法是使用右移,但这是针对一个数字2^n
.
另外,我是这方面的新手,所以欢迎任何建设性的帮助或评论。
Example:
如何使用 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}
NEON 指令集没有浮点除法。
如果你知道的话a priori如果您的值缩放得不错,并且不需要正确的舍入(如果您正在进行图像处理,则几乎肯定是这种情况),那么您可以使用倒数估计、细化步骤和乘法而不是除法:
// 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);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)