ios - NSLog matrix_float4x4 或 simd::float4x4
<p><p>Apple 没有提供类似于“OpenCV”或“Eigen”的加速矩阵调试工具吗?</p>
<h3>Eigen 和 OpenCV 如何打印矩阵的示例代码</h3>
<pre><code>Eigen::Matrix4f matrix;
std::cout << matrix << std::endl;
</code></pre>
<h3>4x4 矩阵的输出</h3>
<pre><code>-0.483662 0.86859 0.10781 51.8456
0.8650280.4555970.210137 29.6781
0.1334050.194894 -0.971709 192.69
0 0 0 1
</code></pre>
<h3>我想要的粗略近似,但还不够笼统。</h3>
<p>这是我的快速和肮脏的版本。我最终可能会在处理 C 或 C++ 版本的地方使它更彻底,但我真的希望 Apple 提供它,我只是没有找到文档。</p>
<pre><code>void logSIMD(const simd::float4x4 &matrix)
{
std::stringstream output;
int columnCount = sizeof(matrix.columns) / sizeof(matrix.columns);
for (int column = 0; column < columnCount; column++) {
int rowCount = sizeof(matrix.columns) / sizeof(matrix.columns);
for (int row = 0; row < rowCount; row++) {
output << std::setfill(' ') << std::setw(9) << matrix.columns;
output << ' ';
}
output << std::endl;
}
output << std::endl;
NSLog(@"%s", output.str().c_str());
}
</code></pre>
<p>有没有人为 Accelerate 中各种大小的矩阵和向量的 C/C++ 打印提供通用解决方案,或者 Apple 提供了我还没有找到的功能?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p><code><simd/simd.h></code>没有提供这样的功能。这有一些很好的理由,最重要的是,人们对于如何格式化向量和矩阵非常固执己见,所以没有提供的格式将是一小部分用户真正想要的,而且它足够直截了当编写您自己的打印例程,完全符合您的要求。一个可以处理任意用户定义格式的完全通用的格式化程序函数会更合理,但与 <code><simd/simd.h></code> 接口(interface)的其余部分相比,它会非常重,所以它不会看起来也不太合适。</p>
<p>也就是说,如果您认为这些作为 API 有用,并且您可以提出一个令人信服的理由来说明为什么您的首选格式是正确的标准化格式,我鼓励您向 Apple 报告一个错误,请求该功能.</p></p>
<p style="font-size: 20px;">关于ios - NSLog matrix_float4x4 或 simd::float4x4,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/29533104/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/29533104/
</a>
</p>
页:
[1]