protected function setUp()
 {
     $this->object = new stubTraitAssertMatrixIsRational();
     $this->mRational = MatrixFactory::createRational([[[1, 1], '2/3', 3.786]]);
     $this->mNumeric = MatrixFactory::createNumeric([[1]]);
     $this->mComplex = MatrixFactory::createComplex([['1+2i', '14-4i', '4-3i']]);
 }
Example #2
0
 public function testYouCanCreateACauchyMatrixWithTwoVectorParamaters()
 {
     $mX = new NumericMatrix([[1, 2, 3]]);
     $mY = new NumericMatrix([[3, 4, 5]]);
     $expected = MatrixFactory::create('rational', [['1/4', '1/5', '1/6'], ['1/5', '1/6', '1/7'], ['1/6', '1/7', '1/8']]);
     $test = $this->sut->create([$mX, $mY]);
     $this->assertTrue($test->equality($expected, false));
 }
function createMatrix($size)
{
    $c = 0;
    $fn = function ($r, $c) use(&$c) {
        return RationalTypeFactory::create($c++, 1);
    };
    $iSize = TypeFactory::createInt($size);
    return MatrixFactory::createFromFunction($fn, $iSize, $iSize, new StringType('rational'));
}
 public function testCreateFromComplexReturnsRationalMatrix()
 {
     $c = CF::fromString('2+4i');
     $mA = MatrixFactory::createFromComplex($c);
     $test = MatrixFactory::createRational([['2/1', '-4/1'], ['4/1', '2/1']]);
     $this->assertEquals($test, $mA);
 }
Example #5
0
 public function testRationalNumberNonIdentityMatrixIsRecognised()
 {
     $test = [['0/1', '0/1', '0/1'], ['0/1', '1/1', '0/1'], ['0/1', '0/1', '1/1']];
     $mA = MatrixFactory::createRational($test);
     $this->assertFalse($this->object->is($mA));
 }