andrey Fri May 13 06:11:19 2005 EDT
Removed files:
/php-src/ext/standard/tests/math math_std_dev.phpt
Modified files:
/php-src/ext/standard basic_functions.c math.c php_math.h
Log:
move math_standard_deviation and math_variance to the stats PECL extension
http://cvs.php.net/diff.php/php-src/ext/standard/basic_functions.c?r1=1.715&r2=1.716&ty=u
Index: php-src/ext/standard/basic_functions.c
diff -u php-src/ext/standard/basic_functions.c:1.715
php-src/ext/standard/basic_functions.c:1.716
--- php-src/ext/standard/basic_functions.c:1.715 Wed May 11 07:43:10 2005
+++ php-src/ext/standard/basic_functions.c Fri May 13 06:11:17 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: basic_functions.c,v 1.715 2005/05/11 11:43:10 andrey Exp $ */
+/* $Id: basic_functions.c,v 1.716 2005/05/13 10:11:17 andrey Exp $ */
#include "php.h"
#include "php_streams.h"
@@ -415,8 +415,6 @@
PHP_FE(base_convert,
NULL)
PHP_FE(number_format,
NULL)
PHP_FE(fmod,
NULL)
- PHP_FE(math_standard_deviation,
NULL)
- PHP_FE(math_variance,
NULL)
#ifdef HAVE_INET_NTOP
PHP_NAMED_FE(inet_ntop, php_inet_ntop,
NULL)
#endif
http://cvs.php.net/diff.php/php-src/ext/standard/math.c?r1=1.128&r2=1.129&ty=u
Index: php-src/ext/standard/math.c
diff -u php-src/ext/standard/math.c:1.128 php-src/ext/standard/math.c:1.129
--- php-src/ext/standard/math.c:1.128 Tue May 10 08:50:53 2005
+++ php-src/ext/standard/math.c Fri May 13 06:11:18 2005
@@ -19,7 +19,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: math.c,v 1.128 2005/05/10 12:50:53 andrey Exp $ */
+/* $Id: math.c,v 1.129 2005/05/13 10:11:18 andrey Exp $ */
#include "php.h"
#include "php_math.h"
@@ -1137,83 +1137,7 @@
}
/* }}} */
-/* {{{ php_population_variance
-*/
-static long double php_population_variance(zval *arr, zend_bool sample)
-{
- double mean, sum = 0.0, vr = 0.0;
- zval **entry;
- HashPosition pos;
- int elements_num;
-
- elements_num = zend_hash_num_elements(Z_ARRVAL_P(arr));
-
- zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(arr), &pos);
- while (zend_hash_get_current_data_ex(Z_ARRVAL_P(arr), (void **)&entry,
&pos) == SUCCESS) {
- convert_to_double_ex(entry);
- sum += Z_DVAL_PP(entry);
- zend_hash_move_forward_ex(Z_ARRVAL_P(arr), &pos);
- }
- mean = sum / elements_num;
-
- zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(arr), &pos);
- while (zend_hash_get_current_data_ex(Z_ARRVAL_P(arr), (void **)&entry,
&pos) == SUCCESS) {
- double d;
- convert_to_double_ex(entry);
- d = Z_DVAL_PP(entry) - mean;
- vr += d*d;
- zend_hash_move_forward_ex(Z_ARRVAL_P(arr), &pos);
- }
- if (sample) {
- --elements_num;
- }
- return (vr / elements_num);
-}
-/* }}} */
-
-/* {{{ proto float math_variance(array a [, bool sample])
- Returns the population variance */
-PHP_FUNCTION(math_variance)
-{
- zval *arr;
- zend_bool sample = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|b", &arr,
&sample) == FAILURE) {
- return;
- }
- if (zend_hash_num_elements(Z_ARRVAL_P(arr)) == 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "The array has zero
elements");
- RETURN_FALSE;
- }
- if (sample && zend_hash_num_elements(Z_ARRVAL_P(arr)) == 1) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "The array has only
1 element");
- RETURN_FALSE;
- }
- RETURN_DOUBLE(php_population_variance(arr, sample));
-}
-/* }}} */
-
-/* {{{ proto float math_standard_deviation(array a[, bool sample = false])
- Returns the standard deviation */
-PHP_FUNCTION(math_standard_deviation)
-{
- zval *arr;
- zend_bool sample = 0;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|b", &arr,
&sample) == FAILURE) {
- return;
- }
- if (zend_hash_num_elements(Z_ARRVAL_P(arr)) == 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "The array has zero
elements");
- RETURN_FALSE;
- }
- if (sample && zend_hash_num_elements(Z_ARRVAL_P(arr)) == 1) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "The array has only
1 element");
- RETURN_FALSE;
- }
- RETURN_DOUBLE(sqrt(php_population_variance(arr, sample)));
-}
-/* }}} */
/*
* Local variables:
http://cvs.php.net/diff.php/php-src/ext/standard/php_math.h?r1=1.26&r2=1.27&ty=u
Index: php-src/ext/standard/php_math.h
diff -u php-src/ext/standard/php_math.h:1.26
php-src/ext/standard/php_math.h:1.27
--- php-src/ext/standard/php_math.h:1.26 Tue May 10 08:50:53 2005
+++ php-src/ext/standard/php_math.h Fri May 13 06:11:18 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_math.h,v 1.26 2005/05/10 12:50:53 andrey Exp $ */
+/* $Id: php_math.h,v 1.27 2005/05/13 10:11:18 andrey Exp $ */
#ifndef PHP_MATH_H
#define PHP_MATH_H
@@ -59,8 +59,6 @@
PHP_FUNCTION(base_convert);
PHP_FUNCTION(number_format);
PHP_FUNCTION(fmod);
-PHP_FUNCTION(math_standard_deviation);
-PHP_FUNCTION(math_variance);
PHP_FUNCTION(deg2rad);
PHP_FUNCTION(rad2deg);
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php