This repository has been archived on 2020-06-07. You can view files and clone it, but cannot push or open issues or pull requests.
php-armadillo/tests/014-arithmetic.phpt

35 lines
877 B
PHP

--TEST--
Test for methods performing arithmetic operations.
--SKIPIF--
<?php
require_once 'includes/loaded.php';
is_php_arma_loaded();
?>
--FILE--
<?php
require_once 'includes/assert.php';
$mat = Arma\IMat::fromString('1 2; 3 4');
$mat1 = Arma\IMat::fromString('5 6; 7 8');
function str2mat($str) {
return Arma\IMat::fromString($str);
}
batch_assert_mat('arithmetic operations',
[str2mat('6 8; 10 12'), $mat->add($mat1)],
[str2mat('2 3; 4 5'), $mat->add(1)],
[str2mat('-4 -4; -4 -4'), $mat->sub($mat1)],
[str2mat('-1 0; 1 2'), $mat->sub(2)],
[str2mat('-1 -2; -3 -4'), $mat->neg()],
[str2mat('19 22; 43 50'), $mat->mul($mat1)],
[str2mat('2 4; 6 8'), $mat->mul(2)],
[str2mat('5 12; 21 32'), $mat->dotMul($mat1)],
[str2mat('0 0; 0 0'), $mat->div($mat1)],
[str2mat('0 1; 1 2'), $mat->div(2)]
);
?>
--EXPECT--