如何在 .NET 中将 Vector128<float> 转换为 Vector128<int>?

Posted

技术标签:

【中文标题】如何在 .NET 中将 Vector128<float> 转换为 Vector128<int>?【英文标题】:How to cast Vector128<float> into Vector128<int> in .NET? 【发布时间】:2019-11-01 18:24:21 【问题描述】:

我正在寻找 .NET 3.0+ 等价的无操作内在 _mm_castps_si128。如何将Vector128&lt;float&gt; 快速转换为Vector128&lt;int&gt;

【问题讨论】:

【参考方案1】:

这样做的预期方法是通过方法Vector128.As()。

Vector128<float> mf = Vector128.Create(42f);
Vector128<int> mi = mf.As<int, float>(); // acts as '_mm_castps_si128'

【讨论】:

以上是关于如何在 .NET 中将 Vector128<float> 转换为 Vector128<int>?的主要内容,如果未能解决你的问题,请参考以下文章