Changeset c0c38c7c in mainline for uspace/lib/math/generic/trig.c


Ignore:
Timestamp:
2015-03-14T21:36:44Z (9 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7f9d97f3
Parents:
2c7fdaa
Message:

software floating point overhaul
use proper type mapping
fix cosine calculation

File:
1 edited

Legend:

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

    r2c7fdaa rc0c38c7c  
    3939
    4040/** Precomputed values for factorial (starting from 1!) */
    41 static double factorials[TAYLOR_DEGREE] = {
     41static float64_t factorials[TAYLOR_DEGREE] = {
    4242        1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800,
    4343        479001600, 6227020800
     
    5656 *
    5757 */
    58 static double taylor_sin(double arg)
    59 {
    60         double ret = 0;
    61         double nom = 1;
     58static float64_t taylor_sin(float64_t arg)
     59{
     60        float64_t ret = 0;
     61        float64_t nom = 1;
    6262       
    6363        for (unsigned int i = 0; i < TAYLOR_DEGREE; i++) {
     
    8585 *
    8686 */
    87 static double taylor_cos(double arg)
    88 {
    89         double ret = 1;
    90         double nom = 1;
     87static float64_t taylor_cos(float64_t arg)
     88{
     89        float64_t ret = 1;
     90        float64_t nom = 1;
    9191       
    9292        for (unsigned int i = 0; i < TAYLOR_DEGREE; i++) {
     
    114114 *
    115115 */
    116 static double base_sin(double arg)
     116static float64_t base_sin(float64_t arg)
    117117{
    118118        unsigned int period = arg / (M_PI / 4);
     
    147147 *
    148148 */
    149 static double base_cos(double arg)
     149static float64_t base_cos(float64_t arg)
    150150{
    151151        unsigned int period = arg / (M_PI / 4);
     
    156156        case 1:
    157157        case 2:
    158                 return taylor_sin(arg - M_PI / 2);
     158                return -taylor_sin(arg - M_PI / 2);
    159159        case 3:
    160160        case 4:
     
    162162        case 5:
    163163        case 6:
    164                 return -taylor_sin(arg - 3 * M_PI / 2);
     164                return taylor_sin(arg - 3 * M_PI / 2);
    165165        default:
    166166                return taylor_cos(arg - 2 * M_PI);
     
    177177 *
    178178 */
    179 double double_sin(double arg)
    180 {
    181         double base_arg = fmod(arg, 2 * M_PI);
     179float64_t float64_sin(float64_t arg)
     180{
     181        float64_t base_arg = fmod(arg, 2 * M_PI);
    182182       
    183183        if (base_arg < 0)
     
    196196 *
    197197 */
    198 double double_cos(double arg)
    199 {
    200         double base_arg = fmod(arg, 2 * M_PI);
     198float64_t float64_cos(float64_t arg)
     199{
     200        float64_t base_arg = fmod(arg, 2 * M_PI);
    201201       
    202202        if (base_arg < 0)
Note: See TracChangeset for help on using the changeset viewer.