近似值的高效数组归一化

发布于 2024-09-17 21:20:05 字数 97 浏览 4 评论 0原文

我正在寻找用近似值(ushort[100])替换其目标值的有效方法。

有两个目标值 (ushort x, 2x),ushort[] 中的每个值都近似于这两个值之一。

I'm looking for the efficient way of replacing approximate values (ushort[100]) for their target values.

There are two target values (ushort x, 2x), each value in the ushort[] approximates one of these two.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

请叫√我孤独 2024-09-24 21:20:05
  • 使用每个近似值的预期值创建一个排序数组
  • ,二分搜索最接近的预期
  • 替换
  • make a sorted array with the expected values
  • for every approx, binary search for the closest expected
  • replace
玩套路吗 2024-09-24 21:20:05

您始终可以定义一个距离度量,该距离度量允许您将每个近似值分配给预期值,将这些值视为“箱”,如直方图中所示。处理这些值意味着用与该值距离最小的已知值替换近似值。

You could always just define a distance metric that allows you to assigns each of the approximate values to the expected values, considering those to be "bins", as in a histogram. Processing the values then means replacing the approximate value with the known value that has the smallest distance to that value.

久而酒知 2024-09-24 21:20:05
var a = target1 > words[i] ? target1 - words[i] : words[i] - target1;
var b = target2 > words[i] ? target2 - words[i] : words[i] - target2;
(OR)
var as = target1 - words[i];
var bs = target2 - words[i];
a = as + (as >> 31) ^ (as >> 31);
b = bs + (bs >> 31) ^ (bs >> 31);

if (a < b)
   normalized[i] = target1;
else
   normalized[i] = target2;
var a = target1 > words[i] ? target1 - words[i] : words[i] - target1;
var b = target2 > words[i] ? target2 - words[i] : words[i] - target2;
(OR)
var as = target1 - words[i];
var bs = target2 - words[i];
a = as + (as >> 31) ^ (as >> 31);
b = bs + (bs >> 31) ^ (bs >> 31);

if (a < b)
   normalized[i] = target1;
else
   normalized[i] = target2;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文