blob: a9a046605ea0ff0d34b39a363c604b3fb717e36d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
/**
* @file cordic.hpp
* @brief Provides mathematical functions for algorithms.
*
* Copyright (C) 2023 Clyne Sullivan
*
* Distributed under the GNU GPL v3 or later. You should have received a copy of
* the GNU General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef CORDIC_HPP_
#define CORDIC_HPP_
/**
* Named after the hardware CORDIC peripheral even though software
* implementations may be used.
*/
namespace cordic {
// Provides pi in case cordic functions require it.
constexpr double PI = 3.1415926535L;
/**
* Prepares cordic functions for use.
*/
void init();
// mod - Calculates remainder for given fraction.
// cos, sin, tan - The trig functions.
#if !defined(TARGET_PLATFORM_L4)
double mod(double n, double d);
double cos(double x);
double sin(double x);
double tan(double x);
#else
float mod(float n, float d);
float cos(float x);
float sin(float x);
float tan(float x);
#endif
}
#endif // CORDIC_HPP_
|