| 1 | /*
|
|---|
| 2 | * Copyright (c) 2014 Martin Decky
|
|---|
| 3 | * Copyright (c) 2015 Jiri Svoboda
|
|---|
| 4 | * All rights reserved.
|
|---|
| 5 | *
|
|---|
| 6 | * Redistribution and use in source and binary forms, with or without
|
|---|
| 7 | * modification, are permitted provided that the following conditions
|
|---|
| 8 | * are met:
|
|---|
| 9 | *
|
|---|
| 10 | * - Redistributions of source code must retain the above copyright
|
|---|
| 11 | * notice, this list of conditions and the following disclaimer.
|
|---|
| 12 | * - Redistributions in binary form must reproduce the above copyright
|
|---|
| 13 | * notice, this list of conditions and the following disclaimer in the
|
|---|
| 14 | * documentation and/or other materials provided with the distribution.
|
|---|
| 15 | * - The name of the author may not be used to endorse or promote products
|
|---|
| 16 | * derived from this software without specific prior written permission.
|
|---|
| 17 | *
|
|---|
| 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|---|
| 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|---|
| 20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|---|
| 21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|---|
| 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|---|
| 23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|---|
| 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|---|
| 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|---|
| 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|---|
| 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|---|
| 28 | */
|
|---|
| 29 |
|
|---|
| 30 | #include <stdbool.h>
|
|---|
| 31 | #include <stdio.h>
|
|---|
| 32 | #include <stdlib.h>
|
|---|
| 33 | #include <stddef.h>
|
|---|
| 34 | #include <math.h>
|
|---|
| 35 | #include "../tester.h"
|
|---|
| 36 |
|
|---|
| 37 | #define OPERANDS 10
|
|---|
| 38 | #define PRECISIONF 10000
|
|---|
| 39 | #define PRECISION 100000000
|
|---|
| 40 |
|
|---|
| 41 | static double arguments[OPERANDS] = {
|
|---|
| 42 | 3.5, -2.1, 100.0, 50.0, -1024.0, 0.0, 768.3156, 1080.499999, -600.0, 1.0
|
|---|
| 43 | };
|
|---|
| 44 |
|
|---|
| 45 | static double arguments_acos[OPERANDS] = {
|
|---|
| 46 | -0.936456687291, -0.504846104600, 0.862318872288, 0.964966028492,
|
|---|
| 47 | 0.987353618220, 1.0, -0.194939922623, 0.978471923925, -0.999023478833,
|
|---|
| 48 | 0.540302305868
|
|---|
| 49 | };
|
|---|
| 50 |
|
|---|
| 51 | static double arguments_asin[OPERANDS] = {
|
|---|
| 52 | -0.350783227690, -0.863209366649, -0.506365641110, -0.262374853704,
|
|---|
| 53 | 0.158533380044, 0.0, 0.980815184715, -0.206379975025, -0.044182448332,
|
|---|
| 54 | 0.841470984808
|
|---|
| 55 | };
|
|---|
| 56 |
|
|---|
| 57 | static double arguments_atan[OPERANDS] = {
|
|---|
| 58 | 3.5, 100.0, 50.0, 768.3156, 1080.499999, 1.0, 66.0,
|
|---|
| 59 | 2.718281828459045, 9.9, 0.001
|
|---|
| 60 | };
|
|---|
| 61 |
|
|---|
| 62 | static double arguments_exp[OPERANDS] = {
|
|---|
| 63 | 3.5, -2.1, 50.0, 0.0, 1.0, 13.2, -1.1, -5.5, 0.1, -66.0
|
|---|
| 64 | };
|
|---|
| 65 |
|
|---|
| 66 | static double arguments_log[OPERANDS] = {
|
|---|
| 67 | 3.5, 100.0, 50.0, 768.3156, 1080.499999, 1.0, 66.0,
|
|---|
| 68 | 2.718281828459045, 9.9, 0.001
|
|---|
| 69 | };
|
|---|
| 70 |
|
|---|
| 71 | static double arguments_sqrt[OPERANDS] = {
|
|---|
| 72 | 3.5, 100.0, 50.0, 768.3156, 1080.499999, 1.0, 66.0,
|
|---|
| 73 | 2.718281828459045, 9.9, 0.001
|
|---|
| 74 | };
|
|---|
| 75 |
|
|---|
| 76 | static double arguments_tanh[OPERANDS] = {
|
|---|
| 77 | 3.5, -2.1, 50.0, 0.0, 1.0, 13.2, -1.1, -5.5, 0.000001, -66000000.0
|
|---|
| 78 | };
|
|---|
| 79 |
|
|---|
| 80 | static double results_acos[OPERANDS] = {
|
|---|
| 81 | 2.783185307180, 2.100000000000, 0.530964914873, 0.265482457437,
|
|---|
| 82 | 0.159205070272, 0.000000000000, 1.766992524091, 0.207873834887,
|
|---|
| 83 | 3.097395817941, 1.000000000000
|
|---|
| 84 | };
|
|---|
| 85 |
|
|---|
| 86 | static double results_asin[OPERANDS] = {
|
|---|
| 87 | -0.358407346411, -1.041592653590, -0.530964914874, -0.265482457437,
|
|---|
| 88 | 0.159205070273, 0.000000000000, 1.374600129498, -0.207873834889,
|
|---|
| 89 | -0.044196835651, 1.000000000000
|
|---|
| 90 | };
|
|---|
| 91 |
|
|---|
| 92 | static double results_atan[OPERANDS] = {
|
|---|
| 93 | 1.292496667790, 1.560796660108, 1.550798992822, 1.569494779052,
|
|---|
| 94 | 1.569870829603, 0.785398163397, 1.555645970920, 1.218282905017,
|
|---|
| 95 | 1.470127674637, 0.000999999667
|
|---|
| 96 | };
|
|---|
| 97 |
|
|---|
| 98 | static double results_ceil[OPERANDS] = {
|
|---|
| 99 | 4.0, -2.0, 100.0, 50.0, -1024.0, 0.0, 769.0, 1081.0, -600.0, 1.0
|
|---|
| 100 | };
|
|---|
| 101 |
|
|---|
| 102 | static double results_cos[OPERANDS] = {
|
|---|
| 103 | -0.936456687291, -0.504846104600, 0.862318872288, 0.964966028492,
|
|---|
| 104 | 0.987353618220, 1.0, -0.194939922623, 0.978471923925, -0.999023478833,
|
|---|
| 105 | 0.540302305868
|
|---|
| 106 | };
|
|---|
| 107 |
|
|---|
| 108 | static double results_cosh[OPERANDS] = {
|
|---|
| 109 | 16.572824671057, 4.144313170410, 2592352764293536022528.000000000000,
|
|---|
| 110 | 1.000000000000, 1.543080634815, 270182.468624271103, 1.668518553822,
|
|---|
| 111 | 122.348009517829, 1.005004168056, 23035933171656458903220125696.0
|
|---|
| 112 | };
|
|---|
| 113 |
|
|---|
| 114 | static double results_fabs[OPERANDS] = {
|
|---|
| 115 | 3.5, 2.1, 100.0, 50.0, 1024.0, 0.0, 768.3156, 1080.499999, 600.0, 1.0
|
|---|
| 116 | };
|
|---|
| 117 |
|
|---|
| 118 | static double results_floor[OPERANDS] = {
|
|---|
| 119 | 3.0, -3.0, 100.0, 50.0, -1024.0, 0.0, 768.0, 1080.0, -600.0, 1.0
|
|---|
| 120 | };
|
|---|
| 121 |
|
|---|
| 122 | static double results_exp[OPERANDS] = {
|
|---|
| 123 | 33.115451958692, 0.122456428253, 5184705528587072045056.0,
|
|---|
| 124 | 1.000000000000, 2.718281828459, 540364.937246691552, 0.332871083698,
|
|---|
| 125 | 0.004086771438, 1.105170918076, 0.000000000000
|
|---|
| 126 | };
|
|---|
| 127 |
|
|---|
| 128 | static double results_log[OPERANDS] = {
|
|---|
| 129 | 1.252762968495, 4.605170185988, 3.912023005428, 6.644200586236,
|
|---|
| 130 | 6.985179175021, 0.000000000000, 4.189654742026, 1.000000000000,
|
|---|
| 131 | 2.292534757141, -6.907755278982
|
|---|
| 132 | };
|
|---|
| 133 |
|
|---|
| 134 | static double results_log10[OPERANDS] = {
|
|---|
| 135 | 0.544068044350, 2.000000000000, 1.698970004336, 2.885539651261,
|
|---|
| 136 | 3.033624770817, 0.000000000000, 1.819543935542, 0.434294481903,
|
|---|
| 137 | 0.995635194598, -3.000000000000
|
|---|
| 138 | };
|
|---|
| 139 |
|
|---|
| 140 | static double results_log2[OPERANDS] = {
|
|---|
| 141 | 1.807354922058, 6.643856189775, 5.643856189775, 9.585555236434,
|
|---|
| 142 | 10.077483355524, 0.000000000000, 6.044394119358, 1.442695040889,
|
|---|
| 143 | 3.307428525192, -9.965784284662
|
|---|
| 144 | };
|
|---|
| 145 |
|
|---|
| 146 | static double results_sin[OPERANDS] = {
|
|---|
| 147 | -0.350783227690, -0.863209366649, -0.506365641110, -0.262374853704,
|
|---|
| 148 | 0.158533380044, 0.0, 0.980815184715, -0.206379975025, -0.044182448332,
|
|---|
| 149 | 0.841470984808
|
|---|
| 150 | };
|
|---|
| 151 |
|
|---|
| 152 | static double results_sinh[OPERANDS] = {
|
|---|
| 153 | 16.542627287635, -4.021856742157, 2592352764293536022528.000000000000,
|
|---|
| 154 | 0.000000000000, 1.175201193644, 270182.468622420449, -1.335647470124,
|
|---|
| 155 | -122.343922746391, 0.100166750020, -23035933171656458903220125696.0
|
|---|
| 156 | };
|
|---|
| 157 |
|
|---|
| 158 | static double results_sqrt[OPERANDS] = {
|
|---|
| 159 | 1.870828693387, 10.000000000000, 7.071067811865, 27.718506453271,
|
|---|
| 160 | 32.870959812576, 1.000000000000, 8.124038404636, 1.648721270700,
|
|---|
| 161 | 3.146426544510, 0.031622776602
|
|---|
| 162 | };
|
|---|
| 163 |
|
|---|
| 164 | static double results_tan[OPERANDS] = {
|
|---|
| 165 | 0.374585640159, 1.709846542905, -0.587213915157, -0.271900611998,
|
|---|
| 166 | 0.160563932839, 0.000000000000, -5.031371570891, -0.210920691722,
|
|---|
| 167 | 0.044225635601, 1.557407724655
|
|---|
| 168 | };
|
|---|
| 169 |
|
|---|
| 170 | static double results_tanh[OPERANDS] = {
|
|---|
| 171 | 0.998177897611, -0.970451936613, 1.000000000000, 0.000000000000,
|
|---|
| 172 | 0.761594155956, 0.999999999993, -0.800499021761, -0.999966597156,
|
|---|
| 173 | 0.000001000000, -1.000000000000
|
|---|
| 174 | };
|
|---|
| 175 |
|
|---|
| 176 | static double results_trunc[OPERANDS] = {
|
|---|
| 177 | 3.0, -2.0, 100.0, 50.0, -1024.0, 0.0, 768.0, 1080.0, -600.0, 1.0
|
|---|
| 178 | };
|
|---|
| 179 |
|
|---|
| 180 | static bool cmp_float(float a, float b)
|
|---|
| 181 | {
|
|---|
| 182 | float r;
|
|---|
| 183 |
|
|---|
| 184 | /* XXX Need fabsf() */
|
|---|
| 185 | if (b < 1.0 / PRECISIONF && b > -1.0 / PRECISIONF)
|
|---|
| 186 | r = a;
|
|---|
| 187 | else
|
|---|
| 188 | r = a / b - 1.0;
|
|---|
| 189 |
|
|---|
| 190 | /* XXX Need fabsf() */
|
|---|
| 191 | if (r < 0.0)
|
|---|
| 192 | r = -r;
|
|---|
| 193 |
|
|---|
| 194 | return r < 1.0 / PRECISIONF;
|
|---|
| 195 | }
|
|---|
| 196 |
|
|---|
| 197 | static bool cmp_double(double a, double b)
|
|---|
| 198 | {
|
|---|
| 199 | double r;
|
|---|
| 200 |
|
|---|
| 201 | /* XXX Need fabs() */
|
|---|
| 202 | if (b < 1.0 / PRECISION && b > -1.0 / PRECISION)
|
|---|
| 203 | r = a;
|
|---|
| 204 | else
|
|---|
| 205 | r = a / b - 1.0;
|
|---|
| 206 |
|
|---|
| 207 | /* XXX Need fabs() */
|
|---|
| 208 | if (r < 0.0)
|
|---|
| 209 | r = -r;
|
|---|
| 210 |
|
|---|
| 211 | return r < 1.0 / PRECISION;
|
|---|
| 212 | }
|
|---|
| 213 |
|
|---|
| 214 | const char *test_float2(void)
|
|---|
| 215 | {
|
|---|
| 216 | bool fail = false;
|
|---|
| 217 |
|
|---|
| 218 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 219 | double res = acos(arguments_acos[i]);
|
|---|
| 220 |
|
|---|
| 221 | if (!cmp_double(res, results_acos[i])) {
|
|---|
| 222 | TPRINTF("Double precision acos failed "
|
|---|
| 223 | "(%lf != %lf, arg %u)\n", res, results_acos[i], i);
|
|---|
| 224 | fail = true;
|
|---|
| 225 | }
|
|---|
| 226 | }
|
|---|
| 227 |
|
|---|
| 228 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 229 | float res = acosf(arguments_acos[i]);
|
|---|
| 230 |
|
|---|
| 231 | if (!cmp_float(res, results_acos[i])) {
|
|---|
| 232 | TPRINTF("Single precision acos failed "
|
|---|
| 233 | "(%f != %lf, arg %u)\n", res, results_acos[i], i);
|
|---|
| 234 | fail = true;
|
|---|
| 235 | }
|
|---|
| 236 | }
|
|---|
| 237 |
|
|---|
| 238 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 239 | double res = asin(arguments_asin[i]);
|
|---|
| 240 |
|
|---|
| 241 | if (!cmp_double(res, results_asin[i])) {
|
|---|
| 242 | TPRINTF("Double precision asin failed "
|
|---|
| 243 | "(%lf != %lf, arg %u)\n", res, results_asin[i], i);
|
|---|
| 244 | fail = true;
|
|---|
| 245 | }
|
|---|
| 246 | }
|
|---|
| 247 |
|
|---|
| 248 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 249 | float res = asinf(arguments_asin[i]);
|
|---|
| 250 |
|
|---|
| 251 | if (!cmp_float(res, results_asin[i])) {
|
|---|
| 252 | TPRINTF("Single precision asin failed "
|
|---|
| 253 | "(%f != %lf, arg %u)\n", res, results_asin[i], i);
|
|---|
| 254 | fail = true;
|
|---|
| 255 | }
|
|---|
| 256 | }
|
|---|
| 257 |
|
|---|
| 258 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 259 | double res = atan(arguments_atan[i]);
|
|---|
| 260 |
|
|---|
| 261 | if (!cmp_double(res, results_atan[i])) {
|
|---|
| 262 | TPRINTF("Double precision atan failed "
|
|---|
| 263 | "(%.12lf != %.12lf, arg %u)\n", res, results_atan[i], i);
|
|---|
| 264 | fail = true;
|
|---|
| 265 | }
|
|---|
| 266 | }
|
|---|
| 267 |
|
|---|
| 268 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 269 | float res = atanf(arguments_atan[i]);
|
|---|
| 270 |
|
|---|
| 271 | if (!cmp_float(res, results_atan[i])) {
|
|---|
| 272 | TPRINTF("Single precision atan failed "
|
|---|
| 273 | "(%f != %lf, arg %u)\n", res, results_atan[i], i);
|
|---|
| 274 | fail = true;
|
|---|
| 275 | }
|
|---|
| 276 | }
|
|---|
| 277 |
|
|---|
| 278 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 279 | double res = ceil(arguments[i]);
|
|---|
| 280 |
|
|---|
| 281 | if (!cmp_double(res, results_ceil[i])) {
|
|---|
| 282 | TPRINTF("Double precision ceil failed "
|
|---|
| 283 | "(%lf != %lf, arg %u)\n", res, results_ceil[i], i);
|
|---|
| 284 | fail = true;
|
|---|
| 285 | }
|
|---|
| 286 | }
|
|---|
| 287 |
|
|---|
| 288 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 289 | float res = ceilf(arguments[i]);
|
|---|
| 290 |
|
|---|
| 291 | if (!cmp_float(res, results_ceil[i])) {
|
|---|
| 292 | TPRINTF("Single precision ceil failed "
|
|---|
| 293 | "(%f != %lf, arg %u)\n", res, results_ceil[i], i);
|
|---|
| 294 | fail = true;
|
|---|
| 295 | }
|
|---|
| 296 | }
|
|---|
| 297 |
|
|---|
| 298 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 299 | double res = cos(arguments[i]);
|
|---|
| 300 |
|
|---|
| 301 | if (!cmp_double(res, results_cos[i])) {
|
|---|
| 302 | TPRINTF("Double precision cos failed "
|
|---|
| 303 | "(%lf != %lf, arg %u)\n", res, results_cos[i], i);
|
|---|
| 304 | fail = true;
|
|---|
| 305 | }
|
|---|
| 306 | }
|
|---|
| 307 |
|
|---|
| 308 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 309 | float res = cosf(arguments[i]);
|
|---|
| 310 |
|
|---|
| 311 | if (!cmp_float(res, results_cos[i])) {
|
|---|
| 312 | TPRINTF("Single precision cos failed "
|
|---|
| 313 | "(%f != %lf, arg %u)\n", res, results_cos[i], i);
|
|---|
| 314 | fail = true;
|
|---|
| 315 | }
|
|---|
| 316 | }
|
|---|
| 317 |
|
|---|
| 318 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 319 | double res = cosh(arguments_exp[i]);
|
|---|
| 320 |
|
|---|
| 321 | if (!cmp_double(res, results_cosh[i])) {
|
|---|
| 322 | TPRINTF("Double precision cosh failed "
|
|---|
| 323 | "(%lf != %lf, arg %u)\n", res, results_cosh[i], i);
|
|---|
| 324 | fail = true;
|
|---|
| 325 | }
|
|---|
| 326 | }
|
|---|
| 327 |
|
|---|
| 328 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 329 | float res = coshf(arguments_exp[i]);
|
|---|
| 330 |
|
|---|
| 331 | if (!cmp_float(res, results_cosh[i])) {
|
|---|
| 332 | TPRINTF("Single precision cosh failed "
|
|---|
| 333 | "(%f != %lf, arg %u)\n", res, results_cosh[i], i);
|
|---|
| 334 | fail = true;
|
|---|
| 335 | }
|
|---|
| 336 | }
|
|---|
| 337 |
|
|---|
| 338 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 339 | double res = exp(arguments_exp[i]);
|
|---|
| 340 |
|
|---|
| 341 | if (!cmp_double(res, results_exp[i])) {
|
|---|
| 342 | TPRINTF("Double precision exp failed "
|
|---|
| 343 | "(%lf != %lf, arg %u)\n", res, results_exp[i], i);
|
|---|
| 344 | fail = true;
|
|---|
| 345 | }
|
|---|
| 346 | }
|
|---|
| 347 |
|
|---|
| 348 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 349 | float res = expf(arguments_exp[i]);
|
|---|
| 350 |
|
|---|
| 351 | if (!cmp_float(res, results_exp[i])) {
|
|---|
| 352 | TPRINTF("Single precision exp failed "
|
|---|
| 353 | "(%f != %lf, arg %u)\n", res, results_exp[i], i);
|
|---|
| 354 | fail = true;
|
|---|
| 355 | }
|
|---|
| 356 | }
|
|---|
| 357 |
|
|---|
| 358 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 359 | double res = fabs(arguments[i]);
|
|---|
| 360 |
|
|---|
| 361 | if (!cmp_double(res, results_fabs[i])) {
|
|---|
| 362 | TPRINTF("Double precision fabs failed "
|
|---|
| 363 | "(%lf != %lf, arg %u)\n", res, results_fabs[i], i);
|
|---|
| 364 | fail = true;
|
|---|
| 365 | }
|
|---|
| 366 | }
|
|---|
| 367 |
|
|---|
| 368 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 369 | float res = fabsf(arguments[i]);
|
|---|
| 370 |
|
|---|
| 371 | if (!cmp_float(res, results_fabs[i])) {
|
|---|
| 372 | TPRINTF("Single precision fabs failed "
|
|---|
| 373 | "(%f != %lf, arg %u)\n", res, results_fabs[i], i);
|
|---|
| 374 | fail = true;
|
|---|
| 375 | }
|
|---|
| 376 | }
|
|---|
| 377 |
|
|---|
| 378 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 379 | double res = floor(arguments[i]);
|
|---|
| 380 |
|
|---|
| 381 | if (!cmp_double(res, results_floor[i])) {
|
|---|
| 382 | TPRINTF("Double precision floor failed "
|
|---|
| 383 | "(%lf != %lf, arg %u)\n", res, results_floor[i], i);
|
|---|
| 384 | fail = true;
|
|---|
| 385 | }
|
|---|
| 386 | }
|
|---|
| 387 |
|
|---|
| 388 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 389 | float res = floorf(arguments[i]);
|
|---|
| 390 |
|
|---|
| 391 | if (!cmp_float(res, results_floor[i])) {
|
|---|
| 392 | TPRINTF("Single precision floor failed "
|
|---|
| 393 | "(%f != %lf, arg %u)\n", res, results_floor[i], i);
|
|---|
| 394 | fail = true;
|
|---|
| 395 | }
|
|---|
| 396 | }
|
|---|
| 397 |
|
|---|
| 398 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 399 | double res = log(arguments_log[i]);
|
|---|
| 400 |
|
|---|
| 401 | if (!cmp_double(res, results_log[i])) {
|
|---|
| 402 | TPRINTF("Double precision log failed "
|
|---|
| 403 | "(%lf != %lf, arg %u)\n", res, results_log[i], i);
|
|---|
| 404 | fail = true;
|
|---|
| 405 | }
|
|---|
| 406 | }
|
|---|
| 407 |
|
|---|
| 408 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 409 | float res = logf(arguments_log[i]);
|
|---|
| 410 |
|
|---|
| 411 | if (!cmp_float(res, results_log[i])) {
|
|---|
| 412 | TPRINTF("Single precision log failed "
|
|---|
| 413 | "(%f != %lf, arg %u)\n", res, results_log[i], i);
|
|---|
| 414 | fail = true;
|
|---|
| 415 | }
|
|---|
| 416 | }
|
|---|
| 417 |
|
|---|
| 418 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 419 | double res = log10(arguments_log[i]);
|
|---|
| 420 |
|
|---|
| 421 | if (!cmp_double(res, results_log10[i])) {
|
|---|
| 422 | TPRINTF("Double precision log10 failed "
|
|---|
| 423 | "(%lf != %lf, arg %u)\n", res, results_log10[i], i);
|
|---|
| 424 | fail = true;
|
|---|
| 425 | }
|
|---|
| 426 | }
|
|---|
| 427 |
|
|---|
| 428 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 429 | float res = log10f(arguments_log[i]);
|
|---|
| 430 |
|
|---|
| 431 | if (!cmp_float(res, results_log10[i])) {
|
|---|
| 432 | TPRINTF("Single precision log10 failed "
|
|---|
| 433 | "(%f != %lf, arg %u)\n", res, results_log10[i], i);
|
|---|
| 434 | fail = true;
|
|---|
| 435 | }
|
|---|
| 436 | }
|
|---|
| 437 |
|
|---|
| 438 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 439 | double res = log2(arguments_log[i]);
|
|---|
| 440 |
|
|---|
| 441 | if (!cmp_double(res, results_log2[i])) {
|
|---|
| 442 | TPRINTF("Double precision log2 failed "
|
|---|
| 443 | "(%lf != %lf, arg %u)\n", res, results_log2[i], i);
|
|---|
| 444 | fail = true;
|
|---|
| 445 | }
|
|---|
| 446 | }
|
|---|
| 447 |
|
|---|
| 448 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 449 | float res = log2f(arguments_log[i]);
|
|---|
| 450 |
|
|---|
| 451 | if (!cmp_float(res, results_log2[i])) {
|
|---|
| 452 | TPRINTF("Single precision log2 failed "
|
|---|
| 453 | "(%f != %lf, arg %u)\n", res, results_log2[i], i);
|
|---|
| 454 | fail = true;
|
|---|
| 455 | }
|
|---|
| 456 | }
|
|---|
| 457 |
|
|---|
| 458 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 459 | double res = sin(arguments[i]);
|
|---|
| 460 |
|
|---|
| 461 | if (!cmp_double(res, results_sin[i])) {
|
|---|
| 462 | TPRINTF("Double precision sin failed "
|
|---|
| 463 | "(%lf != %lf, arg %u)\n", res, results_sin[i], i);
|
|---|
| 464 | fail = true;
|
|---|
| 465 | }
|
|---|
| 466 | }
|
|---|
| 467 |
|
|---|
| 468 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 469 | float res = sinf(arguments[i]);
|
|---|
| 470 |
|
|---|
| 471 | if (!cmp_float(res, results_sin[i])) {
|
|---|
| 472 | TPRINTF("Single precision sin failed "
|
|---|
| 473 | "(%f != %lf, arg %u)\n", res, results_sin[i], i);
|
|---|
| 474 | fail = true;
|
|---|
| 475 | }
|
|---|
| 476 | }
|
|---|
| 477 |
|
|---|
| 478 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 479 | double res = sinh(arguments_exp[i]);
|
|---|
| 480 |
|
|---|
| 481 | if (!cmp_double(res, results_sinh[i])) {
|
|---|
| 482 | TPRINTF("Double precision sinh failed "
|
|---|
| 483 | "(%lf != %lf, arg %u)\n", res, results_sinh[i], i);
|
|---|
| 484 | fail = true;
|
|---|
| 485 | }
|
|---|
| 486 | }
|
|---|
| 487 |
|
|---|
| 488 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 489 | float res = sinhf(arguments_exp[i]);
|
|---|
| 490 |
|
|---|
| 491 | if (!cmp_float(res, results_sinh[i])) {
|
|---|
| 492 | TPRINTF("Single precision sinh failed "
|
|---|
| 493 | "(%f != %lf, arg %u)\n", res, results_sinh[i], i);
|
|---|
| 494 | fail = true;
|
|---|
| 495 | }
|
|---|
| 496 | }
|
|---|
| 497 |
|
|---|
| 498 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 499 | double res = sqrt(arguments_sqrt[i]);
|
|---|
| 500 |
|
|---|
| 501 | if (!cmp_double(res, results_sqrt[i])) {
|
|---|
| 502 | TPRINTF("Double precision sqrt failed "
|
|---|
| 503 | "(%lf != %lf, arg %u)\n", res, results_sqrt[i], i);
|
|---|
| 504 | fail = true;
|
|---|
| 505 | }
|
|---|
| 506 | }
|
|---|
| 507 |
|
|---|
| 508 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 509 | float res = sqrtf(arguments_sqrt[i]);
|
|---|
| 510 |
|
|---|
| 511 | if (!cmp_float(res, results_sqrt[i])) {
|
|---|
| 512 | TPRINTF("Single precision sqrt failed "
|
|---|
| 513 | "(%f != %lf, arg %u)\n", res, results_sqrt[i], i);
|
|---|
| 514 | fail = true;
|
|---|
| 515 | }
|
|---|
| 516 | }
|
|---|
| 517 |
|
|---|
| 518 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 519 | double res = tan(arguments[i]);
|
|---|
| 520 |
|
|---|
| 521 | if (!cmp_double(res, results_tan[i])) {
|
|---|
| 522 | TPRINTF("Double precision tan failed "
|
|---|
| 523 | "(%lf != %lf, arg %u)\n", res, results_tan[i], i);
|
|---|
| 524 | fail = true;
|
|---|
| 525 | }
|
|---|
| 526 | }
|
|---|
| 527 |
|
|---|
| 528 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 529 | float res = tanf(arguments[i]);
|
|---|
| 530 |
|
|---|
| 531 | if (!cmp_float(res, results_tan[i])) {
|
|---|
| 532 | TPRINTF("Single precision tan failed "
|
|---|
| 533 | "(%f != %lf, arg %u)\n", res, results_tan[i], i);
|
|---|
| 534 | fail = true;
|
|---|
| 535 | }
|
|---|
| 536 | }
|
|---|
| 537 |
|
|---|
| 538 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 539 | double res = tanh(arguments_tanh[i]);
|
|---|
| 540 |
|
|---|
| 541 | if (!cmp_double(res, results_tanh[i])) {
|
|---|
| 542 | TPRINTF("Double precision tanh failed "
|
|---|
| 543 | "(%lf != %lf, arg %u)\n", res, results_tanh[i], i);
|
|---|
| 544 | fail = true;
|
|---|
| 545 | }
|
|---|
| 546 | }
|
|---|
| 547 |
|
|---|
| 548 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 549 | float res = tanhf(arguments_tanh[i]);
|
|---|
| 550 |
|
|---|
| 551 | if (!cmp_float(res, results_tanh[i])) {
|
|---|
| 552 | TPRINTF("Single precision tanh failed "
|
|---|
| 553 | "(%f != %lf, arg %u)\n", res, results_tanh[i], i);
|
|---|
| 554 | fail = true;
|
|---|
| 555 | }
|
|---|
| 556 | }
|
|---|
| 557 |
|
|---|
| 558 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 559 | double res = trunc(arguments[i]);
|
|---|
| 560 |
|
|---|
| 561 | if (!cmp_double(res, results_trunc[i])) {
|
|---|
| 562 | TPRINTF("Double precision trunc failed "
|
|---|
| 563 | "(%lf != %lf, arg %u)\n", res, results_trunc[i], i);
|
|---|
| 564 | fail = true;
|
|---|
| 565 | }
|
|---|
| 566 | }
|
|---|
| 567 |
|
|---|
| 568 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 569 | float res = truncf(arguments[i]);
|
|---|
| 570 |
|
|---|
| 571 | if (!cmp_float(res, results_trunc[i])) {
|
|---|
| 572 | TPRINTF("Single precision trunc failed "
|
|---|
| 573 | "(%f != %lf, arg %u)\n", res, results_trunc[i], i);
|
|---|
| 574 | fail = true;
|
|---|
| 575 | }
|
|---|
| 576 | }
|
|---|
| 577 |
|
|---|
| 578 | if (fail)
|
|---|
| 579 | return "Floating point imprecision";
|
|---|
| 580 |
|
|---|
| 581 | return NULL;
|
|---|
| 582 | }
|
|---|