Is rsqrt the same as Fast inverse square root?
조회 수: 66(최근 30일)
I would like to us sqrt() and run it on a embeded controller. I was wondering sqrt() is the same as Fast inverse square root (https://en.wikipedia.org/wiki/Fast_inverse_square_root). if not, is it efficent as Fast inverse square root. Does it support code generation? Can I use it in embeded control software?
Jan 2021년 9월 13일
i = * ( long * ) &y
This is equivalent to:
y = single(pi);
i = typecast(y, 'int32');
The shown code of Q_rsqrt is an approximation of 1/sqrt(x) for single precision floating point values. It might have a fair speed on CPUs without a floating point unit, but it is less accurate then the direct calculation.