diff options
author | Kore Nordmann <github@kore-nordmann.de> | 2006-09-20 15:12:20 +0000 |
---|---|---|
committer | Kore Nordmann <github@kore-nordmann.de> | 2006-09-20 15:12:20 +0000 |
commit | 9d8baefbdf52a83adfb2efed5ebe4bd7b7f765a7 (patch) | |
tree | a5b7b9bdd5be0ffcbf3456fdb0c6c681d3de2c14 /src/math | |
parent | 3fe622918bd1c3e2694ecb2c7d244b9c33eb5693 (diff) | |
download | zetacomponents-graph-9d8baefbdf52a83adfb2efed5ebe4bd7b7f765a7.zip zetacomponents-graph-9d8baefbdf52a83adfb2efed5ebe4bd7b7f765a7.tar.gz |
- Added and improved documentation
Diffstat (limited to 'src/math')
-rw-r--r-- | src/math/boundings.php | 54 | ||||
-rw-r--r-- | src/math/matrix.php | 85 | ||||
-rw-r--r-- | src/math/polynom.php | 12 |
3 files changed, 122 insertions, 29 deletions
diff --git a/src/math/boundings.php b/src/math/boundings.php index 78ce6cb..13426a3 100644 --- a/src/math/boundings.php +++ b/src/math/boundings.php @@ -1,17 +1,60 @@ <?php - +/** + * File containing the ezcGraphBoundings class + * + * @package Graph + * @version //autogentag// + * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + * @access private + */ +/** + * Provides a class representing boundings in a cartesian coordinate system. + * + * Currently only works with plane rectangular boundings, should be enhanced by + * rotated rectangular boundings. + * + * @package Graph + * @access private + */ class ezcGraphBoundings { + /** + * Top left x coordinate + * + * @var float + */ public $x0 = 0; + /** + * Top left y coordinate + * + * @var float + */ public $y0 = 0; + /** + * Bottom right x coordinate + * + * @var float + */ public $x1 = false; + /** + * Bottom right y coordinate + * + * @var float + */ public $y1 = false; /** - * Empty constructor + * Constructor + * + * @param float $x0 Top left x coordinate + * @param float $y0 Top left y coordinate + * @param float $x1 Bottom right x coordinate + * @param float $y1 Bottom right y coordinate + * @return ezcGraphBoundings */ public function __construct( $x0 = 0, $y0 = 0, $x1 = false, $y1 = false ) { @@ -37,7 +80,12 @@ class ezcGraphBoundings } /** - * Throws a BasePropertyNotFound exception. + * Getter for calculated values depending on the boundings. + * - 'width': Width of bounding recangle + * - 'height': Height of bounding recangle + * + * @param string $name Name of property to get + * @return mixed Calculated value */ public function __get( $name ) { diff --git a/src/math/matrix.php b/src/math/matrix.php index eed5c5b..9ce978f 100644 --- a/src/math/matrix.php +++ b/src/math/matrix.php @@ -6,19 +6,45 @@ * @version //autogentag// * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved. * @license http://ez.no/licenses/new_bsd New BSD License + * @access private */ /** * Provides a genereic matrix class with basic math operations * * @package Graph + * @access private */ class ezcGraphMatrix { + /** + * Count of matrix rows + * + * @var int + */ protected $rows; + /** + * Count of matrix columns + * + * @var int + */ protected $columns; + /** + * Array containing matrix values. + * + * // Matrix + * array( + * // Rows + * array( + * // Column values + * (float) + * ) + * ) + * + * @var array( array( float ) ) + */ protected $matrix; /** @@ -51,7 +77,7 @@ class ezcGraphMatrix /** * Create matrix from array * - * Use the array values to set matrix values + * Use an array with float values to set matrix values. * * @param array $values Array with values * @return ezcGraphMatrix Modified matrix @@ -75,7 +101,7 @@ class ezcGraphMatrix /** * Init matrix * - * Sets matrix to identity matrix + * Sets matrix to identity matrix. * * @return ezcGraphMatrix Modified matrix */ @@ -137,7 +163,7 @@ class ezcGraphMatrix /** * Set a single matrix value * - * Sets the value of the matrix at the given position + * Sets the value of the matrix at the given position. * * @param int $i Column * @param int $j Row @@ -379,23 +405,20 @@ class ezcGraphMatrix return $polynom; } - public function __toString() - { - $string = sprintf( "%d x %d matrix:\n", $this->rows, $this->columns ); - - for ( $i = 0; $i < $this->rows; ++$i ) - { - $string .= '| '; - for ( $j = 0; $j < $this->columns; ++$j ) - { - $string .= sprintf( '%04.2f ', $this->get( $i, $j ) ); - } - $string .= "|\n"; - } - - return $string; - } - + /** + * Build LR decomposition from matrix + * + * Use Cholesky-Crout algorithm to get LR decomposition of the current + * matrix. + * + * Will return an array with two matrices: + * array( + * 'l' => (ezcGraphMatrix) $left, + * 'r' => (ezcGraphMatrix) $right, + * ) + * + * @return array( ezcGraphMatrix ) + */ public function LRdecomposition() { /** @@ -451,5 +474,27 @@ class ezcGraphMatrix 'r' => $r, ); } + + /** + * Returns a string representation of the matrix + * + * @return string + */ + public function __toString() + { + $string = sprintf( "%d x %d matrix:\n", $this->rows, $this->columns ); + + for ( $i = 0; $i < $this->rows; ++$i ) + { + $string .= '| '; + for ( $j = 0; $j < $this->columns; ++$j ) + { + $string .= sprintf( '%04.2f ', $this->get( $i, $j ) ); + } + $string .= "|\n"; + } + + return $string; + } } ?> diff --git a/src/math/polynom.php b/src/math/polynom.php index 6939252..42b969d 100644 --- a/src/math/polynom.php +++ b/src/math/polynom.php @@ -6,11 +6,13 @@ * @version //autogentag// * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved. * @license http://ez.no/licenses/new_bsd New BSD License + * @access private */ /** * Provides a class for generic operations on polynoms * * @package Graph + * @access private */ class ezcGraphPolynom { @@ -26,15 +28,13 @@ class ezcGraphPolynom * 2 * x^3 + .5 * x - 3 * Array: * array ( - * 3 => 2, - * 1 => .5, - * 0 => -3, + * (int) 3 => (float) 2, + * (int) 1 => (float) .5, + * (int) 0 => (float) -3, * ) * - * @param int $columns Number of columns - * @param int $rows Number of rows * @param array $values Array with values - * @return void + * @return ezcGraphPolynom */ public function __construct( array $values = array() ) { |