spandsp  0.0.6
math_fixed.h
1 /*
2  * SpanDSP - a series of DSP components for telephony
3  *
4  * math_fixed.h
5  *
6  * Written by Steve Underwood <steveu@coppice.org>
7  *
8  * Copyright (C) 2010 Steve Underwood
9  *
10  * All rights reserved.
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU Lesser General Public License version 2.1,
14  * as published by the Free Software Foundation.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public
22  * License along with this program; if not, write to the Free Software
23  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24  */
25 
26 #if !defined(_MATH_FIXED_H_)
27 #define _MATH_FIXED_H_
28 
29 /*! \page math_fixed_page Fixed point math functions
30 
31 \section math_fixed_page_sec_1 What does it do?
32 
33 \section math_fixed_page_sec_2 How does it work?
34 */
35 
36 #if defined(__cplusplus)
37 extern "C"
38 {
39 #endif
40 
41 #if defined(SPANDSP_USE_FIXED_POINT)
42 SPAN_DECLARE(uint16_t) sqrtu32_u16(uint32_t x);
43 #endif
44 
45 SPAN_DECLARE(uint16_t) fixed_reciprocal16(uint16_t x, int *shift);
46 
47 SPAN_DECLARE(uint16_t) fixed_divide16(uint16_t y, uint16_t x);
48 
49 SPAN_DECLARE(uint16_t) fixed_divide32(uint32_t y, uint16_t x);
50 
51 SPAN_DECLARE(int16_t) fixed_log10_16(uint16_t x);
52 
53 SPAN_DECLARE(int32_t) fixed_log10_32(uint32_t x);
54 
55 SPAN_DECLARE(uint16_t) fixed_sqrt16(uint16_t x);
56 
57 SPAN_DECLARE(uint16_t) fixed_sqrt32(uint32_t x);
58 
59 /*! Evaluate an approximate 16 bit fixed point sine.
60  \brief Evaluate an approximate 16 bit fixed point sine.
61  \param x A 16 bit unsigned angle, in 360/65536 degree steps.
62  \return sin(x)*32767. */
63 SPAN_DECLARE(int16_t) fixed_sin(uint16_t x);
64 
65 /*! Evaluate an approximate 16 bit fixed point cosine.
66  \brief Evaluate an approximate 16 bit fixed point cosine.
67  \param x A 16 bit unsigned angle, in 360/65536 degree steps.
68  \return cos(x)*32767. */
69 SPAN_DECLARE(int16_t) fixed_cos(uint16_t x);
70 
71 /*! Evaluate an approximate 16 bit fixed point sine.
72  \brief Evaluate an approximate 16 bit fixed point sine.
73  \param y .
74  \param x .
75  \return The 16 bit unsigned angle, in 360/65536 degree steps. */
76 SPAN_DECLARE(uint16_t) fixed_atan2(int16_t y, int16_t x);
77 
78 #if defined(__cplusplus)
79 }
80 #endif
81 
82 #endif
83 /*- End of file ------------------------------------------------------------*/
uint16_t fixed_atan2(int16_t y, int16_t x)
Evaluate an approximate 16 bit fixed point sine.
Definition: math_fixed.c:214
int16_t fixed_sin(uint16_t x)
Evaluate an approximate 16 bit fixed point sine.
Definition: math_fixed.c:163
int16_t fixed_cos(uint16_t x)
Evaluate an approximate 16 bit fixed point cosine.
Definition: math_fixed.c:188