00001 /* 00002 * SpanDSP - a series of DSP components for telephony 00003 * 00004 * math_fixed.h 00005 * 00006 * Written by Steve Underwood <steveu@coppice.org> 00007 * 00008 * Copyright (C) 2010 Steve Underwood 00009 * 00010 * All rights reserved. 00011 * 00012 * This program is free software; you can redistribute it and/or modify 00013 * it under the terms of the GNU Lesser General Public License version 2.1, 00014 * as published by the Free Software Foundation. 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Lesser General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Lesser General Public 00022 * License along with this program; if not, write to the Free Software 00023 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00024 */ 00025 00026 #if !defined(_MATH_FIXED_H_) 00027 #define _MATH_FIXED_H_ 00028 00029 /*! \page math_fixed_page Fixed point math functions 00030 00031 \section math_fixed_page_sec_1 What does it do? 00032 00033 \section math_fixed_page_sec_2 How does it work? 00034 */ 00035 00036 #if defined(__cplusplus) 00037 extern "C" 00038 { 00039 #endif 00040 00041 #if defined(SPANDSP_USE_FIXED_POINT) 00042 SPAN_DECLARE(uint16_t) sqrtu32_u16(uint32_t x); 00043 #endif 00044 00045 SPAN_DECLARE(uint16_t) fixed_reciprocal16(uint16_t x, int *shift); 00046 00047 SPAN_DECLARE(uint16_t) fixed_divide16(uint16_t y, uint16_t x); 00048 00049 SPAN_DECLARE(uint16_t) fixed_divide32(uint32_t y, uint16_t x); 00050 00051 SPAN_DECLARE(int16_t) fixed_log10_16(uint16_t x); 00052 00053 SPAN_DECLARE(int32_t) fixed_log10_32(uint32_t x); 00054 00055 SPAN_DECLARE(uint16_t) fixed_sqrt16(uint16_t x); 00056 00057 SPAN_DECLARE(uint16_t) fixed_sqrt32(uint32_t x); 00058 00059 /*! Evaluate an approximate 16 bit fixed point sine. 00060 \brief Evaluate an approximate 16 bit fixed point sine. 00061 \param x A 16 bit unsigned angle, in 360/65536 degree steps. 00062 \return sin(x)*32767. */ 00063 SPAN_DECLARE(int16_t) fixed_sin(uint16_t x); 00064 00065 /*! Evaluate an approximate 16 bit fixed point cosine. 00066 \brief Evaluate an approximate 16 bit fixed point cosine. 00067 \param x A 16 bit unsigned angle, in 360/65536 degree steps. 00068 \return cos(x)*32767. */ 00069 SPAN_DECLARE(int16_t) fixed_cos(uint16_t x); 00070 00071 /*! Evaluate an approximate 16 bit fixed point sine. 00072 \brief Evaluate an approximate 16 bit fixed point sine. 00073 \param y . 00074 \param x . 00075 \return The 16 bit unsigned angle, in 360/65536 degree steps. */ 00076 SPAN_DECLARE(uint16_t) fixed_atan2(int16_t y, int16_t x); 00077 00078 #if defined(__cplusplus) 00079 } 00080 #endif 00081 00082 #endif 00083 /*- End of file ------------------------------------------------------------*/
1.6.1