- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我想访问 System.Numerics.Vector<T>
的元素在 C# 中。我正在关注官方文档:https://learn.microsoft.com/en-us/dotnet/api/system.numerics.vector-1?view=netcore-2.2
我能够创建具有不同数据类型的不同向量。例如:var test = new Vector<double>(new double[] { 1.0, 2.0, 1.0 });
但现在我遇到了问题,我无法调用 test.Count;无法在 System.Numerics.Vector<T>
类型的实例上调用 Count .
我可以使用 access operator []
访问单个元素, 但我不知道向量中有多少个元素。
根据文档,应该有公共(public)属性(property):
public static int Count { get; }
但我无法调用我的 System.Numerics.Vector<T>
实例.相反,我只能以静态方式调用它,如下所示:
Vector<double>.Count
这等于 2。
我也可以调用:
Vector<Int32>.Count
返回:4 和
Vector<Int16>.Count
返回 8.
现在我真的有点困惑,关于如何使用这个静态属性。起初,我以为这个属性会返回存储在向量中的元素数(如文档中所述)。其次,我想,这个属性返回内存中向量的大小,但这个数字从 double 增加到 Int32 到 Int16。
有趣的是,我不能从我创建的实例中调用这个静态属性:
var test = new Vector<double>(new double[] { 1.0, 2.0, 1.0 });
我不能调用test.Count
!
你知道如何访问System.Numerics.Vector<T>
的元素吗? ?
最佳答案
没有办法做到这一点。 Vector<T>
是固定大小的,因为它试图优化硬件加速。文档状态:
The count of a
Vector<T>
instance is fixed, but its upper limit is CPU-register dependent. It is intended to be used as a building block for vectorizing large algorithms.
在 https://source.dot.net/#System.Private.CoreLib/shared/System/Numerics/Vector.cs 阅读源代码
表明如果传入的数据较少,它就会抛出所需的数据,并且最多只占用 Count
。传入的项目数。
关于c# - 如何在 C# 中获取 System.Numerics.Vector 的元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54442779/
我以默认数字 js 格式存储数字和货币格式。我允许用户根据他们的区域设置拥有自己的格式。我正在尝试弄清楚如何将他们的自定义格式转换回默认格式,以便一致地存储它,以防他们更改语言环境。 例如设置电流:
我以默认数字 js 格式存储数字和货币格式。我允许用户根据他们的区域设置拥有自己的格式。我正在尝试弄清楚如何将他们的自定义格式转换回默认格式,以便一致地存储它,以防他们更改语言环境。 例如设置电流:
我正在为 as.POSIXct.numeric 苦苦挣扎。以下代码有效: dates <- structure(c(1649285787, 1651134684), class = c("POSIXc
我正在使用 Azavea Numeric Scala 库进行通用数学运算。但是,我无法将它们与 Scala Collections API 一起使用,因为它们需要 scala Numeric,并且
我在仔细阅读文档时注意到,Numeric 类有一个方法 arg,其解释为“如果值为正,则返回 0,否则返回 pi。直接在这个上面的docs 是一个名为 angle 的方法,其解释相同。 我不明白这个方
我试图总结两列并获得错误:二进制运算符的非数字参数。但是,这两列都是数字。因此,我不明白为什么会收到此错误消息。谢谢你的帮助? data_all% mutate(total='5min'+'10min
我正在尝试创建六个站点上物种丰富度的热图。 我有一个站点与物种的矩阵,其中有数字丰度数据。 但是,当我运行代码时,R返回一个错误,指出我的矩阵是非数字的。 谁能想到这个?我感到难过。 导出的数据框链接
我正在使用一个返回 float 的java函数 private float getEventScaledX(float eventX, float resX) { return (eventX
我有一个函数接收 SearchCriteria 的集合对象:列名或键、运算符( = ### && :letter_date <= ### 我在两个日期之间查找。我不能两次使用相同的参数名称,因此我在遍
我正在尝试将值插入到表中,但我不断收到错误消息 ORA-01858: a non-numeric character was found where a numeric was expected 这是
sort 提供两种数字排序。这是来自手册页: -g, --general-numeric-sort compare according to general numerica
我遇到了一个奇怪的问题,将日期列与 SYSDATE 进行比较会产生以下错误: 01858. 00000 - "a non-numeric character was found where a nu
这是表格 CREATE TABLE Employee (EmpID number(5) primary key, SIN Number(9) Not null, Las
在 bash 中按 alt + numeric 会得到 (arg [numeric]) 那是什么? (这类问题更适合问人,而不是试图“猜测”正确的术语以通过互联网搜索文档)。 最佳答案 您要搜索的字词
当我执行准备好的语句时,我得到了 ORA-01858:在需要数字的地方发现了一个非数字字符。当我搜索一些论坛时,他们说这是因为日期数据类型。我准备好的声明是 insert into OPRS_ZON
我正在使用 Elasticsearch Java API 创建索引并编写搜索查询。 索引是在各种字段上创建的。字段之一是创建索引的数字(整数)。 现在我们得到的输入是字符串的形式。我们必须在所有字段中
我想重新映射启用 Numlock 的数字小键盘,使其表现得像关闭 Numlock 的数字小键盘,包括能够在按住 Shift/Ctrl 的情况下扩展选择范围。 我遇到的问题如下 Numpad8::Up
所以我有一个训练集,其中一个属性的域如下: A = {Type1, Type2, Type3, ... ,Type5} 如果域保持这种形式,我就无法应用线性回归,因为数学假设不可能成立,例如: H =
为什么我会通过 Java 应用程序执行此查询从 Oracle 收到上述 SQL 错误? SELECT * FROM TestSchema.TestTable WHERE userid = :userI
我在 JSP 中添加了以下代码,并在将实体保存到数据库时出现一些异常。 $('.validateWeight').click(function(event) { var id = event.tar
我是一名优秀的程序员,十分优秀!