HPM SDK
HPMicro Software Development Kit
hpm_mcl_math.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023 HPMicro
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 #ifndef HPM_MCL_MATH_H
8 #define HPM_MCL_MATH_H
9 #include "hpm_mcl_cfg.h"
10 
11 #ifndef HPM_MCL_MATH_HARDWARE_ACC
12 #include <math.h>
13 #endif
18 #define MCL_FLOAT_IS_ZERO(val) ((val < 0.000001f) && (val > -0.000001f))
19 #define MCL_FLOAT_IS_INFINITY(val) ((val == INFINITY) || (val == -INFINITY))
20 
21 #define SQRT3 (1.7320508075688773f)
22 #define SQRT3_DIV3 (0.5773502691896258f)
23 #define MCL_SUM_OF_SQUARE_MODE(a, b) sqrtf((float)((a * a) + (b * b)))
24 
29 #ifndef HPM_MCL_Q_EN
30 typedef float hpm_mcl_type_t;
31 #define MCL_MATH_IS_ZERO(x) MCL_FLOAT_IS_ZERO((x))
32 #define MCL_MATH_CONVERT_FLOAT(x) (x)
33 #else
34 typedef int32_t hpm_mcl_type_t;
35 #define MCL_MATH_IS_ZERO(x) (x == 0)
36 #define MCL_MATH_CONVERT_FLOAT(x) (x)
37 #endif
38 
39 #endif
float hpm_mcl_type_t
Enable Q format.
Definition: hpm_mcl_math.h:30