-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTranspose.html
More file actions
149 lines (110 loc) · 3.5 KB
/
Transpose.html
File metadata and controls
149 lines (110 loc) · 3.5 KB
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
---
layout: default
title: Transpose of a Matrix
---
<style media="screen">
</style>
<script type="text/javascript">
var s="";
function func() {
var n=document.getElementById('n').value;
n=parseInt(n);
var str="";
document.getElementById('ma').innerHTML="";
for(let i=0;i<n;i++)
{
str=str+"auto ";
}
s=str;
const dStyle = document.querySelector('style');
dStyle.innerHTML = `.grid-container{display:grid;align:center;grid-template-columns: ${str};padding: 5px;width: 10px;}`;
for(let i=0;i<n*n;i++)
{
var div = document.createElement('div'); // is a node
div.setAttribute('class', 'grid-item');
div.innerHTML=`<input id="${i}" type="text" size=1px value="">`;
document.getElementById("ma").appendChild(div);
}
}
</script>
<script type="text/javascript">
function fun() {
const dtm = document.querySelector('style');//changing the contents of style tag to chnage the css of grid that is for input matrix1
dtm.innerHTML = `.matrix:before { left: -6px;border-right: 0;display: block;} .grid-container{display:grid;align:center;grid-template-columns: ${s};padding: 5px;width: 10px;} .matrix:after { right: -6px;border-left: 0;display: block;}.paragraphout{background-color: lightgrey;margin-top:25px;font-size: 18px;line-height: 28.5px;color:black;padding-left: 15px;padding-right: 30px;margin-right:40px;text-align:left;display: block;} #out{display:block}`;
document.getElementById('man').innerHTML="";
var n=document.getElementById('n').value;
n=parseInt(n);
let str1=[];
for (let i=0;i<n;i++)
{
let a=[]
for(let j=0;j<n;j++)
{
a.push(parseInt(document.getElementById(`${n*i+j}`).value));
}
str1.push(a);
}
var res=math.transpose(str1);
console.log(res);
for (let i=0;i<n;i++)
{
var tr = document.createElement('tr');
var string="";
for(let j=0;j<n;j++)
{
string=string+`<td class="mmm">${res[i][j]}</td>`;
tr.innerHTML=string;
}
document.getElementById("man").appendChild(tr);
}
document.getElementById('a1').innerHTML="Transpose of given Matrix is: ";
let count=0;
for(let i=0;i<n;i++)
{
for(let j=0;j<n;j++)
{
if ( str1[i][j]==res[i][j] )
{
count=count+1;
}
}
}
}
</script>
<div class="right">
<div class="main-heading">
<h2><strong> Transpose of Matrix</strong></h2>
</div>
<div class="paragraph">
<br>
<p>The transpose of a matrix is found by interchanging its rows into columns or columns into rows. <br><br>The transpose of the matrix is denoted by using the letter “T” in the superscript of the given matrix. </p>
</div>
<br>For example, if “A” is the given matrix, then the transpose of the matrix is represented by A’ or A<sup>T</sup>.
<br>
<br>
<img src="https://arm-software.github.io/CMSIS_5/DSP/html/MatrixTranspose.gif" alt="">
<br>
<br>
<p >Now, Let's jump in to have fun, <strong>Practically trying them...</strong></p>
<h3><strong>Enter the order of matrix</strong></h3>
<br>
<div class="input">
<input id="n" type="text" oninput="func()" placeholder="Enter the order of matrix"><!--on changing the input the function is called everytime-->
</div>
<div id="ma" class="grid-container">
</div>
<a class="submit"onclick="fun()"href="#footer" class="btn btn-light">submit</a>
<br>
<br>
<h3 id="out" style="font-weight: bold;" >OUTPUT SECTION:</h3>
<br>
<div class="paragraphout">
<br>
<h3 id="a1"></h3>
<br>
<br>
<table align="center" id="man" class="matrix">
</table>
<br>
<br>
</div>