| 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 <math.h>
|
|---|
| 34 | #include "../tester.h"
|
|---|
| 35 |
|
|---|
| 36 | #define OPERANDS 10
|
|---|
| 37 | #define PRECISIONF 10000
|
|---|
| 38 | #define PRECISION 100000000
|
|---|
| 39 |
|
|---|
| 40 | static double arguments[OPERANDS] = {
|
|---|
| 41 | 3.5, -2.1, 100.0, 50.0, -1024.0, 0.0, 768.3156, 1080.499999, -600.0, 1.0
|
|---|
| 42 | };
|
|---|
| 43 |
|
|---|
| 44 | static double arguments_acos[OPERANDS] = {
|
|---|
| 45 | -0.936456687291, -0.504846104600, 0.862318872288, 0.964966028492,
|
|---|
| 46 | 0.987353618220, 1.0, -0.194939922623, 0.978471923925, -0.999023478833,
|
|---|
| 47 | 0.540302305868
|
|---|
| 48 | };
|
|---|
| 49 |
|
|---|
| 50 | static double arguments_asin[OPERANDS] = {
|
|---|
| 51 | -0.350783227690, -0.863209366649, -0.506365641110, -0.262374853704,
|
|---|
| 52 | 0.158533380044, 0.0, 0.980815184715, -0.206379975025, -0.044182448332,
|
|---|
| 53 | 0.841470984808
|
|---|
| 54 | };
|
|---|
| 55 |
|
|---|
| 56 | static double arguments_atan[OPERANDS] = {
|
|---|
| 57 | 3.5, 100.0, 50.0, 768.3156, 1080.499999, 1.0, 66.0,
|
|---|
| 58 | 2.718281828459045, 9.9, 0.001
|
|---|
| 59 | };
|
|---|
| 60 |
|
|---|
| 61 | static double arguments_exp[OPERANDS] = {
|
|---|
| 62 | 3.5, -2.1, 50.0, 0.0, 1.0, 13.2, -1.1, -5.5, 0.1, -66.0
|
|---|
| 63 | };
|
|---|
| 64 |
|
|---|
| 65 | static double arguments_log[OPERANDS] = {
|
|---|
| 66 | 3.5, 100.0, 50.0, 768.3156, 1080.499999, 1.0, 66.0,
|
|---|
| 67 | 2.718281828459045, 9.9, 0.001
|
|---|
| 68 | };
|
|---|
| 69 |
|
|---|
| 70 | static double arguments_sqrt[OPERANDS] = {
|
|---|
| 71 | 3.5, 100.0, 50.0, 768.3156, 1080.499999, 1.0, 66.0,
|
|---|
| 72 | 2.718281828459045, 9.9, 0.001
|
|---|
| 73 | };
|
|---|
| 74 |
|
|---|
| 75 | static double arguments_tanh[OPERANDS] = {
|
|---|
| 76 | 3.5, -2.1, 50.0, 0.0, 1.0, 13.2, -1.1, -5.5, 0.000001, -66000000.0
|
|---|
| 77 | };
|
|---|
| 78 |
|
|---|
| 79 | static double results_acos[OPERANDS] = {
|
|---|
| 80 | 2.783185307180, 2.100000000000, 0.530964914873, 0.265482457437,
|
|---|
| 81 | 0.159205070272, 0.000000000000, 1.766992524091, 0.207873834887,
|
|---|
| 82 | 3.097395817941, 1.000000000000
|
|---|
| 83 | };
|
|---|
| 84 |
|
|---|
| 85 | static double results_asin[OPERANDS] = {
|
|---|
| 86 | -0.358407346411, -1.041592653590, -0.530964914874, -0.265482457437,
|
|---|
| 87 | 0.159205070273, 0.000000000000, 1.374600129498, -0.207873834889,
|
|---|
| 88 | -0.044196835651, 1.000000000000
|
|---|
| 89 | };
|
|---|
| 90 |
|
|---|
| 91 | static double results_atan[OPERANDS] = {
|
|---|
| 92 | 1.292496667790, 1.560796660108, 1.550798992822, 1.569494779052,
|
|---|
| 93 | 1.569870829603, 0.785398163397, 1.555645970920, 1.218282905017,
|
|---|
| 94 | 1.470127674637, 0.000999999667
|
|---|
| 95 | };
|
|---|
| 96 |
|
|---|
| 97 | static double results_ceil[OPERANDS] = {
|
|---|
| 98 | 4.0, -2.0, 100.0, 50.0, -1024.0, 0.0, 769.0, 1081.0, -600.0, 1.0
|
|---|
| 99 | };
|
|---|
| 100 |
|
|---|
| 101 | static double results_cos[OPERANDS] = {
|
|---|
| 102 | -0.936456687291, -0.504846104600, 0.862318872288, 0.964966028492,
|
|---|
| 103 | 0.987353618220, 1.0, -0.194939922623, 0.978471923925, -0.999023478833,
|
|---|
| 104 | 0.540302305868
|
|---|
| 105 | };
|
|---|
| 106 |
|
|---|
| 107 | static double results_cosh[OPERANDS] = {
|
|---|
| 108 | 16.572824671057, 4.144313170410, 2592352764293536022528.000000000000,
|
|---|
| 109 | 1.000000000000, 1.543080634815, 270182.468624271103, 1.668518553822,
|
|---|
| 110 | 122.348009517829, 1.005004168056, 23035933171656458903220125696.0
|
|---|
| 111 | };
|
|---|
| 112 |
|
|---|
| 113 | static double results_fabs[OPERANDS] = {
|
|---|
| 114 | 3.5, 2.1, 100.0, 50.0, 1024.0, 0.0, 768.3156, 1080.499999, 600.0, 1.0
|
|---|
| 115 | };
|
|---|
| 116 |
|
|---|
| 117 | static double results_floor[OPERANDS] = {
|
|---|
| 118 | 3.0, -3.0, 100.0, 50.0, -1024.0, 0.0, 768.0, 1080.0, -600.0, 1.0
|
|---|
| 119 | };
|
|---|
| 120 |
|
|---|
| 121 | static double results_exp[OPERANDS] = {
|
|---|
| 122 | 33.115451958692, 0.122456428253, 5184705528587072045056.0,
|
|---|
| 123 | 1.000000000000, 2.718281828459, 540364.937246691552, 0.332871083698,
|
|---|
| 124 | 0.004086771438, 1.105170918076, 0.000000000000
|
|---|
| 125 | };
|
|---|
| 126 |
|
|---|
| 127 | static double results_log[OPERANDS] = {
|
|---|
| 128 | 1.252762968495, 4.605170185988, 3.912023005428, 6.644200586236,
|
|---|
| 129 | 6.985179175021, 0.000000000000, 4.189654742026, 1.000000000000,
|
|---|
| 130 | 2.292534757141, -6.907755278982
|
|---|
| 131 | };
|
|---|
| 132 |
|
|---|
| 133 | static double results_log10[OPERANDS] = {
|
|---|
| 134 | 0.544068044350, 2.000000000000, 1.698970004336, 2.885539651261,
|
|---|
| 135 | 3.033624770817, 0.000000000000, 1.819543935542, 0.434294481903,
|
|---|
| 136 | 0.995635194598, -3.000000000000
|
|---|
| 137 | };
|
|---|
| 138 |
|
|---|
| 139 | static double results_sin[OPERANDS] = {
|
|---|
| 140 | -0.350783227690, -0.863209366649, -0.506365641110, -0.262374853704,
|
|---|
| 141 | 0.158533380044, 0.0, 0.980815184715, -0.206379975025, -0.044182448332,
|
|---|
| 142 | 0.841470984808
|
|---|
| 143 | };
|
|---|
| 144 |
|
|---|
| 145 | static double results_sinh[OPERANDS] = {
|
|---|
| 146 | 16.542627287635, -4.021856742157, 2592352764293536022528.000000000000,
|
|---|
| 147 | 0.000000000000, 1.175201193644, 270182.468622420449, -1.335647470124,
|
|---|
| 148 | -122.343922746391, 0.100166750020, -23035933171656458903220125696.0
|
|---|
| 149 | };
|
|---|
| 150 |
|
|---|
| 151 | static double results_sqrt[OPERANDS] = {
|
|---|
| 152 | 1.870828693387, 10.000000000000, 7.071067811865, 27.718506453271,
|
|---|
| 153 | 32.870959812576, 1.000000000000, 8.124038404636, 1.648721270700,
|
|---|
| 154 | 3.146426544510, 0.031622776602
|
|---|
| 155 | };
|
|---|
| 156 |
|
|---|
| 157 | static double results_tan[OPERANDS] = {
|
|---|
| 158 | 0.374585640159, 1.709846542905, -0.587213915157, -0.271900611998,
|
|---|
| 159 | 0.160563932839, 0.000000000000, -5.031371570891, -0.210920691722,
|
|---|
| 160 | 0.044225635601, 1.557407724655
|
|---|
| 161 | };
|
|---|
| 162 |
|
|---|
| 163 | static double results_tanh[OPERANDS] = {
|
|---|
| 164 | 0.998177897611, -0.970451936613, 1.000000000000, 0.000000000000,
|
|---|
| 165 | 0.761594155956, 0.999999999993, -0.800499021761, -0.999966597156,
|
|---|
| 166 | 0.000001000000, -1.000000000000
|
|---|
| 167 | };
|
|---|
| 168 |
|
|---|
| 169 | static double results_trunc[OPERANDS] = {
|
|---|
| 170 | 3.0, -2.0, 100.0, 50.0, -1024.0, 0.0, 768.0, 1080.0, -600.0, 1.0
|
|---|
| 171 | };
|
|---|
| 172 |
|
|---|
| 173 | static bool cmp_float(float a, float b)
|
|---|
| 174 | {
|
|---|
| 175 | float r;
|
|---|
| 176 |
|
|---|
| 177 | /* XXX Need fabsf() */
|
|---|
| 178 | if (b < 1.0 / PRECISIONF && b > -1.0 / PRECISIONF)
|
|---|
| 179 | r = a;
|
|---|
| 180 | else
|
|---|
| 181 | r = a / b - 1.0;
|
|---|
| 182 |
|
|---|
| 183 | /* XXX Need fabsf() */
|
|---|
| 184 | if (r < 0.0)
|
|---|
| 185 | r = -r;
|
|---|
| 186 |
|
|---|
| 187 | return r < 1.0 / PRECISIONF;
|
|---|
| 188 | }
|
|---|
| 189 |
|
|---|
| 190 | static bool cmp_double(double a, double b)
|
|---|
| 191 | {
|
|---|
| 192 | double r;
|
|---|
| 193 |
|
|---|
| 194 | /* XXX Need fabs() */
|
|---|
| 195 | if (b < 1.0 / PRECISION && b > -1.0 / PRECISION)
|
|---|
| 196 | r = a;
|
|---|
| 197 | else
|
|---|
| 198 | r = a / b - 1.0;
|
|---|
| 199 |
|
|---|
| 200 | /* XXX Need fabs() */
|
|---|
| 201 | if (r < 0.0)
|
|---|
| 202 | r = -r;
|
|---|
| 203 |
|
|---|
| 204 | return r < 1.0 / PRECISION;
|
|---|
| 205 | }
|
|---|
| 206 |
|
|---|
| 207 | const char *test_float2(void)
|
|---|
| 208 | {
|
|---|
| 209 | bool fail = false;
|
|---|
| 210 | if (0) {
|
|---|
| 211 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 212 | double res = acos(arguments_acos[i]);
|
|---|
| 213 |
|
|---|
| 214 | if (!cmp_double(res, results_acos[i])) {
|
|---|
| 215 | TPRINTF("Double precision acos failed "
|
|---|
| 216 | "(%lf != %lf, arg %u)\n", res, results_acos[i], i);
|
|---|
| 217 | fail = true;
|
|---|
| 218 | }
|
|---|
| 219 | }
|
|---|
| 220 |
|
|---|
| 221 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 222 | float res = acosf(arguments_acos[i]);
|
|---|
| 223 |
|
|---|
| 224 | if (!cmp_float(res, results_acos[i])) {
|
|---|
| 225 | TPRINTF("Single precision acos failed "
|
|---|
| 226 | "(%f != %lf, arg %u)\n", res, results_acos[i], i);
|
|---|
| 227 | fail = true;
|
|---|
| 228 | }
|
|---|
| 229 | }
|
|---|
| 230 |
|
|---|
| 231 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 232 | double res = asin(arguments_asin[i]);
|
|---|
| 233 |
|
|---|
| 234 | if (!cmp_double(res, results_asin[i])) {
|
|---|
| 235 | TPRINTF("Double precision asin failed "
|
|---|
| 236 | "(%lf != %lf, arg %u)\n", res, results_asin[i], i);
|
|---|
| 237 | fail = true;
|
|---|
| 238 | }
|
|---|
| 239 | }
|
|---|
| 240 |
|
|---|
| 241 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 242 | float res = asinf(arguments_asin[i]);
|
|---|
| 243 |
|
|---|
| 244 | if (!cmp_float(res, results_asin[i])) {
|
|---|
| 245 | TPRINTF("Single precision asin failed "
|
|---|
| 246 | "(%f != %lf, arg %u)\n", res, results_asin[i], i);
|
|---|
| 247 | fail = true;
|
|---|
| 248 | }
|
|---|
| 249 | }
|
|---|
| 250 | }
|
|---|
| 251 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 252 | double res = atan(arguments_atan[i]);
|
|---|
| 253 |
|
|---|
| 254 | if (!cmp_double(res, results_atan[i])) {
|
|---|
| 255 | TPRINTF("Double precision atan failed "
|
|---|
| 256 | "(%.12lf != %.12lf, arg %u)\n", res, results_atan[i], i);
|
|---|
| 257 | fail = true;
|
|---|
| 258 | }
|
|---|
| 259 | }
|
|---|
| 260 |
|
|---|
| 261 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 262 | float res = atanf(arguments_atan[i]);
|
|---|
| 263 |
|
|---|
| 264 | if (!cmp_float(res, results_atan[i])) {
|
|---|
| 265 | TPRINTF("Single precision atan failed "
|
|---|
| 266 | "(%f != %lf, arg %u)\n", res, results_atan[i], i);
|
|---|
| 267 | fail = true;
|
|---|
| 268 | }
|
|---|
| 269 | }
|
|---|
| 270 |
|
|---|
| 271 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 272 | double res = ceil(arguments[i]);
|
|---|
| 273 |
|
|---|
| 274 | if (!cmp_double(res, results_ceil[i])) {
|
|---|
| 275 | TPRINTF("Double precision ceil failed "
|
|---|
| 276 | "(%lf != %lf, arg %u)\n", res, results_ceil[i], i);
|
|---|
| 277 | fail = true;
|
|---|
| 278 | }
|
|---|
| 279 | }
|
|---|
| 280 |
|
|---|
| 281 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 282 | float res = ceilf(arguments[i]);
|
|---|
| 283 |
|
|---|
| 284 | if (!cmp_float(res, results_ceil[i])) {
|
|---|
| 285 | TPRINTF("Single precision ceil failed "
|
|---|
| 286 | "(%f != %lf, arg %u)\n", res, results_ceil[i], i);
|
|---|
| 287 | fail = true;
|
|---|
| 288 | }
|
|---|
| 289 | }
|
|---|
| 290 |
|
|---|
| 291 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 292 | double res = cos(arguments[i]);
|
|---|
| 293 |
|
|---|
| 294 | if (!cmp_double(res, results_cos[i])) {
|
|---|
| 295 | TPRINTF("Double precision cos failed "
|
|---|
| 296 | "(%lf != %lf, arg %u)\n", res, results_cos[i], i);
|
|---|
| 297 | fail = true;
|
|---|
| 298 | }
|
|---|
| 299 | }
|
|---|
| 300 |
|
|---|
| 301 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 302 | float res = cosf(arguments[i]);
|
|---|
| 303 |
|
|---|
| 304 | if (!cmp_float(res, results_cos[i])) {
|
|---|
| 305 | TPRINTF("Single precision cos failed "
|
|---|
| 306 | "(%f != %lf, arg %u)\n", res, results_cos[i], i);
|
|---|
| 307 | fail = true;
|
|---|
| 308 | }
|
|---|
| 309 | }
|
|---|
| 310 |
|
|---|
| 311 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 312 | double res = cosh(arguments_exp[i]);
|
|---|
| 313 |
|
|---|
| 314 | if (!cmp_double(res, results_cosh[i])) {
|
|---|
| 315 | TPRINTF("Double precision cosh failed "
|
|---|
| 316 | "(%lf != %lf, arg %u)\n", res, results_cosh[i], i);
|
|---|
| 317 | fail = true;
|
|---|
| 318 | }
|
|---|
| 319 | }
|
|---|
| 320 |
|
|---|
| 321 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 322 | float res = coshf(arguments_exp[i]);
|
|---|
| 323 |
|
|---|
| 324 | if (!cmp_float(res, results_cosh[i])) {
|
|---|
| 325 | TPRINTF("Single precision cosh failed "
|
|---|
| 326 | "(%f != %lf, arg %u)\n", res, results_cosh[i], i);
|
|---|
| 327 | fail = true;
|
|---|
| 328 | }
|
|---|
| 329 | }
|
|---|
| 330 |
|
|---|
| 331 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 332 | double res = exp(arguments_exp[i]);
|
|---|
| 333 |
|
|---|
| 334 | if (!cmp_double(res, results_exp[i])) {
|
|---|
| 335 | TPRINTF("Double precision exp failed "
|
|---|
| 336 | "(%lf != %lf, arg %u)\n", res, results_exp[i], i);
|
|---|
| 337 | fail = true;
|
|---|
| 338 | }
|
|---|
| 339 | }
|
|---|
| 340 |
|
|---|
| 341 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 342 | float res = expf(arguments_exp[i]);
|
|---|
| 343 |
|
|---|
| 344 | if (!cmp_float(res, results_exp[i])) {
|
|---|
| 345 | TPRINTF("Single precision exp failed "
|
|---|
| 346 | "(%f != %lf, arg %u)\n", res, results_exp[i], i);
|
|---|
| 347 | fail = true;
|
|---|
| 348 | }
|
|---|
| 349 | }
|
|---|
| 350 |
|
|---|
| 351 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 352 | double res = fabs(arguments[i]);
|
|---|
| 353 |
|
|---|
| 354 | if (!cmp_double(res, results_fabs[i])) {
|
|---|
| 355 | TPRINTF("Double precision fabs failed "
|
|---|
| 356 | "(%lf != %lf, arg %u)\n", res, results_fabs[i], i);
|
|---|
| 357 | fail = true;
|
|---|
| 358 | }
|
|---|
| 359 | }
|
|---|
| 360 |
|
|---|
| 361 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 362 | float res = fabsf(arguments[i]);
|
|---|
| 363 |
|
|---|
| 364 | if (!cmp_float(res, results_fabs[i])) {
|
|---|
| 365 | TPRINTF("Single precision fabs failed "
|
|---|
| 366 | "(%f != %lf, arg %u)\n", res, results_fabs[i], i);
|
|---|
| 367 | fail = true;
|
|---|
| 368 | }
|
|---|
| 369 | }
|
|---|
| 370 |
|
|---|
| 371 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 372 | double res = floor(arguments[i]);
|
|---|
| 373 |
|
|---|
| 374 | if (!cmp_double(res, results_floor[i])) {
|
|---|
| 375 | TPRINTF("Double precision floor failed "
|
|---|
| 376 | "(%lf != %lf, arg %u)\n", res, results_floor[i], i);
|
|---|
| 377 | fail = true;
|
|---|
| 378 | }
|
|---|
| 379 | }
|
|---|
| 380 |
|
|---|
| 381 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 382 | float res = floorf(arguments[i]);
|
|---|
| 383 |
|
|---|
| 384 | if (!cmp_float(res, results_floor[i])) {
|
|---|
| 385 | TPRINTF("Single precision floor failed "
|
|---|
| 386 | "(%f != %lf, arg %u)\n", res, results_floor[i], i);
|
|---|
| 387 | fail = true;
|
|---|
| 388 | }
|
|---|
| 389 | }
|
|---|
| 390 |
|
|---|
| 391 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 392 | double res = log(arguments_log[i]);
|
|---|
| 393 |
|
|---|
| 394 | if (!cmp_double(res, results_log[i])) {
|
|---|
| 395 | TPRINTF("Double precision log failed "
|
|---|
| 396 | "(%lf != %lf, arg %u)\n", res, results_log[i], i);
|
|---|
| 397 | fail = true;
|
|---|
| 398 | }
|
|---|
| 399 | }
|
|---|
| 400 |
|
|---|
| 401 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 402 | float res = logf(arguments_log[i]);
|
|---|
| 403 |
|
|---|
| 404 | if (!cmp_float(res, results_log[i])) {
|
|---|
| 405 | TPRINTF("Single precision log failed "
|
|---|
| 406 | "(%f != %lf, arg %u)\n", res, results_log[i], i);
|
|---|
| 407 | fail = true;
|
|---|
| 408 | }
|
|---|
| 409 | }
|
|---|
| 410 |
|
|---|
| 411 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 412 | double res = log10(arguments_log[i]);
|
|---|
| 413 |
|
|---|
| 414 | if (!cmp_double(res, results_log10[i])) {
|
|---|
| 415 | TPRINTF("Double precision log10 failed "
|
|---|
| 416 | "(%lf != %lf, arg %u)\n", res, results_log10[i], i);
|
|---|
| 417 | fail = true;
|
|---|
| 418 | }
|
|---|
| 419 | }
|
|---|
| 420 |
|
|---|
| 421 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 422 | float res = log10f(arguments_log[i]);
|
|---|
| 423 |
|
|---|
| 424 | if (!cmp_float(res, results_log10[i])) {
|
|---|
| 425 | TPRINTF("Single precision log10 failed "
|
|---|
| 426 | "(%f != %lf, arg %u)\n", res, results_log10[i], i);
|
|---|
| 427 | fail = true;
|
|---|
| 428 | }
|
|---|
| 429 | }
|
|---|
| 430 |
|
|---|
| 431 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 432 | double res = sin(arguments[i]);
|
|---|
| 433 |
|
|---|
| 434 | if (!cmp_double(res, results_sin[i])) {
|
|---|
| 435 | TPRINTF("Double precision sin failed "
|
|---|
| 436 | "(%lf != %lf, arg %u)\n", res, results_sin[i], i);
|
|---|
| 437 | fail = true;
|
|---|
| 438 | }
|
|---|
| 439 | }
|
|---|
| 440 |
|
|---|
| 441 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 442 | float res = sinf(arguments[i]);
|
|---|
| 443 |
|
|---|
| 444 | if (!cmp_float(res, results_sin[i])) {
|
|---|
| 445 | TPRINTF("Single precision sin failed "
|
|---|
| 446 | "(%f != %lf, arg %u)\n", res, results_sin[i], i);
|
|---|
| 447 | fail = true;
|
|---|
| 448 | }
|
|---|
| 449 | }
|
|---|
| 450 | ;
|
|---|
| 451 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 452 | double res = sinh(arguments_exp[i]);
|
|---|
| 453 |
|
|---|
| 454 | if (!cmp_double(res, results_sinh[i])) {
|
|---|
| 455 | TPRINTF("Double precision sinh failed "
|
|---|
| 456 | "(%lf != %lf, arg %u)\n", res, results_sinh[i], i);
|
|---|
| 457 | fail = true;
|
|---|
| 458 | }
|
|---|
| 459 | }
|
|---|
| 460 |
|
|---|
| 461 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 462 | float res = sinhf(arguments_exp[i]);
|
|---|
| 463 |
|
|---|
| 464 | if (!cmp_float(res, results_sinh[i])) {
|
|---|
| 465 | TPRINTF("Single precision sinh failed "
|
|---|
| 466 | "(%f != %lf, arg %u)\n", res, results_sinh[i], i);
|
|---|
| 467 | fail = true;
|
|---|
| 468 | }
|
|---|
| 469 | }
|
|---|
| 470 |
|
|---|
| 471 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 472 | double res = sqrt(arguments_sqrt[i]);
|
|---|
| 473 |
|
|---|
| 474 | if (!cmp_double(res, results_sqrt[i])) {
|
|---|
| 475 | TPRINTF("Double precision sqrt failed "
|
|---|
| 476 | "(%lf != %lf, arg %u)\n", res, results_sqrt[i], i);
|
|---|
| 477 | fail = true;
|
|---|
| 478 | }
|
|---|
| 479 | }
|
|---|
| 480 |
|
|---|
| 481 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 482 | float res = sqrtf(arguments_sqrt[i]);
|
|---|
| 483 |
|
|---|
| 484 | if (!cmp_float(res, results_sqrt[i])) {
|
|---|
| 485 | TPRINTF("Single precision sqrt failed "
|
|---|
| 486 | "(%f != %lf, arg %u)\n", res, results_sqrt[i], i);
|
|---|
| 487 | fail = true;
|
|---|
| 488 | }
|
|---|
| 489 | }
|
|---|
| 490 |
|
|---|
| 491 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 492 | double res = tan(arguments[i]);
|
|---|
| 493 |
|
|---|
| 494 | if (!cmp_double(res, results_tan[i])) {
|
|---|
| 495 | TPRINTF("Double precision tan failed "
|
|---|
| 496 | "(%lf != %lf, arg %u)\n", res, results_tan[i], i);
|
|---|
| 497 | fail = true;
|
|---|
| 498 | }
|
|---|
| 499 | }
|
|---|
| 500 |
|
|---|
| 501 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 502 | float res = tanf(arguments[i]);
|
|---|
| 503 |
|
|---|
| 504 | if (!cmp_float(res, results_tan[i])) {
|
|---|
| 505 | TPRINTF("Single precision tan failed "
|
|---|
| 506 | "(%f != %lf, arg %u)\n", res, results_tan[i], i);
|
|---|
| 507 | fail = true;
|
|---|
| 508 | }
|
|---|
| 509 | }
|
|---|
| 510 |
|
|---|
| 511 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 512 | double res = tanh(arguments_tanh[i]);
|
|---|
| 513 |
|
|---|
| 514 | if (!cmp_double(res, results_tanh[i])) {
|
|---|
| 515 | TPRINTF("Double precision tanh failed "
|
|---|
| 516 | "(%lf != %lf, arg %u)\n", res, results_tanh[i], i);
|
|---|
| 517 | fail = true;
|
|---|
| 518 | }
|
|---|
| 519 | }
|
|---|
| 520 |
|
|---|
| 521 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 522 | float res = tanhf(arguments_tanh[i]);
|
|---|
| 523 |
|
|---|
| 524 | if (!cmp_float(res, results_tanh[i])) {
|
|---|
| 525 | TPRINTF("Single precision tanh failed "
|
|---|
| 526 | "(%f != %lf, arg %u)\n", res, results_tanh[i], i);
|
|---|
| 527 | fail = true;
|
|---|
| 528 | }
|
|---|
| 529 | }
|
|---|
| 530 |
|
|---|
| 531 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 532 | double res = trunc(arguments[i]);
|
|---|
| 533 |
|
|---|
| 534 | if (!cmp_double(res, results_trunc[i])) {
|
|---|
| 535 | TPRINTF("Double precision trunc failed "
|
|---|
| 536 | "(%lf != %lf, arg %u)\n", res, results_trunc[i], i);
|
|---|
| 537 | fail = true;
|
|---|
| 538 | }
|
|---|
| 539 | }
|
|---|
| 540 |
|
|---|
| 541 | for (unsigned int i = 0; i < OPERANDS; i++) {
|
|---|
| 542 | float res = truncf(arguments[i]);
|
|---|
| 543 |
|
|---|
| 544 | if (!cmp_float(res, results_trunc[i])) {
|
|---|
| 545 | TPRINTF("Single precision trunc failed "
|
|---|
| 546 | "(%f != %lf, arg %u)\n", res, results_trunc[i], i);
|
|---|
| 547 | fail = true;
|
|---|
| 548 | }
|
|---|
| 549 | }
|
|---|
| 550 |
|
|---|
| 551 | if (fail)
|
|---|
| 552 | return "Floating point imprecision";
|
|---|
| 553 |
|
|---|
| 554 | return NULL;
|
|---|
| 555 | }
|
|---|