使用NXN矩阵计算最近的邻居
假设我有nxn t随机矩阵,我如何找到矩阵中最近的邻居元素?
Supposed I have nxn T random matrix, how can I find nearest neighbors element of the matrix?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据您的图像描述,我通常的方法是生成索引矩阵,计算每个元素和给定位置之间的欧几里得距离,然后判断距离是否为1:
此方法的优势是:
对于大型矩阵,考虑到边界条件,您可以通过这样的功能实现它:
According to your image description, my usual way is to generate an index matrix, calculate the Euclidean distance between each element and a given position, and then judge whether the distance is 1:
The advantage of this method are:
For a large matrix, considering the boundary conditions, you can implement it through such a function: