Example #1
0
PHP_METHOD(Test_Arithmetic, div2) {

	zval *_0;


	_0 = zephir_fetch_nproperty_this(this_ptr, SL("tmp1"), PH_NOISY_CC);
	RETURN_DOUBLE(zephir_safe_div_long_long(((zephir_get_numberval(_0) - 1)), 4 TSRMLS_CC));

}
Example #2
0
PHP_METHOD(Test_Arithmetic, div1) {

	int a;


	a = 100;
	RETURN_DOUBLE(zephir_safe_div_long_long(((a - 1)), 4 TSRMLS_CC));

}
Example #3
0
PHP_METHOD(Test_Statements, test544IssueWithVariable) {

	zephir_fcall_cache_entry *_6 = NULL;
	zval *step_param = NULL, *_0, *_1, *_2, *_3, _4 = zval_used_for_init, *_5 = NULL, *_7, *_8, *_9 = NULL;
	int step, filledWidth, unfilledWidth, totalSteps, ZEPHIR_LAST_CALL_STATUS;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &step_param);

	if (unlikely(Z_TYPE_P(step_param) != IS_LONG)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'step' must be a long/integer") TSRMLS_CC);
		RETURN_MM_NULL();
	}

	step = Z_LVAL_P(step_param);


	_0 = zephir_fetch_nproperty_this(this_ptr, SL("totalSteps"), PH_NOISY_CC);
	totalSteps = zephir_get_numberval(_0);
	if (step < totalSteps) {
		_1 = zephir_fetch_nproperty_this(this_ptr, SL("width"), PH_NOISY_CC);
		filledWidth = (long) ((zephir_safe_div_long_long(((zephir_get_numberval(_1) - 1)), totalSteps TSRMLS_CC) * step));
		_2 = zephir_fetch_nproperty_this(this_ptr, SL("width"), PH_NOISY_CC);
		unfilledWidth = (((zephir_get_numberval(_2) - 1)) - filledWidth);
		_3 = zephir_fetch_nproperty_this(this_ptr, SL("filledChar"), PH_NOISY_CC);
		ZEPHIR_SINIT_VAR(_4);
		ZVAL_LONG(&_4, filledWidth);
		ZEPHIR_CALL_FUNCTION(&_5, "str_repeat", &_6, 17, _3, &_4);
		zephir_check_call_status();
		_7 = zephir_fetch_nproperty_this(this_ptr, SL("arrow"), PH_NOISY_CC);
		_8 = zephir_fetch_nproperty_this(this_ptr, SL("unfilledChar"), PH_NOISY_CC);
		ZEPHIR_SINIT_NVAR(_4);
		ZVAL_LONG(&_4, unfilledWidth);
		ZEPHIR_CALL_FUNCTION(&_9, "str_repeat", &_6, 17, _8, &_4);
		zephir_check_call_status();
		ZEPHIR_CONCAT_VVV(return_value, _5, _7, _9);
		RETURN_MM();
	} else if (step == totalSteps) {
		_1 = zephir_fetch_nproperty_this(this_ptr, SL("filledChar"), PH_NOISY_CC);
		_2 = zephir_fetch_nproperty_this(this_ptr, SL("width"), PH_NOISY_CC);
		ZEPHIR_RETURN_CALL_FUNCTION("str_repeat", &_6, 17, _1, _2);
		zephir_check_call_status();
		RETURN_MM();
	} else {
		_1 = zephir_fetch_nproperty_this(this_ptr, SL("unfilledChar"), PH_NOISY_CC);
		_2 = zephir_fetch_nproperty_this(this_ptr, SL("width"), PH_NOISY_CC);
		ZEPHIR_RETURN_CALL_FUNCTION("str_repeat", &_6, 17, _1, _2);
		zephir_check_call_status();
		RETURN_MM();
	}

}
Example #4
0
PHP_METHOD(Test_SpectralNorm, Ax) {

	zval *i, *j, *_0, _1;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 2, 0, &i, &j);



	ZEPHIR_INIT_VAR(_0);
	zephir_add_function_ex(_0, i, j TSRMLS_CC);
	ZEPHIR_SINIT_VAR(_1);
	zephir_add_function_ex(&_1, i, j TSRMLS_CC);
	RETURN_MM_DOUBLE(zephir_safe_div_long_double((double) 1, ((zephir_safe_div_long_long((zephir_get_numberval(_0) * (zephir_get_numberval(&_1) + 1)), 2 TSRMLS_CC) + zephir_get_numberval(i)) + (double) (1)) TSRMLS_CC));

}
/**
 * @param integer $height
 * @param integer $original_width
 * @param integer $original_height
 * @return integer
 */
PHP_METHOD(Monapi_Image_ResizeOptions_ResizeOptionAbstract, getSizeByFixedHeight) {

	zval *height_param = NULL, *original_width_param = NULL, *original_height_param = NULL;
	int height, original_width, original_height, ratio;

	zephir_fetch_params(0, 3, 0, &height_param, &original_width_param, &original_height_param);

	height = zephir_get_intval(height_param);
	original_width = zephir_get_intval(original_width_param);
	original_height = zephir_get_intval(original_height_param);


	ratio = (long) (zephir_safe_div_long_long(original_width, original_height TSRMLS_CC));
	RETURN_LONG((height * ratio));

}
Example #6
0
void zep_Test_McallInternal_other(int ht, zval *return_value, zval *this_ptr, int return_value_used, zval *a_param_ext, zval *b_param_ext) {

	zval *a_param = NULL, *b_param = NULL;
	long a, b;

	a_param = a_param_ext;

	b_param = b_param_ext;


	a = zephir_get_intval(a_param);
	b = zephir_get_intval(b_param);


	RETURN_DOUBLE(zephir_safe_div_long_long(a, b TSRMLS_CC));

}
/**
 * @param integer $width
 * @param integer $original_width
 * @param integer $original_height
 * @return integer
 */
