matrix - 如何在 IlNumerics 数组中查找行
问题描述
我想根据它的值从矩阵 A 中检索一个子集。
例如,从矩阵 A(见下文),我想获得第一列值等于 9 的行预期输出:
{ 9, 12, 21 },
{ 9, 13, 23 },
{ 9, 14, 24 },
Array<double> A = new double[,] {
{ 1, 9, 20 },
{ 2, 11, 21 },
{ 9, 12, 21 },
{ 9, 13, 23 },
{ 9, 14, 24 },
{ 6, 15, 25 }
};
Array<double> test1 = A[A[0] == 9];
Array<double> test2 = A[A == 9];
///Get the first column
Array<double> D = A[full, 0];
///test 3: Get all rows where the value for the first column is 9
Array<double> match = D.Where(e => e == 9).ToArray();
///test 4:Get all rows where the value for the first column is 9 from A
Array<double> match2 = A.Where(e => e == 9).ToArray();
解决方案
如果没有测试,我想这应该可以解决问题:
Array<double> match = A[A[full, 0] == 9, full];
推荐阅读
- duplicates - 停止应用制作工具创建重复关系
- powershell - 如何在 Batch 或 Powershell 中将二进制转换为十六进制?
- c# - 无法从 VSTO(Excel 加载项)连接到 ENCRYPTED Access db (accdb) - 但可以从 Console-App
- r - 如何在 r 中的 Y 轴上创建具有自定义偏移的多线图?
- android - Mockwebserver 和 OkHttpIdlingResrouce 连接异常
- php - 需要一种更简洁的方法来打破 php 的平局
- javascript - 将 div 中的每个字母拆分为自己的跨度
- javascript - 如何将 html 输入转换为 js 提示?
- telerik - 在 Jenkins 构建期间恢复 Telerik 的 nuget 包
- android - Android udp 服务器无法通过 SIM 卡(4G)接收数据