// // php-armadillo/resizable_matrix.cc // // @Author CismonX // #include "resizable_matrix.hh" #include "resizable.hh" #include "matrix.hh" #include "mat.hh" namespace php_arma { template PHP_ARMA_METHOD(resizable_matrix, reshape, T, T1) { zend_long n_rows, n_cols; ZEND_PARSE_PARAMETERS_START(2, 2) Z_PARAM_LONG(n_rows) Z_PARAM_LONG(n_cols) ZEND_PARSE_PARAMETERS_END(); auto native = THIS_NATIVE; native->reshape(n_rows, n_cols); } template PHP_ARMA_METHOD(resizable_matrix, resize, T, T1) { zend_long n_rows, n_cols; ZEND_PARSE_PARAMETERS_START(2, 2) Z_PARAM_LONG(n_rows) Z_PARAM_LONG(n_cols) ZEND_PARSE_PARAMETERS_END(); auto native = THIS_NATIVE; native->resize(n_rows, n_cols); } template PHP_ARMA_METHOD(resizable_matrix, setSize, T, T1) { zend_long n_rows, n_cols; ZEND_PARSE_PARAMETERS_START(2, 2) Z_PARAM_LONG(n_rows) Z_PARAM_LONG(n_cols) ZEND_PARSE_PARAMETERS_END(); auto native = THIS_NATIVE; native->set_size(n_rows, n_cols); } template PHP_ARMA_METHOD(resizable_matrix, zeros, T, T1) { zend_long n_rows = 0; zend_long n_cols = 0; ZEND_PARSE_PARAMETERS_START(0, 2) Z_PARAM_OPTIONAL Z_PARAM_LONG(n_rows) Z_PARAM_LONG(n_cols) ZEND_PARSE_PARAMETERS_END(); auto native = THIS_NATIVE; native->zeros(n_rows, n_cols); RETVAL_THIS(); } template PHP_ARMA_METHOD(resizable_matrix, eye, T, T1) { zend_long n_rows = 0; zend_long n_cols = 0; ZEND_PARSE_PARAMETERS_START(0, 2) Z_PARAM_OPTIONAL Z_PARAM_LONG(n_rows) Z_PARAM_LONG(n_cols) ZEND_PARSE_PARAMETERS_END(); auto native = THIS_NATIVE; native->eye(n_rows, n_cols); RETVAL_THIS(); } template PHP_ARMA_METHOD(resizable_matrix, inRange, T, T1) { zend_long row; zend_long col; ZEND_PARSE_PARAMETERS_START(1, 2) Z_PARAM_LONG(row) Z_PARAM_OPTIONAL Z_PARAM_LONG(col) ZEND_PARSE_PARAMETERS_END(); auto native = THIS_NATIVE; if (EX_NUM_ARGS() == 1) { RETURN_BOOL(native->in_range(row)); } RETVAL_BOOL(native->in_range(row, col)); } template PHP_ARMA_METHOD(resizable_matrix, shedRow, T, T1) { zend_long row_idx; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_LONG(row_idx) ZEND_PARSE_PARAMETERS_END(); auto native = THIS_NATIVE; native->shed_row(row_idx); } template PHP_ARMA_METHOD(resizable_matrix, shedCol, T, T1) { zend_long col_idx; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_LONG(col_idx) ZEND_PARSE_PARAMETERS_END(); auto native = THIS_NATIVE; native->shed_col(col_idx); } template PHP_ARMA_METHOD(resizable_matrix, shedRows, T, T1) { zend_long first_row, last_row; ZEND_PARSE_PARAMETERS_START(2, 2) Z_PARAM_LONG(first_row) Z_PARAM_LONG(last_row) ZEND_PARSE_PARAMETERS_END(); auto native = THIS_NATIVE; native->shed_rows(first_row, last_row); } template PHP_ARMA_METHOD(resizable_matrix, shedCols, T, T1) { zend_long first_col, last_col; ZEND_PARSE_PARAMETERS_START(2, 2) Z_PARAM_LONG(first_col) Z_PARAM_LONG(last_col) ZEND_PARSE_PARAMETERS_END(); auto native = THIS_NATIVE; native->shed_rows(first_col, last_col); } template PHP_ARMA_START_ME(resizable_matrix, T, T1) PHP_ARMA_ME(reshape, ZEND_ACC_PUBLIC) PHP_ARMA_ME(resize, ZEND_ACC_PUBLIC) PHP_ARMA_ME(setSize, ZEND_ACC_PUBLIC) PHP_ARMA_ME(zeros, ZEND_ACC_PUBLIC) PHP_ARMA_ME(eye, ZEND_ACC_PUBLIC) PHP_ARMA_ME(inRange, ZEND_ACC_PUBLIC) PHP_ARMA_ME(shedRow, ZEND_ACC_PUBLIC) PHP_ARMA_ME(shedCol, ZEND_ACC_PUBLIC) PHP_ARMA_ME(shedRows, ZEND_ACC_PUBLIC) PHP_ARMA_ME(shedCols, ZEND_ACC_PUBLIC) PHP_ARMA_END_ME(); void resizable_matrix_init() { resizable_matrix_ce = interface_register(resizable_ce, matrix_ce); } PHP_ARMA_INSTANTIATE(resizable_matrix, mat); }