PHP_METHOD(Monapi_Image_ResizeOptions_ResizeOptionAbstract, getSizeByFixedWidth) {

	double ratio;
	zval *width_param = NULL, *original_width_param = NULL, *original_height_param = NULL;
	int width, original_width, original_height, result;

	zephir_fetch_params(0, 3, 0, &width_param, &original_width_param, &original_height_param);

	width = zephir_get_intval(width_param);
	original_width = zephir_get_intval(original_width_param);
	original_height = zephir_get_intval(original_height_param);


	ratio = zephir_safe_div_long_long(original_height, original_width TSRMLS_CC);
	result = (long) (((double) width * ratio));
	RETURN_LONG(result);

}
Example #8
0
PHP_METHOD(Test_SpectralNorm, Ax) {

	zval *i, i_sub, *j, j_sub, _0, _1;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&i_sub);
	ZVAL_UNDEF(&j_sub);
	ZVAL_UNDEF(&_0);
	ZVAL_UNDEF(&_1);

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 2, 0, &i, &j);



	ZEPHIR_INIT_VAR(&_0);
	zephir_add_function(&_0, i, j);
	ZEPHIR_SINIT_VAR(_1);
	zephir_add_function(&_1, i, j);
	RETURN_MM_DOUBLE(zephir_safe_div_long_double((double) 1, ((zephir_safe_div_long_long((zephir_get_numberval(&_0) * (zephir_get_numberval(&_1) + 1)), 2 TSRMLS_CC) + zephir_get_numberval(i)) + (double) (1)) TSRMLS_CC));

}
Example #9
0
/**
 * Returns a slice of the resultset to show in the pagination
 */
