<commit_before><?php
namespace Math\LinearAlgebra;

class MatrixFactorTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @dataProvider dataProviderForDiagonalMatrix
     */
    public function testCreateDiagonalMatrix(array $A)
    {
        $A = MatrixFactory::create($A);

        $this->assertInstanceOf('Math\LinearAlgebra\DiagonalMatrix', $A);
        $this->assertInstanceOf('Math\LinearAlgebra\Matrix', $A);
    }

    public function dataProviderForDiagonalMatrix()
    {
        return [
            [[1]],
            [[1, 2]],
            [[1, 2, 3]],
            [[1, 2, 3, 4]],
        ];
    }

    /**
     * @dataProvider dataProviderForSquareMatrix
     */
    public function testCreateSquareMatrix(array $A)
    {
        $A = MatrixFactory::create($A);

        $this->assertInstanceOf('Math\LinearAlgebra\SquareMatrix', $A);
        $this->assertInstanceOf('Math\LinearAlgebra\Matrix', $A);
    }

    public function dataProviderForSquareMatrix()
    {
        return [
            [
                [[1]]
            ],
            [
                [
                    [1, 2],
                    [2, 3],
                ],
            ],
            [
                [
                    [1, 2, 3],
                    [3, 4, 5],
                    [5, 6, 7],
                ],
            ],
        ];
    }

    /**
     * @dataProvider dataProviderForVandermondeSquareMatrix
     */
    public function testCreateVandermondeSquareMatrix(array $A, $n)
    {
        $A = MatrixFactory::create($A, $n);

        $this->assertInstanceOf('Math\LinearAlgebra\VandermondeSquareMatrix', $A);
        $this->assertInstanceOf('Math\LinearAlgebra\SquareMatrix', $A);
        $this->assertInstanceOf('Math\LinearAlgebra\Matrix', $A);
    }

    public function dataProviderForVandermondeSquareMatrix()
    {
        return [
            [
                [1],
                1,
            ],
            [
                [1, 2],
                2
            ],
            [
                [3, 2, 5],
                3,
            ],
        ];
    }

    /**
     * @dataProvider dataProviderForVandermondeMatrix
     */
    public function testCreateVandermondeMatrix(array $A, $n)
    {
        $A = MatrixFactory::create($A, $n);

        $this->assertInstanceOf('Math\LinearAlgebra\VandermondeMatrix', $A);
        $this->assertInstanceOf('Math\LinearAlgebra\Matrix', $A);
    }

    public function dataProviderForVandermondeMatrix()
    {
        return [
            [
                [1],
                2,
            ],
            [
                [1, 2],
                1
            ],
            [
                [1, 2],
                3
            ],
            [
                [3, 2, 5],
                5,
            ],
        ];
    }

    /**
     * @dataProvider dataProviderForFunctionSquareMatrix
     */
    public function testCreateFunctionSquareMatrix(array $A)
    {
        $A = MatrixFactory::create($A);

        $this->assertInstanceOf('Math\LinearAlgebra\FunctionSquareMatrix', $A);
        $this->assertInstanceOf('Math\LinearAlgebra\SquareMatrix', $A);
        $this->assertInstanceOf('Math\LinearAlgebra\Matrix', $A);
    }

    public function dataProviderForFunctionSquareMatrix()
    {
        return [
            [
                [
                    [function ($x) { return $x * 2; }]
                ]
            ],
            [
                [
                    [function ($x) { return $x * 2; }, function ($x) { return $x * 2; }],
                    [function ($x) { return $x * 2; }, function ($x) { return $x * 2; }],
                ],
            ],
            [
                [
                    [function ($x) { return $x * 2; }, function ($x) { return $x * 2; }, function ($x) { return $x * 2; }],
                    [function ($x) { return $x * 2; }, function ($x) { return $x * 2; }, function ($x) { return $x * 2; }],
                    [function ($x) { return $x * 2; }, function ($x) { return $x * 2; }, function ($x) { return $x * 2; }],
                ],
            ],
        ];
    }

    /**
     * @dataProvider dataProviderForFunctionMatrix
     */
    public function testCreateFunctionMatrix(array $A)
    {
        $A = MatrixFactory::create($A);

        $this->assertInstanceOf('Math\LinearAlgebra\FunctionMatrix', $A);
        $this->assertInstanceOf('Math\LinearAlgebra\Matrix', $A);
    }

    public function dataProviderForFunctionMatrix()
    {
        return [
            [
                [
                    [function ($x) { return $x * 2; }, function ($x) { return $x * 2; }]
                ]
            ],
            [
                [
                    [function ($x) { return $x * 2; }, function ($x) { return $x * 2; }],
                    [function ($x) { return $x * 2; }, function ($x) { return $x * 2; }],
                    [function ($x) { return $x * 2; }, function ($x) { return $x * 2; }],
                ],
            ],
            [
                [
                    [function ($x) { return $x * 2; }, function ($x) { return $x * 2; }, function ($x) { return $x * 2; }],
                    [function ($x) { return $x * 2; }, function ($x) { return $x * 2; }, function ($x) { return $x * 2; }],
                    [function ($x) { return $x * 2; }, function ($x) { return $x * 2; }, function ($x) { return $x * 2; }],
                    [function ($x) { return $x * 2; }, function ($x) { return $x * 2; }, function ($x) { return $x * 2; }],
                ],
            ],
        ];
    }

    /**
     * @dataProvider dataProviderForMatrix
     */
    public function testCreateMatrix(array $A)
    {
        $A = MatrixFactory::create($A);

        $this->assertInstanceOf('Math\LinearAlgebra\Matrix', $A);

        $this->assertNotInstanceOf('Math\LinearAlgebra\SquareMatrix', $A);
        $this->assertNotInstanceOf('Math\LinearAlgebra\FunctionMatrix', $A);
        $this->assertNotInstanceOf('Math\LinearAlgebra\VandermondeMatrix', $A);
        $this->assertNotInstanceOf('Math\LinearAlgebra\DiagonalMatrix', $A);
    }

    public function dataProviderForMatrix()
    {
        return [
            [
                [<commit_msg>Update unit test.<commit_after><?php
namespace Math\LinearAlgebra;

class MatrixFactorTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @dataProvider dataProviderForDiagonalMatrix
     */
    public function testCreateDiagonalMatrix(array $A)
    {
        $A = MatrixFactory::create($A);

        $this->assertInstanceOf('Math\LinearAlgebra\DiagonalMatrix', $A);
        $this->assertInstanceOf('Math\LinearAlgebra\Matrix', $A);
    }

    public function dataProviderForDiagonalMatrix()
    {
        return [
            [[1]],
            [[1, 2]],
            [[1, 2, 3]],
            [[1, 2, 3, 4]],
        ];
    }

    /**
     * @dataProvider dataProviderForSquareMatrix
     */
    public function testCreateSquareMatrix(array $A)
    {
        $A = MatrixFactory::create($A);

        $this->assertInstanceOf('Math\LinearAlgebra\SquareMatrix', $A);
        $this->assertInstanceOf('Math\LinearAlgebra\Matrix', $A);
    }

    public function dataProviderForSquareMatrix()
    {
        return [
            [
                [[1]]
            ],
            [
                [
                    [1, 2],
                    [2, 3],
                ],
            ],
            [
                [
                    [1, 2, 3],
                    [3, 4, 5],
                    [5, 6, 7],
                ],
            ],
        ];
    }

    /**
     * @dataProvider dataProviderForVandermondeSquareMatrix
     */
    public function testCreateVandermondeSquareMatrix(array $A, $n)
    {
        $A = MatrixFactory::create($A, $n);

        $this->assertInstanceOf('Math\LinearAlgebra\VandermondeSquareMatrix', $A);
        $this->assertInstanceOf('Math\LinearAlgebra\SquareMatrix', $A);
        $this->assertInstanceOf('Math\LinearAlgebra\Matrix', $A);
    }

    public function dataProviderForVandermondeSquareMatrix()
    {
        return [
            [
                [1],
                1,
            ],
            [
                [1, 2],
                2
            ],
            [
                [3, 2, 5],
                3,
            ],
        ];
    }

    /**
     * @dataProvider dataProviderForVandermondeMatrix
     */
    public function testCreateVandermondeMatrix(array $A, $n)
    {
        $A = MatrixFactory::create($A, $n);

        $this->assertInstanceOf('Math\LinearAlgebra\VandermondeMatrix', $A);
        $this->assertInstanceOf('Math\LinearAlgebra\Matrix', $A);
    }

    public function dataProviderForVandermondeMatrix()
    {
        return [
            [
                [1],
                2,
            ],
            [
                [1, 2],
                1
            ],
            [
                [1, 2],
                3
            ],
            [
                [3, 2, 5],
                5,
            ],
        ];
    }

    /**
     * @dataProvider dataProviderForFunctionSquareMatrix
     */
    public function testCreateFunctionSquareMatrix(array $A)
    {
        $A = MatrixFactory::create($A);

        $this->assertInstanceOf('Math\LinearAlgebra\FunctionSquareMatrix', $A);
        $this->assertInstanceOf('Math\LinearAlgebra\SquareMatrix', $A);
        $this->assertInstanceOf('Math\LinearAlgebra\Matrix', $A);
    }

    public function dataProviderForFunctionSquareMatrix()
    {
        return [
            [
                [
                    [function ($x) { return $x * 2; }]
                ]
            ],
            [
                [
                    [function ($x) { return $x * 2; }, function ($x) { return $x * 2; }],
                    [function ($x) { return $x * 2; }, function ($x) { return $x * 2; }],
                ],
            ],
            [
                [
                    [function ($x) { return $x * 2; }, function ($x) { return $x * 2; }, function ($x) { return $x * 2; }],
                    [function ($x) { return $x * 2; }, function ($x) { return $x * 2; }, function ($x) { return $x * 2; }],
                    [function ($x) { return $x * 2; }, function ($x) { return $x * 2; }, function ($x) { return $x * 2; }],
                ],
            ],
        ];
    }

    /**
     * @dataProvider dataProviderForFunctionMatrix
     */
    public function testCreateFunctionMatrix(array $A)
    {
        $A = MatrixFactory::create($A);

        $this->assertInstanceOf('Math\LinearAlgebra\FunctionMatrix', $A);
        $this->assertInstanceOf('Math\LinearAlgebra\Matrix', $A);
    }

    public function dataProviderForFunctionMatrix()
    {
        $function = function ($x) {
            return $x * 2;
        };

        return [
            [
                [
                    [$function, $function]
                ]
            ],
            [
                [
                    [$function, $function],
                    [$function, $function],
                    [$function, $function],
                ],
            ],
            [
                [
                    [$function, $function, $function],
                    [$function, $function, $function],
                    [$function, $function, $function],
                    [$function, $function, $function],
                ],
            ],
        ];
    }

    /**
     * @dataProvider dataProviderForMatrix
     */
    public function testCreateMatrix(array $A)
    {
        $A = MatrixFactory::create($A);

        $this->assertInstanceOf('Math\LinearAlgebra\Matrix', $A);

        $this->assertNotInstanceOf('Math\LinearAlgebra\SquareMatrix', $A);
        $this->assertNotInstanceOf('Math\LinearAlgebra\FunctionMatrix', $A);
        $this->assertNotInstanceOf('Math\LinearAlgebra\VandermondeMatrix', $A);
        $this->assertNotInstanceOf('Math\LinearAlgebra\DiagonalMatrix', $A);
    }

    public function dataProviderForMatrix()
    {
        return [
            [
                [
{'fraction_non_alphanumeric': 0.14196865411725682, 'fraction_numerical': 0.011526660585454847, 'mean_word_length': 1.3885918003565063, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5439030', 'n_tokens_mistral': 3558, 'n_tokens_neox': 3329, 'n_words': 624}