I'm wondering whether there is any method to show vector/matrix entries values in the debugging section on Visual Studio (in particular VS2012).
This question is very similar to the one posted in:
Is there a way to print an Armadillo matrix in gdb?
however I did not manage to figure out whether this approach also applies to VS.
Thanks.
This .natvis
XML code works fine in visual studio 2013. I added @Claes Rolen XML in visual studio 2013 and that dose not work fine for me.
The trick is to use <IndexListItems>
to visualize armadillo matrix
declare and initialize code
mat tMat(3, 3);
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
tMat(i, j) = i + j;
}
.Natvis File
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="arma::Col<*>">
<DisplayString>{{ Size = {n_elem} }}</DisplayString>
<Expand>
<Item Name="[size]">n_elem</Item>
<ArrayItems>
<Size>n_elem </Size>
<ValuePointer>mem</ValuePointer>
</ArrayItems>
</Expand>
</Type>
<Type Name="arma::Mat<*>">
<DisplayString>{{ {n_rows} x {n_cols} = {n_elem} }}</DisplayString>
<Expand>
<IndexListItems>
<Size>n_cols</Size>
<ValueNode >
mem+($i*n_rows),[n_rows]
</ValueNode>
</IndexListItems>
</Expand>
</Type>
<Type Name="arma::subview_col<*>">
<DisplayString>{{ {n_rows} }}</DisplayString>
<Expand>
<ArrayItems>
<Size>n_rows</Size>
<ValuePointer>colmem</ValuePointer>
</ArrayItems>
</Expand>
</Type>
</AutoVisualizer>
And Result image in debugger:
You may use visualizers in Visual Studio, don´t know from which version but in Visual Studio 2015 you may add a .natvis
file to the project.
arma.natvis:
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="arma::Col<*>">
<DisplayString>{{ Size = {n_elem} }}</DisplayString>
<Expand>
<Item Name="[size]">n_elem</Item>
<ArrayItems>
<Size>n_elem </Size>
<ValuePointer>mem</ValuePointer>
</ArrayItems>
</Expand>
</Type>
<Type Name="arma::Mat<*>">
<DisplayString>{{ Size = {n_rows} x {n_cols} }}</DisplayString>
<Expand>
<Item Name="[size]">n_elem</Item>
<ArrayItems>
<Direction>Backward</Direction>
<Rank>2</Rank>
<Size>$i==0 ? n_rows : n_cols</Size>
<ValuePointer>mem</ValuePointer>
</ArrayItems>
</Expand>
</Type>
</AutoVisualizer>
This will show you readable data for the basic ARMADILLO
types.
An example of how some types are showed: