Skip to content

Commit

Permalink
Zhao (#4)
Browse files Browse the repository at this point in the history
* 新增多参数函数表达式计算组件

* update
  • Loading branch information
BeardedManZhao authored Dec 2, 2023
1 parent f05f5d3 commit f39dcb5
Show file tree
Hide file tree
Showing 74 changed files with 2,564 additions and 1,001 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ add_library(
src/core/calculation/BooleanCalculationTwo.cpp include/BooleanCalculationTwo.h
src/core/calculation/FunctionManager.cpp include/FunctionManager.h
src/core/calculation/FunctionFormulaCalculation.cpp include/FunctionFormulaCalculation.h
src/core/calculation/FunctionFormulaCalculationTwo.cpp include/FunctionFormulaCalculationTwo.h
src/core/calculation/CalculationConstant.cpp include/CalculationConstant.h
src/core/calculation/CumulativeCalculation.cpp include/CumulativeCalculation.h
)
src/core/calculation/FastSumOfIntervalsBrackets.cpp include/FastSumOfIntervalsBrackets.h src/core/calculation/SharedCalculation.cpp include/SharedCalculation.h)

48 changes: 46 additions & 2 deletions README-Chinese.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ project(MyCpp)
set(CMAKE_CXX_STANDARD 14)
# 设置头文件目录(可以自定义)
include_directories(${PROJECT_SOURCE_DIR}/head)
include_directories(${PROJECT_SOURCE_DIR}/include)
# 设置库文件目录
add_executable(MyCpp main.cpp)
# 与项目进行链接(将库链接到编译之后的目标中)
target_link_libraries(${PROJECT_NAME} D:\\liming\\Project\\Clion\\MyCpp\\cmake-build-debug\\mathematical_expression_cpp.dll)
target_link_libraries(
${PROJECT_NAME} D:\\liming\\Project\\Clion\\MyCpp\\cmake-build-debug\\mathematical_expression_cpp_WINx64.dll
)
```

集成操作完毕之后,您可以尝试输入以下代码来判断库的功能是否正常,下面是该库的一个测试代码,如果其运行之后的程序main函数返回值为0
Expand Down Expand Up @@ -263,6 +266,47 @@ Active code page: 65001
进程已结束,退出代码0
```

### 快速区间求和计算组件(基于括号表达式)

- 类组件:ME::FastSumOfIntervalsBrackets.py
- 介绍

1.15版本的新产物,区间快速求和组件,是针对一个等差为1的区间进行所有元素求和的快速组件,它将一个区间在逻辑上模拟成为一个数学数列,并通过求和公式进行快速的求和。

该组件实现了共享池计算功能,将检查,计算,以及上一次结果记录实现,能够加快计算速度,具体API调用如下所示。

```c++
#include "mathematical_expression.h"

int main() {
system("chcp 65001");
// 获取到数学表达式解析库对象
mathematical_expression me;
// 获取到区间累加表达式对象
ME::FastSumOfIntervalsBrackets fastSumOfIntervalsBrackets = me.getFastSumOfIntervalsBrackets();
// 准备需要被计算的数学表达式,这里的数学表达式中有个逗号,逗号两边代表的就是区间的两个边界
string f1 = "1 + 10, 20 - (5 + 2)";
// 检查数学表达式
fastSumOfIntervalsBrackets.check(f1);
// 将步长修改为 2
fastSumOfIntervalsBrackets.step = 2;
// 开始计算 并获取到结果对象
ME::CalculationNumberResults r1 = fastSumOfIntervalsBrackets << f1;
// 开始进行结果查看
cout << "计算层数:" << r1.getResultLayers() << "\t计算结果:" << r1 << "\t计算来源:" << r1.getCalculationSourceName()
<< endl;
}
```

- 运行结果 从上面代码中我们可以看到,快速区间求和计算的公式由被逗号分割的两个括号表达式组成

```
Active code page: 65001
计算层数:1 计算结果:24 计算来源:FastSumOfIntervalsBrackets
进程已结束,退出代码0
```

