#ifdef HAVE_CONFIG_H #include "../ext_config.h" #endif #include #include "../php_ext.h" #include "../ext.h" #include #include #include #include "kernel/main.h" #include "kernel/fcall.h" #include "kernel/memory.h" #include "kernel/operators.h" #include "kernel/object.h" #include "kernel/exception.h" #include "kernel/concat.h" #include "kernel/array.h" #include "math.h" #include "kernel/math.h" #include "ext/spl/spl_array.h" #include "include/linear_algebra.h" #include "include/signal_processing.h" #include "include/arithmetic.h" #include "include/comparison.h" /** * Vector * * A one dimensional (rank 1) tensor with integer and/or floating point elements. * * @category Scientific Computing * @package Rubix/Tensor * @author Andrew DalPino */ ZEPHIR_INIT_CLASS(Tensor_Vector) { ZEPHIR_REGISTER_CLASS(Tensor, Vector, tensor, vector, tensor_vector_method_entry, 0); /** * A 1-d sequential array holding the elements of the vector. * * @var list */ zend_declare_property_null(tensor_vector_ce, SL("a"), ZEND_ACC_PROTECTED); /** * The number of elements in the vector. * * @var int */ zend_declare_property_null(tensor_vector_ce, SL("n"), ZEND_ACC_PROTECTED); zend_class_implements(tensor_vector_ce, 1, tensor_tensor_ce); return SUCCESS; } /** * Factory method to build a new vector from an array. * * @param float[] a * @return self */ PHP_METHOD(Tensor_Vector, build) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *a_param = NULL, _0; zval a; zval *this_ptr = getThis(); ZVAL_UNDEF(&a); ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL Z_PARAM_ARRAY(a) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &a_param); if (!a_param) { ZEPHIR_INIT_VAR(&a); array_init(&a); } else { zephir_get_arrval(&a, a_param); } object_init_ex(return_value, tensor_vector_ce); ZVAL_BOOL(&_0, 1); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 1, &a, &_0); zephir_check_call_status(); RETURN_MM(); } /** * Build a vector foregoing any validation for quicker instantiation. * * @param float[] a * @return self */ PHP_METHOD(Tensor_Vector, quick) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *a_param = NULL, _0; zval a; zval *this_ptr = getThis(); ZVAL_UNDEF(&a); ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL Z_PARAM_ARRAY(a) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &a_param); if (!a_param) { ZEPHIR_INIT_VAR(&a); array_init(&a); } else { zephir_get_arrval(&a, a_param); } object_init_ex(return_value, tensor_vector_ce); ZVAL_BOOL(&_0, 0); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 1, &a, &_0); zephir_check_call_status(); RETURN_MM(); } /** * Build a vector of zeros with n elements. * * @param int n * @throws \Tensor\Exceptions\InvalidArgumentException * @return self */ PHP_METHOD(Tensor_Vector, zeros) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zval *n_param = NULL, _0, _1; zend_long n, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_LONG(n) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &n_param); n = zephir_get_intval(n_param); ZVAL_DOUBLE(&_0, 0.0); ZVAL_LONG(&_1, n); ZEPHIR_RETURN_CALL_STATIC("fill", NULL, 0, &_0, &_1); zephir_check_call_status(); RETURN_MM(); } /** * Build a vector of ones with n elements. * * @param int n * @throws \Tensor\Exceptions\InvalidArgumentException * @return self */ PHP_METHOD(Tensor_Vector, ones) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zval *n_param = NULL, _0, _1; zend_long n, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_LONG(n) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &n_param); n = zephir_get_intval(n_param); ZVAL_DOUBLE(&_0, 1.0); ZVAL_LONG(&_1, n); ZEPHIR_RETURN_CALL_STATIC("fill", NULL, 0, &_0, &_1); zephir_check_call_status(); RETURN_MM(); } /** * Fill a vector with a given value. * * @param float value * @param int n * @throws \Tensor\Exceptions\InvalidArgumentException * @return self */ PHP_METHOD(Tensor_Vector, fill) { zend_bool _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long n, ZEPHIR_LAST_CALL_STATUS; zval *value_param = NULL, *n_param = NULL, _0, _2, _3, _12, _13, _14, _4$$3, _5$$3, _6$$3, _7$$3, _8$$4, _9$$4, _10$$4, _11$$4; double value; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); ZVAL_UNDEF(&_12); ZVAL_UNDEF(&_13); ZVAL_UNDEF(&_14); ZVAL_UNDEF(&_4$$3); ZVAL_UNDEF(&_5$$3); ZVAL_UNDEF(&_6$$3); ZVAL_UNDEF(&_7$$3); ZVAL_UNDEF(&_8$$4); ZVAL_UNDEF(&_9$$4); ZVAL_UNDEF(&_10$$4); ZVAL_UNDEF(&_11$$4); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(2, 2) Z_PARAM_ZVAL(value) Z_PARAM_LONG(n) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &value_param, &n_param); value = zephir_get_doubleval(value_param); n = zephir_get_intval(n_param); ZVAL_DOUBLE(&_0, value); _1 = !(Z_TYPE_P(&_0) == IS_LONG); if (_1) { ZVAL_DOUBLE(&_2, value); ZEPHIR_CALL_FUNCTION(&_3, "is_float", NULL, 2, &_2); zephir_check_call_status(); _1 = !zephir_is_true(&_3); } if (UNEXPECTED(_1)) { ZEPHIR_INIT_VAR(&_4$$3); object_init_ex(&_4$$3, tensor_exceptions_invalidargumentexception_ce); ZEPHIR_INIT_VAR(&_5$$3); ZVAL_DOUBLE(&_6$$3, value); zephir_gettype(&_5$$3, &_6$$3); ZEPHIR_INIT_VAR(&_7$$3); ZEPHIR_CONCAT_SSVS(&_7$$3, "Value must be an", " integer or floating point number, ", &_5$$3, " given."); ZEPHIR_CALL_METHOD(NULL, &_4$$3, "__construct", NULL, 3, &_7$$3); zephir_check_call_status(); zephir_throw_exception_debug(&_4$$3, "tensor/vector.zep", 92); ZEPHIR_MM_RESTORE(); return; } if (UNEXPECTED(n < 1)) { ZEPHIR_INIT_VAR(&_8$$4); object_init_ex(&_8$$4, tensor_exceptions_invalidargumentexception_ce); ZVAL_LONG(&_9$$4, n); ZEPHIR_CALL_FUNCTION(&_10$$4, "strval", NULL, 4, &_9$$4); zephir_check_call_status(); ZEPHIR_INIT_VAR(&_11$$4); ZEPHIR_CONCAT_SSVS(&_11$$4, "N must be", " greater than 0, ", &_10$$4, " given."); ZEPHIR_CALL_METHOD(NULL, &_8$$4, "__construct", NULL, 3, &_11$$4); zephir_check_call_status(); zephir_throw_exception_debug(&_8$$4, "tensor/vector.zep", 97); ZEPHIR_MM_RESTORE(); return; } ZVAL_LONG(&_2, 0); ZVAL_LONG(&_12, n); ZVAL_DOUBLE(&_13, value); ZEPHIR_CALL_FUNCTION(&_14, "array_fill", NULL, 5, &_2, &_12, &_13); zephir_check_call_status(); ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &_14); zephir_check_call_status(); RETURN_MM(); } /** * Return a random uniform vector with values between 0 and 1. * * @param int n * @throws \Tensor\Exceptions\InvalidArgumentException * @return self */ PHP_METHOD(Tensor_Vector, rand) { zval a; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zephir_fcall_cache_entry *_6 = NULL; zval *n_param = NULL, _0$$3, _1$$3, _2$$3, _3$$3, _4, _5$$4, _7$$4; zend_long n, ZEPHIR_LAST_CALL_STATUS, max; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0$$3); ZVAL_UNDEF(&_1$$3); ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_3$$3); ZVAL_UNDEF(&_4); ZVAL_UNDEF(&_5$$4); ZVAL_UNDEF(&_7$$4); ZVAL_UNDEF(&a); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_LONG(n) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &n_param); n = zephir_get_intval(n_param); if (UNEXPECTED(n < 1)) { ZEPHIR_INIT_VAR(&_0$$3); object_init_ex(&_0$$3, tensor_exceptions_invalidargumentexception_ce); ZVAL_LONG(&_1$$3, n); ZEPHIR_CALL_FUNCTION(&_2$$3, "strval", NULL, 4, &_1$$3); zephir_check_call_status(); ZEPHIR_INIT_VAR(&_3$$3); ZEPHIR_CONCAT_SSVS(&_3$$3, "N must be", " greater than 0, ", &_2$$3, " given."); ZEPHIR_CALL_METHOD(NULL, &_0$$3, "__construct", NULL, 3, &_3$$3); zephir_check_call_status(); zephir_throw_exception_debug(&_0$$3, "tensor/vector.zep", 114); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(&a); array_init(&a); ZEPHIR_CALL_FUNCTION(&_4, "getrandmax", NULL, 6); zephir_check_call_status(); max = zephir_get_intval(&_4); while (1) { if (!(zephir_fast_count_int(&a) < n)) { break; } ZEPHIR_CALL_FUNCTION(&_5$$4, "rand", &_6, 7); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_7$$4); ZVAL_DOUBLE(&_7$$4, zephir_safe_div_zval_long(&_5$$4, max)); zephir_array_append(&a, &_7$$4, PH_SEPARATE, "tensor/vector.zep", 122); } ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &a); zephir_check_call_status(); RETURN_MM(); } /** * Return a standard normally distributed (Gaussian) random vector with mean 0 * and unit variance. * * @param int n * @throws \Tensor\Exceptions\InvalidArgumentException * @return self */ PHP_METHOD(Tensor_Vector, gaussian) { zval a; double r = 0, phi = 0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zephir_fcall_cache_entry *_6 = NULL, *_9 = NULL; zval *n_param = NULL, _0$$3, _1$$3, _2$$3, _3$$3, _4, _5$$4, _7$$4, _8$$4, _10$$4, _11$$4, _12$$4, _13$$4; zend_long n, ZEPHIR_LAST_CALL_STATUS, max; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0$$3); ZVAL_UNDEF(&_1$$3); ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_3$$3); ZVAL_UNDEF(&_4); ZVAL_UNDEF(&_5$$4); ZVAL_UNDEF(&_7$$4); ZVAL_UNDEF(&_8$$4); ZVAL_UNDEF(&_10$$4); ZVAL_UNDEF(&_11$$4); ZVAL_UNDEF(&_12$$4); ZVAL_UNDEF(&_13$$4); ZVAL_UNDEF(&a); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_LONG(n) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &n_param); n = zephir_get_intval(n_param); if (UNEXPECTED(n < 1)) { ZEPHIR_INIT_VAR(&_0$$3); object_init_ex(&_0$$3, tensor_exceptions_invalidargumentexception_ce); ZVAL_LONG(&_1$$3, n); ZEPHIR_CALL_FUNCTION(&_2$$3, "strval", NULL, 4, &_1$$3); zephir_check_call_status(); ZEPHIR_INIT_VAR(&_3$$3); ZEPHIR_CONCAT_SSVS(&_3$$3, "N must be", " greater than 0, ", &_2$$3, " given."); ZEPHIR_CALL_METHOD(NULL, &_0$$3, "__construct", NULL, 3, &_3$$3); zephir_check_call_status(); zephir_throw_exception_debug(&_0$$3, "tensor/vector.zep", 140); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(&a); array_init(&a); ZEPHIR_CALL_FUNCTION(&_4, "getrandmax", NULL, 6); zephir_check_call_status(); max = zephir_get_intval(&_4); while (1) { if (!(zephir_fast_count_int(&a) < n)) { break; } ZEPHIR_CALL_FUNCTION(&_5$$4, "rand", &_6, 7); zephir_check_call_status(); ZVAL_DOUBLE(&_7$$4, zephir_safe_div_zval_long(&_5$$4, max)); ZEPHIR_CALL_FUNCTION(&_8$$4, "log", &_9, 8, &_7$$4); zephir_check_call_status(); ZVAL_DOUBLE(&_7$$4, (-2.0 * zephir_get_numberval(&_8$$4))); r = sqrt((-2.0 * zephir_get_numberval(&_8$$4))); ZEPHIR_CALL_FUNCTION(&_10$$4, "rand", &_6, 7); zephir_check_call_status(); phi = (zephir_safe_div_zval_long(&_10$$4, max) * 6.28318530718); ZVAL_DOUBLE(&_11$$4, phi); ZEPHIR_INIT_NVAR(&_12$$4); ZVAL_DOUBLE(&_12$$4, (r * sin(phi))); zephir_array_append(&a, &_12$$4, PH_SEPARATE, "tensor/vector.zep", 154); ZVAL_DOUBLE(&_13$$4, phi); ZEPHIR_INIT_NVAR(&_12$$4); ZVAL_DOUBLE(&_12$$4, (r * cos(phi))); zephir_array_append(&a, &_12$$4, PH_SEPARATE, "tensor/vector.zep", 155); } if (zephir_fast_count_int(&a) > n) { ZEPHIR_MAKE_REF(&a); ZEPHIR_CALL_FUNCTION(NULL, "array_pop", NULL, 9, &a); ZEPHIR_UNREF(&a); zephir_check_call_status(); } ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &a); zephir_check_call_status(); RETURN_MM(); } /** * Generate a vector with n elements from a Poisson distribution. * * @param int n * @param float lambda * @throws \Tensor\Exceptions\InvalidArgumentException * @return self */ PHP_METHOD(Tensor_Vector, poisson) { zval a; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zephir_fcall_cache_entry *_8 = NULL; double lambda, p = 0, k = 0, l; zval *n_param = NULL, *lambda_param = NULL, _0$$3, _1$$3, _2$$3, _3$$3, _4, _5, _6, _7$$5, _9$$4; zend_long n, ZEPHIR_LAST_CALL_STATUS, max; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0$$3); ZVAL_UNDEF(&_1$$3); ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_3$$3); ZVAL_UNDEF(&_4); ZVAL_UNDEF(&_5); ZVAL_UNDEF(&_6); ZVAL_UNDEF(&_7$$5); ZVAL_UNDEF(&_9$$4); ZVAL_UNDEF(&a); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 2) Z_PARAM_LONG(n) Z_PARAM_OPTIONAL Z_PARAM_ZVAL(lambda) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &n_param, &lambda_param); n = zephir_get_intval(n_param); if (!lambda_param) { lambda = 1.0; } else { lambda = zephir_get_doubleval(lambda_param); } if (UNEXPECTED(n < 1)) { ZEPHIR_INIT_VAR(&_0$$3); object_init_ex(&_0$$3, tensor_exceptions_invalidargumentexception_ce); ZVAL_LONG(&_1$$3, n); ZEPHIR_CALL_FUNCTION(&_2$$3, "strval", NULL, 4, &_1$$3); zephir_check_call_status(); ZEPHIR_INIT_VAR(&_3$$3); ZEPHIR_CONCAT_SSVS(&_3$$3, "N must be", " greater than 0, ", &_2$$3, " given."); ZEPHIR_CALL_METHOD(NULL, &_0$$3, "__construct", NULL, 3, &_3$$3); zephir_check_call_status(); zephir_throw_exception_debug(&_0$$3, "tensor/vector.zep", 177); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(&a); array_init(&a); ZVAL_DOUBLE(&_4, -lambda); ZEPHIR_CALL_FUNCTION(&_5, "exp", NULL, 10, &_4); zephir_check_call_status(); l = zephir_get_doubleval(&_5); ZEPHIR_CALL_FUNCTION(&_6, "getrandmax", NULL, 6); zephir_check_call_status(); max = zephir_get_intval(&_6); while (1) { if (!(zephir_fast_count_int(&a) < n)) { break; } k = 0.0; p = 1.0; while (1) { if (!(p > l)) { break; } k++; ZEPHIR_CALL_FUNCTION(&_7$$5, "rand", &_8, 7); zephir_check_call_status(); p *= zephir_safe_div_zval_long(&_7$$5, max); } ZEPHIR_INIT_NVAR(&_9$$4); ZVAL_DOUBLE(&_9$$4, (k - 1.0)); zephir_array_append(&a, &_9$$4, PH_SEPARATE, "tensor/vector.zep", 198); } ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &a); zephir_check_call_status(); RETURN_MM(); } /** * Return a random uniformly distributed vector with values between -1 and 1. * * @param int n * @throws \Tensor\Exceptions\InvalidArgumentException * @return self */ PHP_METHOD(Tensor_Vector, uniform) { zval a; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zephir_fcall_cache_entry *_8 = NULL; zval *n_param = NULL, _0$$3, _1$$3, _2$$3, _3$$3, _4, _5$$4, _6$$4, _7$$4, _9$$4; zend_long n, ZEPHIR_LAST_CALL_STATUS, max; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0$$3); ZVAL_UNDEF(&_1$$3); ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_3$$3); ZVAL_UNDEF(&_4); ZVAL_UNDEF(&_5$$4); ZVAL_UNDEF(&_6$$4); ZVAL_UNDEF(&_7$$4); ZVAL_UNDEF(&_9$$4); ZVAL_UNDEF(&a); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_LONG(n) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &n_param); n = zephir_get_intval(n_param); if (UNEXPECTED(n < 1)) { ZEPHIR_INIT_VAR(&_0$$3); object_init_ex(&_0$$3, tensor_exceptions_invalidargumentexception_ce); ZVAL_LONG(&_1$$3, n); ZEPHIR_CALL_FUNCTION(&_2$$3, "strval", NULL, 4, &_1$$3); zephir_check_call_status(); ZEPHIR_INIT_VAR(&_3$$3); ZEPHIR_CONCAT_SSVS(&_3$$3, "N must be", " greater than 0, ", &_2$$3, " given."); ZEPHIR_CALL_METHOD(NULL, &_0$$3, "__construct", NULL, 3, &_3$$3); zephir_check_call_status(); zephir_throw_exception_debug(&_0$$3, "tensor/vector.zep", 215); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(&a); array_init(&a); ZEPHIR_CALL_FUNCTION(&_4, "getrandmax", NULL, 6); zephir_check_call_status(); max = zephir_get_intval(&_4); while (1) { if (!(zephir_fast_count_int(&a) < n)) { break; } ZVAL_LONG(&_5$$4, -max); ZVAL_LONG(&_6$$4, max); ZEPHIR_CALL_FUNCTION(&_7$$4, "rand", &_8, 7, &_5$$4, &_6$$4); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_9$$4); ZVAL_DOUBLE(&_9$$4, zephir_safe_div_zval_long(&_7$$4, max)); zephir_array_append(&a, &_9$$4, PH_SEPARATE, "tensor/vector.zep", 223); } ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &a); zephir_check_call_status(); RETURN_MM(); } /** * Return evenly spaced values within a given interval. * * @param float start * @param float end * @param float interval * @return self */ PHP_METHOD(Tensor_Vector, range) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *start_param = NULL, *end_param = NULL, *interval_param = NULL, _0, _1, _2, _3; double start, end, interval; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(2, 3) Z_PARAM_ZVAL(start) Z_PARAM_ZVAL(end) Z_PARAM_OPTIONAL Z_PARAM_ZVAL(interval) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 1, &start_param, &end_param, &interval_param); start = zephir_get_doubleval(start_param); end = zephir_get_doubleval(end_param); if (!interval_param) { interval = 1.0; } else { interval = zephir_get_doubleval(interval_param); } ZVAL_DOUBLE(&_0, start); ZVAL_DOUBLE(&_1, end); ZVAL_DOUBLE(&_2, interval); ZEPHIR_CALL_FUNCTION(&_3, "range", NULL, 11, &_0, &_1, &_2); zephir_check_call_status(); ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &_3); zephir_check_call_status(); RETURN_MM(); } /** * Return a vector of n evenly spaced numbers between minimum and maximum. * * @param float min * @param float max * @param int n * @throws \Tensor\Exceptions\InvalidArgumentException * @return self */ PHP_METHOD(Tensor_Vector, linspace) { zval a; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zephir_fcall_cache_entry *_8 = NULL; zend_long n, ZEPHIR_LAST_CALL_STATUS, k; zval *min_param = NULL, *max_param = NULL, *n_param = NULL, _0$$4, _1$$4, _2$$4, _3$$4, _4, _5, _6, _7$$5, _9$$5; double min, max, interval; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0$$4); ZVAL_UNDEF(&_1$$4); ZVAL_UNDEF(&_2$$4); ZVAL_UNDEF(&_3$$4); ZVAL_UNDEF(&_4); ZVAL_UNDEF(&_5); ZVAL_UNDEF(&_6); ZVAL_UNDEF(&_7$$5); ZVAL_UNDEF(&_9$$5); ZVAL_UNDEF(&a); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(3, 3) Z_PARAM_ZVAL(min) Z_PARAM_ZVAL(max) Z_PARAM_LONG(n) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 3, 0, &min_param, &max_param, &n_param); min = zephir_get_doubleval(min_param); max = zephir_get_doubleval(max_param); n = zephir_get_intval(n_param); if (UNEXPECTED(min > max)) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(tensor_exceptions_invalidargumentexception_ce, "Minimum must be less than maximum.", "tensor/vector.zep", 254); return; } if (UNEXPECTED(n < 2)) { ZEPHIR_INIT_VAR(&_0$$4); object_init_ex(&_0$$4, tensor_exceptions_invalidargumentexception_ce); ZVAL_LONG(&_1$$4, n); ZEPHIR_CALL_FUNCTION(&_2$$4, "strval", NULL, 4, &_1$$4); zephir_check_call_status(); ZEPHIR_INIT_VAR(&_3$$4); ZEPHIR_CONCAT_SSVS(&_3$$4, "Number of elements", " must be greater than 1, ", &_2$$4, " given."); ZEPHIR_CALL_METHOD(NULL, &_0$$4, "__construct", NULL, 3, &_3$$4); zephir_check_call_status(); zephir_throw_exception_debug(&_0$$4, "tensor/vector.zep", 259); ZEPHIR_MM_RESTORE(); return; } k = (n - 1); ZVAL_DOUBLE(&_4, (max - min)); ZEPHIR_CALL_FUNCTION(&_5, "abs", NULL, 12, &_4); zephir_check_call_status(); interval = zephir_safe_div_zval_long(&_5, k); ZEPHIR_INIT_VAR(&a); zephir_create_array(&a, 1, 0); ZEPHIR_INIT_VAR(&_6); ZVAL_DOUBLE(&_6, min); zephir_array_fast_append(&a, &_6); while (1) { if (!(zephir_fast_count_int(&a) < k)) { break; } ZEPHIR_MAKE_REF(&a); ZEPHIR_CALL_FUNCTION(&_7$$5, "end", &_8, 13, &a); ZEPHIR_UNREF(&a); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_9$$5); ZVAL_DOUBLE(&_9$$5, (zephir_get_numberval(&_7$$5) + interval)); zephir_array_append(&a, &_9$$5, PH_SEPARATE, "tensor/vector.zep", 269); } ZEPHIR_INIT_NVAR(&_6); ZVAL_DOUBLE(&_6, max); zephir_array_append(&a, &_6, PH_SEPARATE, "tensor/vector.zep", 272); ZEPHIR_RETURN_CALL_SELF("quick", NULL, 0, &a); zephir_check_call_status(); RETURN_MM(); } /** * @param float[] a * @param bool validate */ PHP_METHOD(Tensor_Vector, __construct) { double _5$$5, _7$$7; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zephir_fcall_cache_entry *_4 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zend_bool validate; zval *a_param = NULL, *validate_param = NULL, valueA, _8, _0$$3, *_1$$3, _2$$3, _3$$4, _6$$6; zval a; zval *this_ptr = getThis(); ZVAL_UNDEF(&a); ZVAL_UNDEF(&valueA); ZVAL_UNDEF(&_8); ZVAL_UNDEF(&_0$$3); ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_3$$4); ZVAL_UNDEF(&_6$$6); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 2) Z_PARAM_ARRAY(a) Z_PARAM_OPTIONAL Z_PARAM_BOOL(validate) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &a_param, &validate_param); zephir_get_arrval(&a, a_param); if (!validate_param) { validate = 1; } else { validate = zephir_get_boolval(validate_param); } if (validate) { ZEPHIR_CALL_FUNCTION(&_0$$3, "array_values", NULL, 14, &a); zephir_check_call_status(); ZEPHIR_CPY_WRT(&a, &_0$$3); zephir_is_iterable(&a, 0, "tensor/vector.zep", 293); if (Z_TYPE_P(&a) == IS_ARRAY) { ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&a), _1$$3) { ZEPHIR_INIT_NVAR(&valueA); ZVAL_COPY(&valueA, _1$$3); ZEPHIR_CALL_FUNCTION(&_3$$4, "is_float", &_4, 2, &valueA); zephir_check_call_status(); if (!zephir_is_true(&_3$$4)) { _5$$5 = zephir_get_doubleval(&valueA); ZEPHIR_INIT_NVAR(&valueA); ZVAL_DOUBLE(&valueA, _5$$5); } } ZEND_HASH_FOREACH_END(); } else { ZEPHIR_CALL_METHOD(NULL, &a, "rewind", NULL, 0); zephir_check_call_status(); while (1) { ZEPHIR_CALL_METHOD(&_2$$3, &a, "valid", NULL, 0); zephir_check_call_status(); if (!zend_is_true(&_2$$3)) { break; } ZEPHIR_CALL_METHOD(&valueA, &a, "current", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_6$$6, "is_float", &_4, 2, &valueA); zephir_check_call_status(); if (!zephir_is_true(&_6$$6)) { _7$$7 = zephir_get_doubleval(&valueA); ZEPHIR_INIT_NVAR(&valueA); ZVAL_DOUBLE(&valueA, _7$$7); } ZEPHIR_CALL_METHOD(NULL, &a, "next", NULL, 0); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(&valueA); } zephir_update_property_zval(this_ptr, ZEND_STRL("a"), &a); ZEPHIR_INIT_ZVAL_NREF(_8); ZVAL_LONG(&_8, zephir_fast_count_int(&a)); zephir_update_property_zval(this_ptr, ZEND_STRL("n"), &_8); ZEPHIR_MM_RESTORE(); } /** * Return a tuple with the dimensionality of the tensor. * * @return int[] */ PHP_METHOD(Tensor_Vector, shape) { zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZEPHIR_MM_GROW(); zephir_create_array(return_value, 1, 0); ZEPHIR_OBS_VAR(&_0); zephir_read_property(&_0, this_ptr, ZEND_STRL("n"), PH_NOISY_CC); zephir_array_fast_append(return_value, &_0); RETURN_MM(); } /** * Return the shape of the tensor as a string. * * @return string */ PHP_METHOD(Tensor_Vector, shapeString) { zval _1; zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZEPHIR_MM_GROW(); ZEPHIR_OBS_VAR(&_0); zephir_read_property(&_0, this_ptr, ZEND_STRL("n"), PH_NOISY_CC); zephir_cast_to_string(&_1, &_0); RETURN_CTOR(&_1); } /** * Return the number of elements in the vector. * * @return int */ PHP_METHOD(Tensor_Vector, size) { zval *this_ptr = getThis(); RETURN_MEMBER(getThis(), "n"); } /** * Return the number of rows in the vector. * * @return int */ PHP_METHOD(Tensor_Vector, m) { zval *this_ptr = getThis(); RETURN_LONG(1); } /** * Return the number of columns in the vector. * * @return int */ PHP_METHOD(Tensor_Vector, n) { zval *this_ptr = getThis(); RETURN_MEMBER(getThis(), "n"); } /** * Return the vector as an array. * * @return list */ PHP_METHOD(Tensor_Vector, asArray) { zval *this_ptr = getThis(); RETURN_MEMBER(getThis(), "a"); } /** * Return this vector as a row matrix. * * @return \Tensor\Matrix */ PHP_METHOD(Tensor_Vector, asRowMatrix) { zval _2; zval _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *this_ptr = getThis(); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(&_1); zephir_create_array(&_1, 1, 0); ZEPHIR_OBS_VAR(&_2); zephir_read_property(&_2, this_ptr, ZEND_STRL("a"), PH_NOISY_CC); zephir_array_fast_append(&_1, &_2); ZEPHIR_RETURN_CALL_CE_STATIC(tensor_matrix_ce, "quick", &_0, 0, &_1); zephir_check_call_status(); RETURN_MM(); } /** * Return this vector as a column matrix. * * @return \Tensor\Matrix */ PHP_METHOD(Tensor_Vector, asColumnMatrix) { zval b, _3$$3, _4$$4; zval valueA, _0, *_1, _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zephir_fcall_cache_entry *_5 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&valueA); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&b); ZVAL_UNDEF(&_3$$3); ZVAL_UNDEF(&_4$$4); ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(&b); array_init(&b); zephir_read_property(&_0, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); zephir_is_iterable(&_0, 0, "tensor/vector.zep", 384); if (Z_TYPE_P(&_0) == IS_ARRAY) { ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_0), _1) { ZEPHIR_INIT_NVAR(&valueA); ZVAL_COPY(&valueA, _1); ZEPHIR_INIT_NVAR(&_3$$3); zephir_create_array(&_3$$3, 1, 0); zephir_array_fast_append(&_3$$3, &valueA); zephir_array_append(&b, &_3$$3, PH_SEPARATE, "tensor/vector.zep", 381); } ZEND_HASH_FOREACH_END(); } else { ZEPHIR_CALL_METHOD(NULL, &_0, "rewind", NULL, 0); zephir_check_call_status(); while (1) { ZEPHIR_CALL_METHOD(&_2, &_0, "valid", NULL, 0); zephir_check_call_status(); if (!zend_is_true(&_2)) { break; } ZEPHIR_CALL_METHOD(&valueA, &_0, "current", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_4$$4); zephir_create_array(&_4$$4, 1, 0); zephir_array_fast_append(&_4$$4, &valueA); zephir_array_append(&b, &_4$$4, PH_SEPARATE, "tensor/vector.zep", 381); ZEPHIR_CALL_METHOD(NULL, &_0, "next", NULL, 0); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(&valueA); ZEPHIR_RETURN_CALL_CE_STATIC(tensor_matrix_ce, "quick", &_5, 0, &b); zephir_check_call_status(); RETURN_MM(); } /** * Return a matrix in the shape specified. * * @param int m * @param int n * @throws \Tensor\Exceptions\InvalidArgumentException * @return \Tensor\Matrix */ PHP_METHOD(Tensor_Vector, reshape) { zval _2$$3; zval b, rowB; zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zephir_fcall_cache_entry *_10 = NULL; zval *m_param = NULL, *n_param = NULL, _3, _1$$3, _4$$4, _5$$4, _6$$4, _7$$4, _8$$6, _9$$6; zend_long m, n, ZEPHIR_LAST_CALL_STATUS, nHat, i; zval *this_ptr = getThis(); ZVAL_UNDEF(&_3); ZVAL_UNDEF(&_1$$3); ZVAL_UNDEF(&_4$$4); ZVAL_UNDEF(&_5$$4); ZVAL_UNDEF(&_6$$4); ZVAL_UNDEF(&_7$$4); ZVAL_UNDEF(&_8$$6); ZVAL_UNDEF(&_9$$6); ZVAL_UNDEF(&b); ZVAL_UNDEF(&rowB); ZVAL_UNDEF(&_2$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(2, 2) Z_PARAM_LONG(m) Z_PARAM_LONG(n) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &m_param, &n_param); m = zephir_get_intval(m_param); n = zephir_get_intval(n_param); _0 = m < 0; if (!(_0)) { _0 = n < 0; } if (UNEXPECTED(_0)) { ZEPHIR_INIT_VAR(&_1$$3); object_init_ex(&_1$$3, tensor_exceptions_invalidargumentexception_ce); ZEPHIR_INIT_VAR(&_2$$3); ZEPHIR_CONCAT_SS(&_2$$3, "The number of rows", " and/or columns cannot be less than 0."); ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 3, &_2$$3); zephir_check_call_status(); zephir_throw_exception_debug(&_1$$3, "tensor/vector.zep", 399); ZEPHIR_MM_RESTORE(); return; } nHat = (m * n); zephir_read_property(&_3, this_ptr, ZEND_STRL("n"), PH_NOISY_CC | PH_READONLY); if (UNEXPECTED(!ZEPHIR_IS_LONG_IDENTICAL(&_3, nHat))) { ZEPHIR_INIT_VAR(&_4$$4); object_init_ex(&_4$$4, tensor_exceptions_invalidargumentexception_ce); ZVAL_LONG(&_5$$4, nHat); ZEPHIR_CALL_FUNCTION(&_6$$4, "strval", NULL, 4, &_5$$4); zephir_check_call_status(); zephir_read_property(&_5$$4, this_ptr, ZEND_STRL("n"), PH_NOISY_CC | PH_READONLY); ZEPHIR_INIT_VAR(&_7$$4); ZEPHIR_CONCAT_VSSVS(&_7$$4, &_6$$4, " elements", " are needed but vector only has ", &_5$$4, "."); ZEPHIR_CALL_METHOD(NULL, &_4$$4, "__construct", NULL, 3, &_7$$4); zephir_check_call_status(); zephir_throw_exception_debug(&_4$$4, "tensor/vector.zep", 406); ZEPHIR_MM_RESTORE(); return; } i = 0; ZEPHIR_INIT_VAR(&b); array_init(&b); ZEPHIR_INIT_VAR(&rowB); array_init(&rowB); while (1) { if (!(zephir_fast_count_int(&b) < m)) { break; } ZEPHIR_INIT_NVAR(&rowB); array_init(&rowB); while (1) { if (!(zephir_fast_count_int(&rowB) < n)) { break; } zephir_read_property(&_8$$6, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); zephir_array_fetch_long(&_9$$6, &_8$$6, i, PH_NOISY | PH_READONLY, "tensor/vector.zep", 418); zephir_array_append(&rowB, &_9$$6, PH_SEPARATE, "tensor/vector.zep", 418); i++; } zephir_array_append(&b, &rowB, PH_SEPARATE, "tensor/vector.zep", 423); } ZEPHIR_RETURN_CALL_CE_STATIC(tensor_matrix_ce, "quick", &_10, 0, &b); zephir_check_call_status(); RETURN_MM(); } /** * Transpose the vector i.e. rotate it. * * @return mixed */ PHP_METHOD(Tensor_Vector, transpose) { zval _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zephir_fcall_cache_entry *_0 = NULL; zval *this_ptr = getThis(); ZVAL_UNDEF(&_1); ZEPHIR_MM_GROW(); zephir_read_property(&_1, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); ZEPHIR_RETURN_CALL_CE_STATIC(tensor_columnvector_ce, "quick", &_0, 0, &_1); zephir_check_call_status(); RETURN_MM(); } /** * Map a function over the elements in the vector and return a new vector. * * @internal * * @param callable callback * @return self */ PHP_METHOD(Tensor_Vector, map) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *callback, callback_sub, _0, _1; zval *this_ptr = getThis(); ZVAL_UNDEF(&callback_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ZVAL(callback) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &callback); zephir_read_property(&_0, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_FUNCTION(&_1, "array_map", NULL, 15, callback, &_0); zephir_check_call_status(); ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &_1); zephir_check_call_status(); RETURN_MM(); } /** * Reduce the vector down to a scalar. * * @internal * * @param callable callback * @param float initial * @return float */ PHP_METHOD(Tensor_Vector, reduce) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; double initial; zval *callback, callback_sub, *initial_param = NULL, _0, _1; zval *this_ptr = getThis(); ZVAL_UNDEF(&callback_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 2) Z_PARAM_ZVAL(callback) Z_PARAM_OPTIONAL Z_PARAM_ZVAL(initial) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &callback, &initial_param); if (!initial_param) { initial = 0.0; } else { initial = zephir_get_doubleval(initial_param); } zephir_read_property(&_0, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); ZVAL_DOUBLE(&_1, initial); ZEPHIR_RETURN_CALL_FUNCTION("array_reduce", NULL, 16, &_0, callback, &_1); zephir_check_call_status(); RETURN_MM(); } /** * Compute the dot product of this vector and another vector. * * @param \Tensor\Vector b * @throws \Tensor\Exceptions\DimensionalityMismatch * @return float */ PHP_METHOD(Tensor_Vector, dot) { zval _4$$3, _6$$3, _7$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, _0, _1, _8, _9, _2$$3, _3$$3, _5$$3; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_8); ZVAL_UNDEF(&_9); ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_3$$3); ZVAL_UNDEF(&_5$$3); ZVAL_UNDEF(&_4$$3); ZVAL_UNDEF(&_6$$3); ZVAL_UNDEF(&_7$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_OBJECT_OF_CLASS(b, zephir_get_internal_ce(SL("tensor\\vector"))) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); zephir_read_property(&_0, this_ptr, ZEND_STRL("n"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_1, b, "size", NULL, 0); zephir_check_call_status(); if (UNEXPECTED(!ZEPHIR_IS_IDENTICAL(&_0, &_1))) { ZEPHIR_INIT_VAR(&_2$$3); object_init_ex(&_2$$3, tensor_exceptions_dimensionalitymismatch_ce); ZEPHIR_OBS_VAR(&_3$$3); zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("n"), PH_NOISY_CC); zephir_cast_to_string(&_4$$3, &_3$$3); ZEPHIR_CALL_METHOD(&_5$$3, b, "size", NULL, 0); zephir_check_call_status(); zephir_cast_to_string(&_6$$3, &_5$$3); ZEPHIR_INIT_VAR(&_7$$3); ZEPHIR_CONCAT_SVSVS(&_7$$3, "Vector A expects ", &_4$$3, " elements but vector B has ", &_6$$3, "."); ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 3, &_7$$3); zephir_check_call_status(); zephir_throw_exception_debug(&_2$$3, "tensor/vector.zep", 478); ZEPHIR_MM_RESTORE(); return; } zephir_read_property(&_8, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_9, b, "asarray", NULL, 0); zephir_check_call_status(); tensor_dot(return_value, &_8, &_9); RETURN_MM(); } /** * Return the 1D convolution of this vector and a kernel vector with given stride. * * @param \Tensor\Vector b * @param int stride * @throws \Tensor\Exceptions\InvalidArgumentException * @return self */ PHP_METHOD(Tensor_Vector, convolve) { zval _3$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long stride, ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, *stride_param = NULL, _0, _1, _8, _9, _10, _11, _2$$3, _4$$4, _5$$4, _6$$4, _7$$4; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_8); ZVAL_UNDEF(&_9); ZVAL_UNDEF(&_10); ZVAL_UNDEF(&_11); ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_4$$4); ZVAL_UNDEF(&_5$$4); ZVAL_UNDEF(&_6$$4); ZVAL_UNDEF(&_7$$4); ZVAL_UNDEF(&_3$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 2) Z_PARAM_OBJECT_OF_CLASS(b, zephir_get_internal_ce(SL("tensor\\vector"))) Z_PARAM_OPTIONAL Z_PARAM_LONG(stride) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &b, &stride_param); if (!stride_param) { stride = 1; } else { stride = zephir_get_intval(stride_param); } ZEPHIR_CALL_METHOD(&_0, b, "size", NULL, 0); zephir_check_call_status(); zephir_read_property(&_1, this_ptr, ZEND_STRL("n"), PH_NOISY_CC | PH_READONLY); if (UNEXPECTED(ZEPHIR_GT(&_0, &_1))) { ZEPHIR_INIT_VAR(&_2$$3); object_init_ex(&_2$$3, tensor_exceptions_invalidargumentexception_ce); ZEPHIR_INIT_VAR(&_3$$3); ZEPHIR_CONCAT_SS(&_3$$3, "Vector B cannot be", " larger than Vector A."); ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 3, &_3$$3); zephir_check_call_status(); zephir_throw_exception_debug(&_2$$3, "tensor/vector.zep", 496); ZEPHIR_MM_RESTORE(); return; } if (UNEXPECTED(stride < 1)) { ZEPHIR_INIT_VAR(&_4$$4); object_init_ex(&_4$$4, tensor_exceptions_invalidargumentexception_ce); ZVAL_LONG(&_5$$4, stride); ZEPHIR_CALL_FUNCTION(&_6$$4, "strval", NULL, 4, &_5$$4); zephir_check_call_status(); ZEPHIR_INIT_VAR(&_7$$4); ZEPHIR_CONCAT_SSVS(&_7$$4, "Stride cannot be", " less than 1, ", &_6$$4, " given."); ZEPHIR_CALL_METHOD(NULL, &_4$$4, "__construct", NULL, 3, &_7$$4); zephir_check_call_status(); zephir_throw_exception_debug(&_4$$4, "tensor/vector.zep", 501); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(&_8); zephir_read_property(&_9, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_10, b, "asarray", NULL, 0); zephir_check_call_status(); ZVAL_LONG(&_11, stride); tensor_convolve_1d(&_8, &_9, &_10, &_11); ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &_8); zephir_check_call_status(); RETURN_MM(); } /** * Compute the vector-matrix product of this vector and matrix b. * * @param \Tensor\Matrix b * @return \Tensor\Matrix */ PHP_METHOD(Tensor_Vector, matmul) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, _0; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_OBJECT_OF_CLASS(b, zephir_get_internal_ce(SL("tensor\\matrix"))) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); ZEPHIR_CALL_METHOD(&_0, this_ptr, "asrowmatrix", NULL, 0); zephir_check_call_status(); ZEPHIR_RETURN_CALL_METHOD(&_0, "matmul", NULL, 0, b); zephir_check_call_status(); RETURN_MM(); } /** * Return the inner product of two vectors. * * @param \Tensor\Vector b * @return float */ PHP_METHOD(Tensor_Vector, inner) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_OBJECT_OF_CLASS(b, zephir_get_internal_ce(SL("tensor\\vector"))) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "dot", NULL, 0, b); zephir_check_call_status(); RETURN_MM(); } /** * Calculate the outer product of this and another vector. * * @param \Tensor\Vector b * @return \Tensor\Matrix */ PHP_METHOD(Tensor_Vector, outer) { zend_string *_8$$3, *_14$$6; zend_ulong _7$$3, _13$$6; zval bHat, c, rowC, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zephir_fcall_cache_entry *_17 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, j, valueA, valueB, _0, _2, *_3, _4, *_5$$3, _6$$3, _9$$4, _10$$5, *_11$$6, _12$$6, _15$$7, _16$$8; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&j); ZVAL_UNDEF(&valueA); ZVAL_UNDEF(&valueB); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_4); ZVAL_UNDEF(&_6$$3); ZVAL_UNDEF(&_9$$4); ZVAL_UNDEF(&_10$$5); ZVAL_UNDEF(&_12$$6); ZVAL_UNDEF(&_15$$7); ZVAL_UNDEF(&_16$$8); ZVAL_UNDEF(&bHat); ZVAL_UNDEF(&c); ZVAL_UNDEF(&rowC); ZVAL_UNDEF(&_1); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_OBJECT_OF_CLASS(b, zephir_get_internal_ce(SL("tensor\\vector"))) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); ZEPHIR_INIT_VAR(&bHat); array_init(&bHat); ZEPHIR_INIT_VAR(&c); array_init(&c); ZEPHIR_INIT_VAR(&rowC); array_init(&rowC); ZEPHIR_CALL_METHOD(&_0, b, "asarray", NULL, 0); zephir_check_call_status(); zephir_get_arrval(&_1, &_0); ZEPHIR_CPY_WRT(&bHat, &_1); zephir_read_property(&_2, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); zephir_is_iterable(&_2, 0, "tensor/vector.zep", 555); if (Z_TYPE_P(&_2) == IS_ARRAY) { ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_2), _3) { ZEPHIR_INIT_NVAR(&valueA); ZVAL_COPY(&valueA, _3); ZEPHIR_INIT_NVAR(&rowC); array_init(&rowC); zephir_is_iterable(&bHat, 0, "tensor/vector.zep", 552); if (Z_TYPE_P(&bHat) == IS_ARRAY) { ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&bHat), _7$$3, _8$$3, _5$$3) { ZEPHIR_INIT_NVAR(&j); if (_8$$3 != NULL) { ZVAL_STR_COPY(&j, _8$$3); } else { ZVAL_LONG(&j, _7$$3); } ZEPHIR_INIT_NVAR(&valueB); ZVAL_COPY(&valueB, _5$$3); ZEPHIR_INIT_NVAR(&_9$$4); mul_function(&_9$$4, &valueA, &valueB); zephir_array_append(&rowC, &_9$$4, PH_SEPARATE, "tensor/vector.zep", 549); } ZEND_HASH_FOREACH_END(); } else { ZEPHIR_CALL_METHOD(NULL, &bHat, "rewind", NULL, 0); zephir_check_call_status(); while (1) { ZEPHIR_CALL_METHOD(&_6$$3, &bHat, "valid", NULL, 0); zephir_check_call_status(); if (!zend_is_true(&_6$$3)) { break; } ZEPHIR_CALL_METHOD(&j, &bHat, "key", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&valueB, &bHat, "current", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_10$$5); mul_function(&_10$$5, &valueA, &valueB); zephir_array_append(&rowC, &_10$$5, PH_SEPARATE, "tensor/vector.zep", 549); ZEPHIR_CALL_METHOD(NULL, &bHat, "next", NULL, 0); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(&valueB); ZEPHIR_INIT_NVAR(&j); zephir_array_append(&c, &rowC, PH_SEPARATE, "tensor/vector.zep", 552); } ZEND_HASH_FOREACH_END(); } else { ZEPHIR_CALL_METHOD(NULL, &_2, "rewind", NULL, 0); zephir_check_call_status(); while (1) { ZEPHIR_CALL_METHOD(&_4, &_2, "valid", NULL, 0); zephir_check_call_status(); if (!zend_is_true(&_4)) { break; } ZEPHIR_CALL_METHOD(&valueA, &_2, "current", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&rowC); array_init(&rowC); zephir_is_iterable(&bHat, 0, "tensor/vector.zep", 552); if (Z_TYPE_P(&bHat) == IS_ARRAY) { ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&bHat), _13$$6, _14$$6, _11$$6) { ZEPHIR_INIT_NVAR(&j); if (_14$$6 != NULL) { ZVAL_STR_COPY(&j, _14$$6); } else { ZVAL_LONG(&j, _13$$6); } ZEPHIR_INIT_NVAR(&valueB); ZVAL_COPY(&valueB, _11$$6); ZEPHIR_INIT_NVAR(&_15$$7); mul_function(&_15$$7, &valueA, &valueB); zephir_array_append(&rowC, &_15$$7, PH_SEPARATE, "tensor/vector.zep", 549); } ZEND_HASH_FOREACH_END(); } else { ZEPHIR_CALL_METHOD(NULL, &bHat, "rewind", NULL, 0); zephir_check_call_status(); while (1) { ZEPHIR_CALL_METHOD(&_12$$6, &bHat, "valid", NULL, 0); zephir_check_call_status(); if (!zend_is_true(&_12$$6)) { break; } ZEPHIR_CALL_METHOD(&j, &bHat, "key", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&valueB, &bHat, "current", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_16$$8); mul_function(&_16$$8, &valueA, &valueB); zephir_array_append(&rowC, &_16$$8, PH_SEPARATE, "tensor/vector.zep", 549); ZEPHIR_CALL_METHOD(NULL, &bHat, "next", NULL, 0); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(&valueB); ZEPHIR_INIT_NVAR(&j); zephir_array_append(&c, &rowC, PH_SEPARATE, "tensor/vector.zep", 552); ZEPHIR_CALL_METHOD(NULL, &_2, "next", NULL, 0); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(&valueA); ZEPHIR_RETURN_CALL_CE_STATIC(tensor_matrix_ce, "quick", &_17, 0, &c); zephir_check_call_status(); RETURN_MM(); } /** * Calculate the L1 or Manhattan norm of the vector. * * @return float */ PHP_METHOD(Tensor_Vector, l1Norm) { zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(&_0, this_ptr, "abs", NULL, 0); zephir_check_call_status(); ZEPHIR_RETURN_CALL_METHOD(&_0, "sum", NULL, 0); zephir_check_call_status(); RETURN_MM(); } /** * Calculate the L2 or Euclidean norm of the vector. * * @return float */ PHP_METHOD(Tensor_Vector, l2Norm) { zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(&_0, this_ptr, "square", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_1, &_0, "sum", NULL, 0); zephir_check_call_status(); RETURN_MM_DOUBLE(zephir_sqrt(&_1)); } /** * Calculate the p-norm of the vector. * * @param float p * @throws \Tensor\Exceptions\InvalidArgumentException * @return float */ PHP_METHOD(Tensor_Vector, pNorm) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *p_param = NULL, _0$$3, _1$$3, _2$$3, _3$$3, _4, _5, _6, _7; double p; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0$$3); ZVAL_UNDEF(&_1$$3); ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_3$$3); ZVAL_UNDEF(&_4); ZVAL_UNDEF(&_5); ZVAL_UNDEF(&_6); ZVAL_UNDEF(&_7); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL Z_PARAM_ZVAL(p) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &p_param); if (!p_param) { p = 3.0; } else { p = zephir_get_doubleval(p_param); } if (UNEXPECTED(p <= 0.0)) { ZEPHIR_INIT_VAR(&_0$$3); object_init_ex(&_0$$3, tensor_exceptions_invalidargumentexception_ce); ZVAL_DOUBLE(&_1$$3, p); ZEPHIR_CALL_FUNCTION(&_2$$3, "strval", NULL, 4, &_1$$3); zephir_check_call_status(); ZEPHIR_INIT_VAR(&_3$$3); ZEPHIR_CONCAT_SSVS(&_3$$3, "P must be greater", " than 0, ", &_2$$3, " given."); ZEPHIR_CALL_METHOD(NULL, &_0$$3, "__construct", NULL, 3, &_3$$3); zephir_check_call_status(); zephir_throw_exception_debug(&_0$$3, "tensor/vector.zep", 589); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_CALL_METHOD(&_4, this_ptr, "abs", NULL, 0); zephir_check_call_status(); ZVAL_DOUBLE(&_6, p); ZEPHIR_CALL_METHOD(&_5, &_4, "powscalar", NULL, 0, &_6); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_7, &_5, "sum", NULL, 0); zephir_check_call_status(); ZVAL_DOUBLE(&_6, zephir_safe_div_double_double(1.0, p)); zephir_pow_function(return_value, &_7, &_6); RETURN_MM(); } /** * Calculate the max norm of the vector. * * @return float */ PHP_METHOD(Tensor_Vector, maxNorm) { zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(&_0, this_ptr, "abs", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_1, &_0, "max", NULL, 0); zephir_check_call_status(); RETURN_MM_DOUBLE(zephir_get_doubleval(&_1)); } /** * A universal function to multiply this vector with another tensor element-wise. * * @param mixed b * @throws \Tensor\Exceptions\InvalidArgumentException * @return mixed */ PHP_METHOD(Tensor_Vector, multiply) { zend_bool _1$$3; zval _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, _0, _2; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ZVAL(b) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); ZEPHIR_INIT_VAR(&_0); zephir_gettype(&_0, b); do { if (ZEPHIR_IS_STRING(&_0, "object")) { do { _1$$3 = 1; if (_1$$3 == zephir_instance_of_ev(b, tensor_matrix_ce)) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "multiplymatrix", NULL, 0, b); zephir_check_call_status(); RETURN_MM(); } if (_1$$3 == zephir_instance_of_ev(b, tensor_vector_ce)) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "multiplyvector", NULL, 0, b); zephir_check_call_status(); RETURN_MM(); } } while(0); break; } if (ZEPHIR_IS_STRING(&_0, "double") || ZEPHIR_IS_STRING(&_0, "integer")) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "multiplyscalar", NULL, 0, b); zephir_check_call_status(); RETURN_MM(); } } while(0); ZEPHIR_INIT_VAR(&_2); object_init_ex(&_2, tensor_exceptions_invalidargumentexception_ce); ZEPHIR_INIT_VAR(&_3); ZEPHIR_CONCAT_SS(&_3, "Cannot multiply", " vector by the given input."); ZEPHIR_CALL_METHOD(NULL, &_2, "__construct", NULL, 3, &_3); zephir_check_call_status(); zephir_throw_exception_debug(&_2, "tensor/vector.zep", 632); ZEPHIR_MM_RESTORE(); return; } /** * A universal function to divide this vector by another tensor element-wise. * * @param mixed b * @throws \Tensor\Exceptions\InvalidArgumentException * @return mixed */ PHP_METHOD(Tensor_Vector, divide) { zend_bool _1$$3; zval _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, _0, _2; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ZVAL(b) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); ZEPHIR_INIT_VAR(&_0); zephir_gettype(&_0, b); do { if (ZEPHIR_IS_STRING(&_0, "object")) { do { _1$$3 = 1; if (_1$$3 == zephir_instance_of_ev(b, tensor_matrix_ce)) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "dividematrix", NULL, 0, b); zephir_check_call_status(); RETURN_MM(); } if (_1$$3 == zephir_instance_of_ev(b, tensor_vector_ce)) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "dividevector", NULL, 0, b); zephir_check_call_status(); RETURN_MM(); } } while(0); break; } if (ZEPHIR_IS_STRING(&_0, "double") || ZEPHIR_IS_STRING(&_0, "integer")) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "dividescalar", NULL, 0, b); zephir_check_call_status(); RETURN_MM(); } } while(0); ZEPHIR_INIT_VAR(&_2); object_init_ex(&_2, tensor_exceptions_invalidargumentexception_ce); ZEPHIR_INIT_VAR(&_3); ZEPHIR_CONCAT_SS(&_3, "Cannot divide", " vector by the given input."); ZEPHIR_CALL_METHOD(NULL, &_2, "__construct", NULL, 3, &_3); zephir_check_call_status(); zephir_throw_exception_debug(&_2, "tensor/vector.zep", 662); ZEPHIR_MM_RESTORE(); return; } /** * A universal function to add this vector with another tensor * element-wise. * * @param mixed b * @throws \Tensor\Exceptions\InvalidArgumentException * @return mixed */ PHP_METHOD(Tensor_Vector, add) { zend_bool _1$$3; zval _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, _0, _2; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ZVAL(b) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); ZEPHIR_INIT_VAR(&_0); zephir_gettype(&_0, b); do { if (ZEPHIR_IS_STRING(&_0, "object")) { do { _1$$3 = 1; if (_1$$3 == zephir_instance_of_ev(b, tensor_matrix_ce)) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addmatrix", NULL, 0, b); zephir_check_call_status(); RETURN_MM(); } if (_1$$3 == zephir_instance_of_ev(b, tensor_vector_ce)) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addvector", NULL, 0, b); zephir_check_call_status(); RETURN_MM(); } } while(0); break; } if (ZEPHIR_IS_STRING(&_0, "double") || ZEPHIR_IS_STRING(&_0, "integer")) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addscalar", NULL, 0, b); zephir_check_call_status(); RETURN_MM(); } } while(0); ZEPHIR_INIT_VAR(&_2); object_init_ex(&_2, tensor_exceptions_invalidargumentexception_ce); ZEPHIR_INIT_VAR(&_3); ZEPHIR_CONCAT_SS(&_3, "Cannot add", " vector by the given input."); ZEPHIR_CALL_METHOD(NULL, &_2, "__construct", NULL, 3, &_3); zephir_check_call_status(); zephir_throw_exception_debug(&_2, "tensor/vector.zep", 693); ZEPHIR_MM_RESTORE(); return; } /** * A universal function to subtract this vector from another tensor * element-wise. * * @param mixed b * @throws \Tensor\Exceptions\InvalidArgumentException * @return mixed */ PHP_METHOD(Tensor_Vector, subtract) { zend_bool _1$$3; zval _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, _0, _2; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ZVAL(b) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); ZEPHIR_INIT_VAR(&_0); zephir_gettype(&_0, b); do { if (ZEPHIR_IS_STRING(&_0, "object")) { do { _1$$3 = 1; if (_1$$3 == zephir_instance_of_ev(b, tensor_matrix_ce)) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "subtractmatrix", NULL, 0, b); zephir_check_call_status(); RETURN_MM(); } if (_1$$3 == zephir_instance_of_ev(b, tensor_vector_ce)) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "subtractvector", NULL, 0, b); zephir_check_call_status(); RETURN_MM(); } } while(0); break; } if (ZEPHIR_IS_STRING(&_0, "double") || ZEPHIR_IS_STRING(&_0, "integer")) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "subtractscalar", NULL, 0, b); zephir_check_call_status(); RETURN_MM(); } } while(0); ZEPHIR_INIT_VAR(&_2); object_init_ex(&_2, tensor_exceptions_invalidargumentexception_ce); ZEPHIR_INIT_VAR(&_3); ZEPHIR_CONCAT_SS(&_3, "Cannot subtract", " vector from the given input."); ZEPHIR_CALL_METHOD(NULL, &_2, "__construct", NULL, 3, &_3); zephir_check_call_status(); zephir_throw_exception_debug(&_2, "tensor/vector.zep", 724); ZEPHIR_MM_RESTORE(); return; } /** * A universal function to raise this vector to the power of another * tensor element-wise. * * @param mixed b * @throws \Tensor\Exceptions\InvalidArgumentException * @return mixed */ PHP_METHOD(Tensor_Vector, pow) { zend_bool _1$$3; zval _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, _0, _2; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ZVAL(b) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); ZEPHIR_INIT_VAR(&_0); zephir_gettype(&_0, b); do { if (ZEPHIR_IS_STRING(&_0, "object")) { do { _1$$3 = 1; if (_1$$3 == zephir_instance_of_ev(b, tensor_matrix_ce)) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "powmatrix", NULL, 0, b); zephir_check_call_status(); RETURN_MM(); } if (_1$$3 == zephir_instance_of_ev(b, tensor_vector_ce)) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "powvector", NULL, 0, b); zephir_check_call_status(); RETURN_MM(); } } while(0); break; } if (ZEPHIR_IS_STRING(&_0, "double") || ZEPHIR_IS_STRING(&_0, "integer")) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "powscalar", NULL, 0, b); zephir_check_call_status(); RETURN_MM(); } } while(0); ZEPHIR_INIT_VAR(&_2); object_init_ex(&_2, tensor_exceptions_invalidargumentexception_ce); ZEPHIR_INIT_VAR(&_3); ZEPHIR_CONCAT_SS(&_3, "Cannot raise", " vector to the power of the given input."); ZEPHIR_CALL_METHOD(NULL, &_2, "__construct", NULL, 3, &_3); zephir_check_call_status(); zephir_throw_exception_debug(&_2, "tensor/vector.zep", 755); ZEPHIR_MM_RESTORE(); return; } /** * A universal function to compute the modulus of this vector and * another tensor element-wise. * * @param mixed b * @throws \Tensor\Exceptions\InvalidArgumentException * @return mixed */ PHP_METHOD(Tensor_Vector, mod) { zend_bool _1$$3; zval _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, _0, _2; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ZVAL(b) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); ZEPHIR_INIT_VAR(&_0); zephir_gettype(&_0, b); do { if (ZEPHIR_IS_STRING(&_0, "object")) { do { _1$$3 = 1; if (_1$$3 == zephir_instance_of_ev(b, tensor_matrix_ce)) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "modmatrix", NULL, 0, b); zephir_check_call_status(); RETURN_MM(); } if (_1$$3 == zephir_instance_of_ev(b, tensor_vector_ce)) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "modvector", NULL, 0, b); zephir_check_call_status(); RETURN_MM(); } } while(0); break; } if (ZEPHIR_IS_STRING(&_0, "double") || ZEPHIR_IS_STRING(&_0, "integer")) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "modscalar", NULL, 0, b); zephir_check_call_status(); RETURN_MM(); } } while(0); ZEPHIR_INIT_VAR(&_2); object_init_ex(&_2, tensor_exceptions_invalidargumentexception_ce); ZEPHIR_INIT_VAR(&_3); ZEPHIR_CONCAT_SS(&_3, "Cannot mod", " vector with the given input."); ZEPHIR_CALL_METHOD(NULL, &_2, "__construct", NULL, 3, &_3); zephir_check_call_status(); zephir_throw_exception_debug(&_2, "tensor/vector.zep", 786); ZEPHIR_MM_RESTORE(); return; } /** * A universal function to compute the equality comparison of * this vector and another tensor element-wise. * * @param mixed b * @throws \Tensor\Exceptions\InvalidArgumentException * @return mixed */ PHP_METHOD(Tensor_Vector, equal) { zend_bool _1$$3; zval _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, _0, _2; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ZVAL(b) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); ZEPHIR_INIT_VAR(&_0); zephir_gettype(&_0, b); do { if (ZEPHIR_IS_STRING(&_0, "object")) { do { _1$$3 = 1; if (_1$$3 == zephir_instance_of_ev(b, tensor_matrix_ce)) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "equalmatrix", NULL, 0, b); zephir_check_call_status(); RETURN_MM(); } if (_1$$3 == zephir_instance_of_ev(b, tensor_vector_ce)) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "equalvector", NULL, 0, b); zephir_check_call_status(); RETURN_MM(); } } while(0); break; } if (ZEPHIR_IS_STRING(&_0, "double") || ZEPHIR_IS_STRING(&_0, "integer")) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "equalscalar", NULL, 0, b); zephir_check_call_status(); RETURN_MM(); } } while(0); ZEPHIR_INIT_VAR(&_2); object_init_ex(&_2, tensor_exceptions_invalidargumentexception_ce); ZEPHIR_INIT_VAR(&_3); ZEPHIR_CONCAT_SS(&_3, "Cannot compare", " vector to the given input."); ZEPHIR_CALL_METHOD(NULL, &_2, "__construct", NULL, 3, &_3); zephir_check_call_status(); zephir_throw_exception_debug(&_2, "tensor/vector.zep", 817); ZEPHIR_MM_RESTORE(); return; } /** * A universal function to compute the not equal comparison of * this vector and another tensor element-wise. * * @param mixed b * @throws \Tensor\Exceptions\InvalidArgumentException * @return mixed */ PHP_METHOD(Tensor_Vector, notEqual) { zend_bool _1$$3; zval _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, _0, _2; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ZVAL(b) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); ZEPHIR_INIT_VAR(&_0); zephir_gettype(&_0, b); do { if (ZEPHIR_IS_STRING(&_0, "object")) { do { _1$$3 = 1; if (_1$$3 == zephir_instance_of_ev(b, tensor_matrix_ce)) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "notequalmatrix", NULL, 0, b); zephir_check_call_status(); RETURN_MM(); } if (_1$$3 == zephir_instance_of_ev(b, tensor_vector_ce)) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "notequalvector", NULL, 0, b); zephir_check_call_status(); RETURN_MM(); } } while(0); break; } if (ZEPHIR_IS_STRING(&_0, "double") || ZEPHIR_IS_STRING(&_0, "integer")) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "notequalscalar", NULL, 0, b); zephir_check_call_status(); RETURN_MM(); } } while(0); ZEPHIR_INIT_VAR(&_2); object_init_ex(&_2, tensor_exceptions_invalidargumentexception_ce); ZEPHIR_INIT_VAR(&_3); ZEPHIR_CONCAT_SS(&_3, "Cannot compare", " vector to the given input."); ZEPHIR_CALL_METHOD(NULL, &_2, "__construct", NULL, 3, &_3); zephir_check_call_status(); zephir_throw_exception_debug(&_2, "tensor/vector.zep", 848); ZEPHIR_MM_RESTORE(); return; } /** * A universal function to compute the greater than comparison of * this vector and another tensor element-wise. * * @param mixed b * @throws \Tensor\Exceptions\InvalidArgumentException * @return mixed */ PHP_METHOD(Tensor_Vector, greater) { zend_bool _1$$3; zval _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, _0, _2; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ZVAL(b) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); ZEPHIR_INIT_VAR(&_0); zephir_gettype(&_0, b); do { if (ZEPHIR_IS_STRING(&_0, "object")) { do { _1$$3 = 1; if (_1$$3 == zephir_instance_of_ev(b, tensor_matrix_ce)) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "greatermatrix", NULL, 0, b); zephir_check_call_status(); RETURN_MM(); } if (_1$$3 == zephir_instance_of_ev(b, tensor_vector_ce)) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "greatervector", NULL, 0, b); zephir_check_call_status(); RETURN_MM(); } } while(0); break; } if (ZEPHIR_IS_STRING(&_0, "double") || ZEPHIR_IS_STRING(&_0, "integer")) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "greaterscalar", NULL, 0, b); zephir_check_call_status(); RETURN_MM(); } } while(0); ZEPHIR_INIT_VAR(&_2); object_init_ex(&_2, tensor_exceptions_invalidargumentexception_ce); ZEPHIR_INIT_VAR(&_3); ZEPHIR_CONCAT_SS(&_3, "Cannot compare", " vector to the given input."); ZEPHIR_CALL_METHOD(NULL, &_2, "__construct", NULL, 3, &_3); zephir_check_call_status(); zephir_throw_exception_debug(&_2, "tensor/vector.zep", 879); ZEPHIR_MM_RESTORE(); return; } /** * A universal function to compute the greater than or equal to * comparison of this vector and another tensor element-wise. * * @param mixed b * @throws \Tensor\Exceptions\InvalidArgumentException * @return mixed */ PHP_METHOD(Tensor_Vector, greaterEqual) { zend_bool _1$$3; zval _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, _0, _2; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ZVAL(b) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); ZEPHIR_INIT_VAR(&_0); zephir_gettype(&_0, b); do { if (ZEPHIR_IS_STRING(&_0, "object")) { do { _1$$3 = 1; if (_1$$3 == zephir_instance_of_ev(b, tensor_matrix_ce)) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "greaterequalmatrix", NULL, 0, b); zephir_check_call_status(); RETURN_MM(); } if (_1$$3 == zephir_instance_of_ev(b, tensor_vector_ce)) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "greaterequalvector", NULL, 0, b); zephir_check_call_status(); RETURN_MM(); } } while(0); break; } if (ZEPHIR_IS_STRING(&_0, "double") || ZEPHIR_IS_STRING(&_0, "integer")) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "greaterequalscalar", NULL, 0, b); zephir_check_call_status(); RETURN_MM(); } } while(0); ZEPHIR_INIT_VAR(&_2); object_init_ex(&_2, tensor_exceptions_invalidargumentexception_ce); ZEPHIR_INIT_VAR(&_3); ZEPHIR_CONCAT_SS(&_3, "Cannot compare", " vector to the given input."); ZEPHIR_CALL_METHOD(NULL, &_2, "__construct", NULL, 3, &_3); zephir_check_call_status(); zephir_throw_exception_debug(&_2, "tensor/vector.zep", 910); ZEPHIR_MM_RESTORE(); return; } /** * A universal function to compute the less than comparison of * this vector and another tensor element-wise. * * @param mixed b * @throws \Tensor\Exceptions\InvalidArgumentException * @return mixed */ PHP_METHOD(Tensor_Vector, less) { zend_bool _1$$3; zval _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, _0, _2; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ZVAL(b) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); ZEPHIR_INIT_VAR(&_0); zephir_gettype(&_0, b); do { if (ZEPHIR_IS_STRING(&_0, "object")) { do { _1$$3 = 1; if (_1$$3 == zephir_instance_of_ev(b, tensor_matrix_ce)) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "lessmatrix", NULL, 0, b); zephir_check_call_status(); RETURN_MM(); } if (_1$$3 == zephir_instance_of_ev(b, tensor_vector_ce)) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "lessvector", NULL, 0, b); zephir_check_call_status(); RETURN_MM(); } } while(0); break; } if (ZEPHIR_IS_STRING(&_0, "double") || ZEPHIR_IS_STRING(&_0, "integer")) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "lessscalar", NULL, 0, b); zephir_check_call_status(); RETURN_MM(); } } while(0); ZEPHIR_INIT_VAR(&_2); object_init_ex(&_2, tensor_exceptions_invalidargumentexception_ce); ZEPHIR_INIT_VAR(&_3); ZEPHIR_CONCAT_SS(&_3, "Cannot compare", " vector to the given input."); ZEPHIR_CALL_METHOD(NULL, &_2, "__construct", NULL, 3, &_3); zephir_check_call_status(); zephir_throw_exception_debug(&_2, "tensor/vector.zep", 941); ZEPHIR_MM_RESTORE(); return; } /** * A universal function to compute the less than or equal to * comparison of this vector and another tensor element-wise. * * @param mixed b * @throws \Tensor\Exceptions\InvalidArgumentException * @return mixed */ PHP_METHOD(Tensor_Vector, lessEqual) { zend_bool _1$$3; zval _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, _0, _2; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ZVAL(b) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); ZEPHIR_INIT_VAR(&_0); zephir_gettype(&_0, b); do { if (ZEPHIR_IS_STRING(&_0, "object")) { do { _1$$3 = 1; if (_1$$3 == zephir_instance_of_ev(b, tensor_matrix_ce)) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "lessequalmatrix", NULL, 0, b); zephir_check_call_status(); RETURN_MM(); } if (_1$$3 == zephir_instance_of_ev(b, tensor_vector_ce)) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "lessequalvector", NULL, 0, b); zephir_check_call_status(); RETURN_MM(); } } while(0); break; } if (ZEPHIR_IS_STRING(&_0, "double") || ZEPHIR_IS_STRING(&_0, "integer")) { ZEPHIR_RETURN_CALL_METHOD(this_ptr, "lessequalscalar", NULL, 0, b); zephir_check_call_status(); RETURN_MM(); } } while(0); ZEPHIR_INIT_VAR(&_2); object_init_ex(&_2, tensor_exceptions_invalidargumentexception_ce); ZEPHIR_INIT_VAR(&_3); ZEPHIR_CONCAT_SS(&_3, "Cannot compare", " vector to the given input."); ZEPHIR_CALL_METHOD(NULL, &_2, "__construct", NULL, 3, &_3); zephir_check_call_status(); zephir_throw_exception_debug(&_2, "tensor/vector.zep", 972); ZEPHIR_MM_RESTORE(); return; } /** * Return the reciprocal of the vector element-wise. * * @return self */ PHP_METHOD(Tensor_Vector, reciprocal) { zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZEPHIR_MM_GROW(); zephir_read_property(&_1, this_ptr, ZEND_STRL("n"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_STATIC(&_0, "ones", NULL, 0, &_1); zephir_check_call_status(); ZEPHIR_RETURN_CALL_METHOD(&_0, "dividevector", NULL, 0, this_ptr); zephir_check_call_status(); RETURN_MM(); } /** * Return the absolute value of the vector. * * @return self */ PHP_METHOD(Tensor_Vector, abs) { zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(&_0); ZVAL_STRING(&_0, "abs"); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "map", NULL, 0, &_0); zephir_check_call_status(); RETURN_MM(); } /** * Square the vector. * * @return self */ PHP_METHOD(Tensor_Vector, square) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZEPHIR_MM_GROW(); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "multiplyvector", NULL, 0, this_ptr); zephir_check_call_status(); RETURN_MM(); } /** * Take the square root of the vector. * * @return self */ PHP_METHOD(Tensor_Vector, sqrt) { zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(&_0); ZVAL_STRING(&_0, "sqrt"); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "map", NULL, 0, &_0); zephir_check_call_status(); RETURN_MM(); } /** * Exponentiate each element in the vector. * * @return self */ PHP_METHOD(Tensor_Vector, exp) { zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(&_0); ZVAL_STRING(&_0, "exp"); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "map", NULL, 0, &_0); zephir_check_call_status(); RETURN_MM(); } /** * Return the exponential of the vector minus 1. * * @return self */ PHP_METHOD(Tensor_Vector, expm1) { zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(&_0); ZVAL_STRING(&_0, "expm1"); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "map", NULL, 0, &_0); zephir_check_call_status(); RETURN_MM(); } /** * Take the log to the given base of each element in the vector. * * @param float base * @return self */ PHP_METHOD(Tensor_Vector, log) { zval b; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zephir_fcall_cache_entry *_6 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *base_param = NULL, _0$$3, valueA, _1, *_2, _3, _4$$4, _5$$4, _7$$5, _8$$5; double base; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0$$3); ZVAL_UNDEF(&valueA); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_3); ZVAL_UNDEF(&_4$$4); ZVAL_UNDEF(&_5$$4); ZVAL_UNDEF(&_7$$5); ZVAL_UNDEF(&_8$$5); ZVAL_UNDEF(&b); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL Z_PARAM_ZVAL(base) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &base_param); if (!base_param) { base = 2.7182818284590452354; } else { base = zephir_get_doubleval(base_param); } if (base == 2.7182818284590452354) { ZEPHIR_INIT_VAR(&_0$$3); ZVAL_STRING(&_0$$3, "log"); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "map", NULL, 0, &_0$$3); zephir_check_call_status(); RETURN_MM(); } ZEPHIR_INIT_VAR(&b); array_init(&b); zephir_read_property(&_1, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); zephir_is_iterable(&_1, 0, "tensor/vector.zep", 1056); if (Z_TYPE_P(&_1) == IS_ARRAY) { ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_1), _2) { ZEPHIR_INIT_NVAR(&valueA); ZVAL_COPY(&valueA, _2); ZVAL_DOUBLE(&_4$$4, base); ZEPHIR_CALL_FUNCTION(&_5$$4, "log", &_6, 8, &valueA, &_4$$4); zephir_check_call_status(); zephir_array_append(&b, &_5$$4, PH_SEPARATE, "tensor/vector.zep", 1053); } ZEND_HASH_FOREACH_END(); } else { ZEPHIR_CALL_METHOD(NULL, &_1, "rewind", NULL, 0); zephir_check_call_status(); while (1) { ZEPHIR_CALL_METHOD(&_3, &_1, "valid", NULL, 0); zephir_check_call_status(); if (!zend_is_true(&_3)) { break; } ZEPHIR_CALL_METHOD(&valueA, &_1, "current", NULL, 0); zephir_check_call_status(); ZVAL_DOUBLE(&_7$$5, base); ZEPHIR_CALL_FUNCTION(&_8$$5, "log", &_6, 8, &valueA, &_7$$5); zephir_check_call_status(); zephir_array_append(&b, &_8$$5, PH_SEPARATE, "tensor/vector.zep", 1053); ZEPHIR_CALL_METHOD(NULL, &_1, "next", NULL, 0); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(&valueA); ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &b); zephir_check_call_status(); RETURN_MM(); } /** * Return the log of 1 plus the tensor i.e. a transform. * * @return self */ PHP_METHOD(Tensor_Vector, log1p) { zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(&_0); ZVAL_STRING(&_0, "log1p"); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "map", NULL, 0, &_0); zephir_check_call_status(); RETURN_MM(); } /** * Return the sine of this vector. * * @return self */ PHP_METHOD(Tensor_Vector, sin) { zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(&_0); ZVAL_STRING(&_0, "sin"); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "map", NULL, 0, &_0); zephir_check_call_status(); RETURN_MM(); } /** * Compute the arc sine of the vector. * * @return self */ PHP_METHOD(Tensor_Vector, asin) { zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(&_0); ZVAL_STRING(&_0, "asin"); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "map", NULL, 0, &_0); zephir_check_call_status(); RETURN_MM(); } /** * Return the cosine of this vector. * * @return self */ PHP_METHOD(Tensor_Vector, cos) { zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(&_0); ZVAL_STRING(&_0, "cos"); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "map", NULL, 0, &_0); zephir_check_call_status(); RETURN_MM(); } /** * Compute the arc cosine of the vector. * * @return self */ PHP_METHOD(Tensor_Vector, acos) { zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(&_0); ZVAL_STRING(&_0, "acos"); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "map", NULL, 0, &_0); zephir_check_call_status(); RETURN_MM(); } /** * Return the tangent of this vector. * * @return self */ PHP_METHOD(Tensor_Vector, tan) { zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(&_0); ZVAL_STRING(&_0, "tan"); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "map", NULL, 0, &_0); zephir_check_call_status(); RETURN_MM(); } /** * Compute the arc tangent of the vector. * * @return self */ PHP_METHOD(Tensor_Vector, atan) { zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(&_0); ZVAL_STRING(&_0, "atan"); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "map", NULL, 0, &_0); zephir_check_call_status(); RETURN_MM(); } /** * Convert angles from radians to degrees. * * @return self */ PHP_METHOD(Tensor_Vector, rad2deg) { zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(&_0); ZVAL_STRING(&_0, "rad2deg"); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "map", NULL, 0, &_0); zephir_check_call_status(); RETURN_MM(); } /** * Convert angles from degrees to radians. * * @return self */ PHP_METHOD(Tensor_Vector, deg2rad) { zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(&_0); ZVAL_STRING(&_0, "deg2rad"); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "map", NULL, 0, &_0); zephir_check_call_status(); RETURN_MM(); } /** * The sum of the vector. * * @return float */ PHP_METHOD(Tensor_Vector, sum) { zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZEPHIR_MM_GROW(); zephir_read_property(&_0, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_FUNCTION(&_1, "array_sum", NULL, 17, &_0); zephir_check_call_status(); RETURN_MM_DOUBLE(zephir_get_doubleval(&_1)); } /** * Return the product of the vector. * * @return float */ PHP_METHOD(Tensor_Vector, product) { zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZEPHIR_MM_GROW(); zephir_read_property(&_0, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_FUNCTION(&_1, "array_product", NULL, 18, &_0); zephir_check_call_status(); RETURN_MM_DOUBLE(zephir_get_doubleval(&_1)); } /** * Return the minimum element in the vector. * * @return float */ PHP_METHOD(Tensor_Vector, min) { zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZEPHIR_MM_GROW(); zephir_read_property(&_0, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_FUNCTION(&_1, "min", NULL, 19, &_0); zephir_check_call_status(); RETURN_MM_DOUBLE(zephir_get_doubleval(&_1)); } /** * Return the maximum element in the vector. * * @return float */ PHP_METHOD(Tensor_Vector, max) { zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZEPHIR_MM_GROW(); zephir_read_property(&_0, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_FUNCTION(&_1, "max", NULL, 20, &_0); zephir_check_call_status(); RETURN_MM_DOUBLE(zephir_get_doubleval(&_1)); } /** * Return the mean of the vector. * * @return float */ PHP_METHOD(Tensor_Vector, mean) { zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZEPHIR_MM_GROW(); ZEPHIR_CALL_METHOD(&_0, this_ptr, "sum", NULL, 0); zephir_check_call_status(); zephir_read_property(&_1, this_ptr, ZEND_STRL("n"), PH_NOISY_CC | PH_READONLY); div_function(return_value, &_0, &_1); RETURN_MM(); } /** * Return the median of the vector. * * @return float */ PHP_METHOD(Tensor_Vector, median) { zval median, _0, _1, _2, a, _3$$4, _4$$4, _5$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS, mid; zval *this_ptr = getThis(); ZVAL_UNDEF(&median); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&a); ZVAL_UNDEF(&_3$$4); ZVAL_UNDEF(&_4$$4); ZVAL_UNDEF(&_5$$4); ZEPHIR_MM_GROW(); zephir_read_property(&_0, this_ptr, ZEND_STRL("n"), PH_NOISY_CC | PH_READONLY); ZVAL_LONG(&_1, 2); ZEPHIR_CALL_FUNCTION(&_2, "intdiv", NULL, 21, &_0, &_1); zephir_check_call_status(); mid = zephir_get_intval(&_2); zephir_read_property(&_1, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CPY_WRT(&a, &_1); ZEPHIR_MAKE_REF(&a); ZEPHIR_CALL_FUNCTION(NULL, "sort", NULL, 22, &a); ZEPHIR_UNREF(&a); zephir_check_call_status(); zephir_read_property(&_1, this_ptr, ZEND_STRL("n"), PH_NOISY_CC | PH_READONLY); if (zephir_safe_mod_zval_long(&_1, 2) == 1) { ZEPHIR_OBS_VAR(&median); zephir_array_fetch_long(&median, &a, mid, PH_NOISY, "tensor/vector.zep", 1215); } else { zephir_array_fetch_long(&_3$$4, &a, (mid - 1), PH_NOISY | PH_READONLY, "tensor/vector.zep", 1217); zephir_array_fetch_long(&_4$$4, &a, mid, PH_NOISY | PH_READONLY, "tensor/vector.zep", 1217); ZEPHIR_INIT_VAR(&_5$$4); zephir_add_function(&_5$$4, &_3$$4, &_4$$4); ZEPHIR_INIT_NVAR(&median); ZVAL_DOUBLE(&median, zephir_safe_div_zval_double(&_5$$4, 2.0)); } RETURN_CCTOR(&median); } /** * Return the q'th quantile of the vector. * * @param float q * @throws \Tensor\Exceptions\InvalidArgumentException * @return float */ PHP_METHOD(Tensor_Vector, quantile) { zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS, xHat; zval *q_param = NULL, a, _5, _6, _7, _1$$3, _2$$3, _3$$3, _4$$3; double q, x, remainder, t; zval *this_ptr = getThis(); ZVAL_UNDEF(&a); ZVAL_UNDEF(&_5); ZVAL_UNDEF(&_6); ZVAL_UNDEF(&_7); ZVAL_UNDEF(&_1$$3); ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_3$$3); ZVAL_UNDEF(&_4$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ZVAL(q) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &q_param); q = zephir_get_doubleval(q_param); _0 = q < 0.0; if (!(_0)) { _0 = q > 1.0; } if (UNEXPECTED(_0)) { ZEPHIR_INIT_VAR(&_1$$3); object_init_ex(&_1$$3, tensor_exceptions_invalidargumentexception_ce); ZVAL_DOUBLE(&_2$$3, q); ZEPHIR_CALL_FUNCTION(&_3$$3, "strval", NULL, 4, &_2$$3); zephir_check_call_status(); ZEPHIR_INIT_VAR(&_4$$3); ZEPHIR_CONCAT_SSVS(&_4$$3, "Q must be", " between 0 and 1, ", &_3$$3, " given."); ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 3, &_4$$3); zephir_check_call_status(); zephir_throw_exception_debug(&_1$$3, "tensor/vector.zep", 1234); ZEPHIR_MM_RESTORE(); return; } zephir_read_property(&_5, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CPY_WRT(&a, &_5); ZEPHIR_MAKE_REF(&a); ZEPHIR_CALL_FUNCTION(NULL, "sort", NULL, 22, &a); ZEPHIR_UNREF(&a); zephir_check_call_status(); zephir_read_property(&_5, this_ptr, ZEND_STRL("n"), PH_NOISY_CC | PH_READONLY); x = ((q * (double) ((zephir_get_numberval(&_5) - 1))) + (double) (1)); xHat = (int) (x); remainder = (x - (double) xHat); ZEPHIR_OBS_VAR(&_6); zephir_array_fetch_long(&_6, &a, (xHat - 1), PH_NOISY, "tensor/vector.zep", 1247); t = zephir_get_doubleval(&_6); zephir_array_fetch_long(&_7, &a, xHat, PH_NOISY | PH_READONLY, "tensor/vector.zep", 1249); RETURN_MM_DOUBLE((t + (remainder * ((zephir_get_numberval(&_7) - t))))); } /** * Return the variance of the vector. * * @param mixed mean * @throws \Tensor\Exceptions\InvalidArgumentException * @return float */ PHP_METHOD(Tensor_Vector, variance) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *mean = NULL, mean_sub, __$null, _0$$3, _1$$4, _2$$4, _3$$4, ssd, _4, _5, _6; zval *this_ptr = getThis(); ZVAL_UNDEF(&mean_sub); ZVAL_NULL(&__$null); ZVAL_UNDEF(&_0$$3); ZVAL_UNDEF(&_1$$4); ZVAL_UNDEF(&_2$$4); ZVAL_UNDEF(&_3$$4); ZVAL_UNDEF(&ssd); ZVAL_UNDEF(&_4); ZVAL_UNDEF(&_5); ZVAL_UNDEF(&_6); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL Z_PARAM_ZVAL_OR_NULL(mean) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &mean); if (!mean) { mean = &mean_sub; ZEPHIR_CPY_WRT(mean, &__$null); } else { ZEPHIR_SEPARATE_PARAM(mean); } if (!(Z_TYPE_P(mean) == IS_NULL)) { ZEPHIR_CALL_FUNCTION(&_0$$3, "is_float", NULL, 2, mean); zephir_check_call_status(); if (UNEXPECTED(!zephir_is_true(&_0$$3))) { ZEPHIR_INIT_VAR(&_1$$4); object_init_ex(&_1$$4, tensor_exceptions_invalidargumentexception_ce); ZEPHIR_INIT_VAR(&_2$$4); zephir_gettype(&_2$$4, mean); ZEPHIR_INIT_VAR(&_3$$4); ZEPHIR_CONCAT_SSVS(&_3$$4, "Mean scalar must be", " a floating point number ", &_2$$4, " given."); ZEPHIR_CALL_METHOD(NULL, &_1$$4, "__construct", NULL, 3, &_3$$4); zephir_check_call_status(); zephir_throw_exception_debug(&_1$$4, "tensor/vector.zep", 1264); ZEPHIR_MM_RESTORE(); return; } } else { ZEPHIR_CALL_METHOD(mean, this_ptr, "mean", NULL, 0); zephir_check_call_status(); } ZEPHIR_CALL_METHOD(&_4, this_ptr, "subtractscalar", NULL, 0, mean); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&_5, &_4, "square", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_METHOD(&ssd, &_5, "sum", NULL, 0); zephir_check_call_status(); zephir_read_property(&_6, this_ptr, ZEND_STRL("n"), PH_NOISY_CC | PH_READONLY); div_function(return_value, &ssd, &_6); RETURN_MM(); } /** * Round the elements in the matrix to a given decimal place. * * @param int precision * @throws \Tensor\Exceptions\InvalidArgumentException * @return self */ PHP_METHOD(Tensor_Vector, round) { zval b; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zval *precision_param = NULL, _0$$3, _1$$4, _2$$4, _3$$4, _4$$4, valueA, _5, *_6, _7, _8$$5, _9$$5, _10$$6, _11$$6; zend_long precision, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0$$3); ZVAL_UNDEF(&_1$$4); ZVAL_UNDEF(&_2$$4); ZVAL_UNDEF(&_3$$4); ZVAL_UNDEF(&_4$$4); ZVAL_UNDEF(&valueA); ZVAL_UNDEF(&_5); ZVAL_UNDEF(&_7); ZVAL_UNDEF(&_8$$5); ZVAL_UNDEF(&_9$$5); ZVAL_UNDEF(&_10$$6); ZVAL_UNDEF(&_11$$6); ZVAL_UNDEF(&b); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL Z_PARAM_LONG(precision) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 0, 1, &precision_param); if (!precision_param) { precision = 0; } else { precision = zephir_get_intval(precision_param); } if (precision == 0) { ZEPHIR_INIT_VAR(&_0$$3); ZVAL_STRING(&_0$$3, "round"); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "map", NULL, 0, &_0$$3); zephir_check_call_status(); RETURN_MM(); } if (UNEXPECTED(precision < 0)) { ZEPHIR_INIT_VAR(&_1$$4); object_init_ex(&_1$$4, tensor_exceptions_invalidargumentexception_ce); ZVAL_LONG(&_2$$4, precision); ZEPHIR_CALL_FUNCTION(&_3$$4, "strval", NULL, 4, &_2$$4); zephir_check_call_status(); ZEPHIR_INIT_VAR(&_4$$4); ZEPHIR_CONCAT_SSVS(&_4$$4, "Decimal precision cannot", " be less than 0, ", &_3$$4, " given."); ZEPHIR_CALL_METHOD(NULL, &_1$$4, "__construct", NULL, 3, &_4$$4); zephir_check_call_status(); zephir_throw_exception_debug(&_1$$4, "tensor/vector.zep", 1292); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(&b); array_init(&b); zephir_read_property(&_5, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); zephir_is_iterable(&_5, 0, "tensor/vector.zep", 1303); if (Z_TYPE_P(&_5) == IS_ARRAY) { ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_5), _6) { ZEPHIR_INIT_NVAR(&valueA); ZVAL_COPY(&valueA, _6); ZEPHIR_INIT_NVAR(&_8$$5); ZVAL_LONG(&_9$$5, precision); zephir_round(&_8$$5, &valueA, &_9$$5, NULL); zephir_array_append(&b, &_8$$5, PH_SEPARATE, "tensor/vector.zep", 1300); } ZEND_HASH_FOREACH_END(); } else { ZEPHIR_CALL_METHOD(NULL, &_5, "rewind", NULL, 0); zephir_check_call_status(); while (1) { ZEPHIR_CALL_METHOD(&_7, &_5, "valid", NULL, 0); zephir_check_call_status(); if (!zend_is_true(&_7)) { break; } ZEPHIR_CALL_METHOD(&valueA, &_5, "current", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_10$$6); ZVAL_LONG(&_11$$6, precision); zephir_round(&_10$$6, &valueA, &_11$$6, NULL); zephir_array_append(&b, &_10$$6, PH_SEPARATE, "tensor/vector.zep", 1300); ZEPHIR_CALL_METHOD(NULL, &_5, "next", NULL, 0); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(&valueA); ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &b); zephir_check_call_status(); RETURN_MM(); } /** * Round the elements in the vector down to the nearest integer. * * @return self */ PHP_METHOD(Tensor_Vector, floor) { zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(&_0); ZVAL_STRING(&_0, "floor"); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "map", NULL, 0, &_0); zephir_check_call_status(); RETURN_MM(); } /** * Round the elements in the vector up to the nearest integer. * * @return self */ PHP_METHOD(Tensor_Vector, ceil) { zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(&_0); ZVAL_STRING(&_0, "ceil"); ZEPHIR_RETURN_CALL_METHOD(this_ptr, "map", NULL, 0, &_0); zephir_check_call_status(); RETURN_MM(); } /** * Clip the elements in the vector to be between given minimum and maximum * and return a new vector. * * @param float min * @param float max * @throws \Tensor\Exceptions\InvalidArgumentException * @return self */ PHP_METHOD(Tensor_Vector, clip) { zval b; zval _1$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *min_param = NULL, *max_param = NULL, _0$$3, valueA, _2, *_3, _4, _5$$5, _6$$6, _7$$8, _8$$9; double min, max; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0$$3); ZVAL_UNDEF(&valueA); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_4); ZVAL_UNDEF(&_5$$5); ZVAL_UNDEF(&_6$$6); ZVAL_UNDEF(&_7$$8); ZVAL_UNDEF(&_8$$9); ZVAL_UNDEF(&_1$$3); ZVAL_UNDEF(&b); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(2, 2) Z_PARAM_ZVAL(min) Z_PARAM_ZVAL(max) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &min_param, &max_param); min = zephir_get_doubleval(min_param); max = zephir_get_doubleval(max_param); if (UNEXPECTED(min > max)) { ZEPHIR_INIT_VAR(&_0$$3); object_init_ex(&_0$$3, tensor_exceptions_invalidargumentexception_ce); ZEPHIR_INIT_VAR(&_1$$3); ZEPHIR_CONCAT_SS(&_1$$3, "Minimum cannot be", " greater than maximum."); ZEPHIR_CALL_METHOD(NULL, &_0$$3, "__construct", NULL, 3, &_1$$3); zephir_check_call_status(); zephir_throw_exception_debug(&_0$$3, "tensor/vector.zep", 1339); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(&b); array_init(&b); zephir_read_property(&_2, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); zephir_is_iterable(&_2, 0, "tensor/vector.zep", 1362); if (Z_TYPE_P(&_2) == IS_ARRAY) { ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_2), _3) { ZEPHIR_INIT_NVAR(&valueA); ZVAL_COPY(&valueA, _3); if (ZEPHIR_GT_DOUBLE(&valueA, max)) { ZEPHIR_INIT_NVAR(&_5$$5); ZVAL_DOUBLE(&_5$$5, max); zephir_array_append(&b, &_5$$5, PH_SEPARATE, "tensor/vector.zep", 1348); continue; } if (ZEPHIR_LT_DOUBLE(&valueA, min)) { ZEPHIR_INIT_NVAR(&_6$$6); ZVAL_DOUBLE(&_6$$6, min); zephir_array_append(&b, &_6$$6, PH_SEPARATE, "tensor/vector.zep", 1354); continue; } zephir_array_append(&b, &valueA, PH_SEPARATE, "tensor/vector.zep", 1359); } ZEND_HASH_FOREACH_END(); } else { ZEPHIR_CALL_METHOD(NULL, &_2, "rewind", NULL, 0); zephir_check_call_status(); while (1) { ZEPHIR_CALL_METHOD(&_4, &_2, "valid", NULL, 0); zephir_check_call_status(); if (!zend_is_true(&_4)) { break; } ZEPHIR_CALL_METHOD(&valueA, &_2, "current", NULL, 0); zephir_check_call_status(); if (ZEPHIR_GT_DOUBLE(&valueA, max)) { ZEPHIR_INIT_NVAR(&_7$$8); ZVAL_DOUBLE(&_7$$8, max); zephir_array_append(&b, &_7$$8, PH_SEPARATE, "tensor/vector.zep", 1348); continue; } if (ZEPHIR_LT_DOUBLE(&valueA, min)) { ZEPHIR_INIT_NVAR(&_8$$9); ZVAL_DOUBLE(&_8$$9, min); zephir_array_append(&b, &_8$$9, PH_SEPARATE, "tensor/vector.zep", 1354); continue; } zephir_array_append(&b, &valueA, PH_SEPARATE, "tensor/vector.zep", 1359); ZEPHIR_CALL_METHOD(NULL, &_2, "next", NULL, 0); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(&valueA); ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &b); zephir_check_call_status(); RETURN_MM(); } /** * Clip the tensor to be lower bounded by a given minimum. * * @param float min * @return self */ PHP_METHOD(Tensor_Vector, clipLower) { zval b; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *min_param = NULL, valueA, _0, *_1, _2, _3$$4, _4$$6; double min; zval *this_ptr = getThis(); ZVAL_UNDEF(&valueA); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3$$4); ZVAL_UNDEF(&_4$$6); ZVAL_UNDEF(&b); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ZVAL(min) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &min_param); min = zephir_get_doubleval(min_param); ZEPHIR_INIT_VAR(&b); array_init(&b); zephir_read_property(&_0, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); zephir_is_iterable(&_0, 0, "tensor/vector.zep", 1387); if (Z_TYPE_P(&_0) == IS_ARRAY) { ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_0), _1) { ZEPHIR_INIT_NVAR(&valueA); ZVAL_COPY(&valueA, _1); if (ZEPHIR_LT_DOUBLE(&valueA, min)) { ZEPHIR_INIT_NVAR(&_3$$4); ZVAL_DOUBLE(&_3$$4, min); zephir_array_append(&b, &_3$$4, PH_SEPARATE, "tensor/vector.zep", 1379); continue; } zephir_array_append(&b, &valueA, PH_SEPARATE, "tensor/vector.zep", 1384); } ZEND_HASH_FOREACH_END(); } else { ZEPHIR_CALL_METHOD(NULL, &_0, "rewind", NULL, 0); zephir_check_call_status(); while (1) { ZEPHIR_CALL_METHOD(&_2, &_0, "valid", NULL, 0); zephir_check_call_status(); if (!zend_is_true(&_2)) { break; } ZEPHIR_CALL_METHOD(&valueA, &_0, "current", NULL, 0); zephir_check_call_status(); if (ZEPHIR_LT_DOUBLE(&valueA, min)) { ZEPHIR_INIT_NVAR(&_4$$6); ZVAL_DOUBLE(&_4$$6, min); zephir_array_append(&b, &_4$$6, PH_SEPARATE, "tensor/vector.zep", 1379); continue; } zephir_array_append(&b, &valueA, PH_SEPARATE, "tensor/vector.zep", 1384); ZEPHIR_CALL_METHOD(NULL, &_0, "next", NULL, 0); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(&valueA); ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &b); zephir_check_call_status(); RETURN_MM(); } /** * Clip the tensor to be upper bounded by a given maximum. * * @param float max * @return self */ PHP_METHOD(Tensor_Vector, clipUpper) { zval b; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *max_param = NULL, valueA, _0, *_1, _2, _3$$4, _4$$6; double max; zval *this_ptr = getThis(); ZVAL_UNDEF(&valueA); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3$$4); ZVAL_UNDEF(&_4$$6); ZVAL_UNDEF(&b); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ZVAL(max) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &max_param); max = zephir_get_doubleval(max_param); ZEPHIR_INIT_VAR(&b); array_init(&b); zephir_read_property(&_0, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); zephir_is_iterable(&_0, 0, "tensor/vector.zep", 1412); if (Z_TYPE_P(&_0) == IS_ARRAY) { ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_0), _1) { ZEPHIR_INIT_NVAR(&valueA); ZVAL_COPY(&valueA, _1); if (ZEPHIR_GT_DOUBLE(&valueA, max)) { ZEPHIR_INIT_NVAR(&_3$$4); ZVAL_DOUBLE(&_3$$4, max); zephir_array_append(&b, &_3$$4, PH_SEPARATE, "tensor/vector.zep", 1404); continue; } zephir_array_append(&b, &valueA, PH_SEPARATE, "tensor/vector.zep", 1409); } ZEND_HASH_FOREACH_END(); } else { ZEPHIR_CALL_METHOD(NULL, &_0, "rewind", NULL, 0); zephir_check_call_status(); while (1) { ZEPHIR_CALL_METHOD(&_2, &_0, "valid", NULL, 0); zephir_check_call_status(); if (!zend_is_true(&_2)) { break; } ZEPHIR_CALL_METHOD(&valueA, &_0, "current", NULL, 0); zephir_check_call_status(); if (ZEPHIR_GT_DOUBLE(&valueA, max)) { ZEPHIR_INIT_NVAR(&_4$$6); ZVAL_DOUBLE(&_4$$6, max); zephir_array_append(&b, &_4$$6, PH_SEPARATE, "tensor/vector.zep", 1404); continue; } zephir_array_append(&b, &valueA, PH_SEPARATE, "tensor/vector.zep", 1409); ZEPHIR_CALL_METHOD(NULL, &_0, "next", NULL, 0); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(&valueA); ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &b); zephir_check_call_status(); RETURN_MM(); } /** * Return the element-wise sign indication. * * @return self */ PHP_METHOD(Tensor_Vector, sign) { zval b; zval valueA, _0, *_1, _2, _3$$4, _4$$5, _5$$6, _6$$8, _7$$9, _8$$10; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&valueA); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3$$4); ZVAL_UNDEF(&_4$$5); ZVAL_UNDEF(&_5$$6); ZVAL_UNDEF(&_6$$8); ZVAL_UNDEF(&_7$$9); ZVAL_UNDEF(&_8$$10); ZVAL_UNDEF(&b); ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(&b); array_init(&b); zephir_read_property(&_0, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); zephir_is_iterable(&_0, 0, "tensor/vector.zep", 1436); if (Z_TYPE_P(&_0) == IS_ARRAY) { ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_0), _1) { ZEPHIR_INIT_NVAR(&valueA); ZVAL_COPY(&valueA, _1); if (ZEPHIR_GT_LONG(&valueA, 0)) { ZEPHIR_INIT_NVAR(&_3$$4); ZVAL_DOUBLE(&_3$$4, 1.0); zephir_array_append(&b, &_3$$4, PH_SEPARATE, "tensor/vector.zep", 1428); } else if (ZEPHIR_LT_LONG(&valueA, 0)) { ZEPHIR_INIT_NVAR(&_4$$5); ZVAL_DOUBLE(&_4$$5, -1.0); zephir_array_append(&b, &_4$$5, PH_SEPARATE, "tensor/vector.zep", 1430); } else { ZEPHIR_INIT_NVAR(&_5$$6); ZVAL_DOUBLE(&_5$$6, 0.0); zephir_array_append(&b, &_5$$6, PH_SEPARATE, "tensor/vector.zep", 1432); } } ZEND_HASH_FOREACH_END(); } else { ZEPHIR_CALL_METHOD(NULL, &_0, "rewind", NULL, 0); zephir_check_call_status(); while (1) { ZEPHIR_CALL_METHOD(&_2, &_0, "valid", NULL, 0); zephir_check_call_status(); if (!zend_is_true(&_2)) { break; } ZEPHIR_CALL_METHOD(&valueA, &_0, "current", NULL, 0); zephir_check_call_status(); if (ZEPHIR_GT_LONG(&valueA, 0)) { ZEPHIR_INIT_NVAR(&_6$$8); ZVAL_DOUBLE(&_6$$8, 1.0); zephir_array_append(&b, &_6$$8, PH_SEPARATE, "tensor/vector.zep", 1428); } else if (ZEPHIR_LT_LONG(&valueA, 0)) { ZEPHIR_INIT_NVAR(&_7$$9); ZVAL_DOUBLE(&_7$$9, -1.0); zephir_array_append(&b, &_7$$9, PH_SEPARATE, "tensor/vector.zep", 1430); } else { ZEPHIR_INIT_NVAR(&_8$$10); ZVAL_DOUBLE(&_8$$10, 0.0); zephir_array_append(&b, &_8$$10, PH_SEPARATE, "tensor/vector.zep", 1432); } ZEPHIR_CALL_METHOD(NULL, &_0, "next", NULL, 0); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(&valueA); ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &b); zephir_check_call_status(); RETURN_MM(); } /** * Negate the vector i.e take the negative of each value elementwise. * * @return self */ PHP_METHOD(Tensor_Vector, negate) { zval b; zval valueA, _0, *_1, _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&valueA); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&b); ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(&b); array_init(&b); zephir_read_property(&_0, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); zephir_is_iterable(&_0, 0, "tensor/vector.zep", 1454); if (Z_TYPE_P(&_0) == IS_ARRAY) { ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_0), _1) { ZEPHIR_INIT_NVAR(&valueA); ZVAL_COPY(&valueA, _1); zephir_negate(&valueA); zephir_array_append(&b, &valueA, PH_SEPARATE, "tensor/vector.zep", 1451); } ZEND_HASH_FOREACH_END(); } else { ZEPHIR_CALL_METHOD(NULL, &_0, "rewind", NULL, 0); zephir_check_call_status(); while (1) { ZEPHIR_CALL_METHOD(&_2, &_0, "valid", NULL, 0); zephir_check_call_status(); if (!zend_is_true(&_2)) { break; } ZEPHIR_CALL_METHOD(&valueA, &_0, "current", NULL, 0); zephir_check_call_status(); zephir_negate(&valueA); zephir_array_append(&b, &valueA, PH_SEPARATE, "tensor/vector.zep", 1451); ZEPHIR_CALL_METHOD(NULL, &_0, "next", NULL, 0); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(&valueA); ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &b); zephir_check_call_status(); RETURN_MM(); } /** * Multiply this vector with a matrix. * * @param \Tensor\Matrix b * @throws \Tensor\Exceptions\DimensionalityMismatch * @return \Tensor\Matrix */ PHP_METHOD(Tensor_Vector, multiplyMatrix) { zval _4$$3, _6$$3, _7$$3; zval c; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zephir_fcall_cache_entry *_15 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, _0, _1, rowB, _8, *_9, _10, _2$$3, _3$$3, _5$$3, _11$$4, _12$$4, _13$$5, _14$$5; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&rowB); ZVAL_UNDEF(&_8); ZVAL_UNDEF(&_10); ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_3$$3); ZVAL_UNDEF(&_5$$3); ZVAL_UNDEF(&_11$$4); ZVAL_UNDEF(&_12$$4); ZVAL_UNDEF(&_13$$5); ZVAL_UNDEF(&_14$$5); ZVAL_UNDEF(&c); ZVAL_UNDEF(&_4$$3); ZVAL_UNDEF(&_6$$3); ZVAL_UNDEF(&_7$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_OBJECT_OF_CLASS(b, zephir_get_internal_ce(SL("tensor\\matrix"))) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); zephir_read_property(&_0, this_ptr, ZEND_STRL("n"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_1, b, "n", NULL, 0); zephir_check_call_status(); if (UNEXPECTED(!ZEPHIR_IS_IDENTICAL(&_0, &_1))) { ZEPHIR_INIT_VAR(&_2$$3); object_init_ex(&_2$$3, tensor_exceptions_dimensionalitymismatch_ce); ZEPHIR_OBS_VAR(&_3$$3); zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("n"), PH_NOISY_CC); zephir_cast_to_string(&_4$$3, &_3$$3); ZEPHIR_CALL_METHOD(&_5$$3, b, "n", NULL, 0); zephir_check_call_status(); zephir_cast_to_string(&_6$$3, &_5$$3); ZEPHIR_INIT_VAR(&_7$$3); ZEPHIR_CONCAT_SVSVS(&_7$$3, "Vector A expects ", &_4$$3, " columns but Matrix B has ", &_6$$3, "."); ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 3, &_7$$3); zephir_check_call_status(); zephir_throw_exception_debug(&_2$$3, "tensor/vector.zep", 1469); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(&c); array_init(&c); ZEPHIR_CALL_METHOD(&_8, b, "asarray", NULL, 0); zephir_check_call_status(); zephir_is_iterable(&_8, 0, "tensor/vector.zep", 1480); if (Z_TYPE_P(&_8) == IS_ARRAY) { ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_8), _9) { ZEPHIR_INIT_NVAR(&rowB); ZVAL_COPY(&rowB, _9); ZEPHIR_INIT_NVAR(&_11$$4); zephir_read_property(&_12$$4, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); tensor_multiply(&_11$$4, &_12$$4, &rowB); zephir_array_append(&c, &_11$$4, PH_SEPARATE, "tensor/vector.zep", 1477); } ZEND_HASH_FOREACH_END(); } else { ZEPHIR_CALL_METHOD(NULL, &_8, "rewind", NULL, 0); zephir_check_call_status(); while (1) { ZEPHIR_CALL_METHOD(&_10, &_8, "valid", NULL, 0); zephir_check_call_status(); if (!zend_is_true(&_10)) { break; } ZEPHIR_CALL_METHOD(&rowB, &_8, "current", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_13$$5); zephir_read_property(&_14$$5, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); tensor_multiply(&_13$$5, &_14$$5, &rowB); zephir_array_append(&c, &_13$$5, PH_SEPARATE, "tensor/vector.zep", 1477); ZEPHIR_CALL_METHOD(NULL, &_8, "next", NULL, 0); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(&rowB); ZEPHIR_RETURN_CALL_CE_STATIC(tensor_matrix_ce, "quick", &_15, 0, &c); zephir_check_call_status(); RETURN_MM(); } /** * Divide this vector with a matrix. * * @param \Tensor\Matrix b * @throws \Tensor\Exceptions\DimensionalityMismatch * @return \Tensor\Matrix */ PHP_METHOD(Tensor_Vector, divideMatrix) { zval _4$$3, _6$$3, _7$$3; zval c; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zephir_fcall_cache_entry *_15 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, _0, _1, rowB, _8, *_9, _10, _2$$3, _3$$3, _5$$3, _11$$4, _12$$4, _13$$5, _14$$5; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&rowB); ZVAL_UNDEF(&_8); ZVAL_UNDEF(&_10); ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_3$$3); ZVAL_UNDEF(&_5$$3); ZVAL_UNDEF(&_11$$4); ZVAL_UNDEF(&_12$$4); ZVAL_UNDEF(&_13$$5); ZVAL_UNDEF(&_14$$5); ZVAL_UNDEF(&c); ZVAL_UNDEF(&_4$$3); ZVAL_UNDEF(&_6$$3); ZVAL_UNDEF(&_7$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_OBJECT_OF_CLASS(b, zephir_get_internal_ce(SL("tensor\\matrix"))) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); zephir_read_property(&_0, this_ptr, ZEND_STRL("n"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_1, b, "n", NULL, 0); zephir_check_call_status(); if (UNEXPECTED(!ZEPHIR_IS_IDENTICAL(&_0, &_1))) { ZEPHIR_INIT_VAR(&_2$$3); object_init_ex(&_2$$3, tensor_exceptions_dimensionalitymismatch_ce); ZEPHIR_OBS_VAR(&_3$$3); zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("n"), PH_NOISY_CC); zephir_cast_to_string(&_4$$3, &_3$$3); ZEPHIR_CALL_METHOD(&_5$$3, b, "n", NULL, 0); zephir_check_call_status(); zephir_cast_to_string(&_6$$3, &_5$$3); ZEPHIR_INIT_VAR(&_7$$3); ZEPHIR_CONCAT_SVSVS(&_7$$3, "Vector A expects ", &_4$$3, " columns but Matrix B has ", &_6$$3, "."); ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 3, &_7$$3); zephir_check_call_status(); zephir_throw_exception_debug(&_2$$3, "tensor/vector.zep", 1495); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(&c); array_init(&c); ZEPHIR_CALL_METHOD(&_8, b, "asarray", NULL, 0); zephir_check_call_status(); zephir_is_iterable(&_8, 0, "tensor/vector.zep", 1506); if (Z_TYPE_P(&_8) == IS_ARRAY) { ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_8), _9) { ZEPHIR_INIT_NVAR(&rowB); ZVAL_COPY(&rowB, _9); ZEPHIR_INIT_NVAR(&_11$$4); zephir_read_property(&_12$$4, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); tensor_divide(&_11$$4, &_12$$4, &rowB); zephir_array_append(&c, &_11$$4, PH_SEPARATE, "tensor/vector.zep", 1503); } ZEND_HASH_FOREACH_END(); } else { ZEPHIR_CALL_METHOD(NULL, &_8, "rewind", NULL, 0); zephir_check_call_status(); while (1) { ZEPHIR_CALL_METHOD(&_10, &_8, "valid", NULL, 0); zephir_check_call_status(); if (!zend_is_true(&_10)) { break; } ZEPHIR_CALL_METHOD(&rowB, &_8, "current", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_13$$5); zephir_read_property(&_14$$5, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); tensor_divide(&_13$$5, &_14$$5, &rowB); zephir_array_append(&c, &_13$$5, PH_SEPARATE, "tensor/vector.zep", 1503); ZEPHIR_CALL_METHOD(NULL, &_8, "next", NULL, 0); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(&rowB); ZEPHIR_RETURN_CALL_CE_STATIC(tensor_matrix_ce, "quick", &_15, 0, &c); zephir_check_call_status(); RETURN_MM(); } /** * Add this vector to a matrix. * * @param \Tensor\Matrix b * @throws \Tensor\Exceptions\DimensionalityMismatch * @return \Tensor\Matrix */ PHP_METHOD(Tensor_Vector, addMatrix) { zval _4$$3, _6$$3, _7$$3; zval c; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zephir_fcall_cache_entry *_15 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, _0, _1, rowB, _8, *_9, _10, _2$$3, _3$$3, _5$$3, _11$$4, _12$$4, _13$$5, _14$$5; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&rowB); ZVAL_UNDEF(&_8); ZVAL_UNDEF(&_10); ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_3$$3); ZVAL_UNDEF(&_5$$3); ZVAL_UNDEF(&_11$$4); ZVAL_UNDEF(&_12$$4); ZVAL_UNDEF(&_13$$5); ZVAL_UNDEF(&_14$$5); ZVAL_UNDEF(&c); ZVAL_UNDEF(&_4$$3); ZVAL_UNDEF(&_6$$3); ZVAL_UNDEF(&_7$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_OBJECT_OF_CLASS(b, zephir_get_internal_ce(SL("tensor\\matrix"))) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); zephir_read_property(&_0, this_ptr, ZEND_STRL("n"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_1, b, "n", NULL, 0); zephir_check_call_status(); if (UNEXPECTED(!ZEPHIR_IS_IDENTICAL(&_0, &_1))) { ZEPHIR_INIT_VAR(&_2$$3); object_init_ex(&_2$$3, tensor_exceptions_dimensionalitymismatch_ce); ZEPHIR_OBS_VAR(&_3$$3); zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("n"), PH_NOISY_CC); zephir_cast_to_string(&_4$$3, &_3$$3); ZEPHIR_CALL_METHOD(&_5$$3, b, "n", NULL, 0); zephir_check_call_status(); zephir_cast_to_string(&_6$$3, &_5$$3); ZEPHIR_INIT_VAR(&_7$$3); ZEPHIR_CONCAT_SVSVS(&_7$$3, "Vector A expects ", &_4$$3, " columns but Matrix B has ", &_6$$3, "."); ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 3, &_7$$3); zephir_check_call_status(); zephir_throw_exception_debug(&_2$$3, "tensor/vector.zep", 1521); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(&c); array_init(&c); ZEPHIR_CALL_METHOD(&_8, b, "asarray", NULL, 0); zephir_check_call_status(); zephir_is_iterable(&_8, 0, "tensor/vector.zep", 1532); if (Z_TYPE_P(&_8) == IS_ARRAY) { ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_8), _9) { ZEPHIR_INIT_NVAR(&rowB); ZVAL_COPY(&rowB, _9); ZEPHIR_INIT_NVAR(&_11$$4); zephir_read_property(&_12$$4, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); tensor_add(&_11$$4, &_12$$4, &rowB); zephir_array_append(&c, &_11$$4, PH_SEPARATE, "tensor/vector.zep", 1529); } ZEND_HASH_FOREACH_END(); } else { ZEPHIR_CALL_METHOD(NULL, &_8, "rewind", NULL, 0); zephir_check_call_status(); while (1) { ZEPHIR_CALL_METHOD(&_10, &_8, "valid", NULL, 0); zephir_check_call_status(); if (!zend_is_true(&_10)) { break; } ZEPHIR_CALL_METHOD(&rowB, &_8, "current", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_13$$5); zephir_read_property(&_14$$5, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); tensor_add(&_13$$5, &_14$$5, &rowB); zephir_array_append(&c, &_13$$5, PH_SEPARATE, "tensor/vector.zep", 1529); ZEPHIR_CALL_METHOD(NULL, &_8, "next", NULL, 0); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(&rowB); ZEPHIR_RETURN_CALL_CE_STATIC(tensor_matrix_ce, "quick", &_15, 0, &c); zephir_check_call_status(); RETURN_MM(); } /** * Subtract a matrix from this vector. * * @param \Tensor\Matrix b * @throws \Tensor\Exceptions\DimensionalityMismatch * @return \Tensor\Matrix */ PHP_METHOD(Tensor_Vector, subtractMatrix) { zval _4$$3, _6$$3, _7$$3; zval c; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zephir_fcall_cache_entry *_15 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, _0, _1, rowB, _8, *_9, _10, _2$$3, _3$$3, _5$$3, _11$$4, _12$$4, _13$$5, _14$$5; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&rowB); ZVAL_UNDEF(&_8); ZVAL_UNDEF(&_10); ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_3$$3); ZVAL_UNDEF(&_5$$3); ZVAL_UNDEF(&_11$$4); ZVAL_UNDEF(&_12$$4); ZVAL_UNDEF(&_13$$5); ZVAL_UNDEF(&_14$$5); ZVAL_UNDEF(&c); ZVAL_UNDEF(&_4$$3); ZVAL_UNDEF(&_6$$3); ZVAL_UNDEF(&_7$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_OBJECT_OF_CLASS(b, zephir_get_internal_ce(SL("tensor\\matrix"))) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); zephir_read_property(&_0, this_ptr, ZEND_STRL("n"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_1, b, "n", NULL, 0); zephir_check_call_status(); if (UNEXPECTED(!ZEPHIR_IS_IDENTICAL(&_0, &_1))) { ZEPHIR_INIT_VAR(&_2$$3); object_init_ex(&_2$$3, tensor_exceptions_dimensionalitymismatch_ce); ZEPHIR_OBS_VAR(&_3$$3); zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("n"), PH_NOISY_CC); zephir_cast_to_string(&_4$$3, &_3$$3); ZEPHIR_CALL_METHOD(&_5$$3, b, "n", NULL, 0); zephir_check_call_status(); zephir_cast_to_string(&_6$$3, &_5$$3); ZEPHIR_INIT_VAR(&_7$$3); ZEPHIR_CONCAT_SVSVS(&_7$$3, "Vector A expects ", &_4$$3, " columns but Matrix B has ", &_6$$3, "."); ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 3, &_7$$3); zephir_check_call_status(); zephir_throw_exception_debug(&_2$$3, "tensor/vector.zep", 1547); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(&c); array_init(&c); ZEPHIR_CALL_METHOD(&_8, b, "asarray", NULL, 0); zephir_check_call_status(); zephir_is_iterable(&_8, 0, "tensor/vector.zep", 1558); if (Z_TYPE_P(&_8) == IS_ARRAY) { ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_8), _9) { ZEPHIR_INIT_NVAR(&rowB); ZVAL_COPY(&rowB, _9); ZEPHIR_INIT_NVAR(&_11$$4); zephir_read_property(&_12$$4, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); tensor_subtract(&_11$$4, &_12$$4, &rowB); zephir_array_append(&c, &_11$$4, PH_SEPARATE, "tensor/vector.zep", 1555); } ZEND_HASH_FOREACH_END(); } else { ZEPHIR_CALL_METHOD(NULL, &_8, "rewind", NULL, 0); zephir_check_call_status(); while (1) { ZEPHIR_CALL_METHOD(&_10, &_8, "valid", NULL, 0); zephir_check_call_status(); if (!zend_is_true(&_10)) { break; } ZEPHIR_CALL_METHOD(&rowB, &_8, "current", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_13$$5); zephir_read_property(&_14$$5, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); tensor_subtract(&_13$$5, &_14$$5, &rowB); zephir_array_append(&c, &_13$$5, PH_SEPARATE, "tensor/vector.zep", 1555); ZEPHIR_CALL_METHOD(NULL, &_8, "next", NULL, 0); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(&rowB); ZEPHIR_RETURN_CALL_CE_STATIC(tensor_matrix_ce, "quick", &_15, 0, &c); zephir_check_call_status(); RETURN_MM(); } /** * Raise this vector to the power of a matrix. * * @param \Tensor\Matrix b * @throws \Tensor\Exceptions\DimensionalityMismatch * @return \Tensor\Matrix */ PHP_METHOD(Tensor_Vector, powMatrix) { zval _4$$3, _6$$3, _7$$3; zval c; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zephir_fcall_cache_entry *_15 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, _0, _1, rowB, _8, *_9, _10, _2$$3, _3$$3, _5$$3, _11$$4, _12$$4, _13$$5, _14$$5; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&rowB); ZVAL_UNDEF(&_8); ZVAL_UNDEF(&_10); ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_3$$3); ZVAL_UNDEF(&_5$$3); ZVAL_UNDEF(&_11$$4); ZVAL_UNDEF(&_12$$4); ZVAL_UNDEF(&_13$$5); ZVAL_UNDEF(&_14$$5); ZVAL_UNDEF(&c); ZVAL_UNDEF(&_4$$3); ZVAL_UNDEF(&_6$$3); ZVAL_UNDEF(&_7$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_OBJECT_OF_CLASS(b, zephir_get_internal_ce(SL("tensor\\matrix"))) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); zephir_read_property(&_0, this_ptr, ZEND_STRL("n"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_1, b, "n", NULL, 0); zephir_check_call_status(); if (UNEXPECTED(!ZEPHIR_IS_IDENTICAL(&_0, &_1))) { ZEPHIR_INIT_VAR(&_2$$3); object_init_ex(&_2$$3, tensor_exceptions_dimensionalitymismatch_ce); ZEPHIR_OBS_VAR(&_3$$3); zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("n"), PH_NOISY_CC); zephir_cast_to_string(&_4$$3, &_3$$3); ZEPHIR_CALL_METHOD(&_5$$3, b, "n", NULL, 0); zephir_check_call_status(); zephir_cast_to_string(&_6$$3, &_5$$3); ZEPHIR_INIT_VAR(&_7$$3); ZEPHIR_CONCAT_SVSVS(&_7$$3, "Vector A expects ", &_4$$3, " columns but Matrix B has ", &_6$$3, "."); ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 3, &_7$$3); zephir_check_call_status(); zephir_throw_exception_debug(&_2$$3, "tensor/vector.zep", 1573); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(&c); array_init(&c); ZEPHIR_CALL_METHOD(&_8, b, "asarray", NULL, 0); zephir_check_call_status(); zephir_is_iterable(&_8, 0, "tensor/vector.zep", 1584); if (Z_TYPE_P(&_8) == IS_ARRAY) { ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_8), _9) { ZEPHIR_INIT_NVAR(&rowB); ZVAL_COPY(&rowB, _9); ZEPHIR_INIT_NVAR(&_11$$4); zephir_read_property(&_12$$4, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); tensor_pow(&_11$$4, &_12$$4, &rowB); zephir_array_append(&c, &_11$$4, PH_SEPARATE, "tensor/vector.zep", 1581); } ZEND_HASH_FOREACH_END(); } else { ZEPHIR_CALL_METHOD(NULL, &_8, "rewind", NULL, 0); zephir_check_call_status(); while (1) { ZEPHIR_CALL_METHOD(&_10, &_8, "valid", NULL, 0); zephir_check_call_status(); if (!zend_is_true(&_10)) { break; } ZEPHIR_CALL_METHOD(&rowB, &_8, "current", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_13$$5); zephir_read_property(&_14$$5, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); tensor_pow(&_13$$5, &_14$$5, &rowB); zephir_array_append(&c, &_13$$5, PH_SEPARATE, "tensor/vector.zep", 1581); ZEPHIR_CALL_METHOD(NULL, &_8, "next", NULL, 0); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(&rowB); ZEPHIR_RETURN_CALL_CE_STATIC(tensor_matrix_ce, "quick", &_15, 0, &c); zephir_check_call_status(); RETURN_MM(); } /** * Mod this vector with a matrix. * * @param \Tensor\Matrix b * @throws \Tensor\Exceptions\DimensionalityMismatch * @return \Tensor\Matrix */ PHP_METHOD(Tensor_Vector, modMatrix) { zval _4$$3, _6$$3, _7$$3; zval c; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zephir_fcall_cache_entry *_15 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, _0, _1, rowB, _8, *_9, _10, _2$$3, _3$$3, _5$$3, _11$$4, _12$$4, _13$$5, _14$$5; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&rowB); ZVAL_UNDEF(&_8); ZVAL_UNDEF(&_10); ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_3$$3); ZVAL_UNDEF(&_5$$3); ZVAL_UNDEF(&_11$$4); ZVAL_UNDEF(&_12$$4); ZVAL_UNDEF(&_13$$5); ZVAL_UNDEF(&_14$$5); ZVAL_UNDEF(&c); ZVAL_UNDEF(&_4$$3); ZVAL_UNDEF(&_6$$3); ZVAL_UNDEF(&_7$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_OBJECT_OF_CLASS(b, zephir_get_internal_ce(SL("tensor\\matrix"))) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); zephir_read_property(&_0, this_ptr, ZEND_STRL("n"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_1, b, "n", NULL, 0); zephir_check_call_status(); if (UNEXPECTED(!ZEPHIR_IS_IDENTICAL(&_0, &_1))) { ZEPHIR_INIT_VAR(&_2$$3); object_init_ex(&_2$$3, tensor_exceptions_dimensionalitymismatch_ce); ZEPHIR_OBS_VAR(&_3$$3); zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("n"), PH_NOISY_CC); zephir_cast_to_string(&_4$$3, &_3$$3); ZEPHIR_CALL_METHOD(&_5$$3, b, "n", NULL, 0); zephir_check_call_status(); zephir_cast_to_string(&_6$$3, &_5$$3); ZEPHIR_INIT_VAR(&_7$$3); ZEPHIR_CONCAT_SVSVS(&_7$$3, "Vector A expects ", &_4$$3, " columns but Matrix B has ", &_6$$3, "."); ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 3, &_7$$3); zephir_check_call_status(); zephir_throw_exception_debug(&_2$$3, "tensor/vector.zep", 1599); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(&c); array_init(&c); ZEPHIR_CALL_METHOD(&_8, b, "asarray", NULL, 0); zephir_check_call_status(); zephir_is_iterable(&_8, 0, "tensor/vector.zep", 1610); if (Z_TYPE_P(&_8) == IS_ARRAY) { ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_8), _9) { ZEPHIR_INIT_NVAR(&rowB); ZVAL_COPY(&rowB, _9); ZEPHIR_INIT_NVAR(&_11$$4); zephir_read_property(&_12$$4, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); tensor_mod(&_11$$4, &_12$$4, &rowB); zephir_array_append(&c, &_11$$4, PH_SEPARATE, "tensor/vector.zep", 1607); } ZEND_HASH_FOREACH_END(); } else { ZEPHIR_CALL_METHOD(NULL, &_8, "rewind", NULL, 0); zephir_check_call_status(); while (1) { ZEPHIR_CALL_METHOD(&_10, &_8, "valid", NULL, 0); zephir_check_call_status(); if (!zend_is_true(&_10)) { break; } ZEPHIR_CALL_METHOD(&rowB, &_8, "current", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_13$$5); zephir_read_property(&_14$$5, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); tensor_mod(&_13$$5, &_14$$5, &rowB); zephir_array_append(&c, &_13$$5, PH_SEPARATE, "tensor/vector.zep", 1607); ZEPHIR_CALL_METHOD(NULL, &_8, "next", NULL, 0); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(&rowB); ZEPHIR_RETURN_CALL_CE_STATIC(tensor_matrix_ce, "quick", &_15, 0, &c); zephir_check_call_status(); RETURN_MM(); } /** * Return the element-wise equality comparison of this vector and a matrix. * * @param \Tensor\Matrix b * @throws \Tensor\Exceptions\DimensionalityMismatch * @return \Tensor\Matrix */ PHP_METHOD(Tensor_Vector, equalMatrix) { zval _4$$3, _6$$3, _7$$3; zval c; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zephir_fcall_cache_entry *_15 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, _0, _1, rowB, _8, *_9, _10, _2$$3, _3$$3, _5$$3, _11$$4, _12$$4, _13$$5, _14$$5; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&rowB); ZVAL_UNDEF(&_8); ZVAL_UNDEF(&_10); ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_3$$3); ZVAL_UNDEF(&_5$$3); ZVAL_UNDEF(&_11$$4); ZVAL_UNDEF(&_12$$4); ZVAL_UNDEF(&_13$$5); ZVAL_UNDEF(&_14$$5); ZVAL_UNDEF(&c); ZVAL_UNDEF(&_4$$3); ZVAL_UNDEF(&_6$$3); ZVAL_UNDEF(&_7$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_OBJECT_OF_CLASS(b, zephir_get_internal_ce(SL("tensor\\matrix"))) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); zephir_read_property(&_0, this_ptr, ZEND_STRL("n"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_1, b, "n", NULL, 0); zephir_check_call_status(); if (UNEXPECTED(!ZEPHIR_IS_IDENTICAL(&_0, &_1))) { ZEPHIR_INIT_VAR(&_2$$3); object_init_ex(&_2$$3, tensor_exceptions_dimensionalitymismatch_ce); ZEPHIR_OBS_VAR(&_3$$3); zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("n"), PH_NOISY_CC); zephir_cast_to_string(&_4$$3, &_3$$3); ZEPHIR_CALL_METHOD(&_5$$3, b, "n", NULL, 0); zephir_check_call_status(); zephir_cast_to_string(&_6$$3, &_5$$3); ZEPHIR_INIT_VAR(&_7$$3); ZEPHIR_CONCAT_SVSVS(&_7$$3, "Vector A expects ", &_4$$3, " columns but Matrix B has ", &_6$$3, "."); ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 3, &_7$$3); zephir_check_call_status(); zephir_throw_exception_debug(&_2$$3, "tensor/vector.zep", 1625); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(&c); array_init(&c); ZEPHIR_CALL_METHOD(&_8, b, "asarray", NULL, 0); zephir_check_call_status(); zephir_is_iterable(&_8, 0, "tensor/vector.zep", 1636); if (Z_TYPE_P(&_8) == IS_ARRAY) { ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_8), _9) { ZEPHIR_INIT_NVAR(&rowB); ZVAL_COPY(&rowB, _9); ZEPHIR_INIT_NVAR(&_11$$4); zephir_read_property(&_12$$4, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); tensor_equal(&_11$$4, &_12$$4, &rowB); zephir_array_append(&c, &_11$$4, PH_SEPARATE, "tensor/vector.zep", 1633); } ZEND_HASH_FOREACH_END(); } else { ZEPHIR_CALL_METHOD(NULL, &_8, "rewind", NULL, 0); zephir_check_call_status(); while (1) { ZEPHIR_CALL_METHOD(&_10, &_8, "valid", NULL, 0); zephir_check_call_status(); if (!zend_is_true(&_10)) { break; } ZEPHIR_CALL_METHOD(&rowB, &_8, "current", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_13$$5); zephir_read_property(&_14$$5, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); tensor_equal(&_13$$5, &_14$$5, &rowB); zephir_array_append(&c, &_13$$5, PH_SEPARATE, "tensor/vector.zep", 1633); ZEPHIR_CALL_METHOD(NULL, &_8, "next", NULL, 0); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(&rowB); ZEPHIR_RETURN_CALL_CE_STATIC(tensor_matrix_ce, "quick", &_15, 0, &c); zephir_check_call_status(); RETURN_MM(); } /** * Return the element-wise not equal comparison of this vector and a matrix. * * @param \Tensor\Matrix b * @throws \Tensor\Exceptions\DimensionalityMismatch * @return \Tensor\Matrix */ PHP_METHOD(Tensor_Vector, notEqualMatrix) { zval _4$$3, _6$$3, _7$$3; zval c; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zephir_fcall_cache_entry *_15 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, _0, _1, rowB, _8, *_9, _10, _2$$3, _3$$3, _5$$3, _11$$4, _12$$4, _13$$5, _14$$5; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&rowB); ZVAL_UNDEF(&_8); ZVAL_UNDEF(&_10); ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_3$$3); ZVAL_UNDEF(&_5$$3); ZVAL_UNDEF(&_11$$4); ZVAL_UNDEF(&_12$$4); ZVAL_UNDEF(&_13$$5); ZVAL_UNDEF(&_14$$5); ZVAL_UNDEF(&c); ZVAL_UNDEF(&_4$$3); ZVAL_UNDEF(&_6$$3); ZVAL_UNDEF(&_7$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_OBJECT_OF_CLASS(b, zephir_get_internal_ce(SL("tensor\\matrix"))) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); zephir_read_property(&_0, this_ptr, ZEND_STRL("n"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_1, b, "n", NULL, 0); zephir_check_call_status(); if (UNEXPECTED(!ZEPHIR_IS_IDENTICAL(&_0, &_1))) { ZEPHIR_INIT_VAR(&_2$$3); object_init_ex(&_2$$3, tensor_exceptions_invalidargumentexception_ce); ZEPHIR_OBS_VAR(&_3$$3); zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("n"), PH_NOISY_CC); zephir_cast_to_string(&_4$$3, &_3$$3); ZEPHIR_CALL_METHOD(&_5$$3, b, "n", NULL, 0); zephir_check_call_status(); zephir_cast_to_string(&_6$$3, &_5$$3); ZEPHIR_INIT_VAR(&_7$$3); ZEPHIR_CONCAT_SVSVS(&_7$$3, "Vector A requires ", &_4$$3, " columns but Matrix B has ", &_6$$3, "."); ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 3, &_7$$3); zephir_check_call_status(); zephir_throw_exception_debug(&_2$$3, "tensor/vector.zep", 1651); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(&c); array_init(&c); ZEPHIR_CALL_METHOD(&_8, b, "asarray", NULL, 0); zephir_check_call_status(); zephir_is_iterable(&_8, 0, "tensor/vector.zep", 1662); if (Z_TYPE_P(&_8) == IS_ARRAY) { ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_8), _9) { ZEPHIR_INIT_NVAR(&rowB); ZVAL_COPY(&rowB, _9); ZEPHIR_INIT_NVAR(&_11$$4); zephir_read_property(&_12$$4, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); tensor_not_equal(&_11$$4, &_12$$4, &rowB); zephir_array_append(&c, &_11$$4, PH_SEPARATE, "tensor/vector.zep", 1659); } ZEND_HASH_FOREACH_END(); } else { ZEPHIR_CALL_METHOD(NULL, &_8, "rewind", NULL, 0); zephir_check_call_status(); while (1) { ZEPHIR_CALL_METHOD(&_10, &_8, "valid", NULL, 0); zephir_check_call_status(); if (!zend_is_true(&_10)) { break; } ZEPHIR_CALL_METHOD(&rowB, &_8, "current", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_13$$5); zephir_read_property(&_14$$5, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); tensor_not_equal(&_13$$5, &_14$$5, &rowB); zephir_array_append(&c, &_13$$5, PH_SEPARATE, "tensor/vector.zep", 1659); ZEPHIR_CALL_METHOD(NULL, &_8, "next", NULL, 0); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(&rowB); ZEPHIR_RETURN_CALL_CE_STATIC(tensor_matrix_ce, "quick", &_15, 0, &c); zephir_check_call_status(); RETURN_MM(); } /** * Return the element-wise greater than comparison of this vector and a matrix. * * @param \Tensor\Matrix b * @throws \Tensor\Exceptions\DimensionalityMismatch * @return \Tensor\Matrix */ PHP_METHOD(Tensor_Vector, greaterMatrix) { zval _4$$3, _6$$3, _7$$3; zval c; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zephir_fcall_cache_entry *_15 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, _0, _1, rowB, _8, *_9, _10, _2$$3, _3$$3, _5$$3, _11$$4, _12$$4, _13$$5, _14$$5; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&rowB); ZVAL_UNDEF(&_8); ZVAL_UNDEF(&_10); ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_3$$3); ZVAL_UNDEF(&_5$$3); ZVAL_UNDEF(&_11$$4); ZVAL_UNDEF(&_12$$4); ZVAL_UNDEF(&_13$$5); ZVAL_UNDEF(&_14$$5); ZVAL_UNDEF(&c); ZVAL_UNDEF(&_4$$3); ZVAL_UNDEF(&_6$$3); ZVAL_UNDEF(&_7$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_OBJECT_OF_CLASS(b, zephir_get_internal_ce(SL("tensor\\matrix"))) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); zephir_read_property(&_0, this_ptr, ZEND_STRL("n"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_1, b, "n", NULL, 0); zephir_check_call_status(); if (UNEXPECTED(!ZEPHIR_IS_IDENTICAL(&_0, &_1))) { ZEPHIR_INIT_VAR(&_2$$3); object_init_ex(&_2$$3, tensor_exceptions_dimensionalitymismatch_ce); ZEPHIR_OBS_VAR(&_3$$3); zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("n"), PH_NOISY_CC); zephir_cast_to_string(&_4$$3, &_3$$3); ZEPHIR_CALL_METHOD(&_5$$3, b, "n", NULL, 0); zephir_check_call_status(); zephir_cast_to_string(&_6$$3, &_5$$3); ZEPHIR_INIT_VAR(&_7$$3); ZEPHIR_CONCAT_SVSVS(&_7$$3, "Vector A expects ", &_4$$3, " columns but Matrix B has ", &_6$$3, "."); ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 3, &_7$$3); zephir_check_call_status(); zephir_throw_exception_debug(&_2$$3, "tensor/vector.zep", 1677); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(&c); array_init(&c); ZEPHIR_CALL_METHOD(&_8, b, "asarray", NULL, 0); zephir_check_call_status(); zephir_is_iterable(&_8, 0, "tensor/vector.zep", 1688); if (Z_TYPE_P(&_8) == IS_ARRAY) { ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_8), _9) { ZEPHIR_INIT_NVAR(&rowB); ZVAL_COPY(&rowB, _9); ZEPHIR_INIT_NVAR(&_11$$4); zephir_read_property(&_12$$4, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); tensor_greater(&_11$$4, &_12$$4, &rowB); zephir_array_append(&c, &_11$$4, PH_SEPARATE, "tensor/vector.zep", 1685); } ZEND_HASH_FOREACH_END(); } else { ZEPHIR_CALL_METHOD(NULL, &_8, "rewind", NULL, 0); zephir_check_call_status(); while (1) { ZEPHIR_CALL_METHOD(&_10, &_8, "valid", NULL, 0); zephir_check_call_status(); if (!zend_is_true(&_10)) { break; } ZEPHIR_CALL_METHOD(&rowB, &_8, "current", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_13$$5); zephir_read_property(&_14$$5, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); tensor_greater(&_13$$5, &_14$$5, &rowB); zephir_array_append(&c, &_13$$5, PH_SEPARATE, "tensor/vector.zep", 1685); ZEPHIR_CALL_METHOD(NULL, &_8, "next", NULL, 0); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(&rowB); ZEPHIR_RETURN_CALL_CE_STATIC(tensor_matrix_ce, "quick", &_15, 0, &c); zephir_check_call_status(); RETURN_MM(); } /** * Return the element-wise greater than or equal to comparison of this vector and a matrix. * * @param \Tensor\Matrix b * @throws \Tensor\Exceptions\DimensionalityMismatch * @return \Tensor\Matrix */ PHP_METHOD(Tensor_Vector, greaterEqualMatrix) { zval _4$$3, _6$$3, _7$$3; zval c; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zephir_fcall_cache_entry *_15 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, _0, _1, rowB, _8, *_9, _10, _2$$3, _3$$3, _5$$3, _11$$4, _12$$4, _13$$5, _14$$5; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&rowB); ZVAL_UNDEF(&_8); ZVAL_UNDEF(&_10); ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_3$$3); ZVAL_UNDEF(&_5$$3); ZVAL_UNDEF(&_11$$4); ZVAL_UNDEF(&_12$$4); ZVAL_UNDEF(&_13$$5); ZVAL_UNDEF(&_14$$5); ZVAL_UNDEF(&c); ZVAL_UNDEF(&_4$$3); ZVAL_UNDEF(&_6$$3); ZVAL_UNDEF(&_7$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_OBJECT_OF_CLASS(b, zephir_get_internal_ce(SL("tensor\\matrix"))) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); zephir_read_property(&_0, this_ptr, ZEND_STRL("n"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_1, b, "n", NULL, 0); zephir_check_call_status(); if (UNEXPECTED(!ZEPHIR_IS_IDENTICAL(&_0, &_1))) { ZEPHIR_INIT_VAR(&_2$$3); object_init_ex(&_2$$3, tensor_exceptions_dimensionalitymismatch_ce); ZEPHIR_OBS_VAR(&_3$$3); zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("n"), PH_NOISY_CC); zephir_cast_to_string(&_4$$3, &_3$$3); ZEPHIR_CALL_METHOD(&_5$$3, b, "n", NULL, 0); zephir_check_call_status(); zephir_cast_to_string(&_6$$3, &_5$$3); ZEPHIR_INIT_VAR(&_7$$3); ZEPHIR_CONCAT_SVSVS(&_7$$3, "Vector A expects ", &_4$$3, " columns but Matrix B has ", &_6$$3, "."); ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 3, &_7$$3); zephir_check_call_status(); zephir_throw_exception_debug(&_2$$3, "tensor/vector.zep", 1703); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(&c); array_init(&c); ZEPHIR_CALL_METHOD(&_8, b, "asarray", NULL, 0); zephir_check_call_status(); zephir_is_iterable(&_8, 0, "tensor/vector.zep", 1714); if (Z_TYPE_P(&_8) == IS_ARRAY) { ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_8), _9) { ZEPHIR_INIT_NVAR(&rowB); ZVAL_COPY(&rowB, _9); ZEPHIR_INIT_NVAR(&_11$$4); zephir_read_property(&_12$$4, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); tensor_greater_equal(&_11$$4, &_12$$4, &rowB); zephir_array_append(&c, &_11$$4, PH_SEPARATE, "tensor/vector.zep", 1711); } ZEND_HASH_FOREACH_END(); } else { ZEPHIR_CALL_METHOD(NULL, &_8, "rewind", NULL, 0); zephir_check_call_status(); while (1) { ZEPHIR_CALL_METHOD(&_10, &_8, "valid", NULL, 0); zephir_check_call_status(); if (!zend_is_true(&_10)) { break; } ZEPHIR_CALL_METHOD(&rowB, &_8, "current", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_13$$5); zephir_read_property(&_14$$5, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); tensor_greater_equal(&_13$$5, &_14$$5, &rowB); zephir_array_append(&c, &_13$$5, PH_SEPARATE, "tensor/vector.zep", 1711); ZEPHIR_CALL_METHOD(NULL, &_8, "next", NULL, 0); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(&rowB); ZEPHIR_RETURN_CALL_CE_STATIC(tensor_matrix_ce, "quick", &_15, 0, &c); zephir_check_call_status(); RETURN_MM(); } /** * Return the element-wise less than comparison of this vector and a matrix. * * @param \Tensor\Matrix b * @throws \Tensor\Exceptions\DimensionalityMismatch * @return \Tensor\Matrix */ PHP_METHOD(Tensor_Vector, lessMatrix) { zval _4$$3, _6$$3, _7$$3; zval c; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zephir_fcall_cache_entry *_15 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, _0, _1, rowB, _8, *_9, _10, _2$$3, _3$$3, _5$$3, _11$$4, _12$$4, _13$$5, _14$$5; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&rowB); ZVAL_UNDEF(&_8); ZVAL_UNDEF(&_10); ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_3$$3); ZVAL_UNDEF(&_5$$3); ZVAL_UNDEF(&_11$$4); ZVAL_UNDEF(&_12$$4); ZVAL_UNDEF(&_13$$5); ZVAL_UNDEF(&_14$$5); ZVAL_UNDEF(&c); ZVAL_UNDEF(&_4$$3); ZVAL_UNDEF(&_6$$3); ZVAL_UNDEF(&_7$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_OBJECT_OF_CLASS(b, zephir_get_internal_ce(SL("tensor\\matrix"))) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); zephir_read_property(&_0, this_ptr, ZEND_STRL("n"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_1, b, "n", NULL, 0); zephir_check_call_status(); if (UNEXPECTED(!ZEPHIR_IS_IDENTICAL(&_0, &_1))) { ZEPHIR_INIT_VAR(&_2$$3); object_init_ex(&_2$$3, tensor_exceptions_dimensionalitymismatch_ce); ZEPHIR_OBS_VAR(&_3$$3); zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("n"), PH_NOISY_CC); zephir_cast_to_string(&_4$$3, &_3$$3); ZEPHIR_CALL_METHOD(&_5$$3, b, "n", NULL, 0); zephir_check_call_status(); zephir_cast_to_string(&_6$$3, &_5$$3); ZEPHIR_INIT_VAR(&_7$$3); ZEPHIR_CONCAT_SVSVS(&_7$$3, "Vector A expects ", &_4$$3, " columns but Matrix B has ", &_6$$3, "."); ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 3, &_7$$3); zephir_check_call_status(); zephir_throw_exception_debug(&_2$$3, "tensor/vector.zep", 1729); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(&c); array_init(&c); ZEPHIR_CALL_METHOD(&_8, b, "asarray", NULL, 0); zephir_check_call_status(); zephir_is_iterable(&_8, 0, "tensor/vector.zep", 1740); if (Z_TYPE_P(&_8) == IS_ARRAY) { ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_8), _9) { ZEPHIR_INIT_NVAR(&rowB); ZVAL_COPY(&rowB, _9); ZEPHIR_INIT_NVAR(&_11$$4); zephir_read_property(&_12$$4, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); tensor_less(&_11$$4, &_12$$4, &rowB); zephir_array_append(&c, &_11$$4, PH_SEPARATE, "tensor/vector.zep", 1737); } ZEND_HASH_FOREACH_END(); } else { ZEPHIR_CALL_METHOD(NULL, &_8, "rewind", NULL, 0); zephir_check_call_status(); while (1) { ZEPHIR_CALL_METHOD(&_10, &_8, "valid", NULL, 0); zephir_check_call_status(); if (!zend_is_true(&_10)) { break; } ZEPHIR_CALL_METHOD(&rowB, &_8, "current", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_13$$5); zephir_read_property(&_14$$5, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); tensor_less(&_13$$5, &_14$$5, &rowB); zephir_array_append(&c, &_13$$5, PH_SEPARATE, "tensor/vector.zep", 1737); ZEPHIR_CALL_METHOD(NULL, &_8, "next", NULL, 0); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(&rowB); ZEPHIR_RETURN_CALL_CE_STATIC(tensor_matrix_ce, "quick", &_15, 0, &c); zephir_check_call_status(); RETURN_MM(); } /** * Return the element-wise less than or equal to comparison of this vector and a matrix. * * @param \Tensor\Matrix b * @throws \Tensor\Exceptions\DimensionalityMismatch * @return \Tensor\Matrix */ PHP_METHOD(Tensor_Vector, lessEqualMatrix) { zval _4$$3, _6$$3, _7$$3; zval c; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zephir_fcall_cache_entry *_15 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, _0, _1, rowB, _8, *_9, _10, _2$$3, _3$$3, _5$$3, _11$$4, _12$$4, _13$$5, _14$$5; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&rowB); ZVAL_UNDEF(&_8); ZVAL_UNDEF(&_10); ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_3$$3); ZVAL_UNDEF(&_5$$3); ZVAL_UNDEF(&_11$$4); ZVAL_UNDEF(&_12$$4); ZVAL_UNDEF(&_13$$5); ZVAL_UNDEF(&_14$$5); ZVAL_UNDEF(&c); ZVAL_UNDEF(&_4$$3); ZVAL_UNDEF(&_6$$3); ZVAL_UNDEF(&_7$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_OBJECT_OF_CLASS(b, zephir_get_internal_ce(SL("tensor\\matrix"))) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); zephir_read_property(&_0, this_ptr, ZEND_STRL("n"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_1, b, "n", NULL, 0); zephir_check_call_status(); if (UNEXPECTED(!ZEPHIR_IS_IDENTICAL(&_0, &_1))) { ZEPHIR_INIT_VAR(&_2$$3); object_init_ex(&_2$$3, tensor_exceptions_dimensionalitymismatch_ce); ZEPHIR_OBS_VAR(&_3$$3); zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("n"), PH_NOISY_CC); zephir_cast_to_string(&_4$$3, &_3$$3); ZEPHIR_CALL_METHOD(&_5$$3, b, "n", NULL, 0); zephir_check_call_status(); zephir_cast_to_string(&_6$$3, &_5$$3); ZEPHIR_INIT_VAR(&_7$$3); ZEPHIR_CONCAT_SVSVS(&_7$$3, "Vector A expects ", &_4$$3, " columns but Matrix B has ", &_6$$3, "."); ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 3, &_7$$3); zephir_check_call_status(); zephir_throw_exception_debug(&_2$$3, "tensor/vector.zep", 1755); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(&c); array_init(&c); ZEPHIR_CALL_METHOD(&_8, b, "asarray", NULL, 0); zephir_check_call_status(); zephir_is_iterable(&_8, 0, "tensor/vector.zep", 1766); if (Z_TYPE_P(&_8) == IS_ARRAY) { ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_8), _9) { ZEPHIR_INIT_NVAR(&rowB); ZVAL_COPY(&rowB, _9); ZEPHIR_INIT_NVAR(&_11$$4); zephir_read_property(&_12$$4, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); tensor_less_equal(&_11$$4, &_12$$4, &rowB); zephir_array_append(&c, &_11$$4, PH_SEPARATE, "tensor/vector.zep", 1763); } ZEND_HASH_FOREACH_END(); } else { ZEPHIR_CALL_METHOD(NULL, &_8, "rewind", NULL, 0); zephir_check_call_status(); while (1) { ZEPHIR_CALL_METHOD(&_10, &_8, "valid", NULL, 0); zephir_check_call_status(); if (!zend_is_true(&_10)) { break; } ZEPHIR_CALL_METHOD(&rowB, &_8, "current", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_NVAR(&_13$$5); zephir_read_property(&_14$$5, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); tensor_less_equal(&_13$$5, &_14$$5, &rowB); zephir_array_append(&c, &_13$$5, PH_SEPARATE, "tensor/vector.zep", 1763); ZEPHIR_CALL_METHOD(NULL, &_8, "next", NULL, 0); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(&rowB); ZEPHIR_RETURN_CALL_CE_STATIC(tensor_matrix_ce, "quick", &_15, 0, &c); zephir_check_call_status(); RETURN_MM(); } /** * Multiply this vector with another vector. * * @param \Tensor\Vector b * @throws \Tensor\Exceptions\DimensionalityMismatch * @return self */ PHP_METHOD(Tensor_Vector, multiplyVector) { zval _4$$3, _6$$3, _7$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, _0, _1, _8, _9, _10, _2$$3, _3$$3, _5$$3; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_8); ZVAL_UNDEF(&_9); ZVAL_UNDEF(&_10); ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_3$$3); ZVAL_UNDEF(&_5$$3); ZVAL_UNDEF(&_4$$3); ZVAL_UNDEF(&_6$$3); ZVAL_UNDEF(&_7$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_OBJECT_OF_CLASS(b, zephir_get_internal_ce(SL("tensor\\vector"))) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); zephir_read_property(&_0, this_ptr, ZEND_STRL("n"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_1, b, "size", NULL, 0); zephir_check_call_status(); if (UNEXPECTED(!ZEPHIR_IS_IDENTICAL(&_0, &_1))) { ZEPHIR_INIT_VAR(&_2$$3); object_init_ex(&_2$$3, tensor_exceptions_dimensionalitymismatch_ce); ZEPHIR_OBS_VAR(&_3$$3); zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("n"), PH_NOISY_CC); zephir_cast_to_string(&_4$$3, &_3$$3); ZEPHIR_CALL_METHOD(&_5$$3, b, "size", NULL, 0); zephir_check_call_status(); zephir_cast_to_string(&_6$$3, &_5$$3); ZEPHIR_INIT_VAR(&_7$$3); ZEPHIR_CONCAT_SVSVS(&_7$$3, "Vector A requires ", &_4$$3, " elements but Vector B has ", &_6$$3, "."); ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 3, &_7$$3); zephir_check_call_status(); zephir_throw_exception_debug(&_2$$3, "tensor/vector.zep", 1781); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(&_8); zephir_read_property(&_9, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_10, b, "asarray", NULL, 0); zephir_check_call_status(); tensor_multiply(&_8, &_9, &_10); ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &_8); zephir_check_call_status(); RETURN_MM(); } /** * Divide this vector by another vector. * * @param \Tensor\Vector b * @throws \Tensor\Exceptions\DimensionalityMismatch * @return self */ PHP_METHOD(Tensor_Vector, divideVector) { zval _4$$3, _6$$3, _7$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, _0, _1, _8, _9, _10, _2$$3, _3$$3, _5$$3; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_8); ZVAL_UNDEF(&_9); ZVAL_UNDEF(&_10); ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_3$$3); ZVAL_UNDEF(&_5$$3); ZVAL_UNDEF(&_4$$3); ZVAL_UNDEF(&_6$$3); ZVAL_UNDEF(&_7$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_OBJECT_OF_CLASS(b, zephir_get_internal_ce(SL("tensor\\vector"))) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); zephir_read_property(&_0, this_ptr, ZEND_STRL("n"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_1, b, "size", NULL, 0); zephir_check_call_status(); if (UNEXPECTED(!ZEPHIR_IS_IDENTICAL(&_0, &_1))) { ZEPHIR_INIT_VAR(&_2$$3); object_init_ex(&_2$$3, tensor_exceptions_dimensionalitymismatch_ce); ZEPHIR_OBS_VAR(&_3$$3); zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("n"), PH_NOISY_CC); zephir_cast_to_string(&_4$$3, &_3$$3); ZEPHIR_CALL_METHOD(&_5$$3, b, "size", NULL, 0); zephir_check_call_status(); zephir_cast_to_string(&_6$$3, &_5$$3); ZEPHIR_INIT_VAR(&_7$$3); ZEPHIR_CONCAT_SVSVS(&_7$$3, "Vector A requires ", &_4$$3, " elements but Vector B has ", &_6$$3, "."); ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 3, &_7$$3); zephir_check_call_status(); zephir_throw_exception_debug(&_2$$3, "tensor/vector.zep", 1799); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(&_8); zephir_read_property(&_9, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_10, b, "asarray", NULL, 0); zephir_check_call_status(); tensor_divide(&_8, &_9, &_10); ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &_8); zephir_check_call_status(); RETURN_MM(); } /** * Add this vector to another vector. * * @param \Tensor\Vector b * @throws \Tensor\Exceptions\DimensionalityMismatch * @return self */ PHP_METHOD(Tensor_Vector, addVector) { zval _4$$3, _6$$3, _7$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, _0, _1, _8, _9, _10, _2$$3, _3$$3, _5$$3; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_8); ZVAL_UNDEF(&_9); ZVAL_UNDEF(&_10); ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_3$$3); ZVAL_UNDEF(&_5$$3); ZVAL_UNDEF(&_4$$3); ZVAL_UNDEF(&_6$$3); ZVAL_UNDEF(&_7$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_OBJECT_OF_CLASS(b, zephir_get_internal_ce(SL("tensor\\vector"))) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); zephir_read_property(&_0, this_ptr, ZEND_STRL("n"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_1, b, "size", NULL, 0); zephir_check_call_status(); if (UNEXPECTED(!ZEPHIR_IS_IDENTICAL(&_0, &_1))) { ZEPHIR_INIT_VAR(&_2$$3); object_init_ex(&_2$$3, tensor_exceptions_dimensionalitymismatch_ce); ZEPHIR_OBS_VAR(&_3$$3); zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("n"), PH_NOISY_CC); zephir_cast_to_string(&_4$$3, &_3$$3); ZEPHIR_CALL_METHOD(&_5$$3, b, "size", NULL, 0); zephir_check_call_status(); zephir_cast_to_string(&_6$$3, &_5$$3); ZEPHIR_INIT_VAR(&_7$$3); ZEPHIR_CONCAT_SVSVS(&_7$$3, "Vector A requires ", &_4$$3, " elements but Vector B has ", &_6$$3, "."); ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 3, &_7$$3); zephir_check_call_status(); zephir_throw_exception_debug(&_2$$3, "tensor/vector.zep", 1817); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(&_8); zephir_read_property(&_9, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_10, b, "asarray", NULL, 0); zephir_check_call_status(); tensor_add(&_8, &_9, &_10); ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &_8); zephir_check_call_status(); RETURN_MM(); } /** * Subtract a vector from this vector. * * @param \Tensor\Vector b * @throws \Tensor\Exceptions\DimensionalityMismatch * @return self */ PHP_METHOD(Tensor_Vector, subtractVector) { zval _4$$3, _6$$3, _7$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, _0, _1, _8, _9, _10, _2$$3, _3$$3, _5$$3; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_8); ZVAL_UNDEF(&_9); ZVAL_UNDEF(&_10); ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_3$$3); ZVAL_UNDEF(&_5$$3); ZVAL_UNDEF(&_4$$3); ZVAL_UNDEF(&_6$$3); ZVAL_UNDEF(&_7$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_OBJECT_OF_CLASS(b, zephir_get_internal_ce(SL("tensor\\vector"))) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); zephir_read_property(&_0, this_ptr, ZEND_STRL("n"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_1, b, "size", NULL, 0); zephir_check_call_status(); if (UNEXPECTED(!ZEPHIR_IS_IDENTICAL(&_0, &_1))) { ZEPHIR_INIT_VAR(&_2$$3); object_init_ex(&_2$$3, tensor_exceptions_dimensionalitymismatch_ce); ZEPHIR_OBS_VAR(&_3$$3); zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("n"), PH_NOISY_CC); zephir_cast_to_string(&_4$$3, &_3$$3); ZEPHIR_CALL_METHOD(&_5$$3, b, "size", NULL, 0); zephir_check_call_status(); zephir_cast_to_string(&_6$$3, &_5$$3); ZEPHIR_INIT_VAR(&_7$$3); ZEPHIR_CONCAT_SVSVS(&_7$$3, "Vector A requires ", &_4$$3, " elements but Vector B has ", &_6$$3, "."); ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 3, &_7$$3); zephir_check_call_status(); zephir_throw_exception_debug(&_2$$3, "tensor/vector.zep", 1835); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(&_8); zephir_read_property(&_9, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_10, b, "asarray", NULL, 0); zephir_check_call_status(); tensor_subtract(&_8, &_9, &_10); ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &_8); zephir_check_call_status(); RETURN_MM(); } /** * Raise this vector to a power of another vector. * * @param \Tensor\Vector b * @throws \Tensor\Exceptions\DimensionalityMismatch * @return self */ PHP_METHOD(Tensor_Vector, powVector) { zval _4$$3, _6$$3, _7$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, _0, _1, _8, _9, _10, _2$$3, _3$$3, _5$$3; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_8); ZVAL_UNDEF(&_9); ZVAL_UNDEF(&_10); ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_3$$3); ZVAL_UNDEF(&_5$$3); ZVAL_UNDEF(&_4$$3); ZVAL_UNDEF(&_6$$3); ZVAL_UNDEF(&_7$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_OBJECT_OF_CLASS(b, zephir_get_internal_ce(SL("tensor\\vector"))) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); zephir_read_property(&_0, this_ptr, ZEND_STRL("n"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_1, b, "size", NULL, 0); zephir_check_call_status(); if (UNEXPECTED(!ZEPHIR_IS_IDENTICAL(&_0, &_1))) { ZEPHIR_INIT_VAR(&_2$$3); object_init_ex(&_2$$3, tensor_exceptions_dimensionalitymismatch_ce); ZEPHIR_OBS_VAR(&_3$$3); zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("n"), PH_NOISY_CC); zephir_cast_to_string(&_4$$3, &_3$$3); ZEPHIR_CALL_METHOD(&_5$$3, b, "size", NULL, 0); zephir_check_call_status(); zephir_cast_to_string(&_6$$3, &_5$$3); ZEPHIR_INIT_VAR(&_7$$3); ZEPHIR_CONCAT_SVSVS(&_7$$3, "Vector A requires ", &_4$$3, " elements but Vector B has ", &_6$$3, "."); ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 3, &_7$$3); zephir_check_call_status(); zephir_throw_exception_debug(&_2$$3, "tensor/vector.zep", 1853); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(&_8); zephir_read_property(&_9, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_10, b, "asarray", NULL, 0); zephir_check_call_status(); tensor_pow(&_8, &_9, &_10); ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &_8); zephir_check_call_status(); RETURN_MM(); } /** * Calculate the modulus of this vector with another vector elementwise. * * @param \Tensor\Vector b * @throws \Tensor\Exceptions\DimensionalityMismatch * @return self */ PHP_METHOD(Tensor_Vector, modVector) { zval _4$$3, _6$$3, _7$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, _0, _1, _8, _9, _10, _2$$3, _3$$3, _5$$3; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_8); ZVAL_UNDEF(&_9); ZVAL_UNDEF(&_10); ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_3$$3); ZVAL_UNDEF(&_5$$3); ZVAL_UNDEF(&_4$$3); ZVAL_UNDEF(&_6$$3); ZVAL_UNDEF(&_7$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_OBJECT_OF_CLASS(b, zephir_get_internal_ce(SL("tensor\\vector"))) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); zephir_read_property(&_0, this_ptr, ZEND_STRL("n"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_1, b, "size", NULL, 0); zephir_check_call_status(); if (UNEXPECTED(!ZEPHIR_IS_IDENTICAL(&_0, &_1))) { ZEPHIR_INIT_VAR(&_2$$3); object_init_ex(&_2$$3, tensor_exceptions_dimensionalitymismatch_ce); ZEPHIR_OBS_VAR(&_3$$3); zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("n"), PH_NOISY_CC); zephir_cast_to_string(&_4$$3, &_3$$3); ZEPHIR_CALL_METHOD(&_5$$3, b, "size", NULL, 0); zephir_check_call_status(); zephir_cast_to_string(&_6$$3, &_5$$3); ZEPHIR_INIT_VAR(&_7$$3); ZEPHIR_CONCAT_SVSVS(&_7$$3, "Vector A requires ", &_4$$3, " elements but Vector B has ", &_6$$3, "."); ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 3, &_7$$3); zephir_check_call_status(); zephir_throw_exception_debug(&_2$$3, "tensor/vector.zep", 1871); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(&_8); zephir_read_property(&_9, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_10, b, "asarray", NULL, 0); zephir_check_call_status(); tensor_mod(&_8, &_9, &_10); ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &_8); zephir_check_call_status(); RETURN_MM(); } /** * Return the element-wise equality comparison of this vector and a * another vector. * * @param \Tensor\Vector b * @throws \Tensor\Exceptions\DimensionalityMismatch * @return self */ PHP_METHOD(Tensor_Vector, equalVector) { zval _4$$3, _6$$3, _7$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, _0, _1, _8, _9, _10, _2$$3, _3$$3, _5$$3; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_8); ZVAL_UNDEF(&_9); ZVAL_UNDEF(&_10); ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_3$$3); ZVAL_UNDEF(&_5$$3); ZVAL_UNDEF(&_4$$3); ZVAL_UNDEF(&_6$$3); ZVAL_UNDEF(&_7$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_OBJECT_OF_CLASS(b, zephir_get_internal_ce(SL("tensor\\vector"))) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); zephir_read_property(&_0, this_ptr, ZEND_STRL("n"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_1, b, "size", NULL, 0); zephir_check_call_status(); if (UNEXPECTED(!ZEPHIR_IS_IDENTICAL(&_0, &_1))) { ZEPHIR_INIT_VAR(&_2$$3); object_init_ex(&_2$$3, tensor_exceptions_dimensionalitymismatch_ce); ZEPHIR_OBS_VAR(&_3$$3); zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("n"), PH_NOISY_CC); zephir_cast_to_string(&_4$$3, &_3$$3); ZEPHIR_CALL_METHOD(&_5$$3, b, "size", NULL, 0); zephir_check_call_status(); zephir_cast_to_string(&_6$$3, &_5$$3); ZEPHIR_INIT_VAR(&_7$$3); ZEPHIR_CONCAT_SVSVS(&_7$$3, "Vector A requires ", &_4$$3, " elements but Vector B has ", &_6$$3, "."); ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 3, &_7$$3); zephir_check_call_status(); zephir_throw_exception_debug(&_2$$3, "tensor/vector.zep", 1890); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(&_8); zephir_read_property(&_9, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_10, b, "asarray", NULL, 0); zephir_check_call_status(); tensor_equal(&_8, &_9, &_10); ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &_8); zephir_check_call_status(); RETURN_MM(); } /** * Return the element-wise not equal comparison of this vector and a another vector. * * @param \Tensor\Vector b * @throws \Tensor\Exceptions\DimensionalityMismatch * @return self */ PHP_METHOD(Tensor_Vector, notEqualVector) { zval _4$$3, _6$$3, _7$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, _0, _1, _8, _9, _10, _2$$3, _3$$3, _5$$3; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_8); ZVAL_UNDEF(&_9); ZVAL_UNDEF(&_10); ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_3$$3); ZVAL_UNDEF(&_5$$3); ZVAL_UNDEF(&_4$$3); ZVAL_UNDEF(&_6$$3); ZVAL_UNDEF(&_7$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_OBJECT_OF_CLASS(b, zephir_get_internal_ce(SL("tensor\\vector"))) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); zephir_read_property(&_0, this_ptr, ZEND_STRL("n"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_1, b, "size", NULL, 0); zephir_check_call_status(); if (UNEXPECTED(!ZEPHIR_IS_IDENTICAL(&_0, &_1))) { ZEPHIR_INIT_VAR(&_2$$3); object_init_ex(&_2$$3, tensor_exceptions_dimensionalitymismatch_ce); ZEPHIR_OBS_VAR(&_3$$3); zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("n"), PH_NOISY_CC); zephir_cast_to_string(&_4$$3, &_3$$3); ZEPHIR_CALL_METHOD(&_5$$3, b, "size", NULL, 0); zephir_check_call_status(); zephir_cast_to_string(&_6$$3, &_5$$3); ZEPHIR_INIT_VAR(&_7$$3); ZEPHIR_CONCAT_SVSVS(&_7$$3, "Vector A requires ", &_4$$3, " elements but Vector B has ", &_6$$3, "."); ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 3, &_7$$3); zephir_check_call_status(); zephir_throw_exception_debug(&_2$$3, "tensor/vector.zep", 1908); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(&_8); zephir_read_property(&_9, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_10, b, "asarray", NULL, 0); zephir_check_call_status(); tensor_not_equal(&_8, &_9, &_10); ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &_8); zephir_check_call_status(); RETURN_MM(); } /** * Return the element-wise greater than comparison of this vector and a another vector. * * @param \Tensor\Vector b * @throws \Tensor\Exceptions\DimensionalityMismatch * @return self */ PHP_METHOD(Tensor_Vector, greaterVector) { zval _4$$3, _6$$3, _7$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, _0, _1, _8, _9, _10, _2$$3, _3$$3, _5$$3; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_8); ZVAL_UNDEF(&_9); ZVAL_UNDEF(&_10); ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_3$$3); ZVAL_UNDEF(&_5$$3); ZVAL_UNDEF(&_4$$3); ZVAL_UNDEF(&_6$$3); ZVAL_UNDEF(&_7$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_OBJECT_OF_CLASS(b, zephir_get_internal_ce(SL("tensor\\vector"))) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); zephir_read_property(&_0, this_ptr, ZEND_STRL("n"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_1, b, "size", NULL, 0); zephir_check_call_status(); if (UNEXPECTED(!ZEPHIR_IS_IDENTICAL(&_0, &_1))) { ZEPHIR_INIT_VAR(&_2$$3); object_init_ex(&_2$$3, tensor_exceptions_dimensionalitymismatch_ce); ZEPHIR_OBS_VAR(&_3$$3); zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("n"), PH_NOISY_CC); zephir_cast_to_string(&_4$$3, &_3$$3); ZEPHIR_CALL_METHOD(&_5$$3, b, "size", NULL, 0); zephir_check_call_status(); zephir_cast_to_string(&_6$$3, &_5$$3); ZEPHIR_INIT_VAR(&_7$$3); ZEPHIR_CONCAT_SVSVS(&_7$$3, "Vector A requires ", &_4$$3, " elements but Vector B has ", &_6$$3, "."); ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 3, &_7$$3); zephir_check_call_status(); zephir_throw_exception_debug(&_2$$3, "tensor/vector.zep", 1926); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(&_8); zephir_read_property(&_9, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_10, b, "asarray", NULL, 0); zephir_check_call_status(); tensor_greater(&_8, &_9, &_10); ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &_8); zephir_check_call_status(); RETURN_MM(); } /** * Return the element-wise greater than or equal to comparison of this vector and a another vector. * * @param \Tensor\Vector b * @throws \Tensor\Exceptions\DimensionalityMismatch * @return self */ PHP_METHOD(Tensor_Vector, greaterEqualVector) { zval _4$$3, _6$$3, _7$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, _0, _1, _8, _9, _10, _2$$3, _3$$3, _5$$3; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_8); ZVAL_UNDEF(&_9); ZVAL_UNDEF(&_10); ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_3$$3); ZVAL_UNDEF(&_5$$3); ZVAL_UNDEF(&_4$$3); ZVAL_UNDEF(&_6$$3); ZVAL_UNDEF(&_7$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_OBJECT_OF_CLASS(b, zephir_get_internal_ce(SL("tensor\\vector"))) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); zephir_read_property(&_0, this_ptr, ZEND_STRL("n"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_1, b, "size", NULL, 0); zephir_check_call_status(); if (UNEXPECTED(!ZEPHIR_IS_IDENTICAL(&_0, &_1))) { ZEPHIR_INIT_VAR(&_2$$3); object_init_ex(&_2$$3, tensor_exceptions_dimensionalitymismatch_ce); ZEPHIR_OBS_VAR(&_3$$3); zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("n"), PH_NOISY_CC); zephir_cast_to_string(&_4$$3, &_3$$3); ZEPHIR_CALL_METHOD(&_5$$3, b, "size", NULL, 0); zephir_check_call_status(); zephir_cast_to_string(&_6$$3, &_5$$3); ZEPHIR_INIT_VAR(&_7$$3); ZEPHIR_CONCAT_SVSVS(&_7$$3, "Vector A requires ", &_4$$3, " elements but Vector B has ", &_6$$3, "."); ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 3, &_7$$3); zephir_check_call_status(); zephir_throw_exception_debug(&_2$$3, "tensor/vector.zep", 1944); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(&_8); zephir_read_property(&_9, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_10, b, "asarray", NULL, 0); zephir_check_call_status(); tensor_greater_equal(&_8, &_9, &_10); ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &_8); zephir_check_call_status(); RETURN_MM(); } /** * Return the element-wise less than comparison of this vector and a another vector. * * @param \Tensor\Vector b * @throws \Tensor\Exceptions\DimensionalityMismatch * @return self */ PHP_METHOD(Tensor_Vector, lessVector) { zval _4$$3, _6$$3, _7$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, _0, _1, _8, _9, _10, _2$$3, _3$$3, _5$$3; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_8); ZVAL_UNDEF(&_9); ZVAL_UNDEF(&_10); ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_3$$3); ZVAL_UNDEF(&_5$$3); ZVAL_UNDEF(&_4$$3); ZVAL_UNDEF(&_6$$3); ZVAL_UNDEF(&_7$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_OBJECT_OF_CLASS(b, zephir_get_internal_ce(SL("tensor\\vector"))) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); zephir_read_property(&_0, this_ptr, ZEND_STRL("n"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_1, b, "size", NULL, 0); zephir_check_call_status(); if (UNEXPECTED(!ZEPHIR_IS_IDENTICAL(&_0, &_1))) { ZEPHIR_INIT_VAR(&_2$$3); object_init_ex(&_2$$3, tensor_exceptions_dimensionalitymismatch_ce); ZEPHIR_OBS_VAR(&_3$$3); zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("n"), PH_NOISY_CC); zephir_cast_to_string(&_4$$3, &_3$$3); ZEPHIR_CALL_METHOD(&_5$$3, b, "size", NULL, 0); zephir_check_call_status(); zephir_cast_to_string(&_6$$3, &_5$$3); ZEPHIR_INIT_VAR(&_7$$3); ZEPHIR_CONCAT_SVSVS(&_7$$3, "Vector A requires ", &_4$$3, " elements but Vector B has ", &_6$$3, "."); ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 3, &_7$$3); zephir_check_call_status(); zephir_throw_exception_debug(&_2$$3, "tensor/vector.zep", 1962); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(&_8); zephir_read_property(&_9, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_10, b, "asarray", NULL, 0); zephir_check_call_status(); tensor_less(&_8, &_9, &_10); ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &_8); zephir_check_call_status(); RETURN_MM(); } /** * Return the element-wise less than or equal to comparison of this vector and a another vector. * * @param \Tensor\Vector b * @throws \Tensor\Exceptions\DimensionalityMismatch * @return self */ PHP_METHOD(Tensor_Vector, lessEqualVector) { zval _4$$3, _6$$3, _7$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b, b_sub, _0, _1, _8, _9, _10, _2$$3, _3$$3, _5$$3; zval *this_ptr = getThis(); ZVAL_UNDEF(&b_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_8); ZVAL_UNDEF(&_9); ZVAL_UNDEF(&_10); ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_3$$3); ZVAL_UNDEF(&_5$$3); ZVAL_UNDEF(&_4$$3); ZVAL_UNDEF(&_6$$3); ZVAL_UNDEF(&_7$$3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_OBJECT_OF_CLASS(b, zephir_get_internal_ce(SL("tensor\\vector"))) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b); zephir_read_property(&_0, this_ptr, ZEND_STRL("n"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_1, b, "size", NULL, 0); zephir_check_call_status(); if (UNEXPECTED(!ZEPHIR_IS_IDENTICAL(&_0, &_1))) { ZEPHIR_INIT_VAR(&_2$$3); object_init_ex(&_2$$3, tensor_exceptions_dimensionalitymismatch_ce); ZEPHIR_OBS_VAR(&_3$$3); zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("n"), PH_NOISY_CC); zephir_cast_to_string(&_4$$3, &_3$$3); ZEPHIR_CALL_METHOD(&_5$$3, b, "size", NULL, 0); zephir_check_call_status(); zephir_cast_to_string(&_6$$3, &_5$$3); ZEPHIR_INIT_VAR(&_7$$3); ZEPHIR_CONCAT_SVSVS(&_7$$3, "Vector A requires ", &_4$$3, " elements but Vector B has ", &_6$$3, "."); ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 3, &_7$$3); zephir_check_call_status(); zephir_throw_exception_debug(&_2$$3, "tensor/vector.zep", 1980); ZEPHIR_MM_RESTORE(); return; } ZEPHIR_INIT_VAR(&_8); zephir_read_property(&_9, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_10, b, "asarray", NULL, 0); zephir_check_call_status(); tensor_less_equal(&_8, &_9, &_10); ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &_8); zephir_check_call_status(); RETURN_MM(); } /** * Multiply this vector by a scalar. * * @param float b * @return self */ PHP_METHOD(Tensor_Vector, multiplyScalar) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b_param = NULL, _0, _1, _2; double b; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ZVAL(b) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b_param); b = zephir_get_doubleval(b_param); ZEPHIR_INIT_VAR(&_0); zephir_read_property(&_1, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); ZVAL_DOUBLE(&_2, b); tensor_multiply_scalar(&_0, &_1, &_2); ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &_0); zephir_check_call_status(); RETURN_MM(); } /** * Divide this vector by a scalar. * * @param float b * @return self */ PHP_METHOD(Tensor_Vector, divideScalar) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b_param = NULL, _0, _1, _2; double b; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ZVAL(b) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b_param); b = zephir_get_doubleval(b_param); ZEPHIR_INIT_VAR(&_0); zephir_read_property(&_1, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); ZVAL_DOUBLE(&_2, b); tensor_divide_scalar(&_0, &_1, &_2); ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &_0); zephir_check_call_status(); RETURN_MM(); } /** * Add a scalar to this vector. * * @param float b * @return self */ PHP_METHOD(Tensor_Vector, addScalar) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b_param = NULL, _0, _1, _2; double b; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ZVAL(b) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b_param); b = zephir_get_doubleval(b_param); ZEPHIR_INIT_VAR(&_0); zephir_read_property(&_1, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); ZVAL_DOUBLE(&_2, b); tensor_add_scalar(&_0, &_1, &_2); ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &_0); zephir_check_call_status(); RETURN_MM(); } /** * Subtract a scalar from this vector. * * @param float b * @return self */ PHP_METHOD(Tensor_Vector, subtractScalar) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b_param = NULL, _0, _1, _2; double b; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ZVAL(b) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b_param); b = zephir_get_doubleval(b_param); ZEPHIR_INIT_VAR(&_0); zephir_read_property(&_1, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); ZVAL_DOUBLE(&_2, b); tensor_subtract_scalar(&_0, &_1, &_2); ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &_0); zephir_check_call_status(); RETURN_MM(); } /** * Raise the vector to a the power of a scalar value. * * @param float b * @return self */ PHP_METHOD(Tensor_Vector, powScalar) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b_param = NULL, _0, _1, _2; double b; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ZVAL(b) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b_param); b = zephir_get_doubleval(b_param); ZEPHIR_INIT_VAR(&_0); zephir_read_property(&_1, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); ZVAL_DOUBLE(&_2, b); tensor_pow_scalar(&_0, &_1, &_2); ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &_0); zephir_check_call_status(); RETURN_MM(); } /** * Calculate the modulus of this vector with a scalar. * * @param float b * @return self */ PHP_METHOD(Tensor_Vector, modScalar) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b_param = NULL, _0, _1, _2; double b; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ZVAL(b) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b_param); b = zephir_get_doubleval(b_param); ZEPHIR_INIT_VAR(&_0); zephir_read_property(&_1, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); ZVAL_DOUBLE(&_2, b); tensor_mod_scalar(&_0, &_1, &_2); ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &_0); zephir_check_call_status(); RETURN_MM(); } /** * Return the element-wise equality comparison of this vector and a scalar. * * @param float b * @return self */ PHP_METHOD(Tensor_Vector, equalScalar) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b_param = NULL, _0, _1, _2; double b; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ZVAL(b) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b_param); b = zephir_get_doubleval(b_param); ZEPHIR_INIT_VAR(&_0); zephir_read_property(&_1, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); ZVAL_DOUBLE(&_2, b); tensor_equal_scalar(&_0, &_1, &_2); ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &_0); zephir_check_call_status(); RETURN_MM(); } /** * Return the element-wise not equal comparison of this vector and a scalar. * * @param float b * @return self */ PHP_METHOD(Tensor_Vector, notEqualScalar) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b_param = NULL, _0, _1, _2; double b; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ZVAL(b) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b_param); b = zephir_get_doubleval(b_param); ZEPHIR_INIT_VAR(&_0); zephir_read_property(&_1, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); ZVAL_DOUBLE(&_2, b); tensor_not_equal_scalar(&_0, &_1, &_2); ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &_0); zephir_check_call_status(); RETURN_MM(); } /** * Return the element-wise greater than comparison of this vector and a scalar. * * @param float b * @return self */ PHP_METHOD(Tensor_Vector, greaterScalar) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b_param = NULL, _0, _1, _2; double b; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ZVAL(b) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b_param); b = zephir_get_doubleval(b_param); ZEPHIR_INIT_VAR(&_0); zephir_read_property(&_1, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); ZVAL_DOUBLE(&_2, b); tensor_greater_scalar(&_0, &_1, &_2); ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &_0); zephir_check_call_status(); RETURN_MM(); } /** * Return the element-wise greater than or equal to comparison of * this vector and a scalar. * * @param float b * @return self */ PHP_METHOD(Tensor_Vector, greaterEqualScalar) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b_param = NULL, _0, _1, _2; double b; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ZVAL(b) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b_param); b = zephir_get_doubleval(b_param); ZEPHIR_INIT_VAR(&_0); zephir_read_property(&_1, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); ZVAL_DOUBLE(&_2, b); tensor_greater_equal_scalar(&_0, &_1, &_2); ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &_0); zephir_check_call_status(); RETURN_MM(); } /** * Return the element-wise less than comparison of this vector and a scalar. * * @param float b * @return self */ PHP_METHOD(Tensor_Vector, lessScalar) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b_param = NULL, _0, _1, _2; double b; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ZVAL(b) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b_param); b = zephir_get_doubleval(b_param); ZEPHIR_INIT_VAR(&_0); zephir_read_property(&_1, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); ZVAL_DOUBLE(&_2, b); tensor_less_scalar(&_0, &_1, &_2); ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &_0); zephir_check_call_status(); RETURN_MM(); } /** * Return the element-wise less than or equal to comparison of * this vector and a scalar. * * @param float b * @return self */ PHP_METHOD(Tensor_Vector, lessEqualScalar) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *b_param = NULL, _0, _1, _2; double b; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ZVAL(b) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &b_param); b = zephir_get_doubleval(b_param); ZEPHIR_INIT_VAR(&_0); zephir_read_property(&_1, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); ZVAL_DOUBLE(&_2, b); tensor_less_equal_scalar(&_0, &_1, &_2); ZEPHIR_RETURN_CALL_STATIC("quick", NULL, 0, &_0); zephir_check_call_status(); RETURN_MM(); } /** * Count method to implement countable interface. * * @return int */ PHP_METHOD(Tensor_Vector, count) { zval *this_ptr = getThis(); RETURN_MEMBER(getThis(), "n"); } /** * @param mixed index * @param array values * @throws \Tensor\Exceptions\RuntimeException */ PHP_METHOD(Tensor_Vector, offsetSet) { zval *index, index_sub, *values, values_sub; zval *this_ptr = getThis(); ZVAL_UNDEF(&index_sub); ZVAL_UNDEF(&values_sub); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(2, 2) Z_PARAM_ZVAL(index) Z_PARAM_ZVAL(values) ZEND_PARSE_PARAMETERS_END(); #endif zephir_fetch_params_without_memory_grow(2, 0, &index, &values); ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(tensor_exceptions_runtimeexception_ce, "Vector cannot be mutated directly.", "tensor/vector.zep", 2137); return; } /** * Does a given column exist in the matrix. * * @param mixed index * @return bool */ PHP_METHOD(Tensor_Vector, offsetExists) { zval *index, index_sub, _0; zval *this_ptr = getThis(); ZVAL_UNDEF(&index_sub); ZVAL_UNDEF(&_0); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ZVAL(index) ZEND_PARSE_PARAMETERS_END(); #endif zephir_fetch_params_without_memory_grow(1, 0, &index); zephir_read_property(&_0, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); RETURN_BOOL(zephir_array_isset(&_0, index)); } /** * @param mixed index * @throws \Tensor\Exceptions\RuntimeException */ PHP_METHOD(Tensor_Vector, offsetUnset) { zval *index, index_sub; zval *this_ptr = getThis(); ZVAL_UNDEF(&index_sub); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ZVAL(index) ZEND_PARSE_PARAMETERS_END(); #endif zephir_fetch_params_without_memory_grow(1, 0, &index); ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(tensor_exceptions_runtimeexception_ce, "Vector cannot be mutated directly.", "tensor/vector.zep", 2157); return; } /** * Return a row from the matrix at the given index. * * @param mixed index * @throws \Tensor\Exceptions\InvalidArgumentException * @return int|float */ PHP_METHOD(Tensor_Vector, offsetGet) { zval _2, _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *index, index_sub, value, _0, _1; zval *this_ptr = getThis(); ZVAL_UNDEF(&index_sub); ZVAL_UNDEF(&value); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); #if PHP_VERSION_ID >= 80000 bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ZVAL(index) ZEND_PARSE_PARAMETERS_END(); #endif ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &index); ZEPHIR_OBS_VAR(&value); zephir_read_property(&_0, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); if (EXPECTED(zephir_array_isset_fetch(&value, &_0, index, 0))) { RETURN_CCTOR(&value); } ZEPHIR_INIT_VAR(&_1); object_init_ex(&_1, tensor_exceptions_invalidargumentexception_ce); zephir_cast_to_string(&_2, index); ZEPHIR_INIT_VAR(&_3); ZEPHIR_CONCAT_SSVS(&_3, "Element not found at", " offset ", &_2, "."); ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 3, &_3); zephir_check_call_status(); zephir_throw_exception_debug(&_1, "tensor/vector.zep", 2176); ZEPHIR_MM_RESTORE(); return; } /** * Get an iterator for the rows in the matrix. * * @return \ArrayIterator */ PHP_METHOD(Tensor_Vector, getIterator) { zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZEPHIR_MM_GROW(); object_init_ex(return_value, spl_ce_ArrayIterator); zephir_read_property(&_0, this_ptr, ZEND_STRL("a"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 23, &_0); zephir_check_call_status(); RETURN_MM(); }