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