芝麻web文件管理V1.00
编辑当前文件:/home/asmplong/www/asm/Classes/PHPExcel/Shared/JAMA/examples/benchmark.php
stat->setData($times); $stats = $this->stat->calcFull(); echo '
'; echo '
n:
' . $stats['count'] . '
'; echo '
Mean:
' . $stats['mean'] . '
'; echo '
Min.:
' . $stats['min'] . '
'; echo '
Max.:
' . $stats['max'] . '
'; echo '
σ:
' . $stats['stdev'] . '
'; echo '
Variance:
' . $stats['variance'] . '
'; echo '
Range:
' . $stats['range'] . '
'; echo '
'; return $stats; } // function displayStats() function runEig($n = 4, $t = 100) { $times = array(); for ($i = 0; $i < $t; ++$i) { $M = Matrix::random($n, $n); $start_time = $this->microtime_float(); $E = new EigenvalueDecomposition($M); $stop_time = $this->microtime_float(); $times[] = $stop_time - $start_time; } return $times; } // function runEig() function runLU($n = 4, $t = 100) { $times = array(); for ($i = 0; $i < $t; ++$i) { $M = Matrix::random($n, $n); $start_time = $this->microtime_float(); $E = new LUDecomposition($M); $stop_time = $this->microtime_float(); $times[] = $stop_time - $start_time; } return $times; } // function runLU() function runQR($n = 4, $t = 100) { $times = array(); for ($i = 0; $i < $t; ++$i) { $M = Matrix::random($n, $n); $start_time = $this->microtime_float(); $E = new QRDecomposition($M); $stop_time = $this->microtime_float(); $times[] = $stop_time - $start_time; } return $times; } // function runQR() function runCholesky($n = 4, $t = 100) { $times = array(); for ($i = 0; $i < $t; ++$i) { $M = Matrix::random($n, $n); $start_time = $this->microtime_float(); $E = new CholeskyDecomposition($M); $stop_time = $this->microtime_float(); $times[] = $stop_time - $start_time; } return $times; } // function runCholesky() function runSVD($n = 4, $t = 100) { $times = array(); for ($i = 0; $i < $t; ++$i) { $M = Matrix::random($n, $n); $start_time = $this->microtime_float(); $E = new SingularValueDecomposition($M); $stop_time = $this->microtime_float(); $times[] = $stop_time - $start_time; } return $times; } // function runSVD() function run() { $n = 8; $t = 16; $sum = 0; echo "
Cholesky decomposition: $t random {$n}x{$n} matrices
"; $r = $this->displayStats($this->runCholesky($n, $t)); $sum += $r['mean'] * $n; echo '
'; echo "
Eigenvalue decomposition: $t random {$n}x{$n} matrices
"; $r = $this->displayStats($this->runEig($n, $t)); $sum += $r['mean'] * $n; echo '
'; echo "
LU decomposition: $t random {$n}x{$n} matrices
"; $r = $this->displayStats($this->runLU($n, $t)); $sum += $r['mean'] * $n; echo '
'; echo "
QR decomposition: $t random {$n}x{$n} matrices
"; $r = $this->displayStats($this->runQR($n, $t)); $sum += $r['mean'] * $n; echo '
'; echo "
Singular Value decomposition: $t random {$n}x{$n} matrices
"; $r = $this->displayStats($this->runSVD($n, $t)); $sum += $r['mean'] * $n; return $sum; } // function run() public function __construct() { $this->stat = new Base(); } // function Benchmark() } // class Benchmark (end MagicSquareExample) $benchmark = new Benchmark(); switch($_REQUEST['decomposition']) { case 'cholesky': $m = array(); for ($i = 2; $i <= 8; $i *= 2) { $t = 32 / $i; echo "
Cholesky decomposition: $t random {$i}x{$i} matrices
"; $s = $benchmark->displayStats($benchmark->runCholesky($i, $t)); $m[$i] = $s['mean']; echo "
"; } echo '
'; foreach($m as $x => $y) { echo "$x\t" . 1000*$y . "\n"; } echo '
'; break; case 'eigenvalue': $m = array(); for ($i = 2; $i <= 8; $i *= 2) { $t = 32 / $i; echo "
Eigenvalue decomposition: $t random {$i}x{$i} matrices
"; $s = $benchmark->displayStats($benchmark->runEig($i, $t)); $m[$i] = $s['mean']; echo "
"; } echo '
'; foreach($m as $x => $y) { echo "$x\t" . 1000*$y . "\n"; } echo '
'; break; case 'lu': $m = array(); for ($i = 2; $i <= 8; $i *= 2) { $t = 32 / $i; echo "
LU decomposition: $t random {$i}x{$i} matrices
"; $s = $benchmark->displayStats($benchmark->runLU($i, $t)); $m[$i] = $s['mean']; echo "
"; } echo '
'; foreach($m as $x => $y) { echo "$x\t" . 1000*$y . "\n"; } echo '
'; break; case 'qr': $m = array(); for ($i = 2; $i <= 8; $i *= 2) { $t = 32 / $i; echo "
QR decomposition: $t random {$i}x{$i} matrices
"; $s = $benchmark->displayStats($benchmark->runQR($i, $t)); $m[$i] = $s['mean']; echo "
"; } echo '
'; foreach($m as $x => $y) { echo "$x\t" . 1000*$y . "\n"; } echo '
'; break; case 'svd': $m = array(); for($i = 2; $i <= 8; $i *= 2) { $t = 32 / $i; echo "
Singular value decomposition: $t random {$i}x{$i} matrices
"; $s = $benchmark->displayStats($benchmark->runSVD($i, $t)); $m[$i] = $s['mean']; echo "
"; } echo '
'; foreach($m as $x => $y) { echo "$x\t" . 1000*$y . "\n"; } echo '
'; break; case 'all': $s = $benchmark->run(); print("
Total
: {$s}s
"); break; default: ?>
Complete Benchmark
Cholesky
Eigenvalue
LU
QR
Singular Value