Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Bug #14989 - PHPCS

  • Loading branch information...
commit e2f2b02a8c839de5a9fc9dac01b926b94abc50f1 1 parent cbfb4cf
Firman Wandayandi authored
View
1  Math/Numerical/RootFinding/Bisection.php
@@ -23,6 +23,7 @@
* @author Firman Wandayandi <firman@php.net>
* @copyright 2004-2008 Firman Wandayandi
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @link http://pear.php.net/package/Math_Numerical_RootFinding
* @version CVS: $Id$
*/
View
2  Math/Numerical/RootFinding/FalsePosition.php
@@ -153,7 +153,7 @@ function compute($fxFunction, $xL, $xU)
// Compute approximation error.
$this->epsError = abs(($xN - $xR) / $xN);
- $epsErrors[] = $this->epsError;
+ $epsErrors[] = $this->epsError;
// Detect for divergent rows.
if ($this->isDivergentRows($epsErrors) &&
View
85 Math/Numerical/RootFinding/FixedPoint.php
@@ -1,8 +1,4 @@
<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
-
-// {{{ Header
-
/**
* Driver file contains Math_Numerical_RootFinding_Bisection class to provide
* Fixed Point method root finding calculation.
@@ -20,51 +16,44 @@
* obtain it through the world-wide-web, please send an email
* to pear-dev@list.php.net so we can send you a copy immediately.
*
- * @category Math
- * @package Math_Numerical_RootFinding
- * @subpackage Methods
- * @author Firman Wandayandi <firman@php.net>
- * @copyright Copyright (c) 2004-2008 Firman Wandayandi
- * @license http://www.opensource.org/licenses/bsd-license.php
- * BSD License
- * @version CVS: $Id$
+ * @category Math
+ * @package Math_Numerical_RootFinding
+ * @subpackage Methods
+ * @author Firman Wandayandi <firman@php.net>
+ * @copyright Copyright (c) 2004-2008 Firman Wandayandi
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @link http://pear.php.net/package/Math_Numerical_RootFinding
+ * @version CVS: $Id$
*/
-// }}}
-// {{{ Dependencies
-
/**
* Math_Numerical_RootFinding_Common
*/
require_once 'Math/Numerical/RootFinding/Common.php';
-// }}}
-// {{{ Class: Math_Numerical_RootFinding_FixedPoint
-
/**
* Fixed Point method class.
*
- * @category Math
- * @package Math_Numerical_RootFinding
- * @subpackage Methods
- * @author Firman Wandayandi <firman@php.net>
- * @copyright Copyright (c) 2004-2008 Firman Wandayandi
- * @license http://www.opensource.org/licenses/bsd-license.php
- * BSD License
- * @version Release: @package_version@
+ * @category Math
+ * @package Math_Numerical_RootFinding
+ * @subpackage Methods
+ * @author Firman Wandayandi <firman@php.net>
+ * @copyright Copyright (c) 2004-2008 Firman Wandayandi
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @link http://pear.php.net/package/Math_Numerical_RootFinding
+ * @version Release: @package_version@
*/
-class Math_Numerical_RootFinding_FixedPoint
-extends Math_Numerical_RootFinding_Common
+class Math_Numerical_RootFinding_FixedPoint extends Math_Numerical_RootFinding_Common
{
// {{{ Constructor
/**
* Constructor.
*
- * @param array $options (optional) Options.
+ * @param array $options (optional) Options.
*
- * @access public
- * @see Math_Numerical_RootFinding_Common::Math_Numerical_RootFinding_Common()
+ * @access public
+ * @see Math_Numerical_RootFinding_Common::Math_Numerical_RootFinding_Common()
*/
function Math_Numerical_RootFinding_FixedPoint($options = null)
{
@@ -78,6 +67,7 @@ function Math_Numerical_RootFinding_FixedPoint($options = null)
* Print out parameters description for compute() function.
*
* @access public
+ * @return void
*/
function infoCompute()
{
@@ -103,20 +93,22 @@ function infoCompute()
*
* This method using g(x) (the modification of f(x), which g(x) = x).
*
- * @param callback $gxFunction Callback g(x) equation function or
- * object/method tuple.
- * @param float $xR Initial guess.
+ * @param callback $gxFunction Callback g(x) equation function or object/method
+ * tuple.
+ * @param float $xR Initial guess.
*
- * @return float|PEAR_Error Root value on success or PEAR_Error on failure.
- * @access public
- * @see Math_Numerical_RootFinding_Common::validateEqFunction()
- * @see Math_Numerical_RootFinding_Common::getEqResult()
- * @see Math_Numerical_RootFinding_Common::isDivergentRow()
+ * @return float|PEAR_Error Root value on success or PEAR_Error on failure.
+ * @access public
+ * @see Math_Numerical_RootFinding_Common::validateEqFunction()
+ * @see Math_Numerical_RootFinding_Common::getEqResult()
+ * @see Math_Numerical_RootFinding_Common::isDivergentRow()
*/
function compute($gxFunction, $xR)
{
// Validate g(x) equation function.
- $err = Math_Numerical_RootFinding_Common::validateEqFunction($gxFunction, $xR);
+ $err = Math_Numerical_RootFinding_Common::validateEqFunction(
+ $gxFunction, $xR
+ );
if (PEAR::isError($err)) {
return $err;
}
@@ -129,7 +121,7 @@ function compute($gxFunction, $xR)
// detection.
$epsErrors = array();
- for($i = 0; $i < $maxIteration; $i++) {
+ for ($i = 0; $i < $maxIteration; $i++) {
// Calculate g(x[i]), where x[i] = $xR (Fixed Point's formula).
$xN = Math_Numerical_RootFinding_Common::getEqResult($gxFunction, $xR);
@@ -141,13 +133,14 @@ function compute($gxFunction, $xR)
// Compute error.
$this->epsError = abs(($xN - $xR) / $xN);
- $epsErrors[] = $this->epsError;
+ $epsErrors[] = $this->epsError;
// Detect for divergent rows.
if ($this->isDivergentRows($epsErrors) &&
- $this->options['divergent_skip'])
- {
- return PEAR::raiseError('Iteration skipped, divergent rows detected');
+ $this->options['divergent_skip']) {
+ return PEAR::raiseError(
+ 'Iteration skipped, divergent rows detected'
+ );
break;
}
@@ -168,8 +161,6 @@ function compute($gxFunction, $xR)
// }}}
}
-// }}}
-
/*
* Local variables:
* mode: php
View
93 Math/Numerical/RootFinding/NewtonRaphson.php
@@ -1,8 +1,4 @@
<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
-
-// {{{ Header
-
/**
* Driver file contains Math_Numerical_RootFinding_Bisection class to provide
* Newton-Raphson method root finding calculation.
@@ -20,38 +16,32 @@
* obtain it through the world-wide-web, please send an email
* to pear-dev@list.php.net so we can send you a copy immediately.
*
- * @category Math
- * @package Math_Numerical_RootFinding
- * @subpackage Methods
- * @author Firman Wandayandi <firman@php.net>
- * @copyright Copyright (c) 2004-2008 Firman Wandayandi
- * @license http://www.opensource.org/licenses/bsd-license.php
- * BSD License
- * @version CVS: $Id$
+ * @category Math
+ * @package Math_Numerical_RootFinding
+ * @subpackage Methods
+ * @author Firman Wandayandi <firman@php.net>
+ * @copyright 2004-2008 Firman Wandayandi
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @link http://pear.php.net/package/Math_Numerical_RootFinding
+ * @version CVS: $Id$
*/
-// }}}
-// {{{ Dependencies
-
/**
* Math_Numerical_RootFinding_Common
*/
require_once 'Math/Numerical/RootFinding/Common.php';
-// }}}
-// {{{ Class: Math_Numerical_RootFinding_NewtonRaphson
-
/**
* Newton-Raphson method class.
*
- * @category Math
- * @package Math_Numerical_RootFinding
- * @subpackage Methods
- * @author Firman Wandayandi <firman@php.net>
- * @copyright Copyright (c) 2004-2008 Firman Wandayandi
- * @license http://www.opensource.org/licenses/bsd-license.php
- * BSD License
- * @version Release: @package_version@
+ * @category Math
+ * @package Math_Numerical_RootFinding
+ * @subpackage Methods
+ * @author Firman Wandayandi <firman@php.net>
+ * @copyright 2004-2008 Firman Wandayandi
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @link http://pear.php.net/package/Math_Numerical_RootFinding
+ * @version Release: @package_version@
*/
class Math_Numerical_RootFinding_NewtonRaphson
extends Math_Numerical_RootFinding_Common
@@ -61,10 +51,10 @@ class Math_Numerical_RootFinding_NewtonRaphson
/**
* Constructor.
*
- * @param array $options (optional) Options.
+ * @param array $options (optional) Options.
*
- * @access public
- * @see Math_Numerical_RootFinding_Common::Math_Numerical_RootFinding_Common()
+ * @access public
+ * @see Math_Numerical_RootFinding_Common::Math_Numerical_RootFinding_Common()
*/
function Math_Numerical_RootFinding_NewtonRaphson($options = null)
{
@@ -78,6 +68,7 @@ function Math_Numerical_RootFinding_NewtonRaphson($options = null)
* Print out parameters description for compute() function.
*
* @access public
+ * @return void
*/
function infoCompute()
{
@@ -105,28 +96,33 @@ function infoCompute()
/**
* Netwon-Raphson method.
*
- * @param callback $fxFunction Callback f(x) equation function or
- * object/method tuple.
- * @param callback $dfxFunction Callback f'(x) equation function or
- * object/method tuple.
- * @param float $xR Initial guess.
+ * @param callback $fxFunction Callback f(x) equation function or object/method
+ * tuple.
+ * @param callback $dfxFunction Callback f'(x) equation function or object/method
+ * tuple.
+ * @param float $xR Initial guess.
*
- * @return float|PEAR_Error Root value on success or PEAR_Error on failure.
- * @access public
- * @see Math_Numerical_RootFinding_Common::validateEqFunction()
- * @see Math_Numerical_RootFinding_Common::getEqResult()
- * @see Math_Numerical_RootFinding_Common::isDivergentRow()
- * @see Math_Numerical_RootFinding_Newtonraphson2::compute()
+ * @return float|PEAR_Error Root value on success or PEAR_Error on failure.
+ * @access public
+ * @see Math_Numerical_RootFinding_Common::validateEqFunction()
+ * @see Math_Numerical_RootFinding_Common::getEqResult()
+ * @see Math_Numerical_RootFinding_Common::isDivergentRow()
+ * @see Math_Numerical_RootFinding_Newtonraphson2::compute()
*/
- function compute($fxFunction, $dfxFunction, $xR) {
+ function compute($fxFunction, $dfxFunction, $xR)
+ {
// evaluate f(x) equation function before begin anything
- $err = Math_Numerical_RootFinding_Common::validateEqFunction($fxFunction, $xR);
+ $err = Math_Numerical_RootFinding_Common::validateEqFunction(
+ $fxFunction, $xR
+ );
if (PEAR::isError($err)) {
return $err;
}
// evaluate df(x) equation function before begin anything
- $err = Math_Numerical_RootFinding_Common::validateEqFunction($dfxFunction, $xR);
+ $err = Math_Numerical_RootFinding_Common::validateEqFunction(
+ $dfxFunction, $xR
+ );
if (PEAR::isError($err)) {
return $err;
}
@@ -162,13 +158,14 @@ function compute($fxFunction, $dfxFunction, $xR) {
// Compute error.
$this->epsError = abs(($xN - $xR) / $xN);
- $epsErrors[] = $this->epsError;
+ $epsErrors[] = $this->epsError;
// Detect for divergent rows.
if ($this->isDivergentRows($epsErrors) &&
- $this->options['divergent_skip'])
- {
- return PEAR::raiseError('Iteration skipped, divergent rows detected');
+ $this->options['divergent_skip']) {
+ return PEAR::raiseError(
+ 'Iteration skipped, divergent rows detected'
+ );
break;
}
@@ -189,8 +186,6 @@ function compute($fxFunction, $dfxFunction, $xR) {
// }}}
}
-// }}}
-
/*
* Local variables:
* mode: php
View
103 Math/Numerical/RootFinding/NewtonRaphson2.php
@@ -1,8 +1,4 @@
<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
-
-// {{{ Header
-
/**
* Driver file contains Math_Numerical_RootFinding_Bisection class to provide
* Newton-Raphson 2 method root finding calculation.
@@ -20,38 +16,32 @@
* obtain it through the world-wide-web, please send an email
* to pear-dev@list.php.net so we can send you a copy immediately.
*
- * @category Math
- * @package Math_Numerical_RootFinding
- * @subpackage Methods
- * @author Firman Wandayandi <firman@php.net>
- * @copyright Copyright (c) 2004-2008 Firman Wandayandi
- * @license http://www.opensource.org/licenses/bsd-license.php
- * BSD License
- * @version CVS: $Id$
+ * @category Math
+ * @package Math_Numerical_RootFinding
+ * @subpackage Methods
+ * @author Firman Wandayandi <firman@php.net>
+ * @copyright Copyright (c) 2004-2008 Firman Wandayandi
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @link http://pear.php.net/package/Math_Numerical_RootFinding
+ * @version CVS: $Id$
*/
-// }}}
-// {{{ Dependencies
-
/**
* Math_Numerical_RootFinding_Common
*/
require_once 'Math/Numerical/RootFinding/Common.php';
-// }}}
-// {{{ Class: Math_Numerical_RootFinding_NewtonRaphson2
-
/**
* Newton-Raphson 2 method class.
*
- * @category Math
- * @package Math_Numerical_RootFinding
- * @subpackage Methods
- * @author Firman Wandayandi <firman@php.net>
- * @copyright Copyright (c) 2004-2008 Firman Wandayandi
- * @license http://www.opensource.org/licenses/bsd-license.php
- * BSD License
- * @version Release: @package_version@
+ * @category Math
+ * @package Math_Numerical_RootFinding
+ * @subpackage Methods
+ * @author Firman Wandayandi <firman@php.net>
+ * @copyright 2004-2008 Firman Wandayandi
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @link http://pear.php.net/package/Math_Numerical_RootFinding
+ * @version Release: @package_version@
*/
class Math_Numerical_RootFinding_NewtonRaphson2
extends Math_Numerical_RootFinding_Common
@@ -61,10 +51,10 @@ class Math_Numerical_RootFinding_NewtonRaphson2
/**
* Constructor.
*
- * @param array $options (optional) Options.
+ * @param array $options (optional) Options.
*
- * @access public
- * @see Math_Numerical_RootFinding_Common::Math_Numerical_RootFinding_Common()
+ * @access public
+ * @see Math_Numerical_RootFinding_Common::Math_Numerical_RootFinding_Common()
*/
function Math_Numerical_RootFinding_NewtonRaphson2($options = null)
{
@@ -78,6 +68,7 @@ function Math_Numerical_RootFinding_NewtonRaphson2($options = null)
* Print out parameters description for compute() function.
*
* @access public
+ * @return void
*/
function infoCompute()
{
@@ -107,34 +98,43 @@ function infoCompute()
/**
* Newton-Raphson method for calculate double root (twin root).
*
- * @param callback $fxFunction Callback f(x) equation function or object/method tuple.
- * @param callback $dfx1Function Callback f'(x) equation function or object/method tuple.
- * @param callback $dfx2Function Callback f''(x) equation function or object/method tuple.
- * @param float $xR Initial guess.
+ * @param callback $fxFunction Callback f(x) equation function or object/method
+ * tuple.
+ * @param callback $dfx1Function Callback f'(x) equation function or
+ * object/method tuple.
+ * @param callback $dfx2Function Callback f''(x) equation function or
+ * object/method tuple.
+ * @param float $xR Initial guess.
*
- * @return float|PEAR_Error Root value on success or PEAR_Error on failure.
- * @access public
- * @see Math_Numerical_RootFinding_Common::validateEqFunction()
- * @see Math_Numerical_RootFinding_Common::getEqResult()
- * @see Math_Numerical_RootFinding_Common::isDivergentRow()
- * @see Math_Numerical_RootFinding_Newtonraphson::compute()
+ * @return float|PEAR_Error Root value on success or PEAR_Error on failure.
+ * @access public
+ * @see Math_Numerical_RootFinding_Common::validateEqFunction()
+ * @see Math_Numerical_RootFinding_Common::getEqResult()
+ * @see Math_Numerical_RootFinding_Common::isDivergentRow()
+ * @see Math_Numerical_RootFinding_Newtonraphson::compute()
*/
function compute($fxFunction, $dfx1Function, $dfx2Function, $xR)
{
// Validate f(x) equation function.
- $err = Math_Numerical_RootFinding_Common::validateEqFunction($fxFunction, $xR);
+ $err = Math_Numerical_RootFinding_Common::validateEqFunction(
+ $fxFunction, $xR
+ );
if (PEAR::isError($err)) {
return $err;
}
// Validate f'(x) equation function.
- $err = Math_Numerical_RootFinding_Common::validateEqFunction($dfx1Function, $xR);
+ $err = Math_Numerical_RootFinding_Common::validateEqFunction(
+ $dfx1Function, $xR
+ );
if (PEAR::isError($err)) {
return $err;
}
// Validate f''(x) equation function.
- $err = Math_Numerical_RootFinding_Common::validateEqFunction($dfx2Function, $xR);
+ $err = Math_Numerical_RootFinding_Common::validateEqFunction(
+ $dfx2Function, $xR
+ );
if (PEAR::isError($err)) {
return $err;
}
@@ -152,10 +152,14 @@ function compute($fxFunction, $dfx1Function, $dfx2Function, $xR)
$fxR = Math_Numerical_RootFinding_Common::getEqResult($fxFunction, $xR);
// Calculate f'(x[i]), where: x[i] = $xR.
- $d1xR = Math_Numerical_RootFinding_Common::getEqResult($dfx1Function, $xR);
+ $d1xR = Math_Numerical_RootFinding_Common::getEqResult(
+ $dfx1Function, $xR
+ );
// Calculate f''(x[i]), where: x[i] = $xR.
- $d2xR = Math_Numerical_RootFinding_Common::getEqResult($dfx2Function, $xR);
+ $d2xR = Math_Numerical_RootFinding_Common::getEqResult(
+ $dfx2Function, $xR
+ );
// Avoid division by zero.
if (pow($d1xR, 2) - ($fxR * $d2xR) == 0) {
@@ -173,13 +177,14 @@ function compute($fxFunction, $dfx1Function, $dfx2Function, $xR)
// Compute error.
$this->epsError = abs(($xN - $xR) / $xN);
- $epsErrors[] = $this->epsError;
+ $epsErrors[] = $this->epsError;
// Detect for divergent rows.
if ($this->isDivergentRows($epsErrors) &&
- $this->options['divergent_skip'])
- {
- return PEAR::raiseError('Iteration skipped, divergent rows detected');
+ $this->options['divergent_skip']) {
+ return PEAR::raiseError(
+ 'Iteration skipped, divergent rows detected'
+ );
break;
}
@@ -200,8 +205,6 @@ function compute($fxFunction, $dfx1Function, $dfx2Function, $xR)
// }}}
}
-// }}}
-
/*
* Local variables:
* mode: php
View
110 Math/Numerical/RootFinding/RalstonRabinowitz.php
@@ -4,8 +4,8 @@
// {{{ Header
/**
- * Driver file contains Math_Numerical_RootFinding_Bisection class to provide
- * Ralston and Rabinowitz method root finding calculation.
+ * Driver file contains Math_Numerical_RootFinding_Bisection class to provide Ralston
+ * and Rabinowitz method root finding calculation.
*
* PHP versions 4 and 5
*
@@ -20,38 +20,32 @@
* obtain it through the world-wide-web, please send an email
* to pear-dev@list.php.net so we can send you a copy immediately.
*
- * @category Math
- * @package Math_Numerical_RootFinding
- * @subpackage Methods
- * @author Firman Wandayandi <firman@php.net>
- * @copyright Copyright (c) 2004-2008 Firman Wandayandi
- * @license http://www.opensource.org/licenses/bsd-license.php
- * BSD License
- * @version CVS: $Id$
+ * @category Math
+ * @package Math_Numerical_RootFinding
+ * @subpackage Methods
+ * @author Firman Wandayandi <firman@php.net>
+ * @copyright 2004-2008 Firman Wandayandi
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @link http://pear.php.net/package/Math_Numerical_RootFinding
+ * @version CVS: $Id$
*/
-// }}}
-// {{{ Dependencies
-
/**
- * Load Math_Numerical_RootFinding_Common as base class.
+ * Math_Numerical_RootFinding_Common
*/
require_once 'Math/Numerical/RootFinding/Common.php';
-// }}}
-// {{{ Class: Math_Numerical_RootFinding_RalstonRabinowitz
-
/**
* Ralston and Rabinowitz method class.
*
- * @category Math
- * @package Math_Numerical_RootFinding
- * @subpackage Methods
- * @author Firman Wandayandi <firman@php.net>
- * @copyright Copyright (c) 2004-2008 Firman Wandayandi
- * @license http://www.opensource.org/licenses/bsd-license.php
- * BSD License
- * @version Release: @package_version@
+ * @category Math
+ * @package Math_Numerical_RootFinding
+ * @subpackage Methods
+ * @author Firman Wandayandi <firman@php.net>
+ * @copyright 2004-2008 Firman Wandayandi
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @link http://pear.php.net/package/Math_Numerical_RootFinding
+ * @version Release: @package_version@
*/
class Math_Numerical_RootFinding_RalstonRabinowitz
extends Math_Numerical_RootFinding_Common
@@ -61,10 +55,10 @@ class Math_Numerical_RootFinding_RalstonRabinowitz
/**
* Constructor.
*
- * @param array $options (optional) Options.
+ * @param array $options (optional) Options.
*
- * @access public
- * @see Math_Numerical_RootFinding_Common::Math_Numerical_RootFinding_Common()
+ * @access public
+ * @see Math_Numerical_RootFinding_Common::Math_Numerical_RootFinding_Common()
*/
function Math_Numerical_RootFinding_RalstonRabinowitz($options = null)
{
@@ -78,6 +72,7 @@ function Math_Numerical_RootFinding_RalstonRabinowitz($options = null)
* Print out parameters description for compute() function.
*
* @access public
+ * @return void
*/
function infoCompute()
{
@@ -106,28 +101,34 @@ function infoCompute()
/**
* Ralston and Rabinowitz method for calculate double root (twin root).
*
- * @param callback $fxFunction Callback f(x) equation function or object/method tuple.
- * @param callback $dxFunction Callback f'(x) equation function or object/method tuple.
- * @param float $xR0 First initial guess.
- * @param float $xR1 Second initial guess.
+ * @param callback $fxFunction Callback f(x) equation function or object/method
+ * tuple.
+ * @param callback $dxFunction Callback f'(x) equation function or object/method
+ * tuple.
+ * @param float $xR0 First initial guess.
+ * @param float $xR1 Second initial guess.
*
- * @return float|PEAR_Error Root value on success or PEAR_Error on failure.
- * @access public
- * @see Math_Numerical_RootFinding_Common::validateEqFunction()
- * @see Math_Numerical_RootFinding_Common::getEqResult()
- * @see Math_Numerical_RootFinding_Common::isDivergentRow()
- * @see Math_Numerical_RootFinding_Secant::compute()
+ * @return float|PEAR_Error Root value on success or PEAR_Error on failure.
+ * @access public
+ * @see Math_Numerical_RootFinding_Common::validateEqFunction()
+ * @see Math_Numerical_RootFinding_Common::getEqResult()
+ * @see Math_Numerical_RootFinding_Common::isDivergentRow()
+ * @see Math_Numerical_RootFinding_Secant::compute()
*/
function compute($fxFunction, $dxFunction, $xR0, $xR1)
{
// Validate f(x) equation function.
- $err = Math_Numerical_RootFinding_Common::validateEqFunction($fxFunction, $xR0);
+ $err = Math_Numerical_RootFinding_Common::validateEqFunction(
+ $fxFunction, $xR0
+ );
if (PEAR::isError($err)) {
return $err;
}
// Validate f'(x) equation function.
- $err = Math_Numerical_RootFinding_Common::validateEqFunction($dxFunction, $xR0);
+ $err = Math_Numerical_RootFinding_Common::validateEqFunction(
+ $dxFunction, $xR0
+ );
if (PEAR::isError($err)) {
return $err;
}
@@ -140,14 +141,22 @@ function compute($fxFunction, $dxFunction, $xR0, $xR1)
// detection.
$epsErrors = array();
- for($i = 1; $i <= $maxIteration; $i++) {
+ for ($i = 1; $i <= $maxIteration; $i++) {
// Calculate f(x[i-1]) and f'(x[1]), where: x[i-1] = $xR0.
- $fxR0 = Math_Numerical_RootFinding_Common::getEqResult($fxFunction, $xR0);
- $dxR0 = Math_Numerical_RootFinding_Common::getEqResult($dxFunction, $xR0);
+ $fxR0 = Math_Numerical_RootFinding_Common::getEqResult(
+ $fxFunction, $xR0
+ );
+ $dxR0 = Math_Numerical_RootFinding_Common::getEqResult(
+ $dxFunction, $xR0
+ );
// Calculate f(x[i]) and f'(x[1]), where: x[i] = $xR1.
- $fxR1 = Math_Numerical_RootFinding_Common::getEqResult($fxFunction, $xR1);
- $dxR1 = Math_Numerical_RootFinding_Common::getEqResult($dxFunction, $xR1);
+ $fxR1 = Math_Numerical_RootFinding_Common::getEqResult(
+ $fxFunction, $xR1
+ );
+ $dxR1 = Math_Numerical_RootFinding_Common::getEqResult(
+ $dxFunction, $xR1
+ );
// Calculate f(x[i-1]) / f'(x[i-1], where x[i-1] = $xR0.
$uxR0 = $fxR0 / $dxR0;
@@ -171,13 +180,14 @@ function compute($fxFunction, $dxFunction, $xR0, $xR1)
// Compute error.
$this->epsError = abs(($xN - $xR1) / $xN);
- $epsErrors[] = $this->epsError;
+ $epsErrors[] = $this->epsError;
// Detect for divergent rows.
if ($this->isDivergentRows($epsErrors) &&
- $this->options['divergent_skip'])
- {
- return PEAR::raiseError('Iteration skipped, divergent rows detected');
+ $this->options['divergent_skip']) {
+ return PEAR::raiseError(
+ 'Iteration skipped, divergent rows detected'
+ );
break;
}
@@ -201,8 +211,6 @@ function compute($fxFunction, $dxFunction, $xR0, $xR1)
// }}}
}
-// }}}
-
/*
* Local variables:
* mode: php
View
100 Math/Numerical/RootFinding/Secant.php
@@ -1,11 +1,7 @@
<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
-
-// {{{ Header
-
/**
- * Driver file contains Math_Numerical_RootFinding_Bisection class to provide
- * Secant method root finding calculation.
+ * Driver file contains Math_Numerical_RootFinding_Bisection class to provide Secant
+ * method root finding calculation.
*
* PHP versions 4 and 5
*
@@ -20,51 +16,44 @@
* obtain it through the world-wide-web, please send an email
* to pear-dev@list.php.net so we can send you a copy immediately.
*
- * @category Math
- * @package Math_Numerical_RootFinding
- * @subpackage Methods
- * @author Firman Wandayandi <firman@php.net>
- * @copyright Copyright (c) 2004-2008 Firman Wandayandi
- * @license http://www.opensource.org/licenses/bsd-license.php
- * BSD License
- * @version CVS: $Id$
+ * @category Math
+ * @package Math_Numerical_RootFinding
+ * @subpackage Methods
+ * @author Firman Wandayandi <firman@php.net>
+ * @copyright 2004-2008 Firman Wandayandi
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @link http://pear.php.net/package/Math_Numerical_RootFinding
+ * @version CVS: $Id$
*/
-// }}}
-// {{{ Dependencies
-
/**
* Math_Numerical_RootFinding_Common
*/
require_once 'Math/Numerical/RootFinding/Common.php';
-// }}}
-// {{{ Class: Math_Numerical_RootFinding_Secant
-
/**
* Secant method class.
*
- * @category Math
- * @package Math_Numerical_RootFinding
- * @subpackage Methods
- * @author Firman Wandayandi <firman@php.net>
- * @copyright Copyright (c) 2004-2008 Firman Wandayandi
- * @license http://www.opensource.org/licenses/bsd-license.php
- * BSD License
- * @version Release: @package_version@
+ * @category Math
+ * @package Math_Numerical_RootFinding
+ * @subpackage Methods
+ * @author Firman Wandayandi <firman@php.net>
+ * @copyright 2004-2008 Firman Wandayandi
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @link http://pear.php.net/package/Math_Numerical_RootFinding
+ * @version Release: @package_version@
*/
-class Math_Numerical_RootFinding_Secant
-extends Math_Numerical_RootFinding_Common
+class Math_Numerical_RootFinding_Secant extends Math_Numerical_RootFinding_Common
{
// {{{ Constructor
/**
* Constructor.
*
- * @param array $options (optional) Options.
+ * @param array $options (optional) Options.
*
- * @access public
- * @see Math_Numerical_RootFinding_Common::Math_Numerical_RootFinding_Common()
+ * @access public
+ * @see Math_Numerical_RootFinding_Common::Math_Numerical_RootFinding_Common()
*/
function Math_Numerical_RootFinding_Secant($options = null)
{
@@ -78,6 +67,7 @@ function Math_Numerical_RootFinding_Secant($options = null)
* Print out parameters description for compute() function.
*
* @access public
+ * @return void
*/
function infoCompute()
{
@@ -103,21 +93,24 @@ function infoCompute()
/**
* Secant method.
*
- * @param callback $fxFunction Callback f(x) equation function or object/method tuple.
- * @param float $xR0 First initial guess.
- * @param float $xR1 Second initial guess.
+ * @param callback $fxFunction Callback f(x) equation function or object/method
+ * tuple.
+ * @param float $xR0 First initial guess.
+ * @param float $xR1 Second initial guess.
*
- * @return float|PEAR_Error Root value on success or PEAR_Error on failure.
- * @access public
- * @see Math_Numerical_RootFinding_Common::validateEqFunction()
- * @see Math_Numerical_RootFinding_Common::getEqResult()
- * @see Math_Numerical_RootFinding_Common::isDivergentRow()
- * @see Math_Numerical_RootFinding_Ralstonrabinowitz::compute()
+ * @return float|PEAR_Error Root value on success or PEAR_Error on failure.
+ * @access public
+ * @see Math_Numerical_RootFinding_Common::validateEqFunction()
+ * @see Math_Numerical_RootFinding_Common::getEqResult()
+ * @see Math_Numerical_RootFinding_Common::isDivergentRow()
+ * @see Math_Numerical_RootFinding_Ralstonrabinowitz::compute()
*/
function compute($fxFunction, $xR0, $xR1)
{
// Validate f(x) equation function.
- $err = Math_Numerical_RootFinding_Common::validateEqFunction($fxFunction, $xR0);
+ $err = Math_Numerical_RootFinding_Common::validateEqFunction(
+ $fxFunction, $xR0
+ );
if (PEAR::isError($err)) {
return $err;
}
@@ -130,12 +123,16 @@ function compute($fxFunction, $xR0, $xR1)
// detection.
$epsErrors = array();
- for($i = 1; $i <= $maxIteration; $i++) {
+ for ($i = 1; $i <= $maxIteration; $i++) {
// Calculate f(x[i-1]), where: x[i-1] = $xR0.
- $fxR0 = Math_Numerical_RootFinding_Common::getEqResult($fxFunction, $xR0);
+ $fxR0 = Math_Numerical_RootFinding_Common::getEqResult(
+ $fxFunction, $xR0
+ );
// Calculate f(x[i]), where: x[i] = $xR1.
- $fxR1 = Math_Numerical_RootFinding_Common::getEqResult($fxFunction, $xR1);
+ $fxR1 = Math_Numerical_RootFinding_Common::getEqResult(
+ $fxFunction, $xR1
+ );
// Avoid division by zero.
if ($fxR0 - $fxR1 == 0) {
@@ -153,13 +150,14 @@ function compute($fxFunction, $xR0, $xR1)
// Compute error.
$this->epsError = abs(($xN - $xR1) / $xN);
- $epsErrors[] = $this->epsError;
+ $epsErrors[] = $this->epsError;
// Detect for divergent rows.
if ($this->isDivergentRows($epsErrors) &&
- $this->options['divergent_skip'])
- {
- return PEAR::raiseError('Iteration skipped, divergent rows detected');
+ $this->options['divergent_skip']) {
+ return PEAR::raiseError(
+ 'Iteration skipped, divergent rows detected'
+ );
break;
}
@@ -183,8 +181,6 @@ function compute($fxFunction, $xR0, $xR1)
// }}}
}
-// }}}
-
/*
* Local variables:
* mode: php
Please sign in to comment.
Something went wrong with that request. Please try again.