-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDifferentiator.h
94 lines (72 loc) · 1.84 KB
/
Differentiator.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include <iostream>
#include <fstream>
#include <cmath>
#include <cassert>
#include <cstring>
#define TPCHAR 1
#define TCHAR 2
#define TDOUBLE 3
#define SIZEBLOCK 48
#define DOUBLEPTR 0.001
union Value
{
const char* cp;
char c;
double d;
};
typedef struct Block
{
Value val;
Block* left = nullptr;
Block* right = nullptr;
size_t num = 0;
size_t type = 0;
bool parenthes = false;
}Block_Tree;
enum Function
{
Eadd = 1,
Esub,
Emul,
Ediv,
Edeg,
Esin,
Ecos,
Etan,
Earcsin,
Earccos,
Earctan,
};
class Differentiator{
public:
Block_Tree* HeadRead_ = new Block_Tree;
Block_Tree* HeadWrite_ = new Block_Tree;
Differentiator();
~Differentiator();
void Insert(Block_Tree* elem, size_t type, Value val);
//Read and make Tree
void EquactionRead(char* buffer);
Block_Tree* setReadAddAndSub(char* buffer, size_t* i);
Block_Tree* setReadMulAndDiv(char* buffer, size_t* i);
Block_Tree* setReadDegree(char* buffer, size_t* i);
Block_Tree* setReadSpecFunc(char* buffer, size_t* i);
Block_Tree* setReadParenthes(char* buffer, size_t* i);
Block_Tree* setReadValAndNum(char* buffer, size_t* i);
void Reduction(Block_Tree* Head);
void setNulAndFunc(Block_Tree* node, bool* repeat);
void setNumAndNum(Block_Tree* node, bool* repeat);
void setAddAndSub(Block_Tree* node, bool* repeat);
void setSpecFuncAndNum(Block_Tree* node, bool* repeat);
Block_Tree* Derivative(const Block_Tree* node);
Block_Tree* DiffStandartFunc(const Block_Tree* node);
Block_Tree* DiffSpecFunc(const Block_Tree* node);
private:
size_t size_ = 0;
};
void DumpEquatiton(Block_Tree* node);
void getDump(Block_Tree* Head);
void PrintElement(Block_Tree* Tree);
void BodyDump(Block_Tree* Tree, Block_Tree* Tree_Next, std::ofstream* GRAF, size_t* num, size_t* num_next);
void setFree(Block_Tree* Tree);
char* BufferFileRead();
char* BufferTerminalRead();