Android 使用NEON内部函数除以浮点数
我当时正在处理一张四像素的图像,这是在Android应用程序的Android 使用NEON内部函数除以浮点数,android,c,arm,intrinsics,neon,Android,C,Arm,Intrinsics,Neon,我当时正在处理一张四像素的图像,这是在Android应用程序的armv7上进行的 我想将一个float32x4_t向量除以另一个向量,但其中的数字从大约0.7到3.85不等,在我看来,唯一的除法是使用右移,但这是一个2^n的数字 另外,我是这方面的新手,所以欢迎任何建设性的帮助或评论 例如: 如何使用NEON Intrinsic执行这些操作 float32x4_t a = {25.3,34.1,11.0,25.1}; float32x4_t b = {1.2,3.5,2.5,2.0}; //
armv7
上进行的
我想将一个float32x4_t
向量除以另一个向量,但其中的数字从大约0.7
到3.85
不等,在我看来,唯一的除法是使用右移,但这是一个2^n
的数字
另外,我是这方面的新手,所以欢迎任何建设性的帮助或评论
例如:
如何使用NEON Intrinsic执行这些操作
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指令集没有浮点除法 如果您先验地知道您的值没有很差的缩放比例,并且不需要正确的舍入(如果您正在进行图像处理,则几乎可以肯定这种情况),那么您可以使用倒数估计、细化步骤和乘法而不是除法:
// 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);
我也教过这种解决方案,但我不知道vrecpeq_f32,所以非常感谢。我认为neon intrinsics需要更好地说明它所使用的函数has@Darkmax:您应该从ARM下载架构参考手册,而不是依赖NEON标题文档。