Add `toMat()`. Update tests.
This commit is contained in:
parent
af6e0c53f5
commit
665145a40e
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include "subview_mat.hh"
|
#include "subview_mat.hh"
|
||||||
#include "subview.hh"
|
#include "subview.hh"
|
||||||
|
#include "mat.hh"
|
||||||
#include "base.hh"
|
#include "base.hh"
|
||||||
#include "dense.hh"
|
#include "dense.hh"
|
||||||
#include "matrix.hh"
|
#include "matrix.hh"
|
||||||
|
@ -16,8 +17,16 @@
|
||||||
|
|
||||||
namespace php_arma
|
namespace php_arma
|
||||||
{
|
{
|
||||||
|
template <typename T>
|
||||||
|
PHP_ARMA_METHOD(subview_mat, toMat, T)
|
||||||
|
{
|
||||||
|
auto native = THIS_NATIVE;
|
||||||
|
RETVAL_OBJ(mat<T>::create(*native));
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
PHP_ARMA_START_ME(subview_mat, T)
|
PHP_ARMA_START_ME(subview_mat, T)
|
||||||
|
PHP_ARMA_ME(toMat, ZEND_ACC_PUBLIC)
|
||||||
PHP_ARMA_END_ME();
|
PHP_ARMA_END_ME();
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|
|
@ -31,6 +31,8 @@ namespace php_arma
|
||||||
private:
|
private:
|
||||||
PHP_ARMA_COMMON_DECLARE();
|
PHP_ARMA_COMMON_DECLARE();
|
||||||
|
|
||||||
|
static PHP_FUNCTION(toMat);
|
||||||
|
|
||||||
static void ce_init(zend_class_entry*);
|
static void ce_init(zend_class_entry*);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -9,5 +9,9 @@ namespace Arma;
|
||||||
*/
|
*/
|
||||||
abstract class SvMat implements Internal\DenseNonResizableMatrix, Internal\Subview
|
abstract class SvMat implements Internal\DenseNonResizableMatrix, Internal\Subview
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Create a new matrix with elements copied from this matrix subview.
|
||||||
|
* @return Mat
|
||||||
|
*/
|
||||||
|
function toMat() {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,6 @@ is_php_arma_loaded();
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'includes/assert.php';
|
|
||||||
|
|
||||||
$mat = Arma\CxDMat::fromString('(1,2) (3,4); (5,6) (7,8)');
|
$mat = Arma\CxDMat::fromString('(1,2) (3,4); (5,6) (7,8)');
|
||||||
$mat->print();
|
$mat->print();
|
||||||
$mat->rawPrint();
|
$mat->rawPrint();
|
||||||
|
|
|
@ -8,8 +8,6 @@ is_php_arma_loaded();
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'includes/assert.php';
|
|
||||||
|
|
||||||
$mat = Arma\IMat::fromString('1 2; 3 4');
|
$mat = Arma\IMat::fromString('1 2; 3 4');
|
||||||
$mat->rawPrint();
|
$mat->rawPrint();
|
||||||
$mat->forEach(function (Arma\MapVal $elem) {
|
$mat->forEach(function (Arma\MapVal $elem) {
|
||||||
|
|
|
@ -8,8 +8,6 @@ is_php_arma_loaded();
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'includes/assert.php';
|
|
||||||
|
|
||||||
$cx = Arma\cx_double(1., 2.);
|
$cx = Arma\cx_double(1., 2.);
|
||||||
$mat = Arma\IMat::fromString('1 2; 3 4');
|
$mat = Arma\IMat::fromString('1 2; 3 4');
|
||||||
echo $cx, ' ', $mat, PHP_EOL;
|
echo $cx, ' ', $mat, PHP_EOL;
|
||||||
|
|
|
@ -8,8 +8,6 @@ is_php_arma_loaded();
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'includes/assert.php';
|
|
||||||
|
|
||||||
$cx_dmat = Arma\CxDMat::fromString('(1,2) (3,4); (5,6) (7,8)');
|
$cx_dmat = Arma\CxDMat::fromString('(1,2) (3,4); (5,6) (7,8)');
|
||||||
$dmat = Arma\DMat::fromString('3 5; 7 9');
|
$dmat = Arma\DMat::fromString('3 5; 7 9');
|
||||||
$cx_dmat->setImag($dmat);
|
$cx_dmat->setImag($dmat);
|
||||||
|
|
|
@ -8,8 +8,6 @@ is_php_arma_loaded();
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'includes/assert.php';
|
|
||||||
|
|
||||||
$mat = Arma\IMat::fromString("1 2; 3 4");
|
$mat = Arma\IMat::fromString("1 2; 3 4");
|
||||||
|
|
||||||
$diag = $mat->diag();
|
$diag = $mat->diag();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
Test for method `copySize()`
|
Test for method `copySize()`.
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php
|
<?php
|
||||||
require_once 'includes/loaded.php';
|
require_once 'includes/loaded.php';
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
--TEST--
|
||||||
|
Test for method `toMat()`.
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
require_once 'includes/loaded.php';
|
||||||
|
is_php_arma_loaded();
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$mat = Arma\IMat::init(3, 3, Arma\Fill::ZEROS);
|
||||||
|
$submat = $mat->submat(1, 1, 2, 2);
|
||||||
|
$mat1 = $submat->toMat();
|
||||||
|
$mat1->at(0, 0)->setTo(1);
|
||||||
|
$mat->rawPrint();
|
||||||
|
$mat1->rawPrint();
|
||||||
|
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
0 0 0
|
||||||
|
0 0 0
|
||||||
|
0 0 0
|
||||||
|
1 0
|
||||||
|
0 0
|
Reference in New Issue