cedric pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=e45b8015772ba0cee01a111080e4c04ea513c23f
commit e45b8015772ba0cee01a111080e4c04ea513c23f Author: Cedric BAIL <ced...@osg.samsung.com> Date: Thu Oct 22 16:55:10 2015 -0700 eina: fix computation of sqrt near 1. This is still not so good below 1. @fix --- src/lib/eina/eina_inline_f16p16.x | 4 ++-- src/lib/eina/eina_inline_f32p32.x | 4 ++-- src/lib/eina/eina_inline_f8p24.x | 12 ++++++------ src/tests/eina/eina_test_quaternion.c | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/lib/eina/eina_inline_f16p16.x b/src/lib/eina/eina_inline_f16p16.x index e16d188..4d906d9 100644 --- a/src/lib/eina/eina_inline_f16p16.x +++ b/src/lib/eina/eina_inline_f16p16.x @@ -58,9 +58,9 @@ eina_f16p16_sqrt(Eina_F16p16 a) root = 0; /* Clear root */ remHi = 0; /* Clear high part of partial remainder */ remLo = a; /* Get argument into low part of partial remainder */ - count = (15 + (16 >> 1)); /* Load loop counter */ + count = 16; /* Load loop counter */ do { - remHi = (remHi << 2) | (remLo >> 30); + remHi = (remHi << 16) | (remLo >> 16); remLo <<= 2; /* get 2 bits of arg */ root <<= 1; /* Get ready for the next bit in the root */ testDiv = (root << 1) + 1; /* Test radical */ diff --git a/src/lib/eina/eina_inline_f32p32.x b/src/lib/eina/eina_inline_f32p32.x index f0c5fd8..cb69e60 100644 --- a/src/lib/eina/eina_inline_f32p32.x +++ b/src/lib/eina/eina_inline_f32p32.x @@ -97,9 +97,9 @@ eina_f32p32_sqrt(Eina_F32p32 a) root = 0; /* Clear root */ remHi = 0; /* Clear high part of partial remainder */ remLo = a; /* Get argument into low part of partial remainder */ - count = (31 + (32 >> 1)); /* Load loop counter */ + count = 32; /* Load loop counter */ do { - remHi = (remHi << 2) | (remLo >> 30); + remHi = (remHi << 32) | (remLo >> 32); remLo <<= 2; /* get 2 bits of arg */ root <<= 1; /* Get ready for the next bit in the root */ testDiv = (root << 1) + 1; /* Test radical */ diff --git a/src/lib/eina/eina_inline_f8p24.x b/src/lib/eina/eina_inline_f8p24.x index f80bf61..315dbdf 100644 --- a/src/lib/eina/eina_inline_f8p24.x +++ b/src/lib/eina/eina_inline_f8p24.x @@ -58,17 +58,17 @@ eina_f8p24_sqrt(Eina_F8p24 a) root = 0; /* Clear root */ remHi = 0; /* Clear high part of partial remainder */ remLo = a; /* Get argument into low part of partial remainder */ - count = (23 + (24 >> 1)); /* Load loop counter */ + count = 24; /* Load loop counter */ do { - remHi = (remHi << 2) | (remLo >> 30); + remHi = (remHi << 8) | (remLo >> 24); remLo <<= 2; /* get 2 bits of arg */ root <<= 1; /* Get ready for the next bit in the root */ testDiv = (root << 1) + 1; /* Test radical */ if (remHi >= testDiv) - { - remHi -= testDiv; - root++; - } + { + remHi -= testDiv; + root++; + } } while (count-- != 0); return (root); } diff --git a/src/tests/eina/eina_test_quaternion.c b/src/tests/eina/eina_test_quaternion.c index 2401dcb..da97dea 100644 --- a/src/tests/eina/eina_test_quaternion.c +++ b/src/tests/eina/eina_test_quaternion.c @@ -180,7 +180,7 @@ START_TEST(eina_test_quaternion_f16p16) fail_if(!eina_quaternion_cmp(&p, &q)); res = eina_quaternion_f16p16_norm(&r); - fail_if(res != 131072); + fail_if(res != 131070); eina_quaternion_f16p16_negative(&s, &r); fail_if(s.x != s.y || --