Changeset 184ff675 in mainline
- Timestamp:
- 2018-08-29T20:05:59Z (6 years ago)
- Children:
- 84929b0
- Parents:
- b2acdf32
- git-author:
- Jiří Zárevúcky <jiri.zarevucky@…> (2018-08-29 16:15:41)
- git-committer:
- Jiří Zárevúcky <jiri.zarevucky@…> (2018-08-29 20:05:59)
- Location:
- uspace
- Files:
-
- 32 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/tester/float/float2.c
rb2acdf32 r184ff675 43 43 }; 44 44 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.047 };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.00152 };53 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.00157 };58 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.061 };62 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.065 };66 67 45 static double results_cos[OPERANDS] = { 68 46 -0.936456687291, -0.504846104600, 0.862318872288, 0.964966028492, … … 71 49 }; 72 50 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.077 };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.081 };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.085 };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.00000000000091 };92 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.90775527898297 };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.000000000000103 };104 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.965784284662109 };110 111 51 static double results_sin[OPERANDS] = { 112 52 -0.350783227690, -0.863209366649, -0.506365641110, -0.262374853704, 113 53 0.158533380044, 0.0, 0.980815184715, -0.206379975025, -0.044182448332, 114 54 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.0121 };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.031622776602127 };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.557407724655133 };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.000000000000139 55 }; 140 56 … … 182 98 183 99 for (unsigned int i = 0; i < OPERANDS; i++) { 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);189 fail = true;190 }191 }192 193 for (unsigned int i = 0; i < OPERANDS; i++) {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);199 fail = true;200 }201 }202 203 for (unsigned int i = 0; i < OPERANDS; i++) {204 100 double res = cos(arguments[i]); 205 101 … … 222 118 223 119 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 243 for (unsigned int i = 0; i < OPERANDS; i++) {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);259 fail = true;260 }261 }262 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 283 for (unsigned int i = 0; i < OPERANDS; i++) {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);289 fail = true;290 }291 }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 303 for (unsigned int i = 0; i < OPERANDS; i++) {304 double res = log(arguments_log[i]);305 306 if (!cmp_double(res, results_log[i])) {307 TPRINTF("Double precision log failed "308 "(%lf != %lf, arg %u)\n", res, results_log[i], i);309 fail = true;310 }311 }312 313 for (unsigned int i = 0; i < OPERANDS; i++) {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);319 fail = true;320 }321 }322 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 343 for (unsigned int i = 0; i < OPERANDS; i++) {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++) {364 120 double res = sin(arguments[i]); 365 121 … … 377 133 TPRINTF("Single precision sin failed " 378 134 "(%f != %lf, arg %u)\n", res, results_sin[i], i); 379 fail = true;380 }381 }382 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 135 fail = true; 460 136 } -
uspace/lib/math/Makefile
rb2acdf32 r184ff675 34 34 35 35 SOURCES = \ 36 generic/ceil.c \37 generic/cosh.c \38 generic/exp.c \39 generic/fabs.c \40 generic/floor.c \41 36 generic/fmod.c \ 42 generic/frexp.c \43 generic/ldexp.c \44 generic/log.c \45 generic/log10.c \46 generic/log2.c \47 generic/modf.c \48 generic/pow.c \49 generic/sinh.c \50 generic/sqrt.c \51 generic/tan.c \52 generic/tanh.c \53 37 generic/trig.c \ 54 38 generic/trunc.c -
uspace/lib/math/include/math.h
rb2acdf32 r184ff675 37 37 #define LIBMATH_MATH_H_ 38 38 39 #include <ceil.h>40 #include <cosh.h>41 #include <exp.h>42 #include <fabs.h>43 #include <floor.h>44 39 #include <fmod.h> 45 #include <frexp.h>46 #include <ldexp.h>47 #include <log.h>48 #include <log10.h>49 #include <log2.h>50 #include <mathtypes.h>51 #include <modf.h>52 #include <pow.h>53 #include <sinh.h>54 #include <sqrt.h>55 #include <tan.h>56 #include <tanh.h>57 40 #include <trig.h> 58 41 #include <trunc.h> 59 42 60 43 #define HUGE_VAL FLOAT64_INF 61 62 static inline float64_t ceil_f64(float64_t val)63 {64 return float64_ceil(val);65 }66 67 static inline float32_t ceil_f32(float32_t val)68 {69 return float32_ceil(val);70 }71 44 72 45 static inline float64_t cos_f64(float64_t val) … … 80 53 } 81 54 82 static inline float64_t cosh_f64(float64_t val)83 {84 return float64_cosh(val);85 }86 87 static inline float32_t cosh_f32(float32_t val)88 {89 return float32_cosh(val);90 }91 92 static inline float64_t exp_f64(float64_t val)93 {94 return float64_exp(val);95 }96 97 static inline float32_t exp_f32(float32_t val)98 {99 return float32_exp(val);100 }101 102 static inline float64_t fabs_f64(float64_t val)103 {104 return float64_fabs(val);105 }106 107 static inline float32_t fabs_f32(float32_t val)108 {109 return float32_fabs(val);110 }111 112 static inline float64_t floor_f64(float64_t val)113 {114 return float64_floor(val);115 }116 117 static inline float32_t floor_f32(float32_t val)118 {119 return float32_floor(val);120 }121 55 static inline float64_t fmod_f64(float64_t dividend, float64_t divisor) 122 56 { … … 127 61 { 128 62 return float32_fmod(dividend, divisor); 129 }130 131 static inline float64_t frexp_f64(float64_t x, int *exp)132 {133 return float64_frexp(x, exp);134 }135 136 static inline float64_t frexp_f32(float32_t x, int *exp)137 {138 return float32_frexp(x, exp);139 }140 141 static inline float64_t ldexp_f64(float64_t x, int exp)142 {143 return float64_ldexp(x, exp);144 }145 146 static inline float64_t ldexp_f32(float32_t x, int exp)147 {148 return float32_ldexp(x, exp);149 }150 151 static inline float64_t log_f64(float64_t val)152 {153 return float64_log(val);154 }155 156 static inline float32_t log_f32(float32_t val)157 {158 return float32_log(val);159 }160 161 static inline float64_t log10_f64(float64_t val)162 {163 return float64_log10(val);164 }165 166 static inline float32_t log10_f32(float32_t val)167 {168 return float32_log10(val);169 }170 171 static inline float32_t log2_f32(float32_t val)172 {173 return float32_log2(val);174 }175 176 static inline float64_t log2_f64(float64_t val)177 {178 return float64_log2(val);179 }180 181 static inline float64_t modf_f64(float64_t value, float64_t *iptr)182 {183 return float64_modf(value, iptr);184 }185 186 static inline float64_t modf_f32(float32_t value, float32_t *iptr)187 {188 return float32_modf(value, iptr);189 }190 191 static inline float64_t pow_f64(float64_t x, float64_t y)192 {193 return float64_pow(x, y);194 }195 196 static inline float32_t pow_f32(float32_t x, float32_t y)197 {198 return float32_pow(x, y);199 63 } 200 64 … … 209 73 } 210 74 211 static inline float64_t sinh_f64(float64_t val)212 {213 return float64_sinh(val);214 }215 216 static inline float32_t sinh_f32(float32_t val)217 {218 return float32_sinh(val);219 }220 221 static inline float64_t sqrt_f64(float64_t val)222 {223 return float64_sqrt(val);224 }225 226 static inline float32_t sqrt_f32(float32_t val)227 {228 return float32_sqrt(val);229 }230 231 static inline float64_t tan_f64(float64_t val)232 {233 return float64_tan(val);234 }235 236 static inline float32_t tan_f32(float32_t val)237 {238 return float32_tan(val);239 }240 241 static inline float64_t tanh_f64(float64_t val)242 {243 return float64_tanh(val);244 }245 246 static inline float32_t tanh_f32(float32_t val)247 {248 return float32_tanh(val);249 }250 251 75 static inline float64_t trunc_f64(float64_t val) 252 76 { … … 257 81 { 258 82 return float32_trunc(val); 259 }260 261 static inline float64_t ceil(float64_t val)262 {263 return ceil_f64(val);264 }265 266 static inline float32_t ceilf(float32_t val)267 {268 return ceil_f32(val);269 83 } 270 84 … … 279 93 } 280 94 281 static inline float64_t cosh(float64_t val)282 {283 return cosh_f64(val);284 }285 286 static inline float32_t coshf(float32_t val)287 {288 return cosh_f32(val);289 }290 291 static inline float64_t exp(float64_t val)292 {293 return exp_f64(val);294 }295 296 static inline float32_t expf(float32_t val)297 {298 return exp_f32(val);299 }300 301 static inline float64_t fabs(float64_t val)302 {303 return fabs_f64(val);304 }305 306 static inline float32_t fabsf(float32_t val)307 {308 return fabs_f32(val);309 }310 311 static inline float64_t floor(float64_t val)312 {313 return floor_f64(val);314 }315 316 static inline float32_t floorf(float32_t val)317 {318 return floor_f32(val);319 }320 321 95 static inline float64_t fmod(float64_t dividend, float64_t divisor) 322 96 { … … 329 103 } 330 104 331 static inline float64_t frexp(float64_t x, int *exp)332 {333 return frexp_f64(x, exp);334 }335 336 static inline float32_t frexpf(float32_t x, int *exp)337 {338 return frexp_f32(x, exp);339 }340 341 static inline float64_t ldexp(float64_t x, int exp)342 {343 return ldexp_f64(x, exp);344 }345 346 static inline float32_t ldexpf(float32_t x, int exp)347 {348 return ldexp_f32(x, exp);349 }350 351 static inline float64_t log(float64_t val)352 {353 return log_f64(val);354 }355 356 static inline float32_t logf(float32_t val)357 {358 return log_f32(val);359 }360 361 static inline float64_t log10(float64_t val)362 {363 return log10_f64(val);364 }365 366 static inline float32_t log10f(float32_t val)367 {368 return log10_f32(val);369 }370 371 static inline float64_t log2(float64_t val)372 {373 return log2_f64(val);374 }375 376 static inline float32_t log2f(float32_t val)377 {378 return log2_f32(val);379 }380 381 static inline float64_t modf(float64_t value, float64_t *iptr)382 {383 return modf_f64(value, iptr);384 }385 386 static inline float32_t modff(float32_t value, float32_t *iptr)387 {388 return modf_f32(value, iptr);389 }390 391 static inline float64_t pow(float64_t x, float64_t y)392 {393 return pow_f64(x, y);394 }395 396 static inline float32_t powf(float32_t x, float32_t y)397 {398 return pow_f32(x, y);399 }400 401 105 static inline float64_t sin(float64_t val) 402 106 { … … 407 111 { 408 112 return sin_f32(val); 409 }410 411 static inline float64_t sinh(float64_t val)412 {413 return sinh_f64(val);414 }415 416 static inline float32_t sinhf(float32_t val)417 {418 return sinh_f32(val);419 }420 421 static inline float64_t sqrt(float64_t val)422 {423 return sqrt_f64(val);424 }425 426 static inline float32_t sqrtf(float32_t val)427 {428 return sqrt_f32(val);429 }430 431 static inline float64_t tan(float64_t val)432 {433 return tan_f64(val);434 }435 436 static inline float32_t tanf(float32_t val)437 {438 return tan_f32(val);439 }440 441 static inline float64_t tanh(float64_t val)442 {443 return tanh_f64(val);444 }445 446 static inline float32_t tanhf(float32_t val)447 {448 return tanh_f32(val);449 113 } 450 114
Note:
See TracChangeset
for help on using the changeset viewer.