-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path8_lib.php
More file actions
62 lines (57 loc) · 737 Bytes
/
8_lib.php
File metadata and controls
62 lines (57 loc) · 737 Bytes
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
<?php
function compute($a,$op,$b)
{
switch($op)
{
case '+':return $a+$b;
}
}
function matrix_print($m)
{
for($i=0;$i<3;$i++)
{
for($j=0;$j<3;$j++)
{
echo $m[$i][$j]." ";
}
echo "<br>";
}
}
function matrix_sum($a,$b)
{
for($i=0;$i<3;$i++)
{
for($j=0;$j<3;$j++)
{
$c[$i][$j]=$a[$i][$j]+$b[$i][$j];
}
}
return $c;
}
function matrix_product($a,$b)
{
for($i=0;$i<3;$i++)
{
for($j=0;$j<3;$j++)
{
$c[$i][$j]=0;
for($k=0;$k<3;$k++)
{
$c[$i][$j]+=$a[$i][$k]*$b[$k][$j];
}
}
}
return $c;
}
function matrix_transpose($a)
{
for($i=0;$i<3;$i++)
{
for($j=0;$j<3;$j++)
{
$b[$i][$j]=$a[$j][$i];
}
}
return $b;
}
?>