|
Posted by Osiris on 12/02/07 11:09
Now for the really kinky thing: running the following routine on my
localhost(apache 2.2.3,PHP5), I get
2 2 2 2 2 2
2 1 1 1 1 1
2 2 1 1 1 1
2 2 2 1 1 1
2 2 2 2 1 1
2 2 2 2 2 1
Running it through the Eclipse PHP Zend debugger I get (which, in my
opinion, is right):
2 4 4 4 4 4
4 2 4 4 4 4
4 4 2 4 4 4
4 4 4 2 4 4
4 4 4 4 2 4
4 4 4 4 4 2
<?php
$k = array(1=> // upper triangular matrix of 1's
array(1=>1,1,1,1,1,1),
array(2=>1,1,1,1,1),
array(3=>1,1,1,1),
array(4=>1,1,1),
array(5=>1,1),
array(6=>1));
// I try to mirror k about diagonal, while doubling:
foreach($k as $i=>& $_k)
foreach($_k as $j=>&$__k)
{
$__k *= 2;
if ($i != $j)
$k[$j][$i ] = $__k;
}
// however:
for ($i=1; $i <= 6; $i++)
{
for ($j=1; $j <= 6; $j++)
echo $k[$i][$j]." ";
echo "<BR>";
}
?>
[Back to original message]
|