-
Notifications
You must be signed in to change notification settings - Fork 4
/
opmap.html
73 lines (61 loc) · 2.12 KB
/
opmap.html
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
<script type="text/javascript" src="NumJS.js"></script>
<script type="text/javascript">NumJS.loader_html("")</script>
<script>
var binOps = [ "ADD", "SUB", "MUL", "DOT", "DIV", "SOLVE", "POW",
"EQ", "EQ_ABS", "EQ_REL" ];
var uniOps = [ "INV", "NEG", "ABS", "NORM", "ARG", "CONJ", "TRANSP",
"EXP", "LOG", "DET", "RE", "IM", "ROUND" ];
var exampleFloat = 1;
var exampleCmplx = NumJS.C(1, 1);
var exampleMatrix = new NumJS.Matrix(1, 1, [ 1 ]);
var examplePMatrix = new NumJS.PMatrix(1);
var operandNames = [ "Real", "Cmplx", "Matrix", "PMatrix" ];
var operandExamples = [ exampleFloat, exampleCmplx, exampleMatrix, examplePMatrix ];
for (i in binOps)
{
document.write("<p>Implentation chart for binary operator " + binOps[i] + ":\n<table border width=\"100%\">\n");
document.write("<tr><td> </td>\n");
for (j in operandNames)
document.write("<th>" + operandNames[j] + "</th>");
document.write("</tr>\n");
for (j in operandNames) {
document.write("<tr><th>" + operandNames[j] + "</th>");
for (k in operandNames) {
var isOk = 1;
try {
NumJS[binOps[i]](operandExamples[j], operandExamples[k]);
} catch (e) {
isOk = 0;
e = "X"; // e = (e + "").replace(/ /, "<br/>");
document.write("<td style=\"background-color: #f00;\">" + e + "</td>");
}
if (isOk)
document.write("<td style=\"background-color: #0f0;\">OK</td>");
}
document.write("</tr>\n");
}
document.write("</table></p>\n");
}
document.write("<p>Implentation chart for unary operators:\n<table border width=\"100%\">\n");
document.write("<tr><td> </td>\n");
for (j in operandNames)
document.write("<th>" + operandNames[j] + "</th>");
document.write("</tr>\n");
for (i in uniOps) {
document.write("<tr><th>" + uniOps[i] + "</th>");
for (k in operandNames) {
var isOk = 1;
try {
NumJS[uniOps[i]](operandExamples[k]);
} catch (e) {
isOk = 0;
e = "X"; // e = (e + "").replace(/ /, "<br/>");
document.write("<td style=\"background-color: #f00;\">" + e + "</td>");
}
if (isOk)
document.write("<td style=\"background-color: #0f0;\">OK</td>");
}
document.write("</tr>\n");
}
document.write("</table></p>\n");
</script>