## C++API 特性

在 C++ 中,库具有更快的解析与计算速度,同时其具有更加庞大的功能,接下来针对C++中的特有功能来进行一个说明。
Expand Down
48 changes: 47 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ set(CMAKE_CXX_STANDARD 14)
include_directories(${PROJECT_SOURCE_DIR}/include)
add_executable(MyCpp main.cpp)
# Link to the project (link the library to the compiled target)
target_link_libraries(${PROJECT_NAME} D:\\liming\\Project\\Clion\\MyCpp\\cmake-build-debug\\libmathematical_expression_cpp.dll)
target_link_libraries(
${PROJECT_NAME} D:\\liming\\Project\\Clion\\MyCpp\\cmake-build-debug\\mathematical_expression_cpp_WINx64.dll
)
```

After the integration operation is completed, you can try to enter the following code to determine whether the function
Expand Down Expand Up @@ -286,6 +288,50 @@ Active code page: 65001
进程已结束,退出代码0
```

### Quick interval summation calculation component (based on parenthesis expression)

- Class component: ME:: FastSumOfIntervalsBrackets
- 介绍

The new product of version 1.15, the interval fast sum component, is a fast component that sums all elements of an
interval with an equal difference of 1. It logically simulates an interval into a mathematical sequence and quickly
sums it using a sum formula.

This component implements the shared pool calculation function, which includes checking, calculating, and recording
the previous result, which can accelerate the calculation speed. The specific API calls are as follows.

```c++
#include "mathematical_expression.h"

int main() {
system("chcp 65001");
// 获取到数学表达式解析库对象
mathematical_expression me;
// 获取到区间累加表达式对象
ME::FastSumOfIntervalsBrackets fastSumOfIntervalsBrackets = me.getFastSumOfIntervalsBrackets();
// 准备需要被计算的数学表达式,这里的数学表达式中有个逗号,逗号两边代表的就是区间的两个边界
string f1 = "1 + 10, 20 - (5 + 2)";
// 检查数学表达式
fastSumOfIntervalsBrackets.check(f1);
// 将步长修改为 2
fastSumOfIntervalsBrackets.step = 2;
// 开始计算 并获取到结果对象
ME::CalculationNumberResults r1 = fastSumOfIntervalsBrackets << f1;
// 开始进行结果查看
cout << "计算层数:" << r1.getResultLayers() << "\t计算结果:" << r1 << "\t计算来源:" << r1.getCalculationSourceName()
<< endl;
}
```

- 运行结果 从上面代码中我们可以看到,快速区间求和计算的公式由被逗号分割的两个括号表达式组成

```
Active code page: 65001
计算层数:1 计算结果:24 计算来源:FastSumOfIntervalsBrackets
进程已结束,退出代码0
```

## C++API characteristic

