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"; $a = Math_Matrix::readFromFile('data.mat', 'csv'); $b = new Math_Vector(range(1, 9)); $x = Math_Matrix::solve($a, $b); echo "\nA\n" . $a->toString('%8.4f') . "\n"; echo "B " . $b->toString() . "\n"; echo "Solution " . $x->toString() . "\n"; //print_r($x); echo "\nSolving with error correction\n"; $x = Math_Matrix::solveEC($a, $b); echo "EC Solution " . $x->toString() . "\n"; //print_r($x); // Another set of equations /* $adata = array( array(1,2,3), array(2,-1,1),
function testReadFromFile() { $p = Math_Matrix::readFromFile('testdata.mat', 'csv'); $this->assertEquals($this->m->getData(), $p->getData()); }