有没有一种方法可以在Visual Studio调试中打印Armadillo矩阵或矢量? [英] Is there a way to print an Armadillo matrix or vector in Visual Studio Debug?
问题描述
我想知道是否有任何方法可以在Visual Studio(尤其是VS2012)的调试部分中显示矢量/矩阵项的值.
此问题与以下问题非常相似:
但是我没有弄清楚这种方法是否也适用于VS.
谢谢.
此.natvis
XML代码在Visual Studio 2013中可以正常工作.我在Visual Studio 2013中添加了@Claes Rolen XML,对我来说这不能正常工作./p>
诀窍是使用<IndexListItems>
可视化犰狳矩阵
声明并初始化代码
mat tMat(3, 3);
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
tMat(i, j) = i + j;
}
.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>{{ {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>
调试器中的结果图像:
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:
这篇关于有没有一种方法可以在Visual Studio调试中打印Armadillo矩阵或矢量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!