PHP_METHOD(Phalcon_Paginator_Adapter_Model, getPaginate) {

	zephir_fcall_cache_entry *_5 = NULL, *_6 = NULL;
	int pageNumber, show, n, start, lastShowPage, i, next, totalPages, before, ZEPHIR_LAST_CALL_STATUS;
	zval *config, *items, *pageItems, *page, *_0, *_1, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_7;

	ZEPHIR_MM_GROW();

	ZEPHIR_OBS_VAR(_0);
	zephir_read_property_this(&_0, this_ptr, SL("_limitRows"), PH_NOISY_CC);
	show = zephir_get_intval(_0);
	ZEPHIR_OBS_VAR(config);
	zephir_read_property_this(&config, this_ptr, SL("_config"), PH_NOISY_CC);
	ZEPHIR_OBS_VAR(items);
	zephir_array_fetch_string(&items, config, SL("data"), PH_NOISY, "phalcon/paginator/adapter/model.zep", 80 TSRMLS_CC);
	ZEPHIR_OBS_VAR(_1);
	zephir_read_property_this(&_1, this_ptr, SL("_page"), PH_NOISY_CC);
	pageNumber = zephir_get_intval(_1);
	if (Z_TYPE_P(items) != IS_OBJECT) {
		ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_paginator_exception_ce, "Invalid data for paginator", "phalcon/paginator/adapter/model.zep", 84);
		return;
	}
	if (pageNumber <= 0) {
		pageNumber = 1;
	}
	if (show <= 0) {
		ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_paginator_exception_ce, "The start page number is zero or less", "phalcon/paginator/adapter/model.zep", 94);
		return;
	}
	n = zephir_fast_count_int(items TSRMLS_CC);
	lastShowPage = (pageNumber - 1);
	start = (show * lastShowPage);
	ZEPHIR_INIT_VAR(pageItems);
	array_init(pageItems);
	if (zephir_safe_mod_long_long(n, show TSRMLS_CC) != 0) {
		totalPages = (int) ((zephir_safe_div_long_long(n, show TSRMLS_CC) + (double) (1)));
	} else {
		totalPages = (int) (zephir_safe_div_long_long(n, show TSRMLS_CC));
	}
	if (n > 0) {
		if (start <= n) {
			ZEPHIR_INIT_VAR(_2);
			ZVAL_LONG(_2, start);
			ZEPHIR_CALL_METHOD(NULL, items, "seek", NULL, _2);
			zephir_check_call_status();
		} else {
			ZEPHIR_INIT_NVAR(_2);
			ZVAL_LONG(_2, 0);
			ZEPHIR_CALL_METHOD(NULL, items, "seek", NULL, _2);
			zephir_check_call_status();
			pageNumber = 1;
		}
		i = 1;
		while (1) {
			ZEPHIR_CALL_METHOD(&_3, items, "valid", NULL);
			zephir_check_call_status();
			if (!(zephir_is_true(_3))) {
				break;
			}
			ZEPHIR_CALL_METHOD(&_4, items, "current", &_5);
			zephir_check_call_status();
			zephir_array_append(&pageItems, _4, PH_SEPARATE, "phalcon/paginator/adapter/model.zep", 121);
			if (i >= show) {
				break;
			}
			i++;
			ZEPHIR_CALL_METHOD(NULL, items, "next", &_6);
			zephir_check_call_status();
		}
	}
	next = (pageNumber + 1);
	if (next > totalPages) {
		next = totalPages;
	}
	if (pageNumber > 1) {
		before = (pageNumber - 1);
	} else {
		before = 1;
	}
	ZEPHIR_INIT_VAR(page);
	object_init(page);
	zephir_update_property_zval(page, SL("items"), pageItems TSRMLS_CC);
	ZEPHIR_INIT_ZVAL_NREF(_7);
	ZVAL_LONG(_7, 1);
	zephir_update_property_zval(page, SL("first"), _7 TSRMLS_CC);
	ZEPHIR_INIT_ZVAL_NREF(_7);
	ZVAL_LONG(_7, before);
	zephir_update_property_zval(page, SL("before"), _7 TSRMLS_CC);
	ZEPHIR_INIT_ZVAL_NREF(_7);
	ZVAL_LONG(_7, pageNumber);
	zephir_update_property_zval(page, SL("current"), _7 TSRMLS_CC);
	ZEPHIR_INIT_ZVAL_NREF(_7);
	ZVAL_LONG(_7, totalPages);
	zephir_update_property_zval(page, SL("last"), _7 TSRMLS_CC);
	ZEPHIR_INIT_ZVAL_NREF(_7);
	ZVAL_LONG(_7, next);
	zephir_update_property_zval(page, SL("next"), _7 TSRMLS_CC);
	ZEPHIR_INIT_ZVAL_NREF(_7);
	ZVAL_LONG(_7, totalPages);
	zephir_update_property_zval(page, SL("total_pages"), _7 TSRMLS_CC);
	ZEPHIR_INIT_ZVAL_NREF(_7);
	ZVAL_LONG(_7, n);
	zephir_update_property_zval(page, SL("total_items"), _7 TSRMLS_CC);
	_7 = zephir_fetch_nproperty_this(this_ptr, SL("_limitRows"), PH_NOISY_CC);
	zephir_update_property_zval(page, SL("limit"), _7 TSRMLS_CC);
	RETURN_CCTOR(page);

}
Example #10
0
PHP_METHOD(Test_Statements, test544IssueWithVariable) {

	zephir_fcall_cache_entry *_6 = NULL;
	zval *step_param = NULL, _0, _1$$3, _2$$3, _3$$3, _4$$3, _5$$3, _7$$3, _8$$3, _9$$3, _10$$4, _11$$4, _12$$5, _13$$5;
	int step, ZEPHIR_LAST_CALL_STATUS, filledWidth = 0, unfilledWidth = 0, totalSteps = 0;
		zval this_zv;
	zval *this_ptr = getThis();
	if (EXPECTED(this_ptr)) {
		ZVAL_OBJ(&this_zv, Z_OBJ_P(this_ptr));
		this_ptr = &this_zv;
	} else this_ptr = NULL;
	
	ZVAL_UNDEF(&_0);
	ZVAL_UNDEF(&_1$$3);
	ZVAL_UNDEF(&_2$$3);
	ZVAL_UNDEF(&_3$$3);
	ZVAL_UNDEF(&_4$$3);
	ZVAL_UNDEF(&_5$$3);
	ZVAL_UNDEF(&_7$$3);
	ZVAL_UNDEF(&_8$$3);
	ZVAL_UNDEF(&_9$$3);
	ZVAL_UNDEF(&_10$$4);
	ZVAL_UNDEF(&_11$$4);
	ZVAL_UNDEF(&_12$$5);
	ZVAL_UNDEF(&_13$$5);

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &step_param);

	if (unlikely(Z_TYPE_P(step_param) != IS_LONG)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'step' must be a int") TSRMLS_CC);
		RETURN_MM_NULL();
	}
	step = Z_LVAL_P(step_param);


	zephir_read_property(&_0, this_ptr, SL("totalSteps"), PH_NOISY_CC | PH_READONLY);
	totalSteps = zephir_get_numberval(&_0);
	if (step < totalSteps) {
		zephir_read_property(&_1$$3, this_ptr, SL("width"), PH_NOISY_CC | PH_READONLY);
		filledWidth = (long) ((zephir_safe_div_long_long(((zephir_get_numberval(&_1$$3) - 1)), totalSteps TSRMLS_CC) * step));
		zephir_read_property(&_2$$3, this_ptr, SL("width"), PH_NOISY_CC | PH_READONLY);
		unfilledWidth = (((zephir_get_numberval(&_2$$3) - 1)) - filledWidth);
		zephir_read_property(&_3$$3, this_ptr, SL("filledChar"), PH_NOISY_CC | PH_READONLY);
		ZVAL_LONG(&_4$$3, filledWidth);
		ZEPHIR_CALL_FUNCTION(&_5$$3, "str_repeat", &_6, 17, &_3$$3, &_4$$3);
		zephir_check_call_status();
		zephir_read_property(&_4$$3, this_ptr, SL("arrow"), PH_NOISY_CC | PH_READONLY);
		zephir_read_property(&_7$$3, this_ptr, SL("unfilledChar"), PH_NOISY_CC | PH_READONLY);
		ZVAL_LONG(&_8$$3, unfilledWidth);
		ZEPHIR_CALL_FUNCTION(&_9$$3, "str_repeat", &_6, 17, &_7$$3, &_8$$3);
		zephir_check_call_status();
		ZEPHIR_CONCAT_VVV(return_value, &_5$$3, &_4$$3, &_9$$3);
		RETURN_MM();
	} else if (step == totalSteps) {
		zephir_read_property(&_10$$4, this_ptr, SL("filledChar"), PH_NOISY_CC | PH_READONLY);
		zephir_read_property(&_11$$4, this_ptr, SL("width"), PH_NOISY_CC | PH_READONLY);
		ZEPHIR_RETURN_CALL_FUNCTION("str_repeat", &_6, 17, &_10$$4, &_11$$4);
		zephir_check_call_status();
		RETURN_MM();
	} else {
		zephir_read_property(&_12$$5, this_ptr, SL("unfilledChar"), PH_NOISY_CC | PH_READONLY);
		zephir_read_property(&_13$$5, this_ptr, SL("width"), PH_NOISY_CC | PH_READONLY);
		ZEPHIR_RETURN_CALL_FUNCTION("str_repeat", &_6, 17, &_12$$5, &_13$$5);
		zephir_check_call_status();
		RETURN_MM();
	}

}
Example #11
0
PHP_METHOD(Test_SpectralNorm, process) {

	zephir_fcall_cache_entry *_5 = NULL, *_9 = NULL, *_14 = NULL;
	zend_bool _1, _6, _10;
	zval *n_param = NULL, *u, *v, *w, *_0 = NULL, *_4 = NULL, *_13 = NULL, *_15 = NULL, *_16 = NULL, *_17 = NULL, _18;
	int n, i, vv = 0, vBv = 0, ZEPHIR_LAST_CALL_STATUS, _2, _3, _7, _8, _11, _12;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &n_param);

	n = zephir_get_intval(n_param);


	ZEPHIR_INIT_VAR(u);
	object_init_ex(u, spl_ce_SplFixedArray);
	ZEPHIR_INIT_VAR(_0);
	ZVAL_LONG(_0, n);
	ZEPHIR_CALL_METHOD(NULL, u, "__construct", NULL, 73, _0);
	zephir_check_call_status();
	ZEPHIR_INIT_VAR(v);
	object_init_ex(v, spl_ce_SplFixedArray);
	ZEPHIR_INIT_NVAR(_0);
	ZVAL_LONG(_0, n);
	ZEPHIR_CALL_METHOD(NULL, v, "__construct", NULL, 73, _0);
	zephir_check_call_status();
	ZEPHIR_INIT_VAR(w);
	object_init_ex(w, spl_ce_SplFixedArray);
	ZEPHIR_INIT_NVAR(_0);
	ZVAL_LONG(_0, n);
	ZEPHIR_CALL_METHOD(NULL, w, "__construct", NULL, 73, _0);
	zephir_check_call_status();
	_3 = (n - 1);
	_2 = 0;
	_1 = 0;
	if (_2 <= _3) {
		while (1) {
			if (_1) {
				_2++;
				if (!(_2 <= _3)) {
					break;
				}
			} else {
				_1 = 1;
			}
			i = _2;
			ZEPHIR_INIT_NVAR(_0);
			ZVAL_LONG(_0, i);
			ZEPHIR_INIT_NVAR(_4);
			ZVAL_LONG(_4, 1);
			ZEPHIR_CALL_METHOD(NULL, u, "offsetset", &_5, 74, _0, _4);
			zephir_check_call_status();
			ZEPHIR_INIT_NVAR(_0);
			ZVAL_LONG(_0, i);
			ZEPHIR_INIT_NVAR(_4);
			ZVAL_LONG(_4, 1);
			ZEPHIR_CALL_METHOD(NULL, v, "offsetset", &_5, 74, _0, _4);
			zephir_check_call_status();
			ZEPHIR_INIT_NVAR(_0);
			ZVAL_LONG(_0, i);
			ZEPHIR_INIT_NVAR(_4);
			ZVAL_LONG(_4, 1);
			ZEPHIR_CALL_METHOD(NULL, w, "offsetset", &_5, 74, _0, _4);
			zephir_check_call_status();
		}
	}
	_8 = 9;
	_7 = 0;
	_6 = 0;
	if (_7 <= _8) {
		while (1) {
			if (_6) {
				_7++;
				if (!(_7 <= _8)) {
					break;
				}
			} else {
				_6 = 1;
			}
			i = _7;
			ZEPHIR_INIT_NVAR(_0);
			ZVAL_LONG(_0, n);
			ZEPHIR_CALL_METHOD(NULL, this_ptr, "atau", &_9, 75, _0, u, v, w);
			zephir_check_call_status();
			ZEPHIR_INIT_NVAR(_0);
			ZVAL_LONG(_0, n);
			ZEPHIR_CALL_METHOD(NULL, this_ptr, "atau", &_9, 75, _0, v, u, w);
			zephir_check_call_status();
		}
	}
	_12 = (n - 1);
	_11 = 0;
	_10 = 0;
	if (_11 <= _12) {
		while (1) {
			if (_10) {
				_11++;
				if (!(_11 <= _12)) {
					break;
				}
			} else {
				_10 = 1;
			}
			i = _11;
			ZEPHIR_INIT_NVAR(_0);
			ZVAL_LONG(_0, i);
			ZEPHIR_CALL_METHOD(&_13, u, "offsetget", &_14, 76, _0);
			zephir_check_call_status();
			ZEPHIR_INIT_NVAR(_0);
			ZVAL_LONG(_0, i);
			ZEPHIR_CALL_METHOD(&_15, v, "offsetget", &_14, 76, _0);
			zephir_check_call_status();
			ZEPHIR_INIT_LNVAR(_16);
			mul_function(_16, _13, _15 TSRMLS_CC);
			vBv += zephir_get_numberval(_16);
			ZEPHIR_INIT_NVAR(_0);
			ZVAL_LONG(_0, i);
			ZEPHIR_CALL_METHOD(&_13, v, "offsetget", &_14, 76, _0);
			zephir_check_call_status();
			ZEPHIR_INIT_NVAR(_0);
			ZVAL_LONG(_0, i);
			ZEPHIR_CALL_METHOD(&_15, v, "offsetget", &_14, 76, _0);
			zephir_check_call_status();
			ZEPHIR_INIT_LNVAR(_17);
			mul_function(_17, _13, _15 TSRMLS_CC);
			vv += zephir_get_numberval(_17);
		}
	}
	ZEPHIR_SINIT_VAR(_18);
	ZVAL_DOUBLE(&_18, zephir_safe_div_long_long(vBv, vv TSRMLS_CC));
	ZEPHIR_RETURN_CALL_FUNCTION("sqrt", NULL, 9, &_18);
	zephir_check_call_status();
	RETURN_MM();

}
Example #12
0
PHP_METHOD(Test_Fannkuch, process) {

	zend_bool _0, _5$$4, _11$$8;
	zval *n_param = NULL, *perm = NULL, *perm0 = NULL, *perm1 = NULL, *count = NULL, *temp = NULL, *_3$$3 = NULL, *_4$$6 = NULL, *_9$$4, *_8$$7, *_10$$8 = NULL, *_14$$9, *_15$$14 = NULL, *_16$$15, *_17$$13, *_18$$13 = NULL, *_19$$13;
	int n, maxFlipsCount, permCount, checksum, i = 0, j = 0, flipsCount = 0, k = 0, r = 0, k2 = 0, _1, _2, _6$$4, _7$$4, _12$$8, _13$$8;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &n_param);

	n = zephir_get_intval(n_param);


	maxFlipsCount = 0;
	permCount = 0;
	checksum = 0;
	ZEPHIR_INIT_VAR(perm);
	array_init(perm);
	ZEPHIR_INIT_VAR(perm1);
	array_init(perm1);
	ZEPHIR_INIT_VAR(count);
	array_init(count);
	_2 = n;
	_1 = 0;
	_0 = 0;
	if (_1 <= _2) {
		while (1) {
			if (_0) {
				_1++;
				if (!(_1 <= _2)) {
					break;
				}
			} else {
				_0 = 1;
			}
			i = _1;
			ZEPHIR_INIT_NVAR(_3$$3);
			ZVAL_LONG(_3$$3, i);
			zephir_array_update_long(&perm1, i, &_3$$3, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY);
		}
	}
	r = n;
	while (1) {
		if (0) {
			break;
		}
		while (1) {
			if (!(r != 1)) {
				break;
			}
			ZEPHIR_INIT_NVAR(_4$$6);
			ZVAL_LONG(_4$$6, r);
			zephir_array_update_long(&count, (r - 1), &_4$$6, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY);
			r--;
		}
		_7$$4 = n;
		_6$$4 = 0;
		_5$$4 = 0;
		if (_6$$4 <= _7$$4) {
			while (1) {
				if (_5$$4) {
					_6$$4++;
					if (!(_6$$4 <= _7$$4)) {
						break;
					}
				} else {
					_5$$4 = 1;
				}
				i = _6$$4;
				zephir_array_fetch_long(&_8$$7, perm1, i, PH_NOISY | PH_READONLY, "test/fannkuch.zep", 43 TSRMLS_CC);
				zephir_array_update_long(&perm, i, &_8$$7, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY);
			}
		}
		flipsCount = 0;
		k = 0;
		while (1) {
			zephir_array_fetch_long(&_9$$4, perm, 0, PH_NOISY | PH_READONLY, "test/fannkuch.zep", 48 TSRMLS_CC);
			if (!(!ZEPHIR_IS_LONG(_9$$4, 0))) {
				break;
			}
			ZEPHIR_OBS_NVAR(_10$$8);
			zephir_array_fetch_long(&_10$$8, perm, 0, PH_NOISY, "test/fannkuch.zep", 49 TSRMLS_CC);
			k = zephir_get_intval(_10$$8);
			k2 = (long) (((zephir_safe_div_long_long(((k + 1)), 2 TSRMLS_CC)) - (double) (1)));
			_13$$8 = k2;
			_12$$8 = 0;
			_11$$8 = 0;
			if (_12$$8 <= _13$$8) {
				while (1) {
					if (_11$$8) {
						_12$$8++;
						if (!(_12$$8 <= _13$$8)) {
							break;
						}
					} else {
						_11$$8 = 1;
					}
					i = _12$$8;
					zephir_array_fetch_long(&temp, perm, i, PH_NOISY | PH_READONLY, "test/fannkuch.zep", 51 TSRMLS_CC);
					zephir_array_fetch_long(&_14$$9, perm, (k - i), PH_NOISY | PH_READONLY, "test/fannkuch.zep", 51 TSRMLS_CC);
					zephir_array_update_long(&perm, i, &_14$$9, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY);
					zephir_array_update_long(&perm, (k - i), &temp, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY);
				}
			}
			flipsCount++;
		}
		if (maxFlipsCount < flipsCount) {
			maxFlipsCount = flipsCount;
		}
		if (zephir_safe_mod_long_long(permCount, 2 TSRMLS_CC) == 0) {
			checksum += flipsCount;
		} else {
			checksum -= flipsCount;
		}
		while (1) {
			if (r == n) {
				zephir_create_array(return_value, 3, 0 TSRMLS_CC);
				ZEPHIR_INIT_NVAR(_15$$14);
				ZVAL_LONG(_15$$14, checksum);
				zephir_array_fast_append(return_value, _15$$14);
				ZEPHIR_INIT_NVAR(_15$$14);
				ZVAL_LONG(_15$$14, n);
				zephir_array_fast_append(return_value, _15$$14);
				ZEPHIR_INIT_NVAR(_15$$14);
				ZVAL_LONG(_15$$14, maxFlipsCount);
				zephir_array_fast_append(return_value, _15$$14);
				RETURN_MM();
			}
			zephir_array_fetch_long(&perm0, perm1, 0, PH_NOISY | PH_READONLY, "test/fannkuch.zep", 75 TSRMLS_CC);
			i = 0;
			while (1) {
				if (!(i < r)) {
					break;
				}
				j = (i + 1);
				zephir_array_fetch_long(&_16$$15, perm1, j, PH_NOISY | PH_READONLY, "test/fannkuch.zep", 78 TSRMLS_CC);
				zephir_array_update_long(&perm1, i, &_16$$15, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY);
				i = j;
			}
			zephir_array_update_long(&perm1, r, &perm0, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY);
			zephir_array_fetch_long(&_17$$13, count, r, PH_NOISY | PH_READONLY, "test/fannkuch.zep", 82 TSRMLS_CC);
			ZEPHIR_INIT_NVAR(_18$$13);
			ZVAL_LONG(_18$$13, (zephir_get_numberval(_17$$13) - 1));
			zephir_array_update_long(&count, r, &_18$$13, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY);
			zephir_array_fetch_long(&_19$$13, count, r, PH_NOISY | PH_READONLY, "test/fannkuch.zep", 83 TSRMLS_CC);
			if (ZEPHIR_GT_LONG(_19$$13, 0)) {
				break;
			}
			r++;
		}
		permCount++;
	}
	ZEPHIR_MM_RESTORE();

}
Example #13
0
PHP_METHOD(Test_SpectralNorm, process) {

	zend_bool _1, _7, _12;
	zephir_fcall_cache_entry *_6 = NULL, *_11 = NULL, *_17 = NULL;
	zval *n_param = NULL, u, v, w, _0, _4$$3, _5$$3, _10$$4, _15$$5, _16$$5, _18$$5, _19$$5, _20$$5;
	zend_long n, ZEPHIR_LAST_CALL_STATUS, i = 0, vv, vBv, _2, _3, _8, _9, _13, _14;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&u);
	ZVAL_UNDEF(&v);
	ZVAL_UNDEF(&w);
	ZVAL_UNDEF(&_0);
	ZVAL_UNDEF(&_4$$3);
	ZVAL_UNDEF(&_5$$3);
	ZVAL_UNDEF(&_10$$4);
	ZVAL_UNDEF(&_15$$5);
	ZVAL_UNDEF(&_16$$5);
	ZVAL_UNDEF(&_18$$5);
	ZVAL_UNDEF(&_19$$5);
	ZVAL_UNDEF(&_20$$5);

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &n_param);

	n = zephir_get_intval(n_param);


	vv = 0;
	vBv = 0;
	ZEPHIR_INIT_VAR(&u);
	object_init_ex(&u, spl_ce_SplFixedArray);
	ZVAL_LONG(&_0, n);
	ZEPHIR_CALL_METHOD(NULL, &u, "__construct", NULL, 74, &_0);
	zephir_check_call_status();
	ZEPHIR_INIT_VAR(&v);
	object_init_ex(&v, spl_ce_SplFixedArray);
	ZVAL_LONG(&_0, n);
	ZEPHIR_CALL_METHOD(NULL, &v, "__construct", NULL, 74, &_0);
	zephir_check_call_status();
	ZEPHIR_INIT_VAR(&w);
	object_init_ex(&w, spl_ce_SplFixedArray);
	ZVAL_LONG(&_0, n);
	ZEPHIR_CALL_METHOD(NULL, &w, "__construct", NULL, 74, &_0);
	zephir_check_call_status();
	_3 = (n - 1);
	_2 = 0;
	_1 = 0;
	if (_2 <= _3) {
		while (1) {
			if (_1) {
				_2++;
				if (!(_2 <= _3)) {
					break;
				}
			} else {
				_1 = 1;
			}
			i = _2;
			ZVAL_LONG(&_4$$3, i);
			ZVAL_LONG(&_5$$3, 1);
			ZEPHIR_CALL_METHOD(NULL, &u, "offsetset", &_6, 75, &_4$$3, &_5$$3);
			zephir_check_call_status();
			ZVAL_LONG(&_4$$3, i);
			ZVAL_LONG(&_5$$3, 1);
			ZEPHIR_CALL_METHOD(NULL, &v, "offsetset", &_6, 75, &_4$$3, &_5$$3);
			zephir_check_call_status();
			ZVAL_LONG(&_4$$3, i);
			ZVAL_LONG(&_5$$3, 1);
			ZEPHIR_CALL_METHOD(NULL, &w, "offsetset", &_6, 75, &_4$$3, &_5$$3);
			zephir_check_call_status();
		}
	}
	_9 = 9;
	_8 = 0;
	_7 = 0;
	if (_8 <= _9) {
		while (1) {
			if (_7) {
				_8++;
				if (!(_8 <= _9)) {
					break;
				}
			} else {
				_7 = 1;
			}
			i = _8;
			ZVAL_LONG(&_10$$4, n);
			ZEPHIR_CALL_METHOD(NULL, this_ptr, "atau", &_11, 76, &_10$$4, &u, &v, &w);
			zephir_check_call_status();
			ZVAL_LONG(&_10$$4, n);
			ZEPHIR_CALL_METHOD(NULL, this_ptr, "atau", &_11, 76, &_10$$4, &v, &u, &w);
			zephir_check_call_status();
		}
	}
	_14 = (n - 1);
	_13 = 0;
	_12 = 0;
	if (_13 <= _14) {
		while (1) {
			if (_12) {
				_13++;
				if (!(_13 <= _14)) {
					break;
				}
			} else {
				_12 = 1;
			}
			i = _13;
			ZVAL_LONG(&_16$$5, i);
			ZEPHIR_CALL_METHOD(&_15$$5, &u, "offsetget", &_17, 77, &_16$$5);
			zephir_check_call_status();
			ZVAL_LONG(&_16$$5, i);
			ZEPHIR_CALL_METHOD(&_18$$5, &v, "offsetget", &_17, 77, &_16$$5);
			zephir_check_call_status();
			ZEPHIR_INIT_LNVAR(_19$$5);
			mul_function(&_19$$5, &_15$$5, &_18$$5 TSRMLS_CC);
			vBv += zephir_get_numberval(&_19$$5);
			ZVAL_LONG(&_16$$5, i);
			ZEPHIR_CALL_METHOD(&_15$$5, &v, "offsetget", &_17, 77, &_16$$5);
			zephir_check_call_status();
			ZVAL_LONG(&_16$$5, i);
			ZEPHIR_CALL_METHOD(&_18$$5, &v, "offsetget", &_17, 77, &_16$$5);
			zephir_check_call_status();
			ZEPHIR_INIT_LNVAR(_20$$5);
			mul_function(&_20$$5, &_15$$5, &_18$$5 TSRMLS_CC);
			vv += zephir_get_numberval(&_20$$5);
		}
	}
	ZVAL_DOUBLE(&_0, zephir_safe_div_long_long(vBv, vv TSRMLS_CC));
	RETURN_MM_DOUBLE(sqrt(zephir_safe_div_long_long(vBv, vv TSRMLS_CC)));

}
Example #14
0
/**
 * Crop an image to the given size
 */
