Skip to content

Commit 40f8c5b

Browse files
文档更新
1 parent f39dcb5 commit 40f8c5b

File tree

9 files changed

+215
-75
lines changed

9 files changed

+215
-75
lines changed

Diff for: README-Chinese.md

+70-5
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,10 @@ project(MyCpp)
1919
set(CMAKE_CXX_STANDARD 14)
2020
2121
# 设置头文件目录(可以自定义)
22-
include_directories(${PROJECT_SOURCE_DIR}/include)
23-
# 设置库文件目录
22+
include_directories(${PROJECT_SOURCE_DIR}/head)
2423
add_executable(MyCpp main.cpp)
2524
# 与项目进行链接(将库链接到编译之后的目标中)
26-
target_link_libraries(
27-
${PROJECT_NAME} D:\\liming\\Project\\Clion\\MyCpp\\cmake-build-debug\\mathematical_expression_cpp_WINx64.dll
28-
)
25+
target_link_libraries(${PROJECT_NAME} D:\\liming\\Project\\Clion\\MyCpp\\cmake-build-debug\\mathematical_expression_cpp.dll)
2926
```
3027

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

266+
#### 注意事项
267+
268+
1.0.2 版本中 针对函数的注册操作不能向后兼容,如果是在1.0.2版本以以后的版本 请使用下面的方式注册函数
269+
270+
```c++
271+
// 准备函数 将函数的形参类型 由 double* 更改为 ME::MEStack<double> 即可 因为 ME::MEStack<double> 具有更大的灵活性
272+
auto myFun =[](const ME::MEStack<double>& v) {
273+
double res = 0;
274+
for (int i = 0; i < v.size(); ++i){
275+
res += v.get(i);
276+
}
277+
return res;
278+
};
279+
// 注册函数 将我们的函数注册成为 DoubleValue 的名称
280+
ME::FunctionManager::append("sum", myFun);
281+
```
282+
283+
### 函数多参数运算表达式
284+
285+
- 类组件:ME::FunctionFormulaCalculationTwo
286+
- 介绍
287+
288+
针对一些在表达式中使用了函数的表达式计算,可以使用上面的类进行操作,它是“core.calculation.number.FunctionFormulaCalculation”类的升级版,从1.0.2版本开始出现,同时也是它的一个子类拓展实现。
289+
290+
相较于父类,本组件弥补了父类只能解析带有一个参数函数表达式的不足,在该组件中,可以使用很多的实参进行函数的运算,例如sum(
291+
1,2,3) 这类函数,就是一个多参函数,接下来请看API的使用示例,在此示例中,展示了多惨函数表达式的计算与结果。
292+
293+
- API使用示例
294+
295+
```c++
296+
#include <mathematical_expression.h>
297+
#include "FunctionManager.h"
298+
int main() {
299+
system("chcp 65001");
300+
// 准备函数 这里的函数的作用是将 3 个参数求和
301+
auto myFun = [](const ME::MEStack<double>& v) {
302+
double res = 0;
303+
for (int i = 0; i < v.size(); ++i){
304+
res += v.get(i);
305+
}
306+
return res;
307+
};
308+
// 注册函数 将我们的函数注册成为 DoubleValue 的名称
309+
ME::FunctionManager::append("sum", myFun);
310+
// 构建一个数学表达式,表达式中使用到了函数 DoubleValue
311+
string s = "2 * sum(2 + 3, 1 + 20, 10 + (1 - 2)) + 1";
312+
// 获取到 数学表达式解析库
313+
mathematical_expression me;
314+
// 获取到函数表达式计算组件
315+
auto functionFormulaCalculation = me.getFunctionFormulaCalculation2();
316+
// 检查数学表达式
317+
functionFormulaCalculation.check(s);
318+
// 计算出结果
319+
ME::CalculationNumberResults results = functionFormulaCalculation << s;
320+
// 将结果打印出来
321+
cout << "计算层数:" << results.getResultLayers() << "\t计算结果:" << results << "\t计算来源:" << results.getCalculationSourceName() << endl;
322+
}
323+
```
324+
325+
- 运行结果
326+
327+
```
328+
Active code page: 65001
329+
计算层数:1 计算结果:71 计算来源:BracketsCalculation
330+
331+
进程已结束,退出代码0
332+
```
333+
269334
### 快速区间求和计算组件(基于括号表达式)
270335

271336
- 类组件:ME::FastSumOfIntervalsBrackets.py

Diff for: README.md

+79-4
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ set(CMAKE_CXX_STANDARD 14)
2727
include_directories(${PROJECT_SOURCE_DIR}/include)
2828
add_executable(MyCpp main.cpp)
2929
# Link to the project (link the library to the compiled target)
30-
target_link_libraries(
31-
${PROJECT_NAME} D:\\liming\\Project\\Clion\\MyCpp\\cmake-build-debug\\mathematical_expression_cpp_WINx64.dll
32-
)
30+
target_link_libraries(${PROJECT_NAME} D:\\liming\\Project\\Clion\\MyCpp\\cmake-build-debug\\libmathematical_expression_cpp.dll)
3331
```
3432

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