In C++, libraries have faster parsing and computation speeds, while also having larger functionalities. Next, we will
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}
],
"type" : "FILEPATH",
"value" : "D:/liming/CX/Clion/CLion 2022.2.1/bin/mingw/bin/addr2line.exe"
"value" : "D:/Liming/MyApplication/CLion/CLion 2022.2.1/bin/mingw/bin/addr2line.exe"
},
{
"name" : "CMAKE_AR",
Expand All @@ -31,7 +31,7 @@
}
],
"type" : "FILEPATH",
"value" : "D:/liming/CX/Clion/CLion 2022.2.1/bin/mingw/bin/ar.exe"
"value" : "D:/Liming/MyApplication/CLion/CLion 2022.2.1/bin/mingw/bin/ar.exe"
},
{
"name" : "CMAKE_BUILD_TYPE",
Expand All @@ -55,7 +55,7 @@
}
],
"type" : "INTERNAL",
"value" : "d:/MyGithub/mathematical-expression-cpp/cmake-build-debug"
"value" : "g:/MyGithub/mathematical-expression-cpp/cmake-build-debug"
},
{
"name" : "CMAKE_CACHE_MAJOR_VERSION",
Expand Down Expand Up @@ -155,7 +155,7 @@
}
],
"type" : "INTERNAL",
"value" : "D:/liming/CX/Clion/CLion 2022.2.1/bin/cmake/win/bin/cmake.exe"
"value" : "D:/Liming/MyApplication/CLion/CLion 2022.2.1/bin/cmake/win/bin/cmake.exe"
},
{
"name" : "CMAKE_CPACK_COMMAND",
Expand All @@ -167,7 +167,7 @@
}
],
"type" : "INTERNAL",
"value" : "D:/liming/CX/Clion/CLion 2022.2.1/bin/cmake/win/bin/cpack.exe"
"value" : "D:/Liming/MyApplication/CLion/CLion 2022.2.1/bin/cmake/win/bin/cpack.exe"
},
{
"name" : "CMAKE_CTEST_COMMAND",
Expand All @@ -179,7 +179,7 @@
}
],
"type" : "INTERNAL",
"value" : "D:/liming/CX/Clion/CLion 2022.2.1/bin/cmake/win/bin/ctest.exe"
"value" : "D:/Liming/MyApplication/CLion/CLion 2022.2.1/bin/cmake/win/bin/ctest.exe"
},
{
"name" : "CMAKE_CXX_COMPILER",
Expand All @@ -195,7 +195,7 @@
}
],
"type" : "FILEPATH",
"value" : "D:/liming/CX/Clion/CLion 2022.2.1/bin/mingw/bin/g++.exe"
"value" : "D:/Liming/MyApplication/CLion/CLion 2022.2.1/bin/mingw/bin/g++.exe"
},
{
"name" : "CMAKE_CXX_COMPILER_AR",
Expand All @@ -211,7 +211,7 @@
}
],
"type" : "FILEPATH",
"value" : "D:/liming/CX/Clion/CLion 2022.2.1/bin/mingw/bin/gcc-ar.exe"
"value" : "D:/Liming/MyApplication/CLion/CLion 2022.2.1/bin/mingw/bin/gcc-ar.exe"
},
{
"name" : "CMAKE_CXX_COMPILER_RANLIB",
Expand All @@ -227,7 +227,7 @@
}
],
"type" : "FILEPATH",
"value" : "D:/liming/CX/Clion/CLion 2022.2.1/bin/mingw/bin/gcc-ranlib.exe"
"value" : "D:/Liming/MyApplication/CLion/CLion 2022.2.1/bin/mingw/bin/gcc-ranlib.exe"
},
{
"name" : "CMAKE_CXX_FLAGS",
Expand Down Expand Up @@ -339,7 +339,7 @@
}
],
"type" : "FILEPATH",
"value" : "D:/liming/CX/Clion/CLion 2022.2.1/bin/mingw/bin/gcc.exe"
"value" : "D:/Liming/MyApplication/CLion/CLion 2022.2.1/bin/mingw/bin/gcc.exe"
},
{
"name" : "CMAKE_C_COMPILER_AR",
Expand All @@ -355,7 +355,7 @@
}
],
"type" : "FILEPATH",
"value" : "D:/liming/CX/Clion/CLion 2022.2.1/bin/mingw/bin/gcc-ar.exe"
"value" : "D:/Liming/MyApplication/CLion/CLion 2022.2.1/bin/mingw/bin/gcc-ar.exe"
},
{
"name" : "CMAKE_C_COMPILER_RANLIB",
Expand All @@ -371,7 +371,7 @@
}
],
"type" : "FILEPATH",
"value" : "D:/liming/CX/Clion/CLion 2022.2.1/bin/mingw/bin/gcc-ranlib.exe"
"value" : "D:/Liming/MyApplication/CLion/CLion 2022.2.1/bin/mingw/bin/gcc-ranlib.exe"
},
{
"name" : "CMAKE_C_FLAGS",
Expand Down Expand Up @@ -483,7 +483,7 @@
}
],
"type" : "FILEPATH",
"value" : "D:/liming/CX/Clion/CLion 2022.2.1/bin/mingw/bin/dlltool.exe"
"value" : "D:/Liming/MyApplication/CLion/CLion 2022.2.1/bin/mingw/bin/dlltool.exe"
},
{
"name" : "CMAKE_EXECUTABLE_FORMAT",
Expand Down Expand Up @@ -611,7 +611,7 @@
}
],
"type" : "INTERNAL",
"value" : "D:/liming/CX/Clion/CLion 2022.2.1/bin/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++;D:/liming/CX/Clion/CLion 2022.2.1/bin/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/x86_64-w64-mingw32;D:/liming/CX/Clion/CLion 2022.2.1/bin/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/backward;D:/liming/CX/Clion/CLion 2022.2.1/bin/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/include;D:/liming/CX/Clion/CLion 2022.2.1/bin/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../include;D:/liming/CX/Clion/CLion 2022.2.1/bin/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/include-fixed;D:/liming/CX/Clion/CLion 2022.2.1/bin/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/include"
"value" : "D:/Liming/MyApplication/CLion/CLion 2022.2.1/bin/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++;D:/Liming/MyApplication/CLion/CLion 2022.2.1/bin/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/x86_64-w64-mingw32;D:/Liming/MyApplication/CLion/CLion 2022.2.1/bin/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/backward;D:/Liming/MyApplication/CLion/CLion 2022.2.1/bin/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/include;D:/Liming/MyApplication/CLion/CLion 2022.2.1/bin/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../include;D:/Liming/MyApplication/CLion/CLion 2022.2.1/bin/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/include-fixed;D:/Liming/MyApplication/CLion/CLion 2022.2.1/bin/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/include"
},
{
"name" : "CMAKE_EXTRA_GENERATOR_C_SYSTEM_DEFINED_MACROS",
Expand All @@ -635,7 +635,7 @@
}
],
"type" : "INTERNAL",
"value" : "D:/liming/CX/Clion/CLion 2022.2.1/bin/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/include;D:/liming/CX/Clion/CLion 2022.2.1/bin/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../include;D:/liming/CX/Clion/CLion 2022.2.1/bin/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/include-fixed;D:/liming/CX/Clion/CLion 2022.2.1/bin/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/include"
"value" : "D:/Liming/MyApplication/CLion/CLion 2022.2.1/bin/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/include;D:/Liming/MyApplication/CLion/CLion 2022.2.1/bin/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../include;D:/Liming/MyApplication/CLion/CLion 2022.2.1/bin/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/include-fixed;D:/Liming/MyApplication/CLion/CLion 2022.2.1/bin/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/include"
},
{
"name" : "CMAKE_GENERATOR",
Expand Down Expand Up @@ -707,7 +707,7 @@
}
],
"type" : "INTERNAL",
"value" : "D:/MyGithub/mathematical-expression-cpp"
"value" : "G:/MyGithub/mathematical-expression-cpp"
},
{
"name" : "CMAKE_INSTALL_PREFIX",
Expand Down Expand Up @@ -735,7 +735,7 @@
}
],
"type" : "FILEPATH",
"value" : "D:/liming/CX/Clion/CLion 2022.2.1/bin/mingw/bin/ld.exe"
"value" : "D:/Liming/MyApplication/CLion/CLion 2022.2.1/bin/mingw/bin/ld.exe"
},
{
"name" : "CMAKE_MAKE_PROGRAM",
Expand All @@ -751,7 +751,7 @@
}
],
"type" : "FILEPATH",
"value" : "D:/liming/CX/Clion/CLION2~1.1/bin/mingw/bin/mingw32-make.exe"
"value" : "D:/Liming/MyApplication/CLion/CLion 2022.2.1/bin/mingw/bin/mingw32-make.exe"
},
{
"name" : "CMAKE_MODULE_LINKER_FLAGS",
Expand Down Expand Up @@ -847,7 +847,7 @@
}
],
"type" : "FILEPATH",
"value" : "D:/liming/CX/Clion/CLion 2022.2.1/bin/mingw/bin/nm.exe"
"value" : "D:/Liming/MyApplication/CLion/CLion 2022.2.1/bin/mingw/bin/nm.exe"
},
{
"name" : "CMAKE_NUMBER_OF_MAKEFILES",
Expand Down Expand Up @@ -875,7 +875,7 @@
}
],
"type" : "FILEPATH",
"value" : "D:/liming/CX/Clion/CLion 2022.2.1/bin/mingw/bin/objcopy.exe"
"value" : "D:/Liming/MyApplication/CLion/CLion 2022.2.1/bin/mingw/bin/objcopy.exe"
},
{
"name" : "CMAKE_OBJDUMP",
Expand All @@ -891,7 +891,7 @@
}
],
"type" : "FILEPATH",
"value" : "D:/liming/CX/Clion/CLion 2022.2.1/bin/mingw/bin/objdump.exe"
"value" : "D:/Liming/MyApplication/CLion/CLion 2022.2.1/bin/mingw/bin/objdump.exe"
},
{
"name" : "CMAKE_PLATFORM_INFO_INITIALIZED",
Expand Down Expand Up @@ -955,7 +955,7 @@
}
],
"type" : "FILEPATH",
"value" : "D:/liming/CX/Clion/CLion 2022.2.1/bin/mingw/bin/ranlib.exe"
"value" : "D:/Liming/MyApplication/CLion/CLion 2022.2.1/bin/mingw/bin/ranlib.exe"
},
{
"name" : "CMAKE_RC_COMPILER",
Expand All @@ -971,7 +971,7 @@
}
],
"type" : "FILEPATH",
"value" : "D:/liming/CX/Clion/CLion 2022.2.1/bin/mingw/bin/windres.exe"
"value" : "D:/Liming/MyApplication/CLion/CLion 2022.2.1/bin/mingw/bin/windres.exe"
},
{
"name" : "CMAKE_RC_COMPILER_WORKS",
Expand Down Expand Up @@ -1079,7 +1079,7 @@
}
],
"type" : "FILEPATH",
"value" : "D:/liming/CX/Clion/CLion 2022.2.1/bin/mingw/bin/readelf.exe"
"value" : "D:/Liming/MyApplication/CLion/CLion 2022.2.1/bin/mingw/bin/readelf.exe"
},
{
"name" : "CMAKE_ROOT",
Expand All @@ -1091,7 +1091,7 @@
}
],
"type" : "INTERNAL",
"value" : "D:/liming/CX/Clion/CLion 2022.2.1/bin/cmake/win/share/cmake-3.23"
"value" : "D:/Liming/MyApplication/CLion/CLion 2022.2.1/bin/cmake/win/share/cmake-3.23"
},
{
"name" : "CMAKE_SHARED_LINKER_FLAGS",
Expand Down Expand Up @@ -1299,7 +1299,7 @@
}
],
"type" : "FILEPATH",
"value" : "D:/liming/CX/Clion/CLion 2022.2.1/bin/mingw/bin/strip.exe"
"value" : "D:/Liming/MyApplication/CLion/CLion 2022.2.1/bin/mingw/bin/strip.exe"
},
{
"name" : "CMAKE_VERBOSE_MAKEFILE",
Expand Down Expand Up @@ -1327,7 +1327,7 @@
}
],
"type" : "STATIC",
"value" : "D:/MyGithub/mathematical-expression-cpp/cmake-build-debug"
"value" : "G:/MyGithub/mathematical-expression-cpp/cmake-build-debug"
},
{
"name" : "mathematical_expression_cpp_IS_TOP_LEVEL",
Expand All @@ -1351,7 +1351,7 @@
}
],
"type" : "STATIC",
"value" : "D:/MyGithub/mathematical-expression-cpp"
"value" : "G:/MyGithub/mathematical-expression-cpp"
}
],
"kind" : "cache",
Expand Down
Loading

0 comments on commit f39dcb5

Please sign in to comment.