diff --git a/test/cmocka/include/trig_tables.h b/test/cmocka/include/trig_tables.h deleted file mode 100644 index 3e1f8a7eb94f..000000000000 --- a/test/cmocka/include/trig_tables.h +++ /dev/null @@ -1,360 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * - * Copyright(c) 2021 Intel Corporation. All rights reserved. - * - * Author: Shriram Shastry - */ - -/* Reference table generated by sin(), gcc-4.3.2 */ -static const float sin_ref_table[] = { - 0.0000000000, 0.0174524064, 0.0348994967, 0.0523359562, - 0.0697564737, 0.0871557427, 0.1045284633, 0.1218693434, - 0.1391731010, 0.1564344650, 0.1736481777, 0.1908089954, - 0.2079116908, 0.2249510543, 0.2419218956, 0.2588190451, - 0.2756373558, 0.2923717047, 0.3090169944, 0.3255681545, - 0.3420201433, 0.3583679495, 0.3746065934, 0.3907311285, - 0.4067366431, 0.4226182617, 0.4383711468, 0.4539904997, - 0.4694715628, 0.4848096202, 0.5000000000, 0.5150380749, - 0.5299192642, 0.5446390350, 0.5591929035, 0.5735764364, - 0.5877852523, 0.6018150232, 0.6156614753, 0.6293203910, - 0.6427876097, 0.6560590290, 0.6691306064, 0.6819983601, - 0.6946583705, 0.7071067812, 0.7193398003, 0.7313537016, - 0.7431448255, 0.7547095802, 0.7660444431, 0.7771459615, - 0.7880107536, 0.7986355100, 0.8090169944, 0.8191520443, - 0.8290375726, 0.8386705679, 0.8480480962, 0.8571673007, - 0.8660254038, 0.8746197071, 0.8829475929, 0.8910065242, - 0.8987940463, 0.9063077870, 0.9135454576, 0.9205048535, - 0.9271838546, 0.9335804265, 0.9396926208, 0.9455185756, - 0.9510565163, 0.9563047560, 0.9612616959, 0.9659258263, - 0.9702957263, 0.9743700648, 0.9781476007, 0.9816271834, - 0.9848077530, 0.9876883406, 0.9902680687, 0.9925461516, - 0.9945218954, 0.9961946981, 0.9975640503, 0.9986295348, - 0.9993908270, 0.9998476952, 1.0000000000, 0.9998476952, - 0.9993908270, 0.9986295348, 0.9975640503, 0.9961946981, - 0.9945218954, 0.9925461516, 0.9902680687, 0.9876883406, - 0.9848077530, 0.9816271834, 0.9781476007, 0.9743700648, - 0.9702957263, 0.9659258263, 0.9612616959, 0.9563047560, - 0.9510565163, 0.9455185756, 0.9396926208, 0.9335804265, - 0.9271838546, 0.9205048535, 0.9135454576, 0.9063077870, - 0.8987940463, 0.8910065242, 0.8829475929, 0.8746197071, - 0.8660254038, 0.8571673007, 0.8480480962, 0.8386705679, - 0.8290375726, 0.8191520443, 0.8090169944, 0.7986355100, - 0.7880107536, 0.7771459615, 0.7660444431, 0.7547095802, - 0.7431448255, 0.7313537016, 0.7193398003, 0.7071067812, - 0.6946583705, 0.6819983601, 0.6691306064, 0.6560590290, - 0.6427876097, 0.6293203910, 0.6156614753, 0.6018150232, - 0.5877852523, 0.5735764364, 0.5591929035, 0.5446390350, - 0.5299192642, 0.5150380749, 0.5000000000, 0.4848096202, - 0.4694715628, 0.4539904997, 0.4383711468, 0.4226182617, - 0.4067366431, 0.3907311285, 0.3746065934, 0.3583679495, - 0.3420201433, 0.3255681545, 0.3090169944, 0.2923717047, - 0.2756373558, 0.2588190451, 0.2419218956, 0.2249510543, - 0.2079116908, 0.1908089954, 0.1736481777, 0.1564344650, - 0.1391731010, 0.1218693434, 0.1045284633, 0.0871557427, - 0.0697564737, 0.0523359562, 0.0348994967, 0.0174524064, - 0.0000000000, -0.0174524064, -0.0348994967, -0.0523359562, - -0.0697564737, -0.0871557427, -0.1045284633, -0.1218693434, - -0.1391731010, -0.1564344650, -0.1736481777, -0.1908089954, - -0.2079116908, -0.2249510543, -0.2419218956, -0.2588190451, - -0.2756373558, -0.2923717047, -0.3090169944, -0.3255681545, - -0.3420201433, -0.3583679495, -0.3746065934, -0.3907311285, - -0.4067366431, -0.4226182617, -0.4383711468, -0.4539904997, - -0.4694715628, -0.4848096202, -0.5000000000, -0.5150380749, - -0.5299192642, -0.5446390350, -0.5591929035, -0.5735764364, - -0.5877852523, -0.6018150232, -0.6156614753, -0.6293203910, - -0.6427876097, -0.6560590290, -0.6691306064, -0.6819983601, - -0.6946583705, -0.7071067812, -0.7193398003, -0.7313537016, - -0.7431448255, -0.7547095802, -0.7660444431, -0.7771459615, - -0.7880107536, -0.7986355100, -0.8090169944, -0.8191520443, - -0.8290375726, -0.8386705679, -0.8480480962, -0.8571673007, - -0.8660254038, -0.8746197071, -0.8829475929, -0.8910065242, - -0.8987940463, -0.9063077870, -0.9135454576, -0.9205048535, - -0.9271838546, -0.9335804265, -0.9396926208, -0.9455185756, - -0.9510565163, -0.9563047560, -0.9612616959, -0.9659258263, - -0.9702957263, -0.9743700648, -0.9781476007, -0.9816271834, - -0.9848077530, -0.9876883406, -0.9902680687, -0.9925461516, - -0.9945218954, -0.9961946981, -0.9975640503, -0.9986295348, - -0.9993908270, -0.9998476952, -1.0000000000, -0.9998476952, - -0.9993908270, -0.9986295348, -0.9975640503, -0.9961946981, - -0.9945218954, -0.9925461516, -0.9902680687, -0.9876883406, - -0.9848077530, -0.9816271834, -0.9781476007, -0.9743700648, - -0.9702957263, -0.9659258263, -0.9612616959, -0.9563047560, - -0.9510565163, -0.9455185756, -0.9396926208, -0.9335804265, - -0.9271838546, -0.9205048535, -0.9135454576, -0.9063077870, - -0.8987940463, -0.8910065242, -0.8829475929, -0.8746197071, - -0.8660254038, -0.8571673007, -0.8480480962, -0.8386705679, - -0.8290375726, -0.8191520443, -0.8090169944, -0.7986355100, - -0.7880107536, -0.7771459615, -0.7660444431, -0.7547095802, - -0.7431448255, -0.7313537016, -0.7193398003, -0.7071067812, - -0.6946583705, -0.6819983601, -0.6691306064, -0.6560590290, - -0.6427876097, -0.6293203910, -0.6156614753, -0.6018150232, - -0.5877852523, -0.5735764364, -0.5591929035, -0.5446390350, - -0.5299192642, -0.5150380749, -0.5000000000, -0.4848096202, - -0.4694715628, -0.4539904997, -0.4383711468, -0.4226182617, - -0.4067366431, -0.3907311285, -0.3746065934, -0.3583679495, - -0.3420201433, -0.3255681545, -0.3090169944, -0.2923717047, - -0.2756373558, -0.2588190451, -0.2419218956, -0.2249510543, - -0.2079116908, -0.1908089954, -0.1736481777, -0.1564344650, - -0.1391731010, -0.1218693434, -0.1045284633, -0.0871557427, - -0.0697564737, -0.0523359562, -0.0348994967, -0.0174524064 -}; - -/* Reference table generated by cos(), gcc-4.3.2 */ -static const float cos_ref_table[] = { - 1.000000000000000, 0.999847695156391, 0.999390827019096, 0.998629534754574, - 0.997564050259824, 0.996194698091746, 0.994521895368273, 0.992546151641322, - 0.99026806874157, 0.987688340595138, 0.984807753012208, 0.981627183447664, - 0.978147600733806, 0.974370064785235, 0.970295726275996, 0.965925826289068, - 0.961261695938319, 0.956304755963035, 0.951056516295154, 0.945518575599317, - 0.939692620785908, 0.933580426497202, 0.927183854566787, 0.92050485345244, - 0.913545457642601, 0.90630778703665, 0.898794046299167, 0.891006524188368, - 0.882947592858927, 0.874619707139396, 0.866025403784439, 0.857167300702112, - 0.848048096156426, 0.838670567945424, 0.829037572555042, 0.819152044288992, - 0.809016994374947, 0.798635510047293, 0.788010753606722, 0.777145961456971, - 0.766044443118978, 0.754709580222772, 0.743144825477394, 0.731353701619171, - 0.719339800338651, 0.707106781186548, 0.694658370458997, 0.681998360062498, - 0.669130606358858, 0.656059028990507, 0.642787609686539, 0.629320391049838, - 0.615661475325658, 0.601815023152048, 0.587785252292473, 0.573576436351046, - 0.559192903470747, 0.544639035015027, 0.529919264233205, 0.515038074910054, - 0.500000000000000, 0.484809620246337, 0.469471562785891, 0.453990499739547, - 0.438371146789077, 0.422618261740699, 0.4067366430758, 0.390731128489274, - 0.374606593415912, 0.3583679495453, 0.342020143325669, 0.325568154457157, - 0.309016994374947, 0.292371704722737, 0.275637355816999, 0.258819045102521, - 0.241921895599668, 0.224951054343865, 0.207911690817759, 0.190808995376545, - 0.17364817766693, 0.156434465040231, 0.139173100960066, 0.121869343405147, - 0.104528463267653, 0.0871557427476581, 0.0697564737441255, 0.052335956242944, - 0.0348994967025011, 0.0174524064372834, 6.12323399573677e-17, -0.0174524064372835, - -0.0348994967025007, -0.0523359562429436, -0.0697564737441253, -0.0871557427476582, - -0.104528463267653, -0.121869343405147, -0.139173100960065, -0.156434465040231, - -0.17364817766693, -0.190808995376545, -0.207911690817759, -0.224951054343865, - -0.241921895599668, -0.258819045102521, -0.275637355816999, -0.292371704722737, - -0.309016994374947, -0.325568154457156, -0.342020143325669, -0.3583679495453, - -0.374606593415912, -0.390731128489274, -0.4067366430758, -0.422618261740699, - -0.438371146789078, -0.453990499739547, -0.469471562785891, -0.484809620246337, - -0.500000000000000, -0.515038074910054, -0.529919264233205, -0.544639035015027, - -0.559192903470747, -0.573576436351046, -0.587785252292473, -0.601815023152048, - -0.615661475325658, -0.629320391049837, -0.642787609686539, -0.656059028990507, - -0.669130606358858, -0.681998360062498, -0.694658370458997, -0.707106781186547, - -0.719339800338651, -0.73135370161917, -0.743144825477394, -0.754709580222772, - -0.766044443118978, -0.777145961456971, -0.788010753606722, -0.798635510047293, - -0.809016994374947, -0.819152044288992, -0.829037572555042, -0.838670567945424, - -0.848048096156426, -0.857167300702112, -0.866025403784439, -0.874619707139396, - -0.882947592858927, -0.891006524188368, -0.898794046299167, -0.90630778703665, - -0.913545457642601, -0.92050485345244, -0.927183854566787, -0.933580426497202, - -0.939692620785908, -0.945518575599317, -0.951056516295154, -0.956304755963035, - -0.961261695938319, -0.965925826289068, -0.970295726275996, -0.974370064785235, - -0.978147600733806, -0.981627183447664, -0.984807753012208, -0.987688340595138, - -0.99026806874157, -0.992546151641322, -0.994521895368273, -0.996194698091746, - -0.997564050259824, -0.998629534754574, -0.999390827019096, -0.999847695156391, - -1.000000000000000, -0.999847695156391, -0.999390827019096, -0.998629534754574, - -0.997564050259824, -0.996194698091746, -0.994521895368273, -0.992546151641322, - -0.99026806874157, -0.987688340595138, -0.984807753012208, -0.981627183447664, - -0.978147600733806, -0.974370064785235, -0.970295726275997, -0.965925826289068, - -0.961261695938319, -0.956304755963036, -0.951056516295154, -0.945518575599317, - -0.939692620785908, -0.933580426497202, -0.927183854566787, -0.92050485345244, - -0.913545457642601, -0.90630778703665, -0.898794046299167, -0.891006524188368, - -0.882947592858927, -0.874619707139396, -0.866025403784439, -0.857167300702112, - -0.848048096156426, -0.838670567945424, -0.829037572555042, -0.819152044288992, - -0.809016994374947, -0.798635510047293, -0.788010753606722, -0.777145961456971, - -0.766044443118978, -0.754709580222772, -0.743144825477394, -0.731353701619171, - -0.719339800338651, -0.707106781186548, -0.694658370458997, -0.681998360062499, - -0.669130606358858, -0.656059028990508, -0.642787609686539, -0.629320391049837, - -0.615661475325658, -0.601815023152048, -0.587785252292473, -0.573576436351046, - -0.559192903470747, -0.544639035015027, -0.529919264233205, -0.515038074910054, - -0.500000000000000, -0.484809620246337, -0.469471562785891, -0.453990499739547, - -0.438371146789078, -0.4226182617407, -0.4067366430758, -0.390731128489274, - -0.374606593415912, -0.358367949545301, -0.342020143325669, -0.325568154457157, - -0.309016994374948, -0.292371704722737, -0.275637355816999, -0.258819045102521, - -0.241921895599668, -0.224951054343865, -0.20791169081776, -0.190808995376545, - -0.17364817766693, -0.156434465040231, -0.139173100960065, -0.121869343405147, - -0.104528463267653, -0.0871557427476582, -0.0697564737441256, -0.0523359562429443, - -0.0348994967025016, -0.0174524064372835, -1.83697019872103e-16, 0.0174524064372831, - 0.0348994967025013, 0.0523359562429439, 0.0697564737441252, 0.0871557427476579, - 0.104528463267653, 0.121869343405148, 0.139173100960065, 0.156434465040231, - 0.17364817766693, 0.190808995376544, 0.207911690817759, 0.224951054343865, - 0.241921895599667, 0.258819045102521, 0.275637355816999, 0.292371704722737, - 0.309016994374947, 0.325568154457156, 0.342020143325668, 0.3583679495453, - 0.374606593415912, 0.390731128489273, 0.406736643075801, 0.4226182617407, - 0.438371146789077, 0.453990499739547, 0.46947156278589, 0.484809620246337, - 0.500000000000000, 0.515038074910054, 0.529919264233205, 0.544639035015027, - 0.559192903470746, 0.573576436351046, 0.587785252292473, 0.601815023152048, - 0.615661475325659, 0.629320391049838, 0.642787609686539, 0.656059028990507, - 0.669130606358858, 0.681998360062498, 0.694658370458997, 0.707106781186547, - 0.719339800338651, 0.731353701619171, 0.743144825477394, 0.754709580222772, - 0.766044443118978, 0.777145961456971, 0.788010753606722, 0.798635510047293, - 0.809016994374947, 0.819152044288992, 0.829037572555041, 0.838670567945424, - 0.848048096156425, 0.857167300702112, 0.866025403784438, 0.874619707139396, - 0.882947592858927, 0.891006524188368, 0.898794046299167, 0.90630778703665, - 0.913545457642601, 0.92050485345244, 0.927183854566787, 0.933580426497202, - 0.939692620785908, 0.945518575599317, 0.951056516295154, 0.956304755963036, - 0.961261695938319, 0.965925826289068, 0.970295726275996, 0.974370064785235, - 0.978147600733806, 0.981627183447664, 0.984807753012208, 0.987688340595138, - 0.99026806874157, 0.992546151641322, 0.994521895368273, 0.996194698091746, - 0.997564050259824, 0.998629534754574, 0.999390827019096, 0.999847695156391, - 1 -}; - -/* Reference table generated by asin(), gcc-4.3.2 */ -static const float asin_ref_table[] = { - -1.5707963258028030, -1.4292567726224661, -1.3704614471644163, -1.3252307642251253, - -1.2870021797716618, -1.2532358597964048, -1.2226302791386843, -1.1944128256291151, - -1.1680804640054703, -1.1432840377092361, -1.1197695024311543, -1.0973451361060143, - -1.0758621711283922, -1.0552022922784090, -1.0352696590125561, -1.0159852746874094, - -0.9972832072526217, -0.9791076704859734, -0.9614110030233860, -0.9441520925611258, - -0.9272952042520046, -0.9108089841902256, -0.8946658074855804, -0.8788411282002926, - -0.8633130993694067, -0.8480620700865984, -0.8330703470855951, -0.8183219302445650, - -0.8038023039698601, -0.7894981894642115, -0.7753974795341492, -0.7614890411496162, - -0.7477626111358404, -0.7342087719589472, -0.7208187356591225, -0.7075844295322895, - -0.6944982521235943, -0.6815531998872757, -0.6687426939606667, -0.6560605876147747, - -0.6435010936111212, -0.6310588326305151, -0.6187286712229252, -0.6065058410167694, - -0.5943857878446579, -0.5823642127215862, -0.5704370923340321, -0.5586005486547947, - -0.5468509383499622, -0.5351847745478153, -0.5235987640917301, -0.5120897386223078, - -0.5006546974182129, -0.4892907701432705, -0.4779951833188534, -0.4667653329670429, - -0.4555986635386944, -0.4444927759468555, -0.4334453158080578, -0.4224540572613478, - -0.4115168377757072, -0.4006315693259239, -0.3897962793707848, -0.3790090084075928, - -0.3682678826153278, -0.3575710840523243, -0.3469168916344643, -0.3363035582005978, - -0.3257294744253159, -0.3151930235326290, -0.3046926259994507, -0.2942268401384354, - -0.2837941013276577, -0.2733930107206106, -0.2630221955478191, -0.2526802383363247, - -0.2423658333718777, -0.2320776768028736, -0.2218144722282887, -0.2115749418735504, - -0.2013579159975052, -0.1911621354520321, -0.1809864528477192, -0.1708296611905098, - -0.1606906354427338, -0.1505682766437531, -0.1404614131897688, -0.1303689777851105, - -0.1202898658812046, -0.1102230437099934, -0.1001674197614193, -0.0901219304651022, - -0.0800855793058872, -0.0700572803616524, -0.0600360594689846, -0.0500208474695683, - -0.0400106683373451, -0.0300045013427734, -0.0200013294816017, -0.0100001543760300, - 0.0000000000000000, 0.0100001543760300, 0.0200013294816017, 0.0300045013427734, - 0.0400106683373451, 0.0500208474695683, 0.0600360594689846, 0.0700572803616524, - 0.0800855793058872, 0.0901219304651022, 0.1001674197614193, 0.1102230437099934, - 0.1202898658812046, 0.1303689777851105, 0.1404614131897688, 0.1505682766437531, - 0.1606906354427338, 0.1708296611905098, 0.1809864528477192, 0.1911621354520321, - 0.2013579159975052, 0.2115749418735504, 0.2218144722282887, 0.2320776768028736, - 0.2423658333718777, 0.2526802383363247, 0.2630221955478191, 0.2733930107206106, - 0.2837941013276577, 0.2942268401384354, 0.3046926259994507, 0.3151930235326290, - 0.3257294744253159, 0.3363035582005978, 0.3469168916344643, 0.3575710840523243, - 0.3682678826153278, 0.3790090084075928, 0.3897962793707848, 0.4006315693259239, - 0.4115168377757072, 0.4224540572613478, 0.4334453158080578, 0.4444927759468555, - 0.4555986635386944, 0.4667653329670429, 0.4779951833188534, 0.4892907701432705, - 0.5006546974182129, 0.5120897386223078, 0.5235987640917301, 0.5351847745478153, - 0.5468509383499622, 0.5586005486547947, 0.5704370923340321, 0.5823642127215862, - 0.5943857878446579, 0.6065058410167694, 0.6187286712229252, 0.6310588326305151, - 0.6435010936111212, 0.6560605876147747, 0.6687426939606667, 0.6815531998872757, - 0.6944982521235943, 0.7075844295322895, 0.7208187356591225, 0.7342087719589472, - 0.7477626111358404, 0.7614890411496162, 0.7753974795341492, 0.7894981894642115, - 0.8038023039698601, 0.8183219302445650, 0.8330703470855951, 0.8480620700865984, - 0.8633130993694067, 0.8788411282002926, 0.8946658074855804, 0.9108089841902256, - 0.9272952042520046, 0.9441520925611258, 0.9614110030233860, 0.9791076704859734, - 0.9972832072526217, 1.0159852746874094, 1.0352696590125561, 1.0552022922784090, - 1.0758621711283922, 1.0973451361060143, 1.1197695024311543, 1.1432840377092361, - 1.1680804640054703, 1.1944128256291151, 1.2226302791386843, 1.2532358597964048, - 1.2870021797716618, 1.3252307642251253, 1.3704614471644163, 1.4292567726224661, - 1.5707963258028030, -}; - -/* Reference table generated by acos(), gcc-4.3.2 */ -static const float acos_ref_table[] = { - 3.1415926534682512, 3.0000531002879143, 2.9412577748298645, 2.8960270918905735, - 2.8577985074371099, 2.8240321874618530, 2.7934266068041325, 2.7652091532945633, - 2.7388767916709185, 2.7140803653746843, 2.6905658300966024, 2.6681414637714624, - 2.6466584987938404, 2.6259986199438572, 2.6060659866780043, 2.5867816023528576, - 2.5680795349180698, 2.5499039981514215, 2.5322073306888342, 2.5149484202265739, - 2.4980915319174528, 2.4816053118556738, 2.4654621351510286, 2.4496374558657408, - 2.4341094270348549, 2.4188583977520466, 2.4038666747510433, 2.3891182579100132, - 2.3745986316353083, 2.3602945171296597, 2.3461938071995974, 2.3322853688150644, - 2.3185589388012886, 2.3050050996243954, 2.2916150633245707, 2.2783807571977377, - 2.2652945797890425, 2.2523495275527239, 2.2395390216261148, 2.2268569152802229, - 2.2142974212765694, 2.2018551602959633, 2.1895249988883734, 2.1773021686822176, - 2.1651821155101061, 2.1531605403870344, 2.1412334199994802, 2.1293968763202429, - 2.1176472660154104, 2.1059811022132635, 2.0943950917571783, 2.0828860662877560, - 2.0714510250836611, 2.0600870978087187, 2.0487915109843016, 2.0375616606324911, - 2.0263949912041426, 2.0152891036123037, 2.0042416434735060, 1.9932503849267960, - 1.9823131654411554, 1.9714278969913721, 1.9605926070362329, 1.9498053360730410, - 1.9390642102807760, 1.9283674117177725, 1.9177132192999125, 1.9070998858660460, - 1.8965258020907640, 1.8859893511980772, 1.8754889536648989, 1.8650231678038836, - 1.8545904289931059, 1.8441893383860588, 1.8338185232132673, 1.8234765660017729, - 1.8131621610373259, 1.8028740044683218, 1.7926107998937368, 1.7823712695389986, - 1.7721542436629534, 1.7619584631174803, 1.7517827805131674, 1.7416259888559580, - 1.7314869631081820, 1.7213646043092012, 1.7112577408552170, 1.7011653054505587, - 1.6910861935466528, 1.6810193713754416, 1.6709637474268675, 1.6609182581305504, - 1.6508819069713354, 1.6408536080271006, 1.6308323871344328, 1.6208171751350164, - 1.6108069960027933, 1.6008008290082216, 1.5907976571470499, 1.5807964820414782, - 1.5707963258028030, 1.5607961714267731, 1.5507949963212013, 1.5407918244600296, - 1.5307856574654579, 1.5207754783332348, 1.5107602663338184, 1.5007390454411507, - 1.4907107464969158, 1.4806743953377008, 1.4706289060413837, 1.4605732820928097, - 1.4505064599215984, 1.4404273480176926, 1.4303349126130342, 1.4202280491590500, - 1.4101056903600693, 1.3999666646122932, 1.3898098729550838, 1.3796341903507710, - 1.3694384098052979, 1.3592213839292526, 1.3489818535745144, 1.3387186489999294, - 1.3284304924309254, 1.3181160874664783, 1.3077741302549839, 1.2974033150821924, - 1.2870022244751453, 1.2765694856643677, 1.2661036998033524, 1.2556033022701740, - 1.2450668513774872, 1.2344927676022053, 1.2238794341683388, 1.2132252417504787, - 1.2025284431874752, 1.1917872473952103, 1.1810000464320183, 1.1701647564768791, - 1.1592794880270958, 1.1483422685414553, 1.1373510099947453, 1.1263035498559475, - 1.1151976622641087, 1.1040309928357601, 1.0928011424839497, 1.0815055556595325, - 1.0701416283845901, 1.0587065871804953, 1.0471975617110729, 1.0356115512549877, - 1.0239453874528408, 1.0121957771480083, 1.0003592334687710, 0.9884321130812168, - 0.9764105379581451, 0.9642904847860336, 0.9520676545798779, 0.9397374931722879, - 0.9272952321916819, 0.9147357381880283, 0.9020536318421364, 0.8892431259155273, - 0.8762980736792088, 0.8632118962705135, 0.8499775901436806, 0.8365875538438559, - 0.8230337146669626, 0.8093072846531868, 0.7953988462686539, 0.7812981363385916, - 0.7669940218329430, 0.7524743955582380, 0.7377259787172079, 0.7227342557162046, - 0.7074832264333963, 0.6919551976025105, 0.6761305183172226, 0.6599873416125774, - 0.6435011215507984, 0.6266442332416773, 0.6093853227794170, 0.5916886553168297, - 0.5735131185501814, 0.5548110511153936, 0.5355266667902470, 0.5155940335243940, - 0.4949341546744108, 0.4734511896967888, 0.4510268233716488, 0.4275122880935669, - 0.4027158617973328, 0.3763835001736879, 0.3481660466641188, 0.3175604660063982, - 0.2837941460311413, 0.2455655615776777, 0.2003348786383867, 0.1415395531803370, - 0.0000000000000000 -}; - -/* Reference degree table generated for acos(),asin() in range of [-1:1e-2:1]*/ -static const double degree_table[] = { - -57.2957795262336731, -56.7228217124938965, -56.1498639285564423, -55.5769061148166656, - -55.0039483308792114, -54.4309905469417572, -53.8580327332019806, -53.2850749492645264, - -52.7121171653270721, -52.1391593515872955, -51.5662015676498413, -50.9932437539100647, - -50.4202859699726105, -49.8473281860351562, -49.2743703722953796, -48.7014125883579254, - -48.1284548044204712, -47.5554969906806946, -46.9825392067432404, -46.4095813930034637, - -45.8366236090660095, -45.2636658251285553, -44.6907080113887787, -44.1177502274513245, - -43.5447924435138702, -42.9718346297740936, -42.3988768458366394, -41.8259190320968628, - -41.2529612481594086, -40.6800034642219543, -40.1070456504821777, -39.5340878665447235, - -38.9611300826072693, -38.3881722688674927, -37.8152144849300385, -37.2422566711902618, - -36.6692988872528076, -36.0963411033153534, -35.5233832895755768, -34.9504255056381226, - -34.3774677217006683, -33.8045099079608917, -33.2315521240234375, -32.6585943102836609, - -32.0856365263462067, -31.5126787424087524, -30.9397209286689758, -30.3667631447315216, - -29.7938053607940674, -29.2208475470542908, -28.6478897631168365, -28.0749319493770599, - -27.5019741654396057, -26.9290163815021515, -26.3560585677623749, -25.7831007838249207, - -25.2101429998874664, -24.6371851861476898, -24.0642274022102356, -23.4912695884704590, - -22.9183118045330048, -22.3453540205955505, -21.7723962068557739, -21.1994384229183197, - -20.6264806389808655, -20.0535228252410889, -19.4805650413036346, -18.9076072275638580, - -18.3346494436264038, -17.7616916596889496, -17.1887338459491730, -16.6157760620117188, - -16.0428182780742645, -15.4698604643344879, -14.8969026803970337, -14.3239448666572571, - -13.7509870827198029, -13.1780292987823486, -12.6050714850425720, -12.0321137011051178, - -11.4591559171676636, -10.8861981034278870, -10.3132403194904327, -9.7402825057506561, - -9.1673247218132019, -8.5943669378757477, -8.0214091241359711, -7.4484513401985168, - -6.8754935562610626, -6.3025357425212860, -5.7295779585838318, -5.1566201448440552, - -4.5836623609066010, -4.0107045769691467, -3.4377467632293701, -2.8647889792919159, - -2.2918311953544617, -1.7188733816146851, -1.1459155976772308, -0.5729577839374542, - 0.0000000000000000, 0.5729577839374542, 1.1459155976772308, 1.7188733816146851, - 2.2918311953544617, 2.8647889792919159, 3.4377467632293701, 4.0107045769691467, - 4.5836623609066010, 5.1566201448440552, 5.7295779585838318, 6.3025357425212860, - 6.8754935562610626, 7.4484513401985168, 8.0214091241359711, 8.5943669378757477, - 9.1673247218132019, 9.7402825057506561, 10.3132403194904327, 10.8861981034278870, - 11.4591559171676636, 12.0321137011051178, 12.6050714850425720, 13.1780292987823486, - 13.7509870827198029, 14.3239448666572571, 14.8969026803970337, 15.4698604643344879, - 16.0428182780742645, 16.6157760620117188, 17.1887338459491730, 17.7616916596889496, - 18.3346494436264038, 18.9076072275638580, 19.4805650413036346, 20.0535228252410889, - 20.6264806389808655, 21.1994384229183197, 21.7723962068557739, 22.3453540205955505, - 22.9183118045330048, 23.4912695884704590, 24.0642274022102356, 24.6371851861476898, - 25.2101429998874664, 25.7831007838249207, 26.3560585677623749, 26.9290163815021515, - 27.5019741654396057, 28.0749319493770599, 28.6478897631168365, 29.2208475470542908, - 29.7938053607940674, 30.3667631447315216, 30.9397209286689758, 31.5126787424087524, - 32.0856365263462067, 32.6585943102836609, 33.2315521240234375, 33.8045099079608917, - 34.3774677217006683, 34.9504255056381226, 35.5233832895755768, 36.0963411033153534, - 36.6692988872528076, 37.2422566711902618, 37.8152144849300385, 38.3881722688674927, - 38.9611300826072693, 39.5340878665447235, 40.1070456504821777, 40.6800034642219543, - 41.2529612481594086, 41.8259190320968628, 42.3988768458366394, 42.9718346297740936, - 43.5447924435138702, 44.1177502274513245, 44.6907080113887787, 45.2636658251285553, - 45.8366236090660095, 46.4095813930034637, 46.9825392067432404, 47.5554969906806946, - 48.1284548044204712, 48.7014125883579254, 49.2743703722953796, 49.8473281860351562, - 50.4202859699726105, 50.9932437539100647, 51.5662015676498413, 52.1391593515872955, - 52.7121171653270721, 53.2850749492645264, 53.8580327332019806, 54.4309905469417572, - 55.0039483308792114, 55.5769061148166656, 56.1498639285564423, 56.7228217124938965, - 57.2957795262336731 -}; diff --git a/test/cmocka/src/math/CMakeLists.txt b/test/cmocka/src/math/CMakeLists.txt index 07e5c495a382..83180953eb55 100644 --- a/test/cmocka/src/math/CMakeLists.txt +++ b/test/cmocka/src/math/CMakeLists.txt @@ -1,7 +1,5 @@ # SPDX-License-Identifier: BSD-3-Clause -add_subdirectory(numbers) -add_subdirectory(trig) add_subdirectory(arithmetic) add_subdirectory(fft) add_subdirectory(window) diff --git a/test/cmocka/src/math/numbers/CMakeLists.txt b/test/cmocka/src/math/numbers/CMakeLists.txt deleted file mode 100644 index 7a8c71670daf..000000000000 --- a/test/cmocka/src/math/numbers/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -# SPDX-License-Identifier: BSD-3-Clause - -cmocka_test(gcd - gcd.c - ${PROJECT_SOURCE_DIR}/src/math/numbers.c -) - -cmocka_test(ceil_divide - ceil_divide.c - ${PROJECT_SOURCE_DIR}/src/math/numbers.c -) -target_link_libraries(ceil_divide PRIVATE -lm) - -cmocka_test(find_equal_int16 - find_equal_int16.c - ${PROJECT_SOURCE_DIR}/src/math/numbers.c -) - -cmocka_test(find_min_int16 - find_min_int16.c - ${PROJECT_SOURCE_DIR}/src/math/numbers.c -) - -cmocka_test(find_max_abs_int32 - find_max_abs_int32.c - ${PROJECT_SOURCE_DIR}/src/math/numbers.c -) - -cmocka_test(norm_int32 - norm_int32.c - ${PROJECT_SOURCE_DIR}/src/math/numbers.c -) diff --git a/test/cmocka/src/math/numbers/ceil_divide.c b/test/cmocka/src/math/numbers/ceil_divide.c deleted file mode 100644 index 578df9b281b3..000000000000 --- a/test/cmocka/src/math/numbers/ceil_divide.c +++ /dev/null @@ -1,59 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// -// Copyright(c) 2018 Intel Corporation. All rights reserved. -// -// Author: Slawomir Blauciak - -#include - -#include -#include -#include -#include -#include -#include -#include - -static void test_math_numbers_ceil_divide(void **state) -{ - (void)state; - - int params[8] = { - -1000, - 300, - 123, - -10, - 1337, - -6, - 999, - -2 - }; - - int i, j; - - for (i = 0; i < 8; ++i) { - for (j = 0; j < 8; ++j) { - int ref = ceilf((float)params[i] / (float)params[j]); - int r = ceil_divide(params[i], params[j]); - - if (r != ref) { - printf("%s: %d / %d = %d (ref: %d)\n", __func__, - params[i], params[j], r, ref); - } - - assert_int_equal(r, ref); - } - } - -} - -int main(void) -{ - const struct CMUnitTest tests[] = { - cmocka_unit_test(test_math_numbers_ceil_divide) - }; - - cmocka_set_message_output(CM_OUTPUT_TAP); - - return cmocka_run_group_tests(tests, NULL, NULL); -} diff --git a/test/cmocka/src/math/numbers/find_equal_int16.c b/test/cmocka/src/math/numbers/find_equal_int16.c deleted file mode 100644 index fc202f50f75b..000000000000 --- a/test/cmocka/src/math/numbers/find_equal_int16.c +++ /dev/null @@ -1,55 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// -// Copyright(c) 2018 Intel Corporation. All rights reserved. -// -// Author: Slawomir Blauciak - -#include - -#include -#include -#include -#include -#include - -static void test_math_numbers_find_equal_int16_for_5_123_5_10_123_500_123_n_123_equals_1_4_and_6 - (void **state) -{ - (void)state; - - int16_t r[4]; - int16_t vec[] = {5, 123, 5, 10, 123, 500, 123}; - int16_t template[] = {1, 4, 6}; - - int r_num = find_equal_int16(r, vec, 123, 7, 4); - - assert_int_equal(r_num, 3); - assert_memory_equal(r, template, sizeof(int16_t) * 3); -} - -static void test_math_numbers_find_equal_int16_for_1_2_3_4_5_n_0_equals_nothing - (void **state) -{ - (void)state; - - int16_t r[4]; - int16_t vec[] = {1, 2, 3, 4, 5}; - - int r_num = find_equal_int16(r, vec, 0, 5, 4); - - assert_int_equal(r_num, 0); -} - -int main(void) -{ - const struct CMUnitTest tests[] = { - cmocka_unit_test - (test_math_numbers_find_equal_int16_for_5_123_5_10_123_500_123_n_123_equals_1_4_and_6), - cmocka_unit_test - (test_math_numbers_find_equal_int16_for_1_2_3_4_5_n_0_equals_nothing) - }; - - cmocka_set_message_output(CM_OUTPUT_TAP); - - return cmocka_run_group_tests(tests, NULL, NULL); -} diff --git a/test/cmocka/src/math/numbers/find_max_abs_int32.c b/test/cmocka/src/math/numbers/find_max_abs_int32.c deleted file mode 100644 index aa669887dcab..000000000000 --- a/test/cmocka/src/math/numbers/find_max_abs_int32.c +++ /dev/null @@ -1,50 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// -// Copyright(c) 2018 Intel Corporation. All rights reserved. -// -// Author: Slawomir Blauciak - -#include -#include - -#include -#include -#include -#include -#include - -static void test_math_numbers_find_max_abs_int32_for_neg100_99_98_50_equals_100 - (void **state) -{ - (void)state; - - int32_t vec[] = {-100, 99, 98, 50}; - int r = find_max_abs_int32(vec, ARRAY_SIZE(vec)); - - assert_int_equal(r, 100); -} - -static void test_math_numbers_find_max_abs_int32_for_neg100_99_98_50_101_equals_101 - (void **state) -{ - (void)state; - - int32_t vec[] = {-100, 99, 98, 50, 101}; - int r = find_max_abs_int32(vec, ARRAY_SIZE(vec)); - - assert_int_equal(r, 101); -} - -int main(void) -{ - const struct CMUnitTest tests[] = { - cmocka_unit_test - (test_math_numbers_find_max_abs_int32_for_neg100_99_98_50_equals_100), - cmocka_unit_test - (test_math_numbers_find_max_abs_int32_for_neg100_99_98_50_101_equals_101) - }; - - cmocka_set_message_output(CM_OUTPUT_TAP); - - return cmocka_run_group_tests(tests, NULL, NULL); -} diff --git a/test/cmocka/src/math/numbers/find_min_int16.c b/test/cmocka/src/math/numbers/find_min_int16.c deleted file mode 100644 index 919898fe5710..000000000000 --- a/test/cmocka/src/math/numbers/find_min_int16.c +++ /dev/null @@ -1,49 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// -// Copyright(c) 2018 Intel Corporation. All rights reserved. -// -// Author: Slawomir Blauciak - -#include -#include - -#include -#include -#include -#include -#include - -static void test_math_numbers_find_min_int16_for_2_equals_2(void **state) -{ - (void)state; - - int16_t vec[] = {2}; - int r = find_min_int16(vec, ARRAY_SIZE(vec)); - - assert_int_equal(r, 2); -} - -static void test_math_numbers_find_min_int16_for_5_2_3_4_1_equals_1 - (void **state) -{ - (void)state; - - int16_t vec[] = {5, 2, 3, 4, 1}; - int r = find_min_int16(vec, ARRAY_SIZE(vec)); - - assert_int_equal(r, 1); -} - -int main(void) -{ - const struct CMUnitTest tests[] = { - cmocka_unit_test - (test_math_numbers_find_min_int16_for_2_equals_2), - cmocka_unit_test - (test_math_numbers_find_min_int16_for_5_2_3_4_1_equals_1) - }; - - cmocka_set_message_output(CM_OUTPUT_TAP); - - return cmocka_run_group_tests(tests, NULL, NULL); -} diff --git a/test/cmocka/src/math/numbers/gcd.c b/test/cmocka/src/math/numbers/gcd.c deleted file mode 100644 index 23f2dad2191a..000000000000 --- a/test/cmocka/src/math/numbers/gcd.c +++ /dev/null @@ -1,116 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// -// Copyright(c) 2018 Intel Corporation. All rights reserved. -// -// Author: Marcin Maka -// Janusz Jankowski - -#include - -#include -#include -#include -#include -#include - -static void test_math_numbers_gcd_for_5083_and_391_equals_391(void **state) -{ - int r; - - (void)state; - - r = gcd(5083, 391); - assert_int_equal(r, 391); -} - -static void test_math_numbers_gcd_for_12_and_9_equals_3(void **state) -{ - int r; - - (void)state; - - r = gcd(12, 9); - assert_int_equal(r, 3); -} - -static void test_math_numbers_gcd_for_5_and_0_equals_5(void **state) -{ - int r; - - (void)state; - - r = gcd(5, 0); - assert_int_equal(r, 5); -} - -static void test_math_numbers_gcd_for_0_and_5_equals_5(void **state) -{ - int r; - - (void)state; - - r = gcd(0, 5); - assert_int_equal(r, 5); -} - -static void test_math_numbers_gcd_for_0_and_0_equals_0(void **state) -{ - int r; - - (void)state; - - r = gcd(0, 0); - assert_int_equal(r, 0); -} - -static void test_math_numbers_gcd_for_neg_4_and_14_equals_2(void **state) -{ - int r; - - (void)state; - - r = gcd(-4, 14); - assert_int_equal(r, 2); -} - -static void test_math_numbers_gcd_for_4_and_neg_14_equals_2(void **state) -{ - int r; - - (void)state; - - r = gcd(4, -14); - assert_int_equal(r, 2); -} - -static void test_math_numbers_gcd_for_neg_4_and_neg_14_equals_2(void **state) -{ - int r; - - (void)state; - - r = gcd(-4, -14); - assert_int_equal(r, 2); -} - -int main(void) -{ - const struct CMUnitTest tests[] = { - cmocka_unit_test - (test_math_numbers_gcd_for_5083_and_391_equals_391), - cmocka_unit_test(test_math_numbers_gcd_for_12_and_9_equals_3), - cmocka_unit_test(test_math_numbers_gcd_for_5_and_0_equals_5), - cmocka_unit_test(test_math_numbers_gcd_for_0_and_5_equals_5), - cmocka_unit_test(test_math_numbers_gcd_for_0_and_0_equals_0), - cmocka_unit_test - (test_math_numbers_gcd_for_neg_4_and_14_equals_2), - cmocka_unit_test - (test_math_numbers_gcd_for_4_and_neg_14_equals_2), - cmocka_unit_test - (test_math_numbers_gcd_for_neg_4_and_neg_14_equals_2) - }; - - cmocka_set_message_output(CM_OUTPUT_TAP); - - return cmocka_run_group_tests(tests, NULL, NULL); -} diff --git a/test/cmocka/src/math/numbers/norm_int32.c b/test/cmocka/src/math/numbers/norm_int32.c deleted file mode 100644 index 7397d2359c7a..000000000000 --- a/test/cmocka/src/math/numbers/norm_int32.c +++ /dev/null @@ -1,55 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// -// Copyright(c) 2018 Intel Corporation. All rights reserved. -// -// Author: Slawomir Blauciak - -#include - -#include -#include -#include -#include -#include - -static void test_math_numbers_norm_int32_for_0_equals_31(void **state) -{ - (void)state; - - int r = norm_int32(0); - - assert_int_equal(r, 31); -} - -static void test_math_numbers_norm_int32_for_35_equals_10(void **state) -{ - (void)state; - - int r = norm_int32(35); - - assert_int_equal(r, 25); -} - -static void test_math_numbers_norm_int32_for_2147483647_equals_0(void **state) -{ - (void)state; - - int r = norm_int32(2147483647); - - assert_int_equal(r, 0); -} - -int main(void) -{ - const struct CMUnitTest tests[] = { - cmocka_unit_test(test_math_numbers_norm_int32_for_0_equals_31), - cmocka_unit_test - (test_math_numbers_norm_int32_for_35_equals_10), - cmocka_unit_test - (test_math_numbers_norm_int32_for_2147483647_equals_0) - }; - - cmocka_set_message_output(CM_OUTPUT_TAP); - - return cmocka_run_group_tests(tests, NULL, NULL); -} diff --git a/test/cmocka/src/math/trig/CMakeLists.txt b/test/cmocka/src/math/trig/CMakeLists.txt deleted file mode 100644 index 2d39eecd27b0..000000000000 --- a/test/cmocka/src/math/trig/CMakeLists.txt +++ /dev/null @@ -1,46 +0,0 @@ -# SPDX-License-Identifier: BSD-3-Clause - -cmocka_test(sin_32b_fixed - sin_32b_fixed.c - ${PROJECT_SOURCE_DIR}/src/math/trig.c -) - -cmocka_test(cos_32b_fixed - cos_32b_fixed.c - ${PROJECT_SOURCE_DIR}/src/math/trig.c -) - -cmocka_test(sin_16b_fixed - sin_16b_fixed.c - ${PROJECT_SOURCE_DIR}/src/math/trig.c -) - -cmocka_test(cos_16b_fixed - cos_16b_fixed.c - ${PROJECT_SOURCE_DIR}/src/math/trig.c -) - -cmocka_test(asin_32b_fixed - asin_32b_fixed.c - ${PROJECT_SOURCE_DIR}/src/math/trig.c -) - -cmocka_test(acos_32b_fixed - acos_32b_fixed.c - ${PROJECT_SOURCE_DIR}/src/math/trig.c -) - -cmocka_test(asin_16b_fixed - asin_16b_fixed.c - ${PROJECT_SOURCE_DIR}/src/math/trig.c -) - -cmocka_test(acos_16b_fixed - acos_16b_fixed.c - ${PROJECT_SOURCE_DIR}/src/math/trig.c -) - -cmocka_test(lut_sin_16b_fixed - lut_sin_16b_fixed.c - ${PROJECT_SOURCE_DIR}/src/math/lut_trig.c -) diff --git a/test/cmocka/src/math/trig/acos_16b_fixed.c b/test/cmocka/src/math/trig/acos_16b_fixed.c deleted file mode 100644 index b0454b104dd9..000000000000 --- a/test/cmocka/src/math/trig/acos_16b_fixed.c +++ /dev/null @@ -1,62 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// -// Copyright(c) 2021 Intel Corporation. All rights reserved. -// -// Author: Shriram Shastry -// - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include "trig_tables.h" -/* ' Error (max = 0.000059799232976), THD+N = -89.824298401466635 (dBc)' */ -#define CMP_TOLERANCE 0.0001196862 -#define _M_PI 3.14159265358979323846 /* pi */ - -static void test_math_trig_acos_16b_fixed(void **state) -{ - (void)state; - double u; - double v; - int indx; - int b_i; - - for (indx = 0; indx < ARRAY_SIZE(degree_table); ++indx) { - /* convert angle unit degrees to radians */ - /* angleInRadians = pi/180 * angleInDegrees & const Q2.30 format */ - u = (0.017453292519943295 * (double)degree_table[indx] * 0x40000000); - v = fabs(u); - /* GitHub macro Q_CONVERT_FLOAT is inaccurate, so replaced with below */ - u = (v >= 0.5) ? floor(u + 0.5) : 0.0; - b_i = (int)u; - - float r = Q_CONVERT_QTOF(acos_fixed_16b(b_i), 13); - float diff = fabsf(acos_ref_table[indx] - r); - - if (diff > CMP_TOLERANCE) { - printf("%s: diff for %.16f deg = %.10f\n", __func__, - ((180 / _M_PI) * b_i) / (1 << 30), diff); - } - - assert_true(diff <= CMP_TOLERANCE); - } -} - -int main(void) -{ - const struct CMUnitTest tests[] = { - cmocka_unit_test(test_math_trig_acos_16b_fixed) - }; - - cmocka_set_message_output(CM_OUTPUT_TAP); - - return cmocka_run_group_tests(tests, NULL, NULL); -} diff --git a/test/cmocka/src/math/trig/acos_32b_fixed.c b/test/cmocka/src/math/trig/acos_32b_fixed.c deleted file mode 100644 index 01c7a754ba75..000000000000 --- a/test/cmocka/src/math/trig/acos_32b_fixed.c +++ /dev/null @@ -1,62 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// -// Copyright(c) 2021 Intel Corporation. All rights reserved. -// -// Author: Shriram Shastry -// - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include "trig_tables.h" -/* 'Error (max = 0.000000026077032), THD+N = -157.948952635422842 (dBc)' */ -#define CMP_TOLERANCE 0.000000060077032 -#define _M_PI 3.14159265358979323846 /* pi */ - -static void test_math_trig_acos_32b_fixed(void **state) -{ - (void)state; - double u; - double v; - int indx; - int b_i; - - for (indx = 0; indx < ARRAY_SIZE(degree_table); ++indx) { - /* convert angle unit degrees to radians */ - /* angleInRadians = pi/180 * angleInDegrees & const Q2.30 format */ - u = (0.017453292519943295 * (double)degree_table[indx] * 0x40000000); - v = fabs(u); - /* GitHub macro Q_CONVERT_FLOAT is inaccurate, so replaced with below */ - u = (v >= 0.5) ? floor(u + 0.5) : 0.0; - b_i = (int)u; - - float r = Q_CONVERT_QTOF(acos_fixed_32b(b_i), 29); - float diff = fabsf(acos_ref_table[indx] - r); - - if (diff > CMP_TOLERANCE) { - printf("%s: diff for %.16f deg = %.10f\n", __func__, - ((180 / _M_PI) * b_i) / (1 << 30), diff); - } - - assert_true(diff <= CMP_TOLERANCE); - } -} - -int main(void) -{ - const struct CMUnitTest tests[] = { - cmocka_unit_test(test_math_trig_acos_32b_fixed) - }; - - cmocka_set_message_output(CM_OUTPUT_TAP); - - return cmocka_run_group_tests(tests, NULL, NULL); -} diff --git a/test/cmocka/src/math/trig/asin_16b_fixed.c b/test/cmocka/src/math/trig/asin_16b_fixed.c deleted file mode 100644 index 8361c8aa5858..000000000000 --- a/test/cmocka/src/math/trig/asin_16b_fixed.c +++ /dev/null @@ -1,62 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// -// Copyright(c) 2018 Intel Corporation. All rights reserved. -// -// Author: Shriram Shastry - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include "trig_tables.h" -/* 'Error (max = 0.000059799232976), THD+N = -89.824298401466635 (dBc) */ -#define CMP_TOLERANCE 0.0001152158 -#define _M_PI 3.14159265358979323846 /* pi */ - -static void test_math_trig_asin_16b_fixed(void **state) -{ - (void)state; - - double u; - double v; - int indx; - int b_i; - - for (indx = 0; indx < ARRAY_SIZE(degree_table); ++indx) { - /* convert angle unit degrees to radians */ - /* angleInRadians = pi/180 * angleInDegrees & const Q2.30 format */ - u = (0.017453292519943295 * (double)degree_table[indx] * 0x40000000); - v = fabs(u); - /* GitHub macro Q_CONVERT_FLOAT is inaccurate, so replaced with below */ - u = (v >= 0.5) ? floor(u + 0.5) : 0.0; - b_i = (int)u; - - float r = Q_CONVERT_QTOF(asin_fixed_16b(b_i), 13); - float diff = fabsf(asin_ref_table[indx] - r); - - if (diff > CMP_TOLERANCE) { - printf("%s: diff for %.16f deg = %.10f\n", __func__, - ((180 / _M_PI) * b_i) / (1 << 30), diff); - } - - assert_true(diff <= CMP_TOLERANCE); - } -} - -int main(void) -{ - const struct CMUnitTest tests[] = { - cmocka_unit_test(test_math_trig_asin_16b_fixed) - }; - - cmocka_set_message_output(CM_OUTPUT_TAP); - - return cmocka_run_group_tests(tests, NULL, NULL); -} diff --git a/test/cmocka/src/math/trig/asin_32b_fixed.c b/test/cmocka/src/math/trig/asin_32b_fixed.c deleted file mode 100644 index f830711a9761..000000000000 --- a/test/cmocka/src/math/trig/asin_32b_fixed.c +++ /dev/null @@ -1,62 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// -// Copyright(c) 2018 Intel Corporation. All rights reserved. -// -// Author: Shriram Shastry - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include "trig_tables.h" -/* 'Error (max = 0.000000027939677), THD+N = -157.454534077921551 (dBc)' */ -#define CMP_TOLERANCE 0.000000068141916 -#define _M_PI 3.14159265358979323846 /* pi */ - -static void test_math_trig_asin_32b_fixed(void **state) -{ - (void)state; - - double u; - double v; - int indx; - int b_i; - - for (indx = 0; indx < ARRAY_SIZE(degree_table); ++indx) { - /* convert angle unit degrees to radians */ - /* angleInRadians = pi/180 * angleInDegrees & const Q2.30 format */ - u = (0.017453292519943295 * (double)degree_table[indx] * 0x40000000); - v = fabs(u); - /* GitHub macro Q_CONVERT_FLOAT is inaccurate, so replaced with below */ - u = (v >= 0.5) ? floor(u + 0.5) : 0.0; - b_i = (int)u; - - float r = Q_CONVERT_QTOF(asin_fixed_32b(b_i), 29); - float diff = fabsf(asin_ref_table[indx] - r); - - if (diff > CMP_TOLERANCE) { - printf("%s: diff for %.16f deg = %.10f\n", __func__, - ((180 / _M_PI) * b_i) / (1 << 30), diff); - } - - assert_true(diff <= CMP_TOLERANCE); - } -} - -int main(void) -{ - const struct CMUnitTest tests[] = { - cmocka_unit_test(test_math_trig_asin_32b_fixed) - }; - - cmocka_set_message_output(CM_OUTPUT_TAP); - - return cmocka_run_group_tests(tests, NULL, NULL); -} diff --git a/test/cmocka/src/math/trig/cos_16b_fixed.c b/test/cmocka/src/math/trig/cos_16b_fixed.c deleted file mode 100644 index 2049a03c23f8..000000000000 --- a/test/cmocka/src/math/trig/cos_16b_fixed.c +++ /dev/null @@ -1,53 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// -// Copyright(c) 2021 Intel Corporation. All rights reserved. -// -// Author: Shriram Shastry -// - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include "trig_tables.h" -/* 'Error (max = 0.000061), THD+N = -91.518584' */ -#define CMP_TOLERANCE 0.000065 -#define _M_PI 3.14159265358979323846 /* pi */ - -static void test_math_trig_cos_fixed(void **state) -{ - (void)state; - int theta; - - for (theta = 0; theta < 360; ++theta) { - double rad = _M_PI * (theta / 180.0); - int32_t rad_q28 = Q_CONVERT_FLOAT(rad, 28); - - float r = Q_CONVERT_QTOF(cos_fixed_16b(rad_q28), 15); - float diff = fabsf(cos_ref_table[theta] - r); - - if (diff > CMP_TOLERANCE) { - printf("%s: diff for %d deg = %.10f\n", __func__, - theta, diff); - } - - assert_true(diff <= CMP_TOLERANCE); - } -} - -int main(void) -{ - const struct CMUnitTest tests[] = { - cmocka_unit_test(test_math_trig_cos_fixed) - }; - - cmocka_set_message_output(CM_OUTPUT_TAP); - - return cmocka_run_group_tests(tests, NULL, NULL); -} diff --git a/test/cmocka/src/math/trig/cos_32b_fixed.c b/test/cmocka/src/math/trig/cos_32b_fixed.c deleted file mode 100644 index d9c2282852dd..000000000000 --- a/test/cmocka/src/math/trig/cos_32b_fixed.c +++ /dev/null @@ -1,53 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// -// Copyright(c) 2021 Intel Corporation. All rights reserved. -// -// Author: Shriram Shastry -// - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include "trig_tables.h" -/* 'Error (max = 0.000000011175871), THD+N = -170.674358910916226' */ -#define CMP_TOLERANCE 0.0000000611175871 -#define _M_PI 3.14159265358979323846 /* pi */ - -static void test_math_trig_cos_fixed(void **state) -{ - (void)state; - int theta; - - for (theta = 0; theta < 360; ++theta) { - double rad = _M_PI * (theta / 180.0); - int32_t rad_q28 = Q_CONVERT_FLOAT(rad, 28); - - float r = Q_CONVERT_QTOF(cos_fixed_32b(rad_q28), 31); - float diff = fabsf(cos_ref_table[theta] - r); - - if (diff > CMP_TOLERANCE) { - printf("%s: diff for %d deg = %.10f\n", __func__, - theta, diff); - } - - assert_true(diff <= CMP_TOLERANCE); - } -} - -int main(void) -{ - const struct CMUnitTest tests[] = { - cmocka_unit_test(test_math_trig_cos_fixed) - }; - - cmocka_set_message_output(CM_OUTPUT_TAP); - - return cmocka_run_group_tests(tests, NULL, NULL); -} diff --git a/test/cmocka/src/math/trig/lut_sin_16b_fixed.c b/test/cmocka/src/math/trig/lut_sin_16b_fixed.c deleted file mode 100644 index b95390022903..000000000000 --- a/test/cmocka/src/math/trig/lut_sin_16b_fixed.c +++ /dev/null @@ -1,54 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// -// Copyright(c) 2024 Intel Corporation. All rights reserved. -// -// Author: Slawomir Blauciak -// Author: Seppo Ingalsuo - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "trig_tables.h" - -#define CMP_TOLERANCE 3.1e-5 -#define _M_PI 3.14159265358979323846 /* pi */ - -static void test_math_trig_lut_sin_fixed(void **state) -{ - (void)state; - - int theta; - - for (theta = 0; theta < 360; ++theta) { - double rad = _M_PI / 180.0 * theta; - int32_t rad_q28 = Q_CONVERT_FLOAT(rad, 28); - float r = Q_CONVERT_QTOF(sofm_lut_sin_fixed_16b(rad_q28), 15); - float diff = fabsf(sin_ref_table[theta] - r); - - if (diff > CMP_TOLERANCE) { - printf("%s: diff for %d deg = %g\n", __func__, - theta, diff); - } - - assert_true(diff <= CMP_TOLERANCE); - } -} - -int main(void) -{ - const struct CMUnitTest tests[] = { - cmocka_unit_test(test_math_trig_lut_sin_fixed) - }; - - cmocka_set_message_output(CM_OUTPUT_TAP); - - return cmocka_run_group_tests(tests, NULL, NULL); -} diff --git a/test/cmocka/src/math/trig/sin_16b_fixed.c b/test/cmocka/src/math/trig/sin_16b_fixed.c deleted file mode 100644 index 47864c41d669..000000000000 --- a/test/cmocka/src/math/trig/sin_16b_fixed.c +++ /dev/null @@ -1,53 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// -// Copyright(c) 2018 Intel Corporation. All rights reserved. -// -// Author: Shriram Shastry - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include "trig_tables.h" -/* 'Error (max = 0.000061), THD+N = -91.502670' */ -#define CMP_TOLERANCE 0.000065 -#define _M_PI 3.14159265358979323846 /* pi */ - -static void test_math_trig_sin_fixed(void **state) -{ - (void)state; - - int theta; - - for (theta = 0; theta < 360; ++theta) { - double rad = _M_PI * (theta / 180.0); - int32_t rad_q28 = Q_CONVERT_FLOAT(rad, 28); - - float r = Q_CONVERT_QTOF(sin_fixed_16b(rad_q28), 15); - float diff = fabsf(sin_ref_table[theta] - r); - - if (diff > CMP_TOLERANCE) { - printf("%s: diff for %d deg = %.10f\n", __func__, - theta, diff); - } - - assert_true(diff <= CMP_TOLERANCE); - } -} - -int main(void) -{ - const struct CMUnitTest tests[] = { - cmocka_unit_test(test_math_trig_sin_fixed) - }; - - cmocka_set_message_output(CM_OUTPUT_TAP); - - return cmocka_run_group_tests(tests, NULL, NULL); -} diff --git a/test/cmocka/src/math/trig/sin_32b_fixed.c b/test/cmocka/src/math/trig/sin_32b_fixed.c deleted file mode 100644 index 6db3ffcbc862..000000000000 --- a/test/cmocka/src/math/trig/sin_32b_fixed.c +++ /dev/null @@ -1,53 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// -// Copyright(c) 2018 Intel Corporation. All rights reserved. -// -// Author: Slawomir Blauciak - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include "trig_tables.h" -/* 'Error (max = 0.000000011175871), THD+N = -170.152933168271659' */ -#define CMP_TOLERANCE 0.0000000611175871 -#define _M_PI 3.14159265358979323846 /* pi */ - -static void test_math_trig_sin_fixed(void **state) -{ - (void)state; - - int theta; - - for (theta = 0; theta < 360; ++theta) { - double rad = _M_PI * (theta / 180.0); - int32_t rad_q28 = Q_CONVERT_FLOAT(rad, 28); - - float r = Q_CONVERT_QTOF(sin_fixed_32b(rad_q28), 31); - float diff = fabsf(sin_ref_table[theta] - r); - - if (diff > CMP_TOLERANCE) { - printf("%s: diff for %d deg = %.10f\n", __func__, - theta, diff); - } - - assert_true(diff <= CMP_TOLERANCE); - } -} - -int main(void) -{ - const struct CMUnitTest tests[] = { - cmocka_unit_test(test_math_trig_sin_fixed) - }; - - cmocka_set_message_output(CM_OUTPUT_TAP); - - return cmocka_run_group_tests(tests, NULL, NULL); -} diff --git a/test/ztest/unit/math/basic/arithmetic/CMakeLists.txt b/test/ztest/unit/math/basic/arithmetic/CMakeLists.txt index 8b280a0dfb49..b71031491abf 100644 --- a/test/ztest/unit/math/basic/arithmetic/CMakeLists.txt +++ b/test/ztest/unit/math/basic/arithmetic/CMakeLists.txt @@ -26,6 +26,7 @@ target_sources(app PRIVATE test_find_min_int16_ztest.c test_find_max_abs_int32_ztest.c test_norm_int32_ztest.c + test_crc32_ztest.c ${SOF_ROOT}/src/math/numbers.c ) diff --git a/test/ztest/unit/math/basic/arithmetic/test_ceil_divide_ztest.c b/test/ztest/unit/math/basic/arithmetic/test_ceil_divide_ztest.c index 91203e376c04..e9ad0c7833a7 100644 --- a/test/ztest/unit/math/basic/arithmetic/test_ceil_divide_ztest.c +++ b/test/ztest/unit/math/basic/arithmetic/test_ceil_divide_ztest.c @@ -6,6 +6,8 @@ // generative artificial intelligence solutions. // // Converted from CMock to Ztest +// Original file: sof/test/cmocka/src/math/numbers/ceil_divide.c +// Author: Slawomir Blauciak #include #include diff --git a/test/ztest/unit/math/basic/arithmetic/test_crc32_ztest.c b/test/ztest/unit/math/basic/arithmetic/test_crc32_ztest.c new file mode 100644 index 000000000000..7485fc13dbc8 --- /dev/null +++ b/test/ztest/unit/math/basic/arithmetic/test_crc32_ztest.c @@ -0,0 +1,104 @@ +// SPDX-License-Identifier: BSD-3-Clause +// +// Copyright(c) 2026 Intel Corporation. All rights reserved. +// +// Author: Tomasz Leman + +#include +#include +#include + +/** + * @brief Test crc32 with an empty buffer + * + * With zero bytes the outer loop does not execute and the function returns + * ~(~base) == 0 for base == 0. + */ +ZTEST(math_arithmetic_suite, test_math_numbers_crc32_empty_buffer) +{ + uint8_t data[1] = {0}; + uint32_t result = crc32(0, data, 0); + + zassert_equal(result, 0x00000000U, + "crc32 of empty buffer with base=0 should be 0x00000000"); +} + +/** + * @brief Test crc32 with a single zero byte + * + * Exercises one iteration of the outer loop and all 8 iterations of the + * inner bit-processing loop. + */ +ZTEST(math_arithmetic_suite, test_math_numbers_crc32_single_zero_byte) +{ + uint8_t data[] = {0x00}; + uint32_t result = crc32(0, data, sizeof(data)); + + zassert_equal(result, 0xD202EF8DU, + "crc32({0x00}, base=0) should be 0xD202EF8D"); +} + +/** + * @brief Test crc32 with a single 0xFF byte + * + * Exercises the branch where (cur & 1) is false in the inner loop. + */ +ZTEST(math_arithmetic_suite, test_math_numbers_crc32_single_ff_byte) +{ + uint8_t data[] = {0xFF}; + uint32_t result = crc32(0, data, sizeof(data)); + + zassert_equal(result, 0xFF000000U, + "crc32({0xFF}, base=0) should be 0xFF000000"); +} + +/** + * @brief Test crc32 against the well-known CRC-32 check value + * + * The string "123456789" must produce 0xCBF43926 — the standard reference + * value for CRC-32 (ISO 3309 / ITU-T V.42). + */ +ZTEST(math_arithmetic_suite, test_math_numbers_crc32_known_vector_123456789) +{ + const uint8_t data[] = "123456789"; + uint32_t result = crc32(0, data, sizeof(data) - 1); /* exclude NUL */ + + zassert_equal(result, 0xCBF43926U, + "crc32(\"123456789\", base=0) should be 0xCBF43926"); +} + +/** + * @brief Test crc32 with a non-zero base + * + * A non-zero base changes the initial CRC register value (~base), allowing + * incremental / chained CRC computation. Verifies the result differs from the + * base=0 case and matches the expected precomputed value. + */ +ZTEST(math_arithmetic_suite, test_math_numbers_crc32_nonzero_base) +{ + uint8_t data[] = {0xAB, 0xCD, 0xEF}; + uint32_t result_base0 = crc32(0x00000000U, data, sizeof(data)); + uint32_t result_nonzero = crc32(0xDEADBEEFU, data, sizeof(data)); + + zassert_equal(result_base0, 0x648D3D79U, + "crc32({0xAB,0xCD,0xEF}, base=0) should be 0x648D3D79"); + zassert_equal(result_nonzero, 0x1412F659U, + "crc32({0xAB,0xCD,0xEF}, base=0xDEADBEEF) should be 0x1412F659"); + zassert_not_equal(result_base0, result_nonzero, + "Different bases must yield different CRC values"); +} + +/** + * @brief Test crc32 over a four-byte all-zeros buffer + * + * Exercises multiple iterations of the outer byte loop, producing a result + * that differs from the single-byte zero-byte case. + */ +ZTEST(math_arithmetic_suite, test_math_numbers_crc32_four_zero_bytes) +{ + uint8_t data[] = {0x00, 0x00, 0x00, 0x00}; + uint32_t result = crc32(0, data, sizeof(data)); + + zassert_equal(result, 0x2144DF1CU, + "crc32({0,0,0,0}, base=0) should be 0x2144DF1C"); +} diff --git a/test/ztest/unit/math/basic/arithmetic/test_find_equal_int16_ztest.c b/test/ztest/unit/math/basic/arithmetic/test_find_equal_int16_ztest.c index ce224907cdc0..268b031eb3e2 100644 --- a/test/ztest/unit/math/basic/arithmetic/test_find_equal_int16_ztest.c +++ b/test/ztest/unit/math/basic/arithmetic/test_find_equal_int16_ztest.c @@ -6,6 +6,8 @@ // generative artificial intelligence solutions. // // Converted from CMock to Ztest +// Original tests from test/cmocka/src/math/numbers/find_equal_int16.c: +// Author: Slawomir Blauciak #include #include diff --git a/test/ztest/unit/math/basic/arithmetic/test_find_max_abs_int32_ztest.c b/test/ztest/unit/math/basic/arithmetic/test_find_max_abs_int32_ztest.c index 6a6fd78468de..7b978188c9a7 100644 --- a/test/ztest/unit/math/basic/arithmetic/test_find_max_abs_int32_ztest.c +++ b/test/ztest/unit/math/basic/arithmetic/test_find_max_abs_int32_ztest.c @@ -6,6 +6,8 @@ // generative artificial intelligence solutions. // // Converted from CMock to Ztest +// Original tests from test/cmocka/src/math/numbers/find_max_abs_int32.c: +// Author: Slawomir Blauciak #include #include diff --git a/test/ztest/unit/math/basic/arithmetic/test_find_min_int16_ztest.c b/test/ztest/unit/math/basic/arithmetic/test_find_min_int16_ztest.c index cbf6c86dc88c..ac9225081a43 100644 --- a/test/ztest/unit/math/basic/arithmetic/test_find_min_int16_ztest.c +++ b/test/ztest/unit/math/basic/arithmetic/test_find_min_int16_ztest.c @@ -6,6 +6,8 @@ // generative artificial intelligence solutions. // // Converted from CMock to Ztest +// Original tests from test/cmocka/src/math/numbers/find_min_int16.c: +// Author: Slawomir Blauciak #include #include diff --git a/test/ztest/unit/math/basic/arithmetic/test_gcd_ztest.c b/test/ztest/unit/math/basic/arithmetic/test_gcd_ztest.c index 821210cac5a8..508afaecb8e1 100644 --- a/test/ztest/unit/math/basic/arithmetic/test_gcd_ztest.c +++ b/test/ztest/unit/math/basic/arithmetic/test_gcd_ztest.c @@ -6,6 +6,9 @@ // generative artificial intelligence solutions. // // Converted from CMock to Ztest +// Original tests from test/cmocka/src/math/numbers/gcd.c: +// Author: Marcin Maka +// Janusz Jankowski #include #include diff --git a/test/ztest/unit/math/basic/arithmetic/test_norm_int32_ztest.c b/test/ztest/unit/math/basic/arithmetic/test_norm_int32_ztest.c index fddb689d3471..4e3d1b830817 100644 --- a/test/ztest/unit/math/basic/arithmetic/test_norm_int32_ztest.c +++ b/test/ztest/unit/math/basic/arithmetic/test_norm_int32_ztest.c @@ -6,6 +6,8 @@ // generative artificial intelligence solutions. // // Converted from CMock to Ztest +// Original tests from test/cmocka/src/math/numbers/norm_int32.c: +// Author: Slawomir Blauciak #include #include diff --git a/test/ztest/unit/math/basic/trigonometry/trig_tables.h b/test/ztest/unit/math/basic/trigonometry/trig_tables.h index 33405231cf48..3e1f8a7eb94f 100644 --- a/test/ztest/unit/math/basic/trigonometry/trig_tables.h +++ b/test/ztest/unit/math/basic/trigonometry/trig_tables.h @@ -1,11 +1,10 @@ /* SPDX-License-Identifier: BSD-3-Clause * - * Copyright(c) 2025 Intel Corporation. All rights reserved. + * Copyright(c) 2021 Intel Corporation. All rights reserved. + * + * Author: Shriram Shastry */ -#ifndef __SOF_ZTEST_TRIG_TABLES_H__ -#define __SOF_ZTEST_TRIG_TABLES_H__ - /* Reference table generated by sin(), gcc-4.3.2 */ static const float sin_ref_table[] = { 0.0000000000, 0.0174524064, 0.0348994967, 0.0523359562, @@ -359,13 +358,3 @@ static const double degree_table[] = { 55.0039483308792114, 55.5769061148166656, 56.1498639285564423, 56.7228217124938965, 57.2957795262336731 }; - -#define CMP_TOLERANCE_32B 0.0000000611175871f -#define CMP_TOLERANCE_16B 0.000065f -#define CMP_TOLERANCE_ASIN_32B 0.000000068141916f -#define CMP_TOLERANCE_ACOS_32B 0.000000060077032f -#define CMP_TOLERANCE_ASIN_16B 0.0001152158f -#define CMP_TOLERANCE_ACOS_16B 0.0001196862f -#define CMP_TOLERANCE_SIN 3.1e-5f - -#endif /* __SOF_ZTEST_TRIG_TABLES_H__ */ diff --git a/test/ztest/unit/math/basic/trigonometry/trig_test.c b/test/ztest/unit/math/basic/trigonometry/trig_test.c index 61cb19ef6142..4c033cc5f54b 100644 --- a/test/ztest/unit/math/basic/trigonometry/trig_test.c +++ b/test/ztest/unit/math/basic/trigonometry/trig_test.c @@ -34,11 +34,19 @@ /* Define M_PI if not available */ #ifndef M_PI -#define M_PI 3.14159265358979323846 +#define M_PI 3.14159265358979323846 #endif /* Conversion factor from degrees to radians (PI/180) */ -#define DEGREES_TO_RADIANS 0.017453292519943295 +#define DEGREES_TO_RADIANS 0.017453292519943295 + +#define CMP_TOLERANCE_32B 0.0000000611175871f +#define CMP_TOLERANCE_16B 0.000065f +#define CMP_TOLERANCE_ASIN_32B 0.000000068141916f +#define CMP_TOLERANCE_ACOS_32B 0.000000060077032f +#define CMP_TOLERANCE_ASIN_16B 0.0001152158f +#define CMP_TOLERANCE_ACOS_16B 0.0001196862f +#define CMP_TOLERANCE_SIN 3.1e-5f /* * Helper function for rounding double values to nearest integer