Changeset ff381a7 in mainline for uspace/lib/math/generic/pow.c


Ignore:
Timestamp:
2015-11-02T20:54:19Z (8 years ago)
Author:
Jiri Svoboda <jiri@…>
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.
Message:

Merge mainline changes.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/math/generic/pow.c

    r3feeab2 rff381a7  
    11/*
     2 * Copyright (c) 2015 Jiri Svoboda
    23 * Copyright (c) 2014 Martin Decky
    34 * All rights reserved.
     
    3435
    3536#include <math.h>
    36 #include <mod.h>
     37#include <pow.h>
    3738
    38 /** Double precision modulo
     39/** Single precision power
    3940 *
    40  * Calculate the modulo of dividend by divisor.
     41 * Compute power value.
    4142 *
    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
    4745 *
    48  * @param dividend Dividend.
    49  * @param divisor  Divisor.
    50  *
    51  * @return Modulo.
     46 * @return Cosine value.
    5247 *
    5348 */
    54 float64_t float64_mod(float64_t dividend, float64_t divisor)
     49float32_t float32_pow(float32_t x, float32_t y)
    5550{
    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 */
     65float64_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);
    6169}
    6270
Note: See TracChangeset for help on using the changeset viewer.