Changeset 8565a42 in mainline for uspace/lib/math/generic


Ignore:
Timestamp:
2018-03-02T20:34:50Z (8 years ago)
Author:
GitHub <noreply@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a1a81f69, d5e5fd1
Parents:
3061bc1 (diff), 34e1206 (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.
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:34:50)
git-committer:
GitHub <noreply@…> (2018-03-02 20:34:50)
Message:

Remove all trailing whitespace, everywhere.

See individual commit messages for details.

Location:
uspace/lib/math/generic
Files:
9 edited

Legend:

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

    r3061bc1 r8565a42  
    4949{
    5050        float32_t aval;
    51        
     51
    5252        if (arg < -1.0 || arg > 1.0) {
    5353                errno = EDOM;
    5454                return FLOAT32_NAN;
    5555        }
    56        
     56
    5757        aval = 2.0 * atan_f32(arg / (1.0 + sqrt_f32(1.0 - arg*arg)));
    5858        if (arg > 0.0)
     
    7474{
    7575        float64_t aval;
    76        
     76
    7777        if (arg < -1.0 || arg > 1.0) {
    7878                errno = EDOM;
    7979                return FLOAT64_NAN;
    8080        }
    81        
     81
    8282        aval = 2.0 * atan_f64(arg / (1.0 + sqrt_f64(1.0 - arg*arg)));
    8383        if (arg > 0.0)
  • uspace/lib/math/generic/atan.c

    r3061bc1 r8565a42  
    5454        float32_t sum = 0;
    5555        float32_t a = arg / (1.0 + arg * arg);
    56        
     56
    5757        /*
    5858         * atan(z) = sum(n=0, +inf) [ (2^2n) * (n!)^2 / (2n + 1)! *
    5959         *    z^(2n+1) / (1 + z^2)^(n+1) ]
    6060         */
    61        
     61
    6262        for (unsigned int n = 0; n < SERIES_DEGREE_32; n++) {
    6363                if (n > 0) {
     
    6868                a = a * 4.0 * arg * arg / (1.0 + arg * arg);
    6969        }
    70        
     70
    7171        return sum;
    7272}
     
    8686        float64_t sum = 0;
    8787        float64_t a = arg / (1.0 + arg * arg);
    88        
     88
    8989        /*
    9090         * atan(z) = sum(n=0, +inf) [ (2^2n) * (n!)^2 / (2n + 1)! *
    9191         *    z^(2n+1) / (1 + z^2)^(n+1) ]
    9292         */
    93        
     93
    9494        for (unsigned int n = 0; n < SERIES_DEGREE_64; n++) {
    9595                if (n > 0) {
     
    100100                a = a * 4.0 * arg * arg / (1.0 + arg * arg);
    101101        }
    102        
     102
    103103        return sum;
    104104}
  • uspace/lib/math/generic/ceil.c

    r3061bc1 r8565a42  
    4848        float32_u v;
    4949        float32_u r;
    50        
     50
    5151        v.val = val;
    5252        t.val = trunc_f32(val);
    53        
     53
    5454        if (v.data.parts.sign == 1 || val == t.val) {
    5555                r = t;
     
    5757                r.val = t.val + 1.0;
    5858        }
    59        
     59
    6060        return r.val;
    6161}
     
    7272        float64_u v;
    7373        float64_u r;
    74        
     74
    7575        v.val = val;
    7676        t.val = trunc_f64(val);
    77        
     77
    7878        if (v.data.parts.sign == 1 || val == t.val) {
    7979                r = t;
     
    8181                r.val = t.val + 1.0;
    8282        }
    83        
     83
    8484        return r.val;
    8585}
  • uspace/lib/math/generic/exp.c

    r3061bc1 r8565a42  
    6464        float32_t ret = 1;
    6565        float32_t nom = 1;
    66        
     66
    6767        for (unsigned int i = 0; i < TAYLOR_DEGREE_32; i++) {
    6868                nom *= arg;
    6969                ret += nom / factorials[i];
    7070        }
    71        
     71
    7272        return ret;
    7373}
     
    8989        float64_t ret = 1;
    9090        float64_t nom = 1;
    91        
     91
    9292        for (unsigned int i = 0; i < TAYLOR_DEGREE_64; i++) {
    9393                nom *= arg;
    9494                ret += nom / factorials[i];
    9595        }
    96        
     96
    9797        return ret;
    9898}
  • uspace/lib/math/generic/floor.c

    r3061bc1 r8565a42  
    4848        float32_t t;
    4949        float32_u v;
    50        
     50
    5151        v.val = val;
    5252        t = trunc_f32(val);
    53        
     53
    5454        if (v.data.parts.sign == 0 || val == t)
    5555                return t;
     
    6969        float64_t t;
    7070        float64_u v;
    71        
     71
    7272        v.val = val;
    7373        t = trunc_f64(val);
    74        
     74
    7575        if (v.data.parts.sign == 0 || val == t)
    7676                return t;
  • uspace/lib/math/generic/fmod.c

    r3061bc1 r8565a42  
    5555{
    5656        // FIXME: replace with exact arithmetics
    57        
     57
    5858        float32_t quotient = trunc_f32(dividend / divisor);
    59        
     59
    6060        return (dividend - quotient * divisor);
    6161}
     
    8080{
    8181        // FIXME: replace with exact arithmetics
    82        
     82
    8383        float64_t quotient = trunc_f64(dividend / divisor);
    84        
     84
    8585        return (dividend - quotient * divisor);
    8686}
  • uspace/lib/math/generic/log.c

    r3061bc1 r8565a42  
    5555        float32_t ret = 0;
    5656        float32_t num = 1;
    57        
     57
    5858        for (unsigned int i = 1; i <= TAYLOR_DEGREE_32; i++) {
    5959                num *= arg;
    60                
     60
    6161                if ((i % 2) == 0)
    6262                        ret += num / i;
     
    6464                        ret -= num / i;
    6565        }
    66        
     66
    6767        return ret;
    6868}
     
    8383        float64_t ret = 0;
    8484        float64_t num = 1;
    85        
     85
    8686        for (unsigned int i = 1; i <= TAYLOR_DEGREE_64; i++) {
    8787                num *= arg;
    88                
     88
    8989                if ((i % 2) == 0)
    9090                        ret += num / i;
     
    9292                        ret -= num / i;
    9393        }
    94        
     94
    9595        return ret;
    9696}
     
    107107        float32_u m;
    108108        int e;
    109        
     109
    110110        m.val = arg;
    111111        /*
     
    118118        e = m.data.parts.exp - (FLOAT32_BIAS - 1);
    119119        m.data.parts.exp = FLOAT32_BIAS - 1;
    120        
     120
    121121        /*
    122122         * arg = m * 2^e ; log(arg) = log(m) + log(2^e) =
     
    137137        float64_u m;
    138138        int e;
    139        
     139
    140140        m.val = arg;
    141        
     141
    142142        /*
    143143         * Factor arg into m * 2^e where m has exponent -1,
     
    149149        e = m.data.parts.exp - (FLOAT64_BIAS - 1);
    150150        m.data.parts.exp = FLOAT64_BIAS - 1;
    151        
     151
    152152        /*
    153153         * arg = m * 2^e ; log(arg) = log(m) + log(2^e) =
  • uspace/lib/math/generic/trig.c

    r3061bc1 r8565a42  
    6464        float32_t ret = 0;
    6565        float32_t nom = 1;
    66        
     66
    6767        for (unsigned int i = 0; i < TAYLOR_DEGREE_32; i++) {
    6868                nom *= arg;
    69                
     69
    7070                if ((i % 4) == 0)
    7171                        ret += nom / factorials[i];
     
    7373                        ret -= nom / factorials[i];
    7474        }
    75        
     75
    7676        return ret;
    7777}
     
    9393        float64_t ret = 0;
    9494        float64_t nom = 1;
    95        
     95
    9696        for (unsigned int i = 0; i < TAYLOR_DEGREE_64; i++) {
    9797                nom *= arg;
    98                
     98
    9999                if ((i % 4) == 0)
    100100                        ret += nom / factorials[i];
     
    102102                        ret -= nom / factorials[i];
    103103        }
    104        
     104
    105105        return ret;
    106106}
     
    122122        float32_t ret = 1;
    123123        float32_t nom = 1;
    124        
     124
    125125        for (unsigned int i = 0; i < TAYLOR_DEGREE_32; i++) {
    126126                nom *= arg;
    127                
     127
    128128                if ((i % 4) == 1)
    129129                        ret -= nom / factorials[i];
     
    131131                        ret += nom / factorials[i];
    132132        }
    133        
     133
    134134        return ret;
    135135}
     
    151151        float64_t ret = 1;
    152152        float64_t nom = 1;
    153        
     153
    154154        for (unsigned int i = 0; i < TAYLOR_DEGREE_64; i++) {
    155155                nom *= arg;
    156                
     156
    157157                if ((i % 4) == 1)
    158158                        ret -= nom / factorials[i];
     
    160160                        ret += nom / factorials[i];
    161161        }
    162        
     162
    163163        return ret;
    164164}
     
    179179{
    180180        unsigned int period = arg / (M_PI / 4);
    181        
     181
    182182        switch (period) {
    183183        case 0:
     
    212212{
    213213        unsigned int period = arg / (M_PI / 4);
    214        
     214
    215215        switch (period) {
    216216        case 0:
     
    245245{
    246246        unsigned int period = arg / (M_PI / 4);
    247        
     247
    248248        switch (period) {
    249249        case 0:
     
    278278{
    279279        unsigned int period = arg / (M_PI / 4);
    280        
     280
    281281        switch (period) {
    282282        case 0:
     
    308308{
    309309        float32_t base_arg = fmod_f32(arg, 2 * M_PI);
    310        
     310
    311311        if (base_arg < 0)
    312312                return -base_sin_32(-base_arg);
    313        
     313
    314314        return base_sin_32(base_arg);
    315315}
     
    327327{
    328328        float64_t base_arg = fmod_f64(arg, 2 * M_PI);
    329        
     329
    330330        if (base_arg < 0)
    331331                return -base_sin_64(-base_arg);
    332        
     332
    333333        return base_sin_64(base_arg);
    334334}
     
    346346{
    347347        float32_t base_arg = fmod_f32(arg, 2 * M_PI);
    348        
     348
    349349        if (base_arg < 0)
    350350                return base_cos_32(-base_arg);
    351        
     351
    352352        return base_cos_32(base_arg);
    353353}
     
    365365{
    366366        float64_t base_arg = fmod_f64(arg, 2 * M_PI);
    367        
     367
    368368        if (base_arg < 0)
    369369                return base_cos_64(-base_arg);
    370        
     370
    371371        return base_cos_64(base_arg);
    372372}
  • uspace/lib/math/generic/trunc.c

    r3061bc1 r8565a42  
    5656        float32_u v;
    5757        int32_t exp;
    58        
     58
    5959        v.val = val;
    6060        exp = v.data.parts.exp - FLOAT32_BIAS;
    61        
     61
    6262        if (exp < 0) {
    6363                /* -1 < val < 1 => result is +0 or -0 */
     
    6969                        // FIXME TODO
    7070                }
    71                
     71
    7272                /* All bits in val are relevant for the result */
    7373        } else {
     
    7575                v.data.parts.fraction &= ~(UINT32_C(0x007fffff) >> exp);
    7676        }
    77        
     77
    7878        return v.val;
    7979}
     
    9898        float64_u v;
    9999        int32_t exp;
    100        
     100
    101101        v.val = val;
    102102        exp = v.data.parts.exp - FLOAT64_BIAS;
    103        
     103
    104104        if (exp < 0) {
    105105                /* -1 < val < 1 => result is +0 or -0 */
     
    111111                        // FIXME TODO
    112112                }
    113                
     113
    114114                /* All bits in val are relevant for the result */
    115115        } else {
     
    117117                v.data.parts.fraction &= ~(UINT64_C(0x000fffffffffffff) >> exp);
    118118        }
    119        
     119
    120120        return v.val;
    121121}
Note: See TracChangeset for help on using the changeset viewer.