Changeset ff381a7 in mainline for uspace/lib/math/generic/pow.c
- Timestamp:
- 2015-11-02T20:54:19Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d8513177
- Parents:
- 3feeab2 (diff), 5265eea4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/math/generic/pow.c
r3feeab2 rff381a7 1 1 /* 2 * Copyright (c) 2015 Jiri Svoboda 2 3 * Copyright (c) 2014 Martin Decky 3 4 * All rights reserved. … … 34 35 35 36 #include <math.h> 36 #include < mod.h>37 #include <pow.h> 37 38 38 /** Double precision modulo39 /** Single precision power 39 40 * 40 * C alculate the modulo of dividend by divisor.41 * Compute power value. 41 42 * 42 * This is a very basic implementation that uses 43 * division and multiplication (instead of exact 44 * arithmetics). Thus the result might be very 45 * imprecise (depending on the magnitude of the 46 * arguments). 43 * @param x Base 44 * @param y Exponent 47 45 * 48 * @param dividend Dividend. 49 * @param divisor Divisor. 50 * 51 * @return Modulo. 46 * @return Cosine value. 52 47 * 53 48 */ 54 float 64_t float64_mod(float64_t dividend, float64_t divisor)49 float32_t float32_pow(float32_t x, float32_t y) 55 50 { 56 // FIXME: replace with exact arithmetics 57 58 float64_t quotient = trunc(dividend / divisor); 59 60 return (dividend - quotient * divisor); 51 /* x^y = (e ^ log(x))^y = e ^ (log(x) * y) */ 52 return exp_f32(log_f32(x) * y); 53 } 54 55 /** Double precision power 56 * 57 * Compute power value. 58 * 59 * @param x Base 60 * @param y Exponent 61 * 62 * @return Cosine value. 63 * 64 */ 65 float64_t float64_pow(float64_t x, float64_t y) 66 { 67 /* x^y = (e ^ log(x))^y = e ^ (log(x) * y) */ 68 return exp_f64(log_f64(x) * y); 61 69 } 62 70
Note:
See TracChangeset
for help on using the changeset viewer.