-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBasFunc.h
68 lines (62 loc) · 1.37 KB
/
BasFunc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#pragma once
#include<string>
/// </summary>
namespace BasFunc {
class AbsBasFunc {
public:
/// <summary>
/// 载入函数,并更新内部参数。
/// </summary>
/// <param name="s">传入函数</param>
virtual void load(std::string s) = 0;
/// <summary>
/// 微分函数,将函数式变成微分形式。
/// </summary>
virtual void dt() = 0;
/// <summary>
/// 返回函数。
/// </summary>
/// <returns></returns>
virtual std::string rtStr() = 0;
virtual AbsBasFunc* copy() = 0;
/// <summary>
/// 传入参数,用于上层合并参数。
/// </summary>
/// <param name="s">参数字符串</param>
void setLpara(double s);
double getLpara();
/// <summary>
/// 后悔函数。撤销操作,只支持一步撤销
/// </summary>
void flhbck();
bool isNorm();
bool isZero();
protected:
std::string now = "";
std::string last = "";
double lpara = 0.0;
bool isNor = false;
/// <summary>
/// 字符转浮点
/// </summary>
/// <param name="s">字符数字</param>
/// <returns>浮点数字</returns>
double str2d(std::string s);
std::string d2str(double x);
/// <summary>
/// 擦除浮点小数多余0
/// </summary>
/// <param name="s">字符</param>
/// <returns>被擦除的字符</returns>
std::string ridz(std::string s);
};
class BasPwrFunc : public AbsBasFunc {
public:
void load(std::string s);
void dt();
std::string rtStr();
AbsBasFunc* copy();
private:
double tpara = 0.0;
};
}