Doc Block changes

git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@87642 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
Mark Baker 2012-03-11 19:24:20 +00:00
parent 891981928d
commit 4bb4f5ebc8
8 changed files with 235 additions and 0 deletions

View File

@ -40,6 +40,13 @@ class PHPExcel_Shared_Date
const CALENDAR_WINDOWS_1900 = 1900; // Base date of 1st Jan 1900 = 1.0
const CALENDAR_MAC_1904 = 1904; // Base date of 2nd Jan 1904 = 1.0
/*
* Names of the months of the year, indexed by shortname
* Planned usage for locale settings
*
* @public
* @var string[]
*/
public static $_monthNames = array( 'Jan' => 'January',
'Feb' => 'February',
'Mar' => 'March',
@ -54,8 +61,20 @@ class PHPExcel_Shared_Date
'Dec' => 'December'
);
/*
* Base calendar year to use for calculations
*
* @private
* @var int
*/
private static $ExcelBaseDate = self::CALENDAR_WINDOWS_1900;
/*
* Object type for PHP Date/Time values
*
* @private
* @var string
*/
public static $dateTimeObjectType = 'DateTime';

View File

@ -35,18 +35,60 @@
*/
class PHPExcel_Best_Fit
{
/*
* Indicator flag for a calculation error
*
* @protected
* @var boolean
*/
protected $_error = False;
/*
* Algorithm type to use for best-fit
*
* @protected
* @var string
*/
protected $_bestFitType = 'undetermined';
/*
* Number of entries in the sets of x- and y-value arrays
*
* @protected
* @var int
*/
protected $_valueCount = 0;
/*
* X-value dataseries of values
*
* @protected
* @var float[]
*/
protected $_xValues = array();
/*
* Y-value dataseries of values
*
* @protected
* @var float[]
*/
protected $_yValues = array();
/*
* X-value series of values
*
* @protected
* @var boolean
*/
protected $_adjustToZero = False;
/*
* Y-value series of best-fit values
*
* @protected
* @var float[]
*/
protected $_yBestFitValues = array();
protected $_goodnessOfFit = 1;
@ -88,11 +130,23 @@ class PHPExcel_Best_Fit
} // function getBestFitType()
/**
* Return the Y-Value for a specified value of X
*
* @param float $xValue X-Value
* @return float Y-Value
*/
public function getValueOfYForX($xValue) {
return False;
} // function getValueOfYForX()
/**
* Return the X-Value for a specified value of Y
*
* @param float $yValue Y-Value
* @return float X-Value
*/
public function getValueOfXForY($yValue) {
return False;
} // function getValueOfXForY()
@ -103,11 +157,23 @@ class PHPExcel_Best_Fit
} // function getValueOfXForY()
/**
* Return the Equation of the best-fit line
*
* @param int $dp Number of places of decimal precision to display
* @return string
*/
public function getEquation($dp=0) {
return False;
} // function getEquation()
/**
* Return the Slope of the line
*
* @param int $dp Number of places of decimal precision to display
* @return string
*/
public function getSlope($dp=0) {
if ($dp != 0) {
return round($this->_slope,$dp);
@ -116,6 +182,12 @@ class PHPExcel_Best_Fit
} // function getSlope()
/**
* Return the standard error of the Slope
*
* @param int $dp Number of places of decimal precision to display
* @return string
*/
public function getSlopeSE($dp=0) {
if ($dp != 0) {
return round($this->_slopeSE,$dp);
@ -124,6 +196,12 @@ class PHPExcel_Best_Fit
} // function getSlopeSE()
/**
* Return the Value of X where it intersects Y = 0
*
* @param int $dp Number of places of decimal precision to display
* @return string
*/
public function getIntersect($dp=0) {
if ($dp != 0) {
return round($this->_intersect,$dp);
@ -132,6 +210,12 @@ class PHPExcel_Best_Fit
} // function getIntersect()
/**
* Return the standard error of the Intersect
*
* @param int $dp Number of places of decimal precision to display
* @return string
*/
public function getIntersectSE($dp=0) {
if ($dp != 0) {
return round($this->_intersectSE,$dp);

View File

@ -41,16 +41,34 @@ class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
protected $_bestFitType = 'exponential';
/**
* Return the Y-Value for a specified value of X
*
* @param float $xValue X-Value
* @return float Y-Value
*/
public function getValueOfYForX($xValue) {
return $this->getIntersect() * pow($this->getSlope(),($xValue - $this->_Xoffset));
} // function getValueOfYForX()
/**
* Return the X-Value for a specified value of Y
*
* @param float $yValue Y-Value
* @return float X-Value
*/
public function getValueOfXForY($yValue) {
return log(($yValue + $this->_Yoffset) / $this->getIntersect()) / log($this->getSlope());
} // function getValueOfXForY()
/**
* Return the Equation of the best-fit line
*
* @param int $dp Number of places of decimal precision to display
* @return string
*/
public function getEquation($dp=0) {
$slope = $this->getSlope($dp);
$intersect = $this->getIntersect($dp);
@ -59,6 +77,12 @@ class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
} // function getEquation()
/**
* Return the Slope of the line
*
* @param int $dp Number of places of decimal precision to display
* @return string
*/
public function getSlope($dp=0) {
if ($dp != 0) {
return round(exp($this->_slope),$dp);
@ -67,6 +91,12 @@ class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
} // function getSlope()
/**
* Return the Value of X where it intersects Y = 0
*
* @param int $dp Number of places of decimal precision to display
* @return string
*/
public function getIntersect($dp=0) {
if ($dp != 0) {
return round(exp($this->_intersect),$dp);

View File

@ -41,16 +41,34 @@ class PHPExcel_Linear_Best_Fit extends PHPExcel_Best_Fit
protected $_bestFitType = 'linear';
/**
* Return the Y-Value for a specified value of X
*
* @param float $xValue X-Value
* @return float Y-Value
*/
public function getValueOfYForX($xValue) {
return $this->getIntersect() + $this->getSlope() * $xValue;
} // function getValueOfYForX()
/**
* Return the X-Value for a specified value of Y
*
* @param float $yValue Y-Value
* @return float X-Value
*/
public function getValueOfXForY($yValue) {
return ($yValue - $this->getIntersect()) / $this->getSlope();
} // function getValueOfXForY()
/**
* Return the Equation of the best-fit line
*
* @param int $dp Number of places of decimal precision to display
* @return string
*/
public function getEquation($dp=0) {
$slope = $this->getSlope($dp);
$intersect = $this->getIntersect($dp);

View File

@ -41,16 +41,34 @@ class PHPExcel_Logarithmic_Best_Fit extends PHPExcel_Best_Fit
protected $_bestFitType = 'logarithmic';
/**
* Return the Y-Value for a specified value of X
*
* @param float $xValue X-Value
* @return float Y-Value
*/
public function getValueOfYForX($xValue) {
return $this->getIntersect() + $this->getSlope() * log($xValue - $this->_Xoffset);
} // function getValueOfYForX()
/**
* Return the X-Value for a specified value of Y
*
* @param float $yValue Y-Value
* @return float X-Value
*/
public function getValueOfXForY($yValue) {
return exp(($yValue - $this->getIntersect()) / $this->getSlope());
} // function getValueOfXForY()
/**
* Return the Equation of the best-fit line
*
* @param int $dp Number of places of decimal precision to display
* @return string
*/
public function getEquation($dp=0) {
$slope = $this->getSlope($dp);
$intersect = $this->getIntersect($dp);

View File

@ -49,6 +49,12 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
} // function getOrder()
/**
* Return the Y-Value for a specified value of X
*
* @param float $xValue X-Value
* @return float Y-Value
*/
public function getValueOfYForX($xValue) {
$retVal = $this->getIntersect();
$slope = $this->getSlope();
@ -61,11 +67,23 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
} // function getValueOfYForX()
/**
* Return the X-Value for a specified value of Y
*
* @param float $yValue Y-Value
* @return float X-Value
*/
public function getValueOfXForY($yValue) {
return ($yValue - $this->getIntersect()) / $this->getSlope();
} // function getValueOfXForY()
/**
* Return the Equation of the best-fit line
*
* @param int $dp Number of places of decimal precision to display
* @return string
*/
public function getEquation($dp=0) {
$slope = $this->getSlope($dp);
$intersect = $this->getIntersect($dp);
@ -83,6 +101,12 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
} // function getEquation()
/**
* Return the Slope of the line
*
* @param int $dp Number of places of decimal precision to display
* @return string
*/
public function getSlope($dp=0) {
if ($dp != 0) {
$coefficients = array();

View File

@ -41,16 +41,34 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
protected $_bestFitType = 'power';
/**
* Return the Y-Value for a specified value of X
*
* @param float $xValue X-Value
* @return float Y-Value
*/
public function getValueOfYForX($xValue) {
return $this->getIntersect() * pow(($xValue - $this->_Xoffset),$this->getSlope());
} // function getValueOfYForX()
/**
* Return the X-Value for a specified value of Y
*
* @param float $yValue Y-Value
* @return float X-Value
*/
public function getValueOfXForY($yValue) {
return pow((($yValue + $this->_Yoffset) / $this->getIntersect()),(1 / $this->getSlope()));
} // function getValueOfXForY()
/**
* Return the Equation of the best-fit line
*
* @param int $dp Number of places of decimal precision to display
* @return string
*/
public function getEquation($dp=0) {
$slope = $this->getSlope($dp);
$intersect = $this->getIntersect($dp);
@ -59,6 +77,12 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
} // function getEquation()
/**
* Return the Value of X where it intersects Y = 0
*
* @param int $dp Number of places of decimal precision to display
* @return string
*/
public function getIntersect($dp=0) {
if ($dp != 0) {
return round(exp($this->_intersect),$dp);

View File

@ -21,11 +21,23 @@ class trendClass
const TREND_BEST_FIT = 'Bestfit';
const TREND_BEST_FIT_NO_POLY = 'Bestfit_no_Polynomials';
/*
* Names of the best-fit trend analysis methods
*
* @private
* @var string[]
*/
private static $_trendTypes = array( self::TREND_LINEAR,
self::TREND_LOGARITHMIC,
self::TREND_EXPONENTIAL,
self::TREND_POWER
);
/*
* Names of the best-fit trend polynomial orders
*
* @private
* @var string[]
*/
private static $_trendTypePolyOrders = array( self::TREND_POLYNOMIAL_2,
self::TREND_POLYNOMIAL_3,
self::TREND_POLYNOMIAL_4,
@ -33,6 +45,12 @@ class trendClass
self::TREND_POLYNOMIAL_6
);
/*
* Cached results for each method when trying to identify which provides the best fit
*
* @private
* @var PHPExcel_Shared_Best_Fit[]
*/
private static $_trendCache = array();