// // php-armadillo/dense.cc // // @Author CismonX // #include "dense.hh" #include "base.hh" #include "mat.hh" #include "subview_mat.hh" #include "diagonal.hh" namespace php_arma { template PHP_ARMA_METHOD(dense, equals, T, T1) { zval *other; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ZVAL(other) ZEND_PARSE_PARAMETERS_END(); operators::equals(&EX(This), other, return_value); } template PHP_ARMA_METHOD(dense, notEquals, T, T1) { zval *other; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ZVAL(other) ZEND_PARSE_PARAMETERS_END(); operators::not_equals(&EX(This), other, return_value); } template PHP_ARMA_METHOD(dense, greaterThan, T, T1) { zval *other; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ZVAL(other) ZEND_PARSE_PARAMETERS_END(); operators::greater_than(&EX(This), other, return_value); } template PHP_ARMA_METHOD(dense, smallerThan, T, T1) { zval *other; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ZVAL(other) ZEND_PARSE_PARAMETERS_END(); operators::smaller_than(&EX(This), other, return_value); } template PHP_ARMA_METHOD(dense, notGreaterThan, T, T1) { zval *other; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ZVAL(other) ZEND_PARSE_PARAMETERS_END(); operators::not_greater_than(&EX(This), other, return_value); } template PHP_ARMA_METHOD(dense, notSmallerThan, T, T1) { zval *other; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ZVAL(other) ZEND_PARSE_PARAMETERS_END(); operators::not_smaller_than(&EX(This), other, return_value); } template PHP_ARMA_METHOD(dense, fill, T, T1) { zval *value; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ZVAL(value); ZEND_PARSE_PARAMETERS_END(); if (!zval_check_scalar(value)) { return; } auto native = THIS_NATIVE; native->fill(zval_get_scalar(value)); } template PHP_ARMA_METHOD(dense, imbue, T, ChildT) { zend_fcall_info fci; zend_fcall_info_cache fcc; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_FUNC(fci, fcc); ZEND_PARSE_PARAMETERS_END(); if constexpr (std::is_same_v>) { throw_error("This method is not yet supported on diagview"); return; } else { zval retval; fci.retval = &retval; auto native = THIS_NATIVE; native->imbue([&fci, &fcc]() { zend_call_function(&fci, &fcc); if (!zval_check_scalar(fci.retval)) { zval_ptr_dtor(fci.retval); return T(); } T retval = zval_get_scalar(fci.retval); if constexpr (std::is_same_v) { zval_ptr_dtor(fci.retval); } return retval; }); } } template PHP_ARMA_START_ME(dense, T, T1) PHP_ARMA_ME(equals, ZEND_ACC_PUBLIC) PHP_ARMA_ME(notEquals, ZEND_ACC_PUBLIC) PHP_ARMA_ME(greaterThan, ZEND_ACC_PUBLIC) PHP_ARMA_ME(smallerThan, ZEND_ACC_PUBLIC) PHP_ARMA_ME(notGreaterThan, ZEND_ACC_PUBLIC) PHP_ARMA_ME(notSmallerThan, ZEND_ACC_PUBLIC) PHP_ARMA_ME(fill, ZEND_ACC_PUBLIC) PHP_ARMA_ME(imbue, ZEND_ACC_PUBLIC) PHP_ARMA_END_ME(); void dense_init() { dense_ce = interface_register(base_ce); } PHP_ARMA_INSTANTIATE(dense, mat); PHP_ARMA_INSTANTIATE(dense, subview_mat); PHP_ARMA_INSTANTIATE(dense, diagview); }