215 parser.add_option(
"-d",
"--dataFmt", default=
"%.2f",
216 help=
"Format for values")
217 parser.add_option(
"-f",
"--formatWidth", type=
"int",
218 default=8, help=
"Field width for values")
219 parser.add_option(
"-o",
"--origin", type=
"str", nargs=
"+",
220 help=
"Origin of the part of the object to print")
223 "eigenObject", help=
"Expression giving Eigen::Matrix/Vector to show")
225 "nx", help=
"Width of patch to print", type=
"int", default=0, nargs=
"?")
227 "ny", help=
"Height of patch to print", type=
"int", default=0, nargs=
"?")
229 opts = parser.parse_args(args)
233 (opts, args) = parser.parse_args(args)
238 raise gdb.GdbError(
"Please specify an object")
239 opts.eigenObject = args.pop(0)
241 opts.nx, opts.ny = 0, 0
243 opts.nx = int(args.pop(0))
245 opts.ny = int(args.pop(0))
249 "Unrecognised trailing arguments: %s" %
" ".join(args))
251 var = gdb.parse_and_eval(opts.eigenObject)
253 if not re.search(
r"(Eigen|LinearTransform)::(Matrix|Vector)", str(var.type)):
255 "Please specify an eigen matrix or vector, not %s" % var.type)
257 if re.search(
r"shared_ptr<", str(var.type)):
258 var = var[
"px"].dereference()
260 if var.type.code == gdb.TYPE_CODE_PTR:
261 var = var.dereference()
263 isMatrix = re.search(
r"Matrix", str(var.type))
268 if len(opts.origin) != 2:
269 raise gdb.GdbError(
"Please specify both x0 and y0")
271 x0 = gdb.parse_and_eval(opts.origin[0])
272 y0 = gdb.parse_and_eval(opts.origin[1])
283 if nx == 1
and ny == 1:
284 print(
"%g" % self.
_vget(var, x0))
287 NX = 0, var[
"m_storage"][
"n"]
290 if len(opts.origin) != 1:
291 raise gdb.GdbError(
"Please only specify x0")
293 x0 = gdb.parse_and_eval(opts.origin[0])
302 print(
"%g" % self.
_vget(var, x0))
308 print(
"%-4s" %
"", end=
' ')
309 for x
in range(x0, min(NX, x0 + nx)):
310 print(
"%*d" % (opts.formatWidth, x), end=
' ')
313 for y
in range(y0, min(NY, y0 + ny)):
314 print(
"%-4d" % y, end=
' ')
315 for x
in range(x0, min(NX, x0 + nx)):
316 print(
"%*s" % (opts.formatWidth, (opts.dataFmt %
317 self.
_mget(var, x, y))), end=
' ')
320 for x
in range(x0, min(NX, x0 + nx)):
321 print(
"%*s" % (opts.formatWidth, (opts.dataFmt %
322 self.
_vget(var, x))), end=
' ')