Пример #1
0
//print_r($m);
echo $m->toString() . "\n";
$det = $m->determinant();
echo "Determinant = {$det}\n";
echo "Trace = " . $m->trace() . "\n";
echo "Euclidean Norm = " . $m->norm() . "\n";
echo "Normalized Determinant = " . $m->normalizedDeterminant() . "\n";
echo "\nSubmatrix(1,1,2,2)\n";
$n = $m->getSubMatrix(1, 1, 2, 2);
echo $n->toString() . "\n";
$det = $n->determinant();
echo "Determinant = {$det}\n";
echo "Euclidean Norm = " . $n->norm() . "\n";
echo "Normalized Determinant = " . $n->normalizedDeterminant() . "\n";
echo "\nWriting original matrix\n";
$e = Math_Matrix::writeToFile($m, 'writetest.mat', 'csv');
echo "... Reading from file\n";
$p = Math_Matrix::readFromFile('writetest.mat', 'csv');
echo $p->toString() . "\n";
$det = $p->determinant();
echo "Determinant = {$det}\n";
echo "Euclidean Norm = " . $p->norm() . "\n";
echo "Normalized Determinant = " . $p->normalizedDeterminant() . "\n";
echo "\nInverting matrix\n";
$det = $p->invert();
echo $p->toString() . "\n";
echo "Product of matrix and its inverse\n";
$q = $m->clone();
$q->multiply($p);
echo $q->toString('%4.12f') . "\n";
echo "\nSolving Ax = b\n";
Пример #2
0
 function testWriteToFile()
 {
     $this->assertTrue(Math_Matrix::writeToFile($this->m, 'testdata.mat', 'csv'));
 }