PHP_METHOD(Phalcon_Image_Adapter, crop) {

	zval *width_param = NULL, *height_param = NULL, *offsetX_param = NULL, *offsetY_param = NULL, _0, *_1, *_2, *_3 = NULL, _4, *_5, *_6, *_7, *_8;
	int width, height, offsetX, offsetY, ZEPHIR_LAST_CALL_STATUS;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 2, 2, &width_param, &height_param, &offsetX_param, &offsetY_param);

	width = zephir_get_intval(width_param);
	height = zephir_get_intval(height_param);
	if (!offsetX_param) {
		offsetX = 0;
	} else {
		offsetX = zephir_get_intval(offsetX_param);
	}
	if (!offsetY_param) {
		offsetY = 0;
	} else {
		offsetY = zephir_get_intval(offsetY_param);
	}


	ZEPHIR_SINIT_VAR(_0);
	ZVAL_LONG(&_0, offsetX);
	if (Z_TYPE_P(&_0) == IS_NULL) {
		_1 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC);
		offsetX = (long) ((zephir_safe_div_long_long(((zephir_get_numberval(_1) - width)), 2 TSRMLS_CC)));
	} else {
		if (offsetX < 0) {
			_1 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC);
			offsetX = ((zephir_get_numberval(_1) - width) + offsetX);
		}
		_2 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC);
		if (ZEPHIR_LT_LONG(_2, offsetX)) {
			ZEPHIR_OBS_VAR(_3);
			zephir_read_property_this(&_3, this_ptr, SL("_width"), PH_NOISY_CC);
			offsetX = zephir_get_intval(_3);
		}
	}
	ZEPHIR_SINIT_VAR(_4);
	ZVAL_LONG(&_4, offsetY);
	if (Z_TYPE_P(&_4) == IS_NULL) {
		_1 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC);
		offsetY = (long) ((zephir_safe_div_long_long(((zephir_get_numberval(_1) - height)), 2 TSRMLS_CC)));
	} else {
		if (offsetY < 0) {
			_1 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC);
			offsetY = ((zephir_get_numberval(_1) - height) + offsetY);
		}
		_2 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC);
		if (ZEPHIR_LT_LONG(_2, offsetY)) {
			ZEPHIR_OBS_NVAR(_3);
			zephir_read_property_this(&_3, this_ptr, SL("_height"), PH_NOISY_CC);
			offsetY = zephir_get_intval(_3);
		}
	}
	_1 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC);
	if (width > ((zephir_get_numberval(_1) - offsetX))) {
		_2 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC);
		width = (zephir_get_numberval(_2) - offsetX);
	}
	_1 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC);
	if (height > ((zephir_get_numberval(_1) - offsetY))) {
		_2 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC);
		height = (zephir_get_numberval(_2) - offsetY);
	}
	ZEPHIR_INIT_VAR(_5);
	ZVAL_LONG(_5, width);
	ZEPHIR_INIT_VAR(_6);
	ZVAL_LONG(_6, height);
	ZEPHIR_INIT_VAR(_7);
	ZVAL_LONG(_7, offsetX);
	ZEPHIR_INIT_VAR(_8);
	ZVAL_LONG(_8, offsetY);
	ZEPHIR_CALL_METHOD(NULL, this_ptr, "_crop", NULL, 0, _5, _6, _7, _8);
	zephir_check_call_status();
	RETURN_THIS();

}
Example #15
0
/**
 * Resize the image to the given size
 */
