code refactor
This commit is contained in:
parent
9033f84132
commit
cc8bafe60b
|
@ -9,6 +9,8 @@
|
|||
#include "mat.hh"
|
||||
#include "subview_mat.hh"
|
||||
|
||||
#include <armadillo>
|
||||
|
||||
namespace php_arma
|
||||
{
|
||||
template <typename T, typename T1>
|
||||
|
|
10
src/dense.hh
10
src/dense.hh
|
@ -10,8 +10,6 @@
|
|||
#include "php_arma.hh"
|
||||
#include "complex.hh"
|
||||
|
||||
#include <armadillo>
|
||||
|
||||
#define PHP_ARMA_DENSE_OPERATOR_EX2(cls, type, func) \
|
||||
PHP_ARMA_OPERATOR_EX2((dense<type, cls<type>>), cls<type>, func)
|
||||
|
||||
|
@ -26,6 +24,11 @@
|
|||
PHP_ARMA_DENSE_OPERATOR_EX(subview_mat, func) \
|
||||
PHP_ARMA_OPERATOR_END()
|
||||
|
||||
namespace arma
|
||||
{
|
||||
template <typename T> class conv_to;
|
||||
}
|
||||
|
||||
namespace php_arma
|
||||
{
|
||||
template <typename T, typename ChildT>
|
||||
|
@ -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<n_orig_t*>(), std::declval<n_orig_t*>()).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) {
|
||||
|
|
|
@ -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<void(base)>::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.
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
#include "non_resizable_matrix.hh"
|
||||
#include "dense_non_resizable_matrix.hh"
|
||||
|
||||
#include <armadillo>
|
||||
|
||||
namespace php_arma
|
||||
{
|
||||
template <typename T>
|
||||
|
|
|
@ -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)]
|
||||
);
|
||||
|
|
Reference in New Issue
Block a user