From 1846fbab1bde9fa16d8bdac8a93fa4c06d06f9ee Mon Sep 17 00:00:00 2001 From: Lamdonn Date: Thu, 13 Mar 2025 00:04:42 +0800 Subject: [PATCH] Add flmath readme, update some module versions --- README.en.md | 9 ++++---- README.md | 9 ++++---- doc/flmath.en.md | 31 +++++++++++++++++++++++++ doc/flmath.md | 30 +++++++++++++++++++++++++ release.txt | 10 +++++++++ source/07_math/flmath.c | 2 +- source/07_math/flmath.h | 2 +- source/07_math/floatl.c | 45 +------------------------------------ source/07_math/floatl.h | 6 ++--- source/07_math/floatl_cfg.h | 2 +- 10 files changed, 87 insertions(+), 59 deletions(-) create mode 100644 doc/flmath.en.md create mode 100644 doc/flmath.md diff --git a/README.en.md b/README.en.md index e5275b6..7e80333 100644 --- a/README.en.md +++ b/README.en.md @@ -2,7 +2,7 @@ ![logo](/image/logo.png) -[![Version](https://img.shields.io/badge/version-0.3.1-blue.svg)](https://gitee.com/Lamdonn/varch) +[![Version](https://img.shields.io/badge/version-0.3.2-blue.svg)](https://gitee.com/Lamdonn/varch) [![License](https://img.shields.io/badge/license-GPL%202.0-brightgreen.svg)](LICENSE) [![Author](https://img.shields.io/badge/author-Lamdonn%20%20%20%20%20-brightblue.svg)](Lamdonn@163.com) ![Supported Platforms](https://img.shields.io/badge/platform-Linux%20&%20MinGW-yellow.svg) @@ -18,7 +18,7 @@ It has the characteristics of **simplicity, universality, and efficiency**, with | module | version | usage | path | describe | |:-------------|:---------|:-----------------------------|:------------------------------------------|:--------------------------------------| -| overall | 00.03.01 | [link](README.en.md) | [path](./) | Overall +| overall | 00.03.02 | [link](README.en.md) | [path](./) | Overall | init | 01.00.00 | [link](/doc/init.en.md) | [path](./source/00_application) | Initialize export module | console | 01.00.01 | [link](/doc/console.en.md) | [path](./source/00_application/console) | Console command input, combined with the 'command' module, parsing commands entered in the console | arg | 01.00.00 | [link](/doc/arg.en.md) | [path](./source/01_general) | Indefinite parameters, obtain the number of indefinite parameters and specified parameters @@ -72,8 +72,9 @@ It has the characteristics of **simplicity, universality, and efficiency**, with | romt | 01.00.00 | [link](/doc/romt.en.md) | [path](./source/06_performance) | ROM test module | cpul | 01.00.00 | [link](/doc/cpul.en.md) | [path](./source/06_performance) | CPU load test module, including obtaining and increasing load | unitt | 01.00.00 | [link](/doc/unitt.en.md) | [path](./source/06_performance) | Simple unit test module -| intl | 01.00.00 | [link](/doc/intl.en.md) | [path](./source/07_math) | Large integer arithmetic module -| floatl | 01.00.00 | [link](/doc/floatl.en.md) | [path](./source/07_math) | Large floating-point arithmetic module +| intl | 01.01.00 | [link](/doc/intl.en.md) | [path](./source/07_math) | Large integer arithmetic module +| floatl | 01.01.00 | [link](/doc/floatl.en.md) | [path](./source/07_math) | Large floating-point arithmetic module +| flmath | 01.00.00 | [link](/doc/flmath.en.md) | [path](./source/07_math) | Large floating-point arithmetic math module ## Usage diff --git a/README.md b/README.md index ad83f50..db97f63 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![logo](/image/logo.png) -[![Version](https://img.shields.io/badge/version-0.3.1-blue.svg)](https://gitee.com/Lamdonn/varch) +[![Version](https://img.shields.io/badge/version-0.3.2-blue.svg)](https://gitee.com/Lamdonn/varch) [![License](https://img.shields.io/badge/license-GPL%202.0-brightgreen.svg)](LICENSE) [![Author](https://img.shields.io/badge/author-Lamdonn%20%20%20%20%20-brightblue.svg)](Lamdonn@163.com) ![Supported Platforms](https://img.shields.io/badge/platform-Linux%20&%20MinGW-yellow.svg) @@ -18,7 +18,7 @@ varch(we-architecture,意为我们的框架库)是嵌入式C语言常用 | module | version | usage | path | describe | |:-------------|:---------|:-----------------------------|:------------------------------------------|:--------------------------------------| -| overall | 00.03.01 | [link](README.md) | [path](./) | 整体 +| overall | 00.03.02 | [link](README.md) | [path](./) | 整体 | init | 01.00.00 | [link](/doc/init.md) | [path](./source/00_application) | 初始化导出模块 | console | 01.00.01 | [link](/doc/console.md) | [path](./source/00_application/console) | 控制台命令输入,结合 `command` 模块,解析在控制台中输入的命令 | arg | 01.00.00 | [link](/doc/arg.md) | [path](./source/01_general) | 不定参数,获取不定参数和指定参数的个数 @@ -72,8 +72,9 @@ varch(we-architecture,意为我们的框架库)是嵌入式C语言常用 | romt | 01.00.00 | [link](/doc/romt.md) | [path](./source/06_performance) | ROM测试模块 | cpul | 01.00.00 | [link](/doc/cpul.md) | [path](./source/06_performance) | CPU负载测试模块,包含获取和增加负载 | unitt | 01.00.00 | [link](/doc/unitt.md) | [path](./source/06_performance) | 简易的单元测试模块 -| intl | 01.00.00 | [link](/doc/intl.md) | [path](./source/07_math) | 大型整数运算模块 -| floatl | 01.00.00 | [link](/doc/floatl.md) | [path](./source/07_math) | 大型浮点数运算模块 +| intl | 01.01.00 | [link](/doc/intl.md) | [path](./source/07_math) | 大型整数运算模块 +| floatl | 01.01.00 | [link](/doc/floatl.md) | [path](./source/07_math) | 大型浮点数运算模块 +| flmath | 01.00.00 | [link](/doc/flmath.md) | [path](./source/07_math) | 大型浮点数数学运算模块 ## 使用说明 diff --git a/doc/flmath.en.md b/doc/flmath.en.md new file mode 100644 index 0000000..3bdea00 --- /dev/null +++ b/doc/flmath.en.md @@ -0,0 +1,31 @@ +## Introduction + +`flmath` is a large floating-point math module that depends on `floatl` and supports common math functions. + +## Interfaces + +### Arithmetic Functions + +```c +floatl floatl_sin(floatl x); +floatl floatl_cos(floatl x); +floatl floatl_sec(floatl x); +floatl floatl_csc(floatl x); +floatl floatl_tan(floatl x); +floatl floatl_exp(floatl x); +floatl floatl_ln(floatl x); +floatl floatl_log(floatl x, floatl y); +floatl floatl_log2(floatl x); +floatl floatl_log10(floatl x); +floatl floatl_sigmoid(floatl x); +floatl floatl_dsigmoid(floatl x); +floatl floatl_sinh(floatl x); +floatl floatl_cosh(floatl x); +floatl floatl_tanh(floatl x); +floatl floatl_coth(floatl x); +floatl floatl_sech(floatl x); +floatl floatl_csch(floatl x); +floatl floatl_sqrt(floatl x); +floatl floatl_pow(floatl x, floatl y); +``` + diff --git a/doc/flmath.md b/doc/flmath.md new file mode 100644 index 0000000..7cc62bc --- /dev/null +++ b/doc/flmath.md @@ -0,0 +1,30 @@ +## 介绍 + +`flmath`为一个大型浮点数数学运算模块,依赖于`floatl`模块,支持常用的数学运算函数。 + +## 接口 + +### 运算函数 + +```c +floatl floatl_sin(floatl x); +floatl floatl_cos(floatl x); +floatl floatl_sec(floatl x); +floatl floatl_csc(floatl x); +floatl floatl_tan(floatl x); +floatl floatl_exp(floatl x); +floatl floatl_ln(floatl x); +floatl floatl_log(floatl x, floatl y); +floatl floatl_log2(floatl x); +floatl floatl_log10(floatl x); +floatl floatl_sigmoid(floatl x); +floatl floatl_dsigmoid(floatl x); +floatl floatl_sinh(floatl x); +floatl floatl_cosh(floatl x); +floatl floatl_tanh(floatl x); +floatl floatl_coth(floatl x); +floatl floatl_sech(floatl x); +floatl floatl_csch(floatl x); +floatl floatl_sqrt(floatl x); +floatl floatl_pow(floatl x, floatl y); +``` diff --git a/release.txt b/release.txt index 6760ffb..70b9e26 100644 --- a/release.txt +++ b/release.txt @@ -1,3 +1,13 @@ +version 0.3.2 +date 2025.03.13 +changes + 1. Add the flmath initial version + 2. Fix floatl print issue + 3. Optimize the configuration code of floatl + +--------------------------------------------------------------------------------------------- +--------------------------------------------------------------------------------------------- + version 0.3.1 date 2025.03.04 changes diff --git a/source/07_math/flmath.c b/source/07_math/flmath.c index 4eb8d64..bad7f18 100644 --- a/source/07_math/flmath.c +++ b/source/07_math/flmath.c @@ -6,7 +6,7 @@ * \unit flmath * \brief This is a simple large float number math calculate module for C language * \author Lamdonn - * \version v1.0.1 + * \version v1.0.0 * \license GPL-2.0 * \copyright Copyright (C) 2023 Lamdonn. ********************************************************************************************************/ diff --git a/source/07_math/flmath.h b/source/07_math/flmath.h index f774ca1..e7c2c9e 100644 --- a/source/07_math/flmath.h +++ b/source/07_math/flmath.h @@ -7,7 +7,7 @@ * \unit flmath * \brief This is a simple large float number math calculate module for C language * \author Lamdonn - * \version v1.0.1 + * \version v1.0.0 * \license GPL-2.0 * \copyright Copyright (C) 2023 Lamdonn. ********************************************************************************************************/ diff --git a/source/07_math/floatl.c b/source/07_math/floatl.c index eb72bde..3b00657 100644 --- a/source/07_math/floatl.c +++ b/source/07_math/floatl.c @@ -6,7 +6,7 @@ * \unit floatl * \brief This is a simple large float number calculate module for C language * \author Lamdonn - * \version v1.0.1 + * \version v1.1.0 * \license GPL-2.0 * \copyright Copyright (C) 2023 Lamdonn. ********************************************************************************************************/ @@ -1687,49 +1687,6 @@ floatl floatl_from(const char *str) return number; } -/** - * \brief Convert a single - precision floating - point number (float) to a 'floatl' type. - * \param[in] value: The single - precision floating - point number to be converted. - * \return A 'floatl' value representing the converted number. Returns FLOATL_NAN if the input is NaN, - * FLOATL_INF if the input is infinity, and the converted value otherwise. - * - * This function takes a float value and converts it to a 'floatl' value. It first checks if the input - * is NaN or infinity and sets the result accordingly. Otherwise, it extracts the mantissa and exponent - * from the float and adjusts them to fit the 'floatl' format. - */ -floatl floatl_from_f(float value) -{ - // Initialize the result to 0 - floatl result = {0}; - // Union to access the float value as an integer and its components - float_u f = {.float_ = value}; - - // Check if the input is NaN - if ((f.int_ & 0x7fffffff) > 0x7f800000) - { - result = FLOATL_NAN; - } - // Check if the input is infinity - else if ((f.int_ & 0x7fffffff) == 0x7f800000) - { - result = FLOATL_INF; - } - else - { - // Extract the mantissa from the float and store it in the 'floatl' mantissa - result.mantissas[0] = f.mantissa; - // Shift the mantissa to the appropriate position in the 'floatl' format - result = floatl_int_shl(result, __FLOATL_MANT_BITS__ - 23); - // Adjust the exponent to fit the 'floatl' format - result.exponent = (uint32_t)(((int32_t)f.exponent - 127) + __FLOATL_EXP_MID_VALUE__); - } - - // Set the sign of the 'floatl' result - result.sign = f.sign; - - return result; -} - /** * \brief Convert a double - precision floating - point number (double) to a 'floatl' type. * \param[in] value: The double - precision floating - point number to be converted. diff --git a/source/07_math/floatl.h b/source/07_math/floatl.h index c642e76..3cc2ddc 100644 --- a/source/07_math/floatl.h +++ b/source/07_math/floatl.h @@ -7,7 +7,7 @@ * \unit floatl * \brief This is a simple large float number calculate module for C language * \author Lamdonn - * \version v1.0.1 + * \version v1.1.0 * \license GPL-2.0 * \copyright Copyright (C) 2023 Lamdonn. ********************************************************************************************************/ @@ -24,7 +24,7 @@ /* Version infomation */ #define FLOATL_V_MAJOR 1 -#define FLOATL_V_MINOR 0 +#define FLOATL_V_MINOR 1 #define FLOATL_V_PATCH 0 /** @@ -150,11 +150,9 @@ floatl floatl_round(floatl a); // Conversion functions // floatl_from: Converts a string to a floatl number -// floatl_from_f: Converts a single-precision floating-point number (float) to a floatl number // floatl_from_d: Converts a double-precision floating-point number (double) to a floatl number floatl floatl_from(const char *str); -floatl floatl_from_f(float value); floatl floatl_from_d(double value); // Output function diff --git a/source/07_math/floatl_cfg.h b/source/07_math/floatl_cfg.h index 735054c..f3f03dc 100644 --- a/source/07_math/floatl_cfg.h +++ b/source/07_math/floatl_cfg.h @@ -7,7 +7,7 @@ * \unit floatl * \brief This is a simple large int number calculate module config header file for C language * \author Lamdonn - * \version v1.0.1 + * \version v1.1.0 * \license GPL-2.0 * \copyright Copyright (C) 2023 Lamdonn. ********************************************************************************************************/