mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-07-02 03:05:10 +08:00
Small cleanup of GDB pretty printer code
This commit is contained in:
parent
dee6428a71
commit
2a6594de29
@ -27,7 +27,6 @@
|
|||||||
|
|
||||||
import gdb
|
import gdb
|
||||||
import re
|
import re
|
||||||
import itertools
|
|
||||||
from bisect import bisect_left
|
from bisect import bisect_left
|
||||||
|
|
||||||
|
|
||||||
@ -54,18 +53,18 @@ class _MatrixEntryIterator(object):
|
|||||||
if self.currentCol >= self.cols:
|
if self.currentCol >= self.cols:
|
||||||
raise StopIteration
|
raise StopIteration
|
||||||
|
|
||||||
self.currentRow = self.currentRow + 1
|
self.currentRow += 1
|
||||||
if self.currentRow >= self.rows:
|
if self.currentRow >= self.rows:
|
||||||
self.currentRow = 0
|
self.currentRow = 0
|
||||||
self.currentCol = self.currentCol + 1
|
self.currentCol += 1
|
||||||
else:
|
else:
|
||||||
if self.currentRow >= self.rows:
|
if self.currentRow >= self.rows:
|
||||||
raise StopIteration
|
raise StopIteration
|
||||||
|
|
||||||
self.currentCol = self.currentCol + 1
|
self.currentCol += 1
|
||||||
if self.currentCol >= self.cols:
|
if self.currentCol >= self.cols:
|
||||||
self.currentCol = 0
|
self.currentCol = 0
|
||||||
self.currentRow = self.currentRow + 1
|
self.currentRow += 1
|
||||||
|
|
||||||
return row, col
|
return row, col
|
||||||
|
|
||||||
@ -126,7 +125,7 @@ class EigenMatrixPrinter:
|
|||||||
row, col = super(EigenMatrixPrinter._Iterator, self).__next__()
|
row, col = super(EigenMatrixPrinter._Iterator, self).__next__()
|
||||||
|
|
||||||
item = self.dataPtr.dereference()
|
item = self.dataPtr.dereference()
|
||||||
self.dataPtr = self.dataPtr + 1
|
self.dataPtr += 1
|
||||||
if self.cols == 1: # if it's a column vector
|
if self.cols == 1: # if it's a column vector
|
||||||
return '[%d]' % (row,), item
|
return '[%d]' % (row,), item
|
||||||
elif self.rows == 1: # if it's a row vector
|
elif self.rows == 1: # if it's a row vector
|
||||||
@ -134,7 +133,6 @@ class EigenMatrixPrinter:
|
|||||||
return '[%d,%d]' % (row, col), item
|
return '[%d,%d]' % (row, col), item
|
||||||
|
|
||||||
def children(self):
|
def children(self):
|
||||||
|
|
||||||
return self._Iterator(self.rows, self.cols, self.data, self.rowMajor)
|
return self._Iterator(self.rows, self.cols, self.data, self.rowMajor)
|
||||||
|
|
||||||
def to_string(self):
|
def to_string(self):
|
||||||
@ -268,14 +266,13 @@ class EigenQuaternionPrinter:
|
|||||||
if self.currentElement >= 4: # there are 4 elements in a quaternion
|
if self.currentElement >= 4: # there are 4 elements in a quaternion
|
||||||
raise StopIteration
|
raise StopIteration
|
||||||
|
|
||||||
self.currentElement = self.currentElement + 1
|
self.currentElement += 1
|
||||||
|
|
||||||
item = self.dataPtr.dereference()
|
item = self.dataPtr.dereference()
|
||||||
self.dataPtr = self.dataPtr + 1
|
self.dataPtr += 1
|
||||||
return '[%s]' % (self.elementNames[element],), item
|
return '[%s]' % (self.elementNames[element],), item
|
||||||
|
|
||||||
def children(self):
|
def children(self):
|
||||||
|
|
||||||
return self._Iterator(self.data)
|
return self._Iterator(self.data)
|
||||||
|
|
||||||
def to_string(self):
|
def to_string(self):
|
||||||
@ -285,15 +282,15 @@ class EigenQuaternionPrinter:
|
|||||||
def cast_eigen_block_to_matrix(val):
|
def cast_eigen_block_to_matrix(val):
|
||||||
# Get the type of the variable (and convert to a string)
|
# Get the type of the variable (and convert to a string)
|
||||||
# Example: 'const Eigen::Block<Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false> const, -1, -1, false>'
|
# Example: 'const Eigen::Block<Eigen::Block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, -1, -1, false> const, -1, -1, false>'
|
||||||
type = str(val.type)
|
val_type = str(val.type)
|
||||||
|
|
||||||
# Extract the Eigen::Matrix type from the Block:
|
# Extract the Eigen::Matrix type from the Block:
|
||||||
# From the previous example: Eigen::Matrix<double, -1, -1, 0, -1, -1>
|
# From the previous example: Eigen::Matrix<double, -1, -1, 0, -1, -1>
|
||||||
begin = type.find('Eigen::Matrix<')
|
begin = val_type.find('Eigen::Matrix<')
|
||||||
end = type.find('>', begin) + 1
|
end = val_type.find('>', begin) + 1
|
||||||
|
|
||||||
# Convert the Eigen::Block to an Eigen::Matrix
|
# Convert the Eigen::Block to an Eigen::Matrix
|
||||||
return val.cast(gdb.lookup_type(type[begin:end]))
|
return val.cast(gdb.lookup_type(val_type[begin:end]))
|
||||||
|
|
||||||
|
|
||||||
def build_eigen_dictionary():
|
def build_eigen_dictionary():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user