Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to print an Armadillo matrix in gdb?

I'm using gdb to debug my c++ program. I'm using the armadillo numerical library to define my matrices. I have an armadillo matrix defined like so:

mat A = randu<mat>(5,5);

Is it possible to print the whole matrix while using the gdb debugger?

like image 463
Eddy Avatar asked Feb 29 '12 12:02

Eddy


1 Answers

The simplest way is to print directly in gdb, unfortunately no fancy format

> print *A.mem@5@5
$1 = {{0.84018771715470952, 0.39438292681909304,0.78309922375860586,0.79844003347607329, 0.91164735793678431},
{0.19755136929338396, 0.33522275571488902, 0.768229594811904, 0.27777471080318777, 0.55396995579543051}, 
{0.47739705186216025, 0.62887092476192441, 0.36478447279184334, 0.51340091019561551, 0.95222972517471283}, 
{0.91619506800370065, 0.63571172795990094, 0.71729692943268308, 0.14160255535580338, 0.60696887625705864}, 
{0.016300571624329581, 0.24288677062973696, 0.13723157678601872, 0.80417675422699042, 0.15667908925408455}}
like image 57
Claes Rolen Avatar answered Sep 28 '22 10:09

Claes Rolen