-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
81 lines (76 loc) · 1.98 KB
/
index.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
74
75
76
77
78
79
80
81
<!DOCTYPE html>
<html>
<head>
<title>tester</title>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjs/6.2.2/math.js"></script>
</head>
<body>
<input type="number" id="iterasi">
<button onclick="execute()">eksekusi</button><br><br>
<input type="file" id="matrixA">
<script >
function execute(){
function Array2Dimensi(x,y)
{
var array2D = new Array(y);
for(var i = 0; i < array2D.length; i++)
{
array2D[i] = new Array(x);
}
return array2D;
}
//matrix A
var myNewArray = Array2Dimensi(2,2);
myNewArray[0][0] = 2;
myNewArray[0][1] = 1;
myNewArray[1][0] = 4;
myNewArray[1][1] = 0;
console.log(myNewArray);
//a0
var myNewArray2 = Array2Dimensi(1,2);
myNewArray2[0][0]=2;
myNewArray2[1][0]=2;
console.log(myNewArray2);
var ite=document.getElementById('iterasi').value,j,k=1; //pangkat
var iterasi=parseFloat(ite);
var ak=[];
var a0=myNewArray2;
var array1=[];
var x=10,i=1;
console.log(iterasi);
ak=math.multiply(myNewArray,a0);
if(iterasi>=1){
while (i<=iterasi) {
math.multiply(myNewArray,ak);
ak=math.multiply(myNewArray,ak);
i++
}
}else{
window.alert("anda salah memasukan nilai");
}
console.log("a0="+a0);
console.log("a1="+ak);
}
// function multiply(a, b) {
// var aNumRows = a.length, aNumCols = a[0].length,
// bNumRows = b.length, bNumCols = b[0].length,
// m = new Array(aNumRows); // initialize array of rows
// for (var r = 0; r < aNumRows; ++r) {
// m[r] = new Array(bNumCols); // initialize the current row
// for (var c = 0; c < bNumCols; ++c) {
// m[r][c] = 0; // initialize the current cell
// for (var i = 0; i < aNumCols; ++i) {
// m[r][c] += a[r][i] * b[i][c];
// }
// }
// }
// return m;
// }
// function display(m) {
// for (var r = 0; r < m.length; ++r) {
// document.write(' '+m[r].join(' ')+'<br />');
// }
// }
</script>
</body>
</html>