PHP_METHOD(Phalcon_Image_Adapter, resize) {

	zephir_fcall_cache_entry *_12 = NULL;
	zend_bool _0, _4;
	double ratio;
	zval *width_param = NULL, *height_param = NULL, *master_param = NULL, *_1 = NULL, *_2, *_3, *_5, *_6, *_7 = NULL, *_8, _9, *_10 = NULL, *_11 = NULL, _13, *_14 = NULL, *_15 = NULL, *_16;
	int width, height, master, ZEPHIR_LAST_CALL_STATUS;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 0, 3, &width_param, &height_param, &master_param);

	if (!width_param) {
		width = 0;
	} else {
		width = zephir_get_intval(width_param);
	}
	if (!height_param) {
		height = 0;
	} else {
		height = zephir_get_intval(height_param);
	}
	if (!master_param) {
		master = 4;
	} else {
		master = zephir_get_intval(master_param);
	}


	if (master == 7) {
		_0 = !width;
		if (!(_0)) {
			_0 = !height;
		}
		if (_0) {
			ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "width and height must be specified", "phalcon/image/adapter.zep", 80);
			return;
		}
	} else {
		if (master == 4) {
			_0 = !width;
			if (!(_0)) {
				_0 = !height;
			}
			if (_0) {
				ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "width and height must be specified", "phalcon/image/adapter.zep", 88);
				return;
			}
			ZEPHIR_INIT_VAR(_1);
			_2 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC);
			_3 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC);
			if ((zephir_safe_div_zval_long(_2, width TSRMLS_CC)) > (int) (zephir_safe_div_zval_long(_3, height TSRMLS_CC))) {
				ZEPHIR_INIT_NVAR(_1);
				ZVAL_LONG(_1, 2);
			} else {
				ZEPHIR_INIT_NVAR(_1);
				ZVAL_LONG(_1, 3);
			}
			master = zephir_get_numberval(_1);
		}
		if (master == 5) {
			_4 = !width;
			if (!(_4)) {
				_4 = !height;
			}
			if (_4) {
				ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "width and height must be specified", "phalcon/image/adapter.zep", 97);
				return;
			}
			ZEPHIR_INIT_LNVAR(_1);
			_2 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC);
			_3 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC);
			if ((zephir_safe_div_zval_long(_2, width TSRMLS_CC)) > (int) (zephir_safe_div_zval_long(_3, height TSRMLS_CC))) {
				ZEPHIR_INIT_NVAR(_1);
				ZVAL_LONG(_1, 3);
			} else {
				ZEPHIR_INIT_NVAR(_1);
				ZVAL_LONG(_1, 2);
			}
			master = zephir_get_numberval(_1);
		}
		do {
			if (master == 2) {
				if (!(width)) {
					ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "width must be specified", "phalcon/image/adapter.zep", 107);
					return;
				}
				_2 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC);
				_3 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC);
				height = (long) (zephir_safe_div_long_zval((zephir_get_numberval(_2) * width), _3 TSRMLS_CC));
				break;
			}
			if (master == 3) {
				if (!(height)) {
					ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "height must be specified", "phalcon/image/adapter.zep", 114);
					return;
				}
				_2 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC);
				_3 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC);
				width = (long) (zephir_safe_div_long_zval((zephir_get_numberval(_2) * height), _3 TSRMLS_CC));
				break;
			}
			if (master == 6) {
				_4 = !width;
				if (!(_4)) {
					_4 = !height;
				}
				if (_4) {
					ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "width and height must be specified", "phalcon/image/adapter.zep", 121);
					return;
				}
				_2 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC);
				_3 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC);
				ZEPHIR_INIT_LNVAR(_1);
				div_function(_1, _2, _3 TSRMLS_CC);
				ratio = zephir_get_numberval(_1);
				if ((zephir_safe_div_long_long(width, height TSRMLS_CC)) > ratio) {
					_2 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC);
					_3 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC);
					height = (long) (zephir_safe_div_long_zval((zephir_get_numberval(_2) * width), _3 TSRMLS_CC));
				} else {
					_5 = zephir_fetch_nproperty_this(this_ptr, SL("_width"), PH_NOISY_CC);
					_6 = zephir_fetch_nproperty_this(this_ptr, SL("_height"), PH_NOISY_CC);
					width = (long) (zephir_safe_div_long_zval((zephir_get_numberval(_5) * height), _6 TSRMLS_CC));
				}
				break;
			}
			if (master == 1) {
				if (!(width)) {
					ZEPHIR_OBS_VAR(_7);
					zephir_read_property_this(&_7, this_ptr, SL("_width"), PH_NOISY_CC);
					width = zephir_get_intval(_7);
				}
				if (!(height)) {
					ZEPHIR_OBS_NVAR(_7);
					zephir_read_property_this(&_7, this_ptr, SL("_height"), PH_NOISY_CC);
					width = zephir_get_intval(_7);
				}
				break;
			}
		} while(0);

	}
	ZEPHIR_INIT_VAR(_8);
	ZEPHIR_SINIT_VAR(_9);
	ZVAL_LONG(&_9, width);
	zephir_round(_8, &_9, NULL, NULL TSRMLS_CC);
	ZEPHIR_INIT_VAR(_10);
	ZVAL_LONG(_10, 1);
	ZEPHIR_CALL_FUNCTION(&_11, "max", &_12, 68, _8, _10);
	zephir_check_call_status();
	width = zephir_get_intval(_11);
	ZEPHIR_INIT_NVAR(_10);
	ZEPHIR_SINIT_VAR(_13);
	ZVAL_LONG(&_13, height);
	zephir_round(_10, &_13, NULL, NULL TSRMLS_CC);
	ZEPHIR_INIT_VAR(_14);
	ZVAL_LONG(_14, 1);
	ZEPHIR_CALL_FUNCTION(&_15, "max", &_12, 68, _10, _14);
	zephir_check_call_status();
	height = zephir_get_intval(_15);
	ZEPHIR_INIT_NVAR(_14);
	ZVAL_LONG(_14, width);
	ZEPHIR_INIT_VAR(_16);
	ZVAL_LONG(_16, height);
	ZEPHIR_CALL_METHOD(NULL, this_ptr, "_resize", NULL, 0, _14, _16);
	zephir_check_call_status();
	RETURN_THIS();

}