MCPcopy Create free account
hub / github.com/creatale/node-dv / cubeRoot

Function cubeRoot

deps/opencv/modules/core/src/mathfuncs.cpp:159–194  ·  view source on GitHub ↗

\ Fast cube root by Ken Turkowski (http://www.worldserver.com/turk/computergraphics/papers.html) \* ************************************************************************** */

Source from the content-addressed store, hash-verified

157 (http://www.worldserver.com/turk/computergraphics/papers.html)
158\* ************************************************************************** */
159float cubeRoot( float value )
160{
161 float fr;
162 Cv32suf v, m;
163 int ix, s;
164 int ex, shx;
165
166 v.f = value;
167 ix = v.i & 0x7fffffff;
168 s = v.i & 0x80000000;
169 ex = (ix >> 23) - 127;
170 shx = ex % 3;
171 shx -= shx >= 0 ? 3 : 0;
172 ex = (ex - shx) / 3; /* exponent of cube root */
173 v.i = (ix & ((1<<23)-1)) | ((shx + 127)<<23);
174 fr = v.f;
175
176 /* 0.125 <= fr < 1.0 */
177 /* Use quartic rational polynomial with error < 2^(-24) */
178 fr = (float)(((((45.2548339756803022511987494 * fr +
179 192.2798368355061050458134625) * fr +
180 119.1654824285581628956914143) * fr +
181 13.43250139086239872172837314) * fr +
182 0.1636161226585754240958355063)/
183 ((((14.80884093219134573786480845 * fr +
184 151.9714051044435648658557668) * fr +
185 168.5254414101568283957668343) * fr +
186 33.9905941350215598754191872) * fr +
187 1.0));
188
189 /* fr *= 2^ex * sign */
190 m.f = value;
191 v.f = fr;
192 v.i = (v.i + (ex << 23) + s) & (m.i*2 != 0 ? -1 : 0);
193 return v.f;
194}
195
196static void Magnitude_32f(const float* x, const float* y, float* mag, int len)
197{

Callers 1

cvCbrtFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected