@@ -27,9 +27,7 @@ set(CMAKE_CXX_STANDARD 14)
27
27
include_directories(${PROJECT_SOURCE_DIR}/include)
28
28
add_executable(MyCpp main.cpp)
29
29
# 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)
33
31
```
34
32
35
33
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
288
286
进程已结束,退出代码0
289
287
```
290
288
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
+
291
363
### Quick interval summation calculation component (based on parenthesis expression)
292
364
293
365
- Class component: ME:: FastSumOfIntervalsBrackets
@@ -323,7 +395,10 @@ int main() {
323
395
}
324
396
```
325
397
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.
327
402
328
403
```
329
404
Active code page: 65001
0 commit comments