Esempio n. 1
0
function matrix($n)
{
    $SIZE = 10;
    $m1 = mkmatrix($SIZE, $SIZE);
    $m2 = mkmatrix($SIZE, $SIZE);
    while ($n--) {
        $mm = mmult($SIZE, $SIZE, $m1, $m2);
    }
    print "{$mm[0][0]} {$mm[2][3]} {$mm[3][2]} {$mm[4][4]}\n";
}
Esempio n. 2
0
        $row = array();
        for ($j = 0; $j < $cols; $j++) {
            $row[$j] = $count++;
        }
        $mx[$i] = $row;
    }
    return $mx;
}
function mmult($rows, $cols, $m1, $m2)
{
    $m3 = array();
    for ($i = 0; $i < $rows; $i++) {
        $row = array();
        for ($j = 0; $j < $cols; $j++) {
            $x = 0;
            for ($k = 0; $k < $cols; $k++) {
                $x += $m1[$i][$k] * $m2[$k][$j];
            }
            $row[$j] = $x;
        }
        $m3[$i] = $row;
    }
    return $m3;
}
$n = $argc == 2 ? $argv[1] : 100;
$m1 = mkmatrix($SIZE, $SIZE);
$m2 = mkmatrix($SIZE, $SIZE);
while ($n--) {
    $mm = mmult($SIZE, $SIZE, $m1, $m2);
}
print "{$mm[0][0]} {$mm[2][3]} {$mm[3][2]} {$mm[4][4]}\n";
Esempio n. 3
0
function matrix($n = 20)
{
    $SIZE = 30;
    $m1 = mkmatrix($SIZE, $SIZE);
    $m2 = mkmatrix($SIZE, $SIZE);
    while ($n--) {
        $mm = mmult($SIZE, $SIZE, $m1, $m2);
    }
}