-
Notifications
You must be signed in to change notification settings - Fork 44
/
util.js
102 lines (79 loc) · 1.38 KB
/
util.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
/* CONSTANTS */
// Some constants are defined in Global.js
DIR_NONE = 0;
DIR_TLBR = 1;
DIR_BRTL = 2;
DIR_TRBL = 3;
DIR_BLTR = 4;
DIR_LR = 5;
DIR_RL = 6;
DIR_TB = 7;
DIR_BT = 8;
FN_UNB = 0;
FN_BLK = 1;
FN_REC = 2;
TYPE_SCA = 0;
TYPE_VEC = 1;
TYPE_MAT = 2;
IO_INPUT = 0;
IO_TEMP = 1;
IO_IO = 2;
/* UTILITY FUNCTIONS */
function isScalar(operand)
{
if (operand[OPERAND_TYPE] == TYPE_SCA)
return true;
else
return false;
}
function isVector(operand)
{
if (operand[OPERAND_TYPE] == TYPE_VEC)
return true;
else
return false;
}
function isMatrix(operand)
{
if (operand[OPERAND_TYPE] == TYPE_MAT)
return true;
else
return false;
}
function scalarForm(operand)
{
return AllChoices[0][operand[OPERAND_NAME]];
}
function vectorForm(operand)
{
return AllChoices[1][operand[OPERAND_NAME]];
}
function matrixForm(operand)
{
return AllChoices[2][operand[OPERAND_NAME]];
}
function defaultForm(operand)
{
return AllChoices[operand[OPERAND_TYPE]][operand[OPERAND_NAME]];
}
function isTwoDimensional(operand)
{
if (1 <= operand[OPERAND_DIR] && operand[OPERAND_DIR] <= 4)
return true;
else
return false;
}
function isHorizontal(operand)
{
if (5 <= operand[OPERAND_DIR] && operand[OPERAND_DIR] <= 6)
return true;
else
return false;
}
function isVertical(operand)
{
if (7 <= operand[OPERAND_DIR] && operand[OPERAND_DIR] <= 8)
return true;
else
return false;
}