- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我在 Nicolai M. Josuttis 编写的 C++ 书中读到了有关 std::valarray
的内容。他在他的书 The C++ Standard Library 第 17.4 章中写道:
The valarray classes were not designed very well. In fact, nobody tried to determine whether the final specification worked. This happened because nobody felt “responsible” for these classes. The people who introduced valarrays to the C++ standard library left the committee long before the standard was finished. As a consequence, valarrays are rarely used.
那么,在哪里使用 std::valarray
是个好主意?
最佳答案
创建 Valarrays 是为了让编译器更快地执行。然而,这些优化可以通过其他方式实现,并且很少使用 valarrays。
std::valarray and helper classes are defined to be free of certain forms of aliasing, thus allowing operations on these classes to be optimized similar to the effect of the keyword restrict in the C programming language. In addition, functions and operators that take valarray arguments are allowed to return proxy objects to make it possible for the compiler to optimize an expression such as v1 = av2 + v3; as a single loop that executes v1[i] = av2[i] + v3[i]; avoiding any temporaries or multiple passes. .....
换句话说,valarrays 应该用在有很多值的地方,这些值主要传递给简单的表达式。
Only rarely are valarrays optimized any further, as in e.g. Intel Parallel Studio.
您可以在 cppreference 找到更多信息。
关于c++ - 在哪里使用 "std::valarray"是个好主意?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46465011/
我正在更新一个旧的经典 ASP 站点并且我需要存储密码,因此考虑到经典 ASP 的局限性,我对如何处理这个问题自然有点过于谨慎。 我同时使用盐和胡椒(胡椒是存储在服务器上而不是数据库中的常量),我只是
我已经设置了我的数据库来记录每次失败的登录尝试。我以为我会将失败尝试的次数乘以 0.05 秒之类的。就像是: time_nanosleep(0, (50000000 * $fa
我想测量 1GB LAN 上消息代理的广播消息延迟。 消息以 pub sub 方式传输,一个发布者,多个消费者。生产者使用系统时钟(C# 中的 DateTime.Now)为每条消息加上时间戳,消费者通
我正在尝试学习代码契约并了解它们的用处。 我有一个 WPF 应用程序,因此很多代码注定要在 UI 线程上独占运行。相当多的实用程序类期望仅从 UI 线程调用。 在我的代码中加入这些是个好主意吗?为什么
我加入了一家小公司,该公司主要销售一种网络应用程序。 Web 应用程序中的数据非常敏感,以至于所有数据都经过字段级加密。应用程序使用 ASP.NET Web API 2(C#) 编写,前端为 html
对于我网站的后端,只有少数人可见,我有一个系统,通过 ajax 与 php 进行通信,如下所示: function ajax(url, opts) { var progress = false
我们有相当大的文档集,我们希望我们的用户能够查看和过滤这些文档。为了加快速度,我们只向客户发送有限数量的文件。但是,由于我们确实需要客户端能够过滤文档,因此我们需要一种方法来发送他们可以过滤的键和值。
我从 14 岁起就开始阅读游戏引擎书籍(那时候我什么都不懂:P)几年后,我想开始为我的游戏引擎编写数学基础。我一直在思考如何设计这个“图书馆”。 (我的意思是“有组织的文件集”)每隔几年就会出现新的
我们正在使用 Rails 为餐厅构建 SaaS 后端。我们直接与 POS 集成,因此每个 POS 不断发送我们存储的客户订单以供以后处理。我们在大约 1,000 个地点进行了这种 POS 集成,每月向
我正在设计一个系统,但我认为让最终用户能够删除数据库中的条目并不是一个好主意。我是这么认为的,因为通常最终用户一旦获得管理员权限,最终可能会在数据库中弄得一团糟,然后求助于我来修复它。 当然,如果他们
我正在考虑使用 RESTful Web 服务构建应用程序。我的想法是将应用程序的 RESTful(json 等)部分构建为独立的,然后将前端(例如 html/css/js/等)构建为该服务的客户端,虽
我有一种情况,我要保留对需要持久化的 ivar 的引用。在一个对象中,我有一个指向另一个对象中的 ivars 的指针数组,这些指针在程序的整个生命周期中都被使用。换句话说,我不只是传递一个引用来检索一
有没有prototype没有任何 DOM/ajax 部件的 fork?我真的更喜欢 jQuery,并且不想背负额外的包袱。到目前为止,我一直在使用优秀的 JS.Class库,它甚至不触及内置类原型(p
我正在从事的项目需要我编写大量重复代码。例如,如果我想在我的代码中加载一个名为“logo.png”的图像文件,我会这样写:位图标志图片; ... // Init logoImage = load("l
关闭。这个问题是opinion-based .它目前不接受答案。 想改善这个问题吗?更新问题,以便可以通过 editing this post 用事实和引文回答问题. 3年前关闭。 Improve t
我有一个小型网站,大约有 5-10 名管理员。我已将其设置为监视每个管理员正在做什么(添加项目、删除项目等)。我在我们的管理面板中有一个列表,显示了集体管理部门之前执行的 10 项事件。今天,我决定每
我看到将 PostgeSQL 数据库转储到一个大 SQL 文件中,然后提交并推送到远程 Git 存储库的方式可能是一个了不起的备份解决方案:我获得了所有版本的历史记录、散列、安全传输、单向(真的很难通
我正在开发一个需要本地化和国际化的 Web 应用程序。我突然想到我可以使用依赖注入(inject)框架来做到这一点。假设我声明了一个接口(interface) ILocalResources(在本示例
更新 :正如我所料,社区针对这个问题给出的合理建议是“衡量并观察”。 chibacity posted an answer一些非常好的测试为我做了这件事;同时,我自己写了一个测试;我看到的性能差异实际
我想知道使用 new 运算符创建对象但不将返回的对象分配给任何变量是否是个好主意。本质上,我只是在同一行中调用这些方法。例如: new Object().ToString(); 好吧,我知道上面的行不
我是一名优秀的程序员,十分优秀!