diff --git a/src/dense.cc b/src/dense.cc index ef66756..a4e5d42 100644 --- a/src/dense.cc +++ b/src/dense.cc @@ -9,6 +9,8 @@ #include "mat.hh" #include "subview_mat.hh" +#include + namespace php_arma { template diff --git a/src/dense.hh b/src/dense.hh index a01d87f..c1af3be 100644 --- a/src/dense.hh +++ b/src/dense.hh @@ -10,8 +10,6 @@ #include "php_arma.hh" #include "complex.hh" -#include - #define PHP_ARMA_DENSE_OPERATOR_EX2(cls, type, func) \ PHP_ARMA_OPERATOR_EX2((dense>), cls, func) @@ -26,6 +24,11 @@ PHP_ARMA_DENSE_OPERATOR_EX(subview_mat, func) \ PHP_ARMA_OPERATOR_END() +namespace arma +{ + template class conv_to; +} + namespace php_arma { template @@ -52,8 +55,9 @@ namespace php_arma using n_subview_t = typename ChildT::subview_t::native_t; using dest_t = typename ChildT::with_int_elem_t::orig_t; using dest_native_t = typename dest_t::native_t; + using n_uint_t = decltype(func(std::declval(), std::declval()).eval()); try { - arma::umat ret; + n_uint_t ret; auto o1 = Z_OBJ_P(zv1); auto o2 = Z_OBJ_P(zv2); if (Z_OBJCE_P(zv1) == ChildT::orig_t::ce) { diff --git a/src/php_arma.hh b/src/php_arma.hh index 7401160..8a808d7 100644 --- a/src/php_arma.hh +++ b/src/php_arma.hh @@ -95,15 +95,19 @@ #define PHP_ARMA_OPERATOR_EX(cls, func) \ PHP_ARMA_OPERATOR_EX2(cls, cls, func) -#define PHP_ARMA_ASSIGN_OPERATOR_EX(cls, func) \ - if (instanceof_function(ce, cls::ce)) { \ - auto v = cls::operators::func(zv1, zv2, zv1); \ +#define PHP_ARMA_ASSIGN_OPERATOR_EX2(base, child, func) \ + if (instanceof_function(ce, child::ce)) { \ + using base_t = arg_type::type; \ + auto v = base_t::operators::func(zv1, zv2, zv1); \ if (rv) { \ ZVAL_COPY(rv, zv1); \ } \ return v; \ } +#define PHP_ARMA_ASSIGN_OPERATOR_EX(cls, func) \ + PHP_ARMA_ASSIGN_OPERATOR_EX2(cls, cls, func) + #endif // PHP_ARMA_OPERATORS /// Helper macros for handling native objects. diff --git a/src/subview_mat.cc b/src/subview_mat.cc index 2157ff9..f7f1d62 100644 --- a/src/subview_mat.cc +++ b/src/subview_mat.cc @@ -14,6 +14,8 @@ #include "non_resizable_matrix.hh" #include "dense_non_resizable_matrix.hh" +#include + namespace php_arma { template diff --git a/tests/004-mat-save-load.phpt b/tests/004-mat-save-load.phpt index fdf42ed..65f6201 100644 --- a/tests/004-mat-save-load.phpt +++ b/tests/004-mat-save-load.phpt @@ -17,7 +17,7 @@ require_once 'includes/assert.php'; $file_name = getenv('TMP_FILE'); -$mat = Arma\CxDMat::fromString('(1 2) (3 4); (5 6) (7 8)'); +$mat = Arma\CxDMat::fromString('(1,2) (3,4); (5,6) (7,8)'); batch_assert('saving of `Arma\\Mat`', [true, $mat->save($file_name, Arma\FileType::ARMA_BINARY)] );