summaryrefslogtreecommitdiffstats
path: root/src/math
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2006-08-16 13:12:44 +0000
committerKore Nordmann <github@kore-nordmann.de>2006-08-16 13:12:44 +0000
commit441e0054ad7b4f38d4596cf3ceda08ec00cc2127 (patch)
tree108710ffe5523dabdf735e538693acb68478288d /src/math
parentbb028918891c1840d200530a0cb458db9a07cf95 (diff)
downloadzetacomponents-graph-441e0054ad7b4f38d4596cf3ceda08ec00cc2127.zip
zetacomponents-graph-441e0054ad7b4f38d4596cf3ceda08ec00cc2127.tar.gz
- Added transpose method to matrix class
Diffstat (limited to 'src/math')
-rw-r--r--src/math/matrix.php25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/math/matrix.php b/src/math/matrix.php
index dae2f64..f64d7e4 100644
--- a/src/math/matrix.php
+++ b/src/math/matrix.php
@@ -228,6 +228,31 @@ class ezcGraphMatrix
}
}
+ /**
+ * Transpose matrix
+ *
+ * @return ezcGraphMatrix Transposed matrix
+ */
+ public function transpose()
+ {
+ $matrix = clone $this;
+
+ $this->rows = $matrix->columns();
+ $this->columns = $matrix->rows();
+
+ $this->matrix = array();
+
+ for ( $i = 0; $i < $this->columns; ++$i )
+ {
+ for ( $j = 0; $j < $this->rows; ++$j )
+ {
+ $this->matrix[$i][$j] = $matrix->get( $j, $i );
+ }
+ }
+
+ return $this;
+ }
+
/**
* Multiplies two matrices
*
OpenPOWER on IntegriCloud