Implement some functions.

This commit is contained in:
CismonX 2019-06-02 23:04:39 +08:00
parent 87187d4fdd
commit a5b4f5b682
1 changed files with 76 additions and 9 deletions

View File

@ -7,60 +7,127 @@
#include "resizable_matrix.hh"
#include "mat.hh"
#include <armadillo>
namespace php_arma
{
template <typename T, typename T1>
PHP_ARMA_METHOD(resizable_matrix, reshape, T, T1)
{
zend_long n_rows, n_cols;
ZEND_PARSE_PARAMETERS_START(2, 2)
Z_PARAM_LONG_DEREF(n_rows)
Z_PARAM_LONG_DEREF(n_cols)
ZEND_PARSE_PARAMETERS_END();
auto native = THIS_NATIVE;
native->reshape(n_rows, n_cols);
}
template <typename T, typename T1>
PHP_ARMA_METHOD(resizable_matrix, resize, T, T1)
{
zend_long n_rows, n_cols;
ZEND_PARSE_PARAMETERS_START(2, 2)
Z_PARAM_LONG_DEREF(n_rows)
Z_PARAM_LONG_DEREF(n_cols)
ZEND_PARSE_PARAMETERS_END();
auto native = THIS_NATIVE;
native->resize(n_rows, n_cols);
}
template <typename T, typename T1>
PHP_ARMA_METHOD(resizable_matrix, setSize, T, T1)
{
zend_long n_rows, n_cols;
ZEND_PARSE_PARAMETERS_START(2, 2)
Z_PARAM_LONG_DEREF(n_rows)
Z_PARAM_LONG_DEREF(n_cols)
ZEND_PARSE_PARAMETERS_END();
auto native = THIS_NATIVE;
native->set_size(n_rows, n_cols);
}
template <typename T, typename T1>
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_DEREF(n_rows)
Z_PARAM_LONG_DEREF(n_cols)
ZEND_PARSE_PARAMETERS_END();
auto native = THIS_NATIVE;
native->zeros(n_rows, n_cols);
}
template <typename T, typename T1>
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_DEREF(n_rows)
Z_PARAM_LONG_DEREF(n_cols)
ZEND_PARSE_PARAMETERS_END();
auto native = THIS_NATIVE;
native->eye(n_rows, n_cols);
}
template <typename T, typename T1>
PHP_ARMA_METHOD(resizable_matrix, shedRow, T, T1)
{
zend_long row_idx;
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_LONG_DEREF(row_idx)
ZEND_PARSE_PARAMETERS_END();
auto native = THIS_NATIVE;
native->shed_row(row_idx);
}
template <typename T, typename T1>
PHP_ARMA_METHOD(resizable_matrix, shedCol, T, T1)
{
zend_long col_idx;
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_LONG_DEREF(col_idx)
ZEND_PARSE_PARAMETERS_END();
auto native = THIS_NATIVE;
native->shed_col(col_idx);
}
template <typename T, typename T1>
PHP_ARMA_METHOD(resizable_matrix, shedRows, T, T1)
{
zend_long first_row, last_row;
ZEND_PARSE_PARAMETERS_START(2, 2)
Z_PARAM_LONG_DEREF(first_row)
Z_PARAM_LONG_DEREF(last_row)
ZEND_PARSE_PARAMETERS_END();
auto native = THIS_NATIVE;
native->shed_rows(first_row, last_row);
}
template <typename T, typename T1>
PHP_ARMA_METHOD(resizable_matrix, shedCols, T, T1)
{
zend_long first_col, last_col;
ZEND_PARSE_PARAMETERS_START(2, 2)
Z_PARAM_LONG_DEREF(first_col)
Z_PARAM_LONG_DEREF(last_col)
ZEND_PARSE_PARAMETERS_END();
auto native = THIS_NATIVE;
native->shed_rows(first_col, last_col);
}
template <typename T, typename T1>