-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcofactor.html
More file actions
175 lines (117 loc) · 3.93 KB
/
cofactor.html
File metadata and controls
175 lines (117 loc) · 3.93 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
---
layout: default
title: Cofactor Matrix
---
<style>
.grid-container {
display: grid;grid-template-columns: auto auto auto auto;background-color: ;padding: 5px;width: 10px;
}
.grid-item {
border: 1px solid rgba(0, 0, 0, 0.8);
padding: 20px;
font-size: 30px;
text-align: center;
}
</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('man1').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.inv(str1);
var adj=math.multiply(res,math.det(str1));
var cofac=math.transpose(adj);
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">${(cofac[i][j]).toFixed(2)}</td>`;
tr.innerHTML=string;
}
document.getElementById("man1").appendChild(tr);
}
document.getElementById('a1').innerHTML="Cofactor of given Matrix is: ";
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]).toFixed(2)}</td>`;
tr.innerHTML=string;
}
}
}
</script>
<div class="right">
<div class="main-heading">
<h2 style="color:white;" ><strong>Co-factor Matrix</strong></h2>
</div>
<div class="paragraph">
<br>
<p> The co-factor matrix is formed with the co-factors of the elements of the given matrix. </p><p>The co-factor of an element of the matrix is equal to the product of the minor of the element and -1 to the power of the positional value of the element.</p>
<p>The co-factor matrix is useful to find the adjoint of the matrix and the inverse of the given matrix.</p> Here we shall learn how to find the co-factor matrix and the applications of the co-factor matrix.
<br><br>
</div>
<br><br>
<img src="cofactor.jpg" 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()"name="" placeholder="Enter the order of matrix">
</div>
<div id="ma" class="grid-container">
</div>
<a class="submit" onclick="fun()"href="#footer">submit</a>
<br><br>
<h4 id="out" style="font-weight: bold;">OUTPUT SECTION:</h4>
<div class="paragraphout">
<br>
<h4 id="a1"></h4>
<br>
<table align="center" id="man1" class="matrix">
</table>
<br>
</div>
<footer id="footer"></footer>
</div>