LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Public Member Functions | Private Member Functions | List of all members
lsst.gdb.afw.printers.GdbOptionParser.PrintEigenCommand Class Reference
Inheritance diagram for lsst.gdb.afw.printers.GdbOptionParser.PrintEigenCommand:

Public Member Functions

def __init__
 
def invoke
 

Private Member Functions

def _mget
 
def _vget
 

Detailed Description

Print an eigen Matrix or Vector
    Usage: show eigen <matrix> [x0 y0 [nx ny]]
   show eigen <vector> [x0 [nx]]

Definition at line 186 of file printers.py.

Constructor & Destructor Documentation

def lsst.gdb.afw.printers.GdbOptionParser.PrintEigenCommand.__init__ (   self)

Definition at line 192 of file printers.py.

193  def __init__ (self):
194  super (PrintEigenCommand, self).__init__ ("show eigen",
195  gdb.COMMAND_DATA,
196  gdb.COMPLETE_SYMBOL)
197 

Member Function Documentation

def lsst.gdb.afw.printers.GdbOptionParser.PrintEigenCommand._mget (   self,
  var,
  x,
  y = 0 
)
private

Definition at line 198 of file printers.py.

199  def _mget(self, var, x, y=0):
200  return getEigenValue(var, x, y)
def lsst.gdb.afw.printers.GdbOptionParser.PrintEigenCommand._vget (   self,
  var,
  x 
)
private

Definition at line 201 of file printers.py.

202  def _vget(self, var, x):
203  return getEigenValue(var, x)
def lsst.gdb.afw.printers.GdbOptionParser.PrintEigenCommand.invoke (   self,
  args,
  fromTty 
)

Definition at line 204 of file printers.py.

205  def invoke (self, args, fromTty):
206  self.dont_repeat()
207 
208  parser = GdbOptionParser("show eigen")
209  parser.add_option("-d", "--dataFmt", default="%.2f", help="Format for values")
210  parser.add_option("-f", "--formatWidth", type="int", default=8, help="Field width for values")
211  parser.add_option("-o", "--origin", type="str", nargs="+",
212  help="Origin of the part of the object to print")
213  if False:
214  parser.add_option("eigenObject", help="Expression giving Eigen::Matrix/Vector to show")
215  parser.add_option("nx", help="Width of patch to print", type="int", default=0, nargs="?")
216  parser.add_option("ny", help="Height of patch to print", type="int", default=0, nargs="?")
217 
218  opts = parser.parse_args(args)
219  if opts.help:
220  return
221  else:
222  (opts, args) = parser.parse_args(args)
223  if opts.help:
224  return
225 
226  if not args:
227  raise gdb.GdbError("Please specify an object")
228  opts.eigenObject = args.pop(0)
229 
230  opts.nx, opts.ny = 0, 0
231  if args:
232  opts.nx = int(args.pop(0))
233  if args:
234  opts.ny = int(args.pop(0))
235 
236  if args:
237  raise gdb.GdbError("Unrecognised trailing arguments: %s" % " ".join(args))
238 
239  var = gdb.parse_and_eval(opts.eigenObject)
240 
241  if not re.search(r"(Eigen|LinearTransform)::(Matrix|Vector)", str(var.type)):
242  raise gdb.GdbError("Please specify an eigen matrix or vector, not %s" % var.type)
243 
244  if re.search(r"shared_ptr<", str(var.type)):
245  var = var["px"].dereference()
246 
247  if var.type.code == gdb.TYPE_CODE_PTR:
248  var = var.dereference() # be nice
249 
250  isMatrix = re.search(r"Matrix", str(var.type))
251  if isMatrix:
252  NX, NY = getEigenMatrixDimensions(var)
253 
254  if opts.origin:
255  if len(opts.origin) != 2:
256  raise gdb.GdbError("Please specify both x0 and y0")
257 
258  x0 = gdb.parse_and_eval(opts.origin[0])
259  y0 = gdb.parse_and_eval(opts.origin[1])
260  else:
261  x0, y0 = 0, 0
262 
263  nx = opts.nx
264  ny = opts.ny
265  if nx == 0:
266  nx = NX
267  if ny == 0:
268  ny = NY
269 
270  if nx == 1 and ny == 1:
271  print "%g" % self._vget(var, x0)
272  return
273  else:
274  NX = 0, var["m_storage"]["n"]
275 
276  if opts.origin:
277  if len(opts.origin) != 1:
278  raise gdb.GdbError("Please only specify x0")
279 
280  x0 = gdb.parse_and_eval(opts.origin[0])
281  else:
282  x0 = 0
283 
284  nx = opts.nx
285  if nx == 0:
286  nx = NX
287 
288  if nx == 1:
289  print "%g" % self._vget(var, x0)
290  return
291  #
292  # OK, finally time to print
293  #
294  if isMatrix:
295  print "%-4s" % "",
296  for x in range(x0, min(NX, x0 + nx)):
297  print "%*d" % (opts.formatWidth, x),
298  print ""
299 
300  for y in range(y0, min(NY, y0 + ny)):
301  print "%-4d" % y,
302  for x in range(x0, min(NX, x0 + nx)):
303  print "%*s" % (opts.formatWidth, (opts.dataFmt % self._mget(var, x, y))),
304  print ""
305  else:
306  for x in range(x0, min(NX, x0 + nx)):
307  print "%*s" % (opts.formatWidth, (opts.dataFmt % self._vget(var, x))),
308  print ""
309 
PrintEigenCommand()

The documentation for this class was generated from the following file: