6 require_once
"../Matrix.php";
24 for ($j = 0; $j <
$n; ++$j)
25 for ($i = 0; $i <
$n; ++$i)
26 $M[$i][$j] = $n*(($i+$j+$a) %
$n) + (($i+2*$j+$b) %
$n) + 1;
30 }
else if ((
$n % 4) == 0) {
31 for ($j = 0; $j <
$n; ++$j) {
32 for ($i = 0; $i <
$n; ++$i) {
33 if ((($i+1)/2)%2 == (($j+1)/2)%2)
34 $M[$i][$j] = $n*$n-$n*$i-$j;
36 $M[$i][$j] = $n*$i+$j+1;
46 $A = $this->
magic($p);
48 for ($j = 0; $j < $p; ++$j) {
49 for ($i = 0; $i < $p; ++$i) {
50 $aij = $A->get($i,$j);
52 $M[$i][$j+$p] = $aij + 2*$p*$p;
53 $M[$i+$p][$j] = $aij + 3*$p*$p;
54 $M[$i+$p][$j+$p] = $aij + $p*$p;
58 for ($i = 0; $i < $p; ++$i) {
59 for ($j = 0; $j < $k; ++$j) {
61 $M[$i][$j] = $M[$i+$p][$j];
64 for ($j =
$n-$k+1; $j <
$n; ++$j) {
66 $M[$i][$j] = $M[$i+$p][$j];
71 $t = $M[$k][0]; $M[$k][0] = $M[$k+$p][0]; $M[$k+$p][0] =
$t;
72 $t = $M[$k][$k]; $M[$k][$k] = $M[$k+$p][$k]; $M[$k+$p][$k] =
$t;
84 list($usec, $sec) = explode(
" ", microtime());
85 return ((
float)$usec + (
float)$sec);
104 <table border=
'1' cellspacing=
'0' cellpadding=
'4'>
116 $eps = pow(2.0,-52.0);
117 for (
$n = 3;
$n <= 6; ++
$n) {
120 echo
"<td align='right'>$n</td>";
123 $t = (int) $M->trace();
125 echo
"<td align='right'>$t</td>";
127 $O = $M->plus($M->transpose());
129 $d = $E->getRealEigenvalues();
131 echo
"<td align='right'>".$d[
$n-1].
"</td>";
135 echo
"<td align='right'>".$r.
"</td>";
140 echo
"<td align='right'>".sprintf(
"%.3f",$c).
"</td>";
142 echo
"<td align='right'>Inf</td>";
147 $p = $LU->getPivot();
150 $R = $S->minus($M->getMatrix($p,0,
$n-1));
151 $res = $R->norm1()/(
$n*$eps);
153 echo
"<td align='right'>".sprintf(
"%.3f",
$res).
"</td>";
160 $res = $R->norm1()/(
$n*$eps);
162 echo
"<td align='right'>".sprintf(
"%.3f",
$res).
"</td>";
171 $etime = $stop_time - $start_time;
173 echo
"<p>Elapsed time is ". sprintf(
"%.4f",$etime) .
" seconds.</p>";