aboutsummaryrefslogtreecommitdiffhomepage
path: root/debug
diff options
context:
space:
mode:
authorGravatar Benjamin Schindler <bschindler@inf.ethz.ch>2009-12-08 19:12:26 +0100
committerGravatar Benjamin Schindler <bschindler@inf.ethz.ch>2009-12-08 19:12:26 +0100
commitf0315295e9ae2fd8afdc05d3e5b790b4660ffc58 (patch)
tree12442ac5ec9361c72ee1f70a45544fe7ceaef9ae /debug
parent4da991eaa811b8e8c31253e1b00d95b0d721d8ef (diff)
Handle row and col major matrices in the gdb pretty printer
Diffstat (limited to 'debug')
-rw-r--r--debug/gdb/printers.py37
1 files changed, 27 insertions, 10 deletions
diff --git a/debug/gdb/printers.py b/debug/gdb/printers.py
index 0b4230498..9f6cfa5d5 100644
--- a/debug/gdb/printers.py
+++ b/debug/gdb/printers.py
@@ -58,6 +58,11 @@ class EigenMatrixPrinter:
self.rows = int(template_params[1])
self.cols = int(template_params[2])
+ self.options = 0 # default value
+ if len(template_params) > 3:
+ self.options = template_params[3];
+
+ self.rowMajor = (int(self.options) & 0x1)
if self.rows == 10000:
self.rows = val['m_storage']['m_rows']
@@ -76,38 +81,50 @@ class EigenMatrixPrinter:
self.data = self.data.cast(self.innerType.pointer())
class _iterator:
- def __init__ (self, rows, cols, dataPtr):
+ def __init__ (self, rows, cols, dataPtr, rowMajor):
self.rows = rows
self.cols = cols
self.dataPtr = dataPtr
self.currentRow = 0
self.currentCol = 0
+ self.rowMajor = rowMajor
def __iter__ (self):
return self
def next(self):
- if self.currentCol >= self.cols:
- raise StopIteration
-
+
row = self.currentRow
col = self.currentCol
- self.currentRow = self.currentRow + 1
- if self.currentRow >= self.rows:
- self.currentRow = 0
+ if self.rowMajor == 0:
+ if self.currentCol >= self.cols:
+ raise StopIteration
+
+ self.currentRow = self.currentRow + 1
+ if self.currentRow >= self.rows:
+ self.currentRow = 0
+ self.currentCol = self.currentCol + 1
+ else:
+ if self.currentRow >= self.rows:
+ raise StopIteration
+
self.currentCol = self.currentCol + 1
+ if self.currentCol >= self.cols:
+ self.currentCol = 0
+ self.currentRow = self.currentRow + 1
+
item = self.dataPtr.dereference()
self.dataPtr = self.dataPtr + 1
-
+
return ('[%d, %d]' % (row, col), item)
def children(self):
- return self._iterator(self.rows, self.cols, self.data)
+ return self._iterator(self.rows, self.cols, self.data, self.rowMajor)
def to_string(self):
- return "Eigen::Matrix<%s,%d,%d> (data ptr: %s)" % (self.innerType, self.rows, self.cols, self.data)
+ return "Eigen::Matrix<%s,%d,%d,%s> (data ptr: %s)" % (self.innerType, self.rows, self.cols, "RowMajor" if self.rowMajor else "ColMajor", self.data)
def build_eigen_dictionary ():
pretty_printers_dict[re.compile('^Eigen::Matrix<.*>$')] = lambda val: EigenMatrixPrinter(val)