问题标签 [forall]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
837 浏览

python - 可以使用 numba.guvectorize 来模拟并行 forall / prange?

作为使用 Python 进行数据分析和数值计算的用户,而不是真正的“编码器”,我一直错过了一种在多个内核上分发令人尴尬的并行循环计算的非常低开销的方法。据我了解,Numba 中曾经有 prange 构造,但由于“不稳定和性能问题”而被放弃

在使用新开源的@guvectorize 装饰器时,我找到了一种使用它来几乎无开销地模拟后期 prange 功能的方法。

感谢 Continuum Analytics 的工作人员,我很高兴现在手头有这个工具,并且在网络上没有找到任何明确提到 @guvectorize 的使用的东西。尽管对于之前一直在使用 NumbaPro 的人来说这可能是微不足道的,但我将其发布给所有那些非编码人员(请参阅我对这个“问题”的回答)。

0 投票
0 回答
504 浏览

oracle - Oracle:FORALL SAVE EXCEPTIONS 不起作用

我正在尝试使用 INSERT 语句的 SAVE EXCEPTIONS 子句处理 FORALL 异常。该过程包含两个简单的表格,如下所示;

这里唯一的区别是列类型的大小。任何插入超过 20 个字符的字符串值的尝试都会导致处理错误。

这是脚本;

不知何故,当为一个超过 20 多个字符的记录的数据集执行以下块时,我只收到这条错误消息;

“ORA-06502:PL/SQL:数字或值错误:批量绑定:截断绑定”

提前感谢您的帮助。

0 投票
3 回答
23566 浏览

oracle - ORACLE:插入对象类型集合的表值

创建了以下类型;

我想简单地将数据集插入到表中;

这个工作正常,但是否有可能更改“VALUES”子句以避免命名源对象中的每个属性?我想要这样的东西:

任何帮助都感激不尽。

0 投票
0 回答
73 浏览

scala - 使用 Scala ForAll 生成多个对象

我有这个简单的对象:

这就是我生成多个对象的方式:

用法:

我的问题:

因此,如果我想生成例如 100 个Person对象,有什么建议如何在不指定这种方式的情况下做到这一点?

0 投票
3 回答
1420 浏览

nested - 如何在 Drools 中进行嵌套 foralls?

问题

考虑这些类:

考虑到这个自然语言规则:

当书柜中的所有页面都是黑色时,执行 A

简单的方法是嵌套 forall 子句,但在 Drools 中不能这样做,因为 forall 子句只允许在里面使用模式(不是条件元素,什么是 forall 子句)!

那么我该如何在 Drools 中表达这一点呢?

0 投票
1 回答
132 浏览

z3 - 界定普遍量化的变量

我想知道是否可以在 Z3 中限定一个普遍量化变量的值范围。

例如,假设我有一个名为“time”的 Real 类型变量,它用于对系统中的时间进行建模。假设我有一个断言,它说某个一元函数“func1”的值应始终在 1 到 100 之间。该函数将输入作为时间变量。在 Z3 中表示,我将属性编码如下:

  1. ForAll(time, And(func1(time) >= 1, func1(time) <= 100))

    请注意,我明确需要对时间变量进行普遍量化,因为如果我注入以下类型的属性,我希望 Z3 能够让我感到不安:

  2. Exists(time, func1(time) == 101)

    就我对 Z3 的理解而言,所有常量都具有数学(理论)而不是计算机(实际)实现,即它们的值不受约束(不幸的是,我目前无法指出我读过这篇文章的资源)。假设随着时间的推移我在我的系统中建模时间,并且根据系统约束它不能运行超过 x 小时,我可以使用它并说时间值在 0 和 x*60'*60 之间以给出最大值执行时间以秒为单位。我知道我可以使用以下断言断言时间的允许值:

  3. And(time >= 0, time <= x*60*60)

    但它会影响 1 中给出的全称量化吗?

因此,这将导致如果属性 2 被注入并且对于我指定的时间值x*60*60 + 1,它不应该被取消设置,因为ForAll它仅对时间值有效。

0 投票
1 回答
2158 浏览

oracle - 批量收集和 ForAll - Oracle

我正在寻找从记录类型(按表索引)访问列的语法。下面是示例代码。我应该如何在需要来自 V_Emprec 记录类型的 empid 的 Declare 块中运行更新脚本。我还创建了一个需要相同参数(empid)的过程。

这可以使用 %Rowtype 来完成,还是我需要使用 emp_stage.empid%type 创建类型?如果我为 Empid 和 Ename 创建 2 种类型作为 emp_stg.column_name%type,我可以使用这些类型来替换使用 Rowtype v_emprec 的插入脚本吗?

请告诉语法来做到这一点。

谢谢

0 投票
1 回答
5219 浏览

oracle - Oracle Bulk Collect with Limit and For All 未正确处理所有记录

我需要通过存储过程处理 Oracle 表的近 60k 条记录。处理过程是,对于每个这样的行,我需要删除和更新第二个表中的一行,并在第三个表中插入一行。

使用光标循环,该过程大约需要 6-8 小时才能完成。如果我切换到带限制的批量收集,执行时间会减少但处理不正确。以下是程序的批量收集版本

对于大约 20k 的这些记录,第一次删除操作被正确处理,但后续更新和插入没有被处理。对于剩余的 40k 记录,所有三个操作都得到了正确处理。

我错过了什么吗?另外,我可以与 Bulk Collect 一起使用的最大 LIMIT 值是多少?

0 投票
1 回答
119 浏览

haskell - ScopedTypeVariables and RankNTypes with GHC.TypeLits

I'm trying to use DataKinds along with type-level literals to make a type safe currency conversion library. So far I have defined these data types:

Along with a function that allows me to convert between them:

Here, I have used ScopedTypeVariables to supply the constraint KnownSymbol a to symbolVal SProxy. This works fine, however, I would like to be able to make the conversion rates update from an external source, perhaps a text file or an API such as fixer.

Obviously, I could just wrap the return type in IO, forming

but I would like to be able to keep a pure API. My first thought was to have the conversion rate map be obtained using unsafePerformIO, but this is unsafe so I instead thought I could use another function getConvert with a type to the effect of

(i.e an IO action returning a convert type function) so that it could be used like this:

However, I have been unable to get this to type check - GHC complains that it:

When I had GHC infer the type of return convert, it did not infer the type I wanted but instead moved the forall a b to the prenex position, which type checks, until I try to use convert' <- getConvert, at which point it fails saying that there is No instance for (KnownSymbol n0)

My question is why does this not type check, and what would be the correct type for the function getConvert?

First I thought that it may be the fact both ScopedTypeVariables and RankNTypes use the forall quantifier in different ways, but toggling RankNTypes has had no effect. I also tried moving the quantifier to the front as GHC suggested but this does not give me the rank-2 type that I need.

0 投票
1 回答
264 浏览

oracle - Oracle FORALL 更新异常

我正在使用 FORALL 语句来更新表中的大量寄存器,我需要做的是在更新“失败”时捕获异常,因为部门号 XXX 不存在。