-
Notifications
You must be signed in to change notification settings - Fork 0
/
Runner.js
120 lines (100 loc) · 2.93 KB
/
Runner.js
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
let MaxSize = 3;
let matrixSizeElement;
let matrixStructure = [
["zby0", "zby1", "zby2"],
["oby0", "oby1", "oby2"],
["tby0", "tby1", "tby2"],
];
matrixSizeElement = document.getElementById("MatSize");
matrixSizeElement.onchange = UpdateMatrixSize;
let LinearSolutionElement = document.getElementById("SolveFurther");
LinearSolutionElement.onchange = UpdateBMatrix;
UpdateMatrixSize();
function UpdateMatrixSize() {
let val = matrixSizeElement.value;
for(let i=0; i<matrixStructure.length; i++)
{
for(let j=0; j<matrixStructure[i].length; j++)
{
var loc = document.getElementById(matrixStructure[i][j]);
loc.disabled = (i >= val || j >= val);
}
}
UpdateBMatrix();
}
function UpdateBMatrix() {
if(LinearSolutionElement.value == "1")
{
document.getElementById("b0").disabled = false;
document.getElementById("b1").disabled = false;
document.getElementById("b2").disabled = !(matrixSizeElement.value > 2);
}
else
{
document.getElementById("b0").disabled = true;
document.getElementById("b1").disabled = true;
document.getElementById("b2").disabled = true;
}
}
//Variables to be used
let fixedLength = 5;
let a = b = c = d = e = f = 0;
let toCheckLength = 5;
let scope;
let equation;
let derivative;
const allConstants = ["a","b", "c", "d", "e", "f"];
let bMatrix = [0,0,0];
let LSolved,USolved;
const keyValue = (input) => Object.entries(input).forEach(([key,value]) => {
println(key +" = "+ value);
});
function Caculate(Method)
{
let data = [];
for(let i=0; i<matrixStructure.length; i++)
{
let row = [];
for(let j=0; j<matrixStructure[i].length; j++)
{
var loc = document.getElementById(matrixStructure[i][j]).value;
row[j] = loc;
}
data[i] = row;
}
bMatrix[0] = document.getElementById("b0").value;
bMatrix[1] = document.getElementById("b1").value;
bMatrix[2] = document.getElementById("b2").value;
if(Method.value == 0)
new DoLittle(matrixSizeElement.value, data);
else
new Crout(matrixSizeElement.value, data);
if(LinearSolutionElement.value == "1")
new SolveEquation(matrixSizeElement.value);
}
function equationSolve(x)
{
return math.evaluate(equation, {x}).toFixed(fixedLength);
}
function getDerivaite()
{
return math.simplify(math.derivative(equation, "x")).toString();
}
function equationDerivativeSolve(x)
{
return math.evaluate(derivative, {x}).toFixed(fixedLength);
}
function clearOutput()
{
document.getElementById("Output").innerHTML="";
}
function rootResultChecker(value)
{
//console.log("before ->" + value);
value = value.toString().slice(0, value.toString().length - (fixedLength - toCheckLength));
//console.log("after ->" + value);
value = parseFloat(value);
if(!(value < 0 || value > 0))
return true;
return false;
}