289+
#### 注意事项
290+
291+
1.0.2 版本中 针对函数的注册操作不能向后兼容,函数的形参有一些小改动,如果是在1.0.2版本以以后的版本 请使用下面的方式注册函数
292+
293+
```
294+
// 准备函数 将函数的形参类型 由 double* 更改为 ME::MEStack<double> 即可 因为 ME::MEStack<double> 具有更大的灵活性
295+
auto myFun =[](const ME::MEStack<double>& v) {
296+
double res = 0;
297+
for (int i = 0; i < v.size(); ++i){
298+
res += v.get(i);
299+
}
300+
return res;
301+
};
302+
// 注册函数 将我们的函数注册成为 DoubleValue 的名称
303+
ME::FunctionManager::append("sum", myFun);
304+
```
305+
306+
### 函数多参数运算表达式
307+
308+
- Multi parameter function operation expression
309+
- introduce
310+
311+
For some expression calculations that use functions in expressions, the above class can be used for operations. It is an
312+
upgraded version of the "core. calculation. number. FunctionFormulaCalculation" class, which has appeared since version
313+
1.1, is also an extended implementation of its subclass.
314+
315+
Compared with the parent class, this component makes up for the deficiency that the parent class can only parse the
316+
function expression with one parameter. In this component, you can use many real parameters for function operations,
317+
such as sum (1,2,3)
318+
319+
This type of function is a multiparameter function. Next, let's look at the API usage example, in which the calculation
320+
and results of the multiparameter function expression are shown.
321+
322+
- API Usage Example
323+
324+
```c++
325+
#include <mathematical_expression.h>
326+
#include "FunctionManager.h"
327+
int main() {
328+
system("chcp 65001");
329+
// 准备函数 这里的函数的作用是将 3 个参数求和
330+
auto myFun = [](const ME::MEStack<double>& v) {
331+
double res = 0;
332+
for (int i = 0; i < v.size(); ++i){
333+
res += v.get(i);
334+
}
335+
return res;
336+
};
337+
// 注册函数 将我们的函数注册成为 DoubleValue 的名称
338+
ME::FunctionManager::append("sum", myFun);
339+
// 构建一个数学表达式,表达式中使用到了函数 DoubleValue
340+
string s = "2 * sum(2 + 3, 1 + 20, 10 + (1 - 2)) + 1";
341+
// 获取到 数学表达式解析库
342+
mathematical_expression me;
343+
// 获取到函数表达式计算组件
344+
auto functionFormulaCalculation = me.getFunctionFormulaCalculation2();
345+
// 检查数学表达式
346+
functionFormulaCalculation.check(s);
347+
// 计算出结果
348+
ME::CalculationNumberResults results = functionFormulaCalculation << s;
349+
// 将结果打印出来
350+
cout << "计算层数:" << results.getResultLayers() << "\t计算结果:" << results << "\t计算来源:" << results.getCalculationSourceName() << endl;
351+
}
352+
```
353+
354+
- 运行结果
355+
356+
```
357+
Active code page: 65001
358+
计算层数:1 计算结果:71 计算来源:BracketsCalculation
359+
360+
进程已结束,退出代码0
361+
```
362+
291363
### Quick interval summation calculation component (based on parenthesis expression)
292364

293365
- Class component: ME:: FastSumOfIntervalsBrackets
@@ -323,7 +395,10 @@ int main() {
323395
}
324396
```
325397

326-
- 运行结果 从上面代码中我们可以看到,快速区间求和计算的公式由被逗号分割的两个括号表达式组成
398+
- 运行结果
399+
400+
From the above code, we can see that the formula for fast interval summation is composed of two parentheses separated by
401+
commas.
327402

328403
```
329404
Active code page: 65001
Binary file not shown.
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)