source: mainline/uspace/lib/math/arch/amd64/include/libarch/math.h@ 992ffa6

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 992ffa6 was 992ffa6, checked in by Jiri Svoboda <jiri@…>, 10 years ago

Add exp(f), log(f), pow(f). Improve precision of sin, cos.

  • Property mode set to 100644
File size: 2.7 KB
Line 
1/*
2 * Copyright (c) 2014 Martin Decky
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup libmathamd64
30 * @{
31 */
32/** @file
33 */
34
35#ifndef LIBMATH_amd64_MATH_H_
36#define LIBMATH_amd64_MATH_H_
37
38#include <ceil.h>
39#include <exp.h>
40#include <floor.h>
41#include <log.h>
42#include <mathtypes.h>
43#include <mod.h>
44#include <pow.h>
45
46static inline float64_t fmod(float64_t dividend, float64_t divisor)
47{
48 return float64_mod(dividend, divisor);
49}
50
51extern float64_t sin(float64_t);
52extern float64_t cos(float64_t);
53
54static inline float64_t ceil(float64_t val)
55{
56 float64_u arg;
57 arg.val = val;
58
59 float64_u ret;
60 ret.data = ceil_float64(arg.data);
61
62 return ret.val;
63}
64
65static inline float32_t expf(float32_t val)
66{
67 return float32_exp(val);
68}
69
70static inline float64_t exp(float64_t val)
71{
72 return float64_exp(val);
73}
74
75static inline float64_t floor(float64_t val)
76{
77 float64_u arg;
78 arg.val = val;
79
80 float64_u ret;
81 ret.data = floor_float64(arg.data);
82
83 return ret.val;
84}
85
86static inline float32_t logf(float32_t val)
87{
88 return float32_log(val);
89}
90
91static inline float64_t log(float64_t val)
92{
93 return float64_log(val);
94}
95
96static inline float32_t powf(float32_t x, float32_t y)
97{
98 return float32_pow(x, y);
99}
100
101static inline float64_t pow(float64_t x, float64_t y)
102{
103 return float64_pow(x, y);
104}
105
106extern float64_t trunc(float64_t);
107
108#endif
109
110/** @}
111 */
Note: See TracBrowser for help on using the repository browser.