残差和全等
Residues and congruence
从 APL 书中,我试图破译当 'j' 不是 0 时如何在 C 中转换 'r' 的计算:
For each set of integers n, j, and b, with b > 0, there exists a
unique pair of integers q and r such that
n = bq + r, j ≤ r < j + b.
The quantity r is called the j-residue of n modulo b and is denoted by
b | j n. For example, 3 |0 9 = 0, 3 |1 9 = 3, and 3 |0 10 = 1.
Moreover, if n ≥ 0, then b |0 n is the remainder obtained in dividing
n by b and q is the integral part of the quotient.
什么代表 'j' 以及如何在不通过在区间内迭代解析的情况下获得 r?
然后,该段的其余部分说:
In classical treatments, such as Wright (1939), only the 0-residue is
considered. The use of 1-origin indexing (cf. Sec. 1.5) accounts for
the interest of the 1-residue.
所以我猜想 n mod b
在 C 中例如是 b | j n
且 j=0,但我不明白为什么使用 'j=1' 有利于使用 1-origin 进行索引。这有什么用?
假设 N 很大(或为负)并且您有一个包含 b < N 个元素的数组。
你想用 N 索引数组,但如果 N 大于
数组中元素的数量。
在从 0 开始的 C 中,您需要 0...b-1 中的索引(均包含在内)。
在默认为 1 源的 APL 中,您需要 1...b 中的索引。
这可能就是 1-index 的用武之地。您可以计算 1-origin
从没有迭代的 fhe 0 原点开始:
if (idx == 0) idx = b;
Q1:是的。
在 b|j n
中,b 是 scalar-extended 以匹配 j n
。所以它与 (b∣j),(b∣n).
相同 j 不是 ∠ 的修饰符。换句话说,b∣j n
不是 n 的 j-residue,而是 j 的 0-残基,然后是 n 的 0-残基。
在 GNU APL 中(我也相信所有其他 APL)你得到:
3∣0 9
0 0
3∣1 9
1 0
从一个 0 残基模 b 你可以得到 j-residue 通过 添加 j∣b
到 0 残基:
+/ 3∣0 9
0
+/ 3∣1 9
1
符号,符号,符号。
艾弗森编程语言中使用的符号早于后来作为现代 APL 实现的符号。
我从 http://www.jsoftware.com/papers/APL.htm
那里得到了这个
因此 3 |0 9 将 0 写为下标,今天在几乎每个 APL 中都可以作为 3 | 9.
3 |1 9 其中 1 被写为下标并没有这样实现,但可以作为定义的运算符来解决。 (我使用的是 Dyalog 13.1)
∇ r←x(i mod)y
[1] r←i+x|y-i
∇
3 (0 mod) 9
0
3 (1 mod) 9
3
3 (0 mod) 10
1
⎕io←0
3 (0 mod) ⍳9
0 1 2 0 1 2 0 1 2
⎕io←1
3 (1 mod) ⍳9
1 2 3 1 2 3 1 2 3
从 APL 书中,我试图破译当 'j' 不是 0 时如何在 C 中转换 'r' 的计算:
For each set of integers n, j, and b, with b > 0, there exists a unique pair of integers q and r such that
n = bq + r, j ≤ r < j + b.
The quantity r is called the j-residue of n modulo b and is denoted by b | j n. For example, 3 |0 9 = 0, 3 |1 9 = 3, and 3 |0 10 = 1. Moreover, if n ≥ 0, then b |0 n is the remainder obtained in dividing n by b and q is the integral part of the quotient.
什么代表 'j' 以及如何在不通过在区间内迭代解析的情况下获得 r?
然后,该段的其余部分说:
In classical treatments, such as Wright (1939), only the 0-residue is considered. The use of 1-origin indexing (cf. Sec. 1.5) accounts for the interest of the 1-residue.
所以我猜想 n mod b
在 C 中例如是 b | j n
且 j=0,但我不明白为什么使用 'j=1' 有利于使用 1-origin 进行索引。这有什么用?
假设 N 很大(或为负)并且您有一个包含 b < N 个元素的数组。 你想用 N 索引数组,但如果 N 大于 数组中元素的数量。
在从 0 开始的 C 中,您需要 0...b-1 中的索引(均包含在内)。
在默认为 1 源的 APL 中,您需要 1...b 中的索引。
这可能就是 1-index 的用武之地。您可以计算 1-origin 从没有迭代的 fhe 0 原点开始:
if (idx == 0) idx = b;
Q1:是的。
在 b|j n
中,b 是 scalar-extended 以匹配 j n
。所以它与 (b∣j),(b∣n).
相同 j 不是 ∠ 的修饰符。换句话说,b∣j n
不是 n 的 j-residue,而是 j 的 0-残基,然后是 n 的 0-残基。
在 GNU APL 中(我也相信所有其他 APL)你得到:
3∣0 9
0 0
3∣1 9
1 0
从一个 0 残基模 b 你可以得到 j-residue 通过 添加 j∣b
到 0 残基:
+/ 3∣0 9
0
+/ 3∣1 9
1
符号,符号,符号。
艾弗森编程语言中使用的符号早于后来作为现代 APL 实现的符号。
我从 http://www.jsoftware.com/papers/APL.htm
那里得到了这个因此 3 |0 9 将 0 写为下标,今天在几乎每个 APL 中都可以作为 3 | 9.
3 |1 9 其中 1 被写为下标并没有这样实现,但可以作为定义的运算符来解决。 (我使用的是 Dyalog 13.1)
∇ r←x(i mod)y
[1] r←i+x|y-i
∇
3 (0 mod) 9
0
3 (1 mod) 9
3
3 (0 mod) 10
1
⎕io←0
3 (0 mod) ⍳9
0 1 2 0 1 2 0 1 2
⎕io←1
3 (1 mod) ⍳9
1 2 3 1 2 3 1 2 3