From: Martin Mares Date: Sun, 3 Feb 2008 20:13:30 +0000 (+0100) Subject: Unification of tenses. X-Git-Tag: printed~247 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=39faa88ff6ca1120071a8f98de54a942251ec7ea;p=saga.git Unification of tenses. --- diff --git a/ram.tex b/ram.tex index fad390c..7dabe91 100644 --- a/ram.tex +++ b/ram.tex @@ -442,7 +442,7 @@ the result fits in $b$~bits: \alik{\(x) = x \bmod \1^{b+1}. \cr} -This works because when we work modulo~$\1^{b+1}$, the number $2^{b+1}=\1\0^{b+1}$ +This is correct because when we calculate modulo~$\1^{b+1}$, the number $2^{b+1}=\1\0^{b+1}$ is congruent to~1 and thus $x = \sum_i 2^{(b+1)i}\cdot x_i \equiv \sum_i 1^i\cdot x_i \equiv \sum_i x_i$. As the result should fit in $b$~bits, the modulo makes no difference. @@ -490,20 +490,20 @@ carries from propagating, so the fields do not interact with each other: It only remains to shift the separator bits to the right positions, negate them and mask out all other bits. -\:$\(x,\alpha)$ --- return the number of elements of~${\bf x}$ which are less than~$\alpha$, +\:$\(x,\alpha)$ --- returns the number of elements of~${\bf x}$ which are less than~$\alpha$, assuming that the result fits in~$b$ bits: \alik{ \(x,\alpha) = \(\(x,\(\alpha))). \cr } -\:$\(x,\alpha)$ --- insert~$\alpha$ into a~sorted vector $\bf x$: +\:$\(x,\alpha)$ --- inserts~$\alpha$ into a~sorted vector $\bf x$: -Calculate $k = \(x,\alpha)$ first, then insert~$\alpha$ as the $k$-th +We calculate $k = \(x,\alpha)$ first, then insert~$\alpha$ as the $k$-th field of~$\bf x$ using masking operations and shifts. -\:$\(\alpha)$ --- create a~vector whose elements are the bits of~$\(\alpha)_d$. -In other words, insert blocks~$\0^b$ between the bits of~$\alpha$. Assuming that $b\ge d$, +\:$\(\alpha)$ --- creates a~vector whose elements are the bits of~$\(\alpha)_d$. +In other words, inserts blocks~$\0^b$ between the bits of~$\alpha$. Assuming that $b\ge d$, we can do it as follows: \algo @@ -550,7 +550,7 @@ affected, so we can handle it separately.) \endlist \para -We can use the above tricks to perform interesting operations on individual +We can use the aforementioned tricks to perform interesting operations on individual numbers in constant time, too. Let us assume for a~while that we are operating on $b$-bit numbers and the word size is at least~$b^2$. This enables us to make use of intermediate vectors with $b$~elements @@ -560,16 +560,16 @@ of $b$~bits each. \itemize\ibull -\:$\(\alpha)$ --- compute the Hamming weight of~$\alpha$, i.e., the number of ones in~$\(\alpha)$. +\:$\(\alpha)$ --- computes the Hamming weight of~$\alpha$, i.e., the number of ones in~$\(\alpha)$. -Perform \ and then \. +We perform \ and then \. -\:$\_\pi(\alpha)$ --- shuffle the bits of~$\alpha$ according +\:$\_\pi(\alpha)$ --- shuffles the bits of~$\alpha$ according to a~fixed permutation~$\pi$. -Perform $\_\pi$ and \ back. +We perform $\_\pi$ and \ back. -\:$\(\alpha)$ --- find the least significant bit of~$\alpha$, +\:$\(\alpha)$ --- finds the least significant bit of~$\alpha$, i.e., the smallest~$i$ such that $\alpha[i]=1$. By a~combination of subtraction with $\bxor$, we create a~number @@ -583,7 +583,7 @@ which contains ones exactly at the position of $\(\alpha)$ and below: Then we calculate the \ of the result and subtract~1. -\:$\(\alpha)$ --- find the most significant bit of~$\alpha$ (the position +\:$\(\alpha)$ --- finds the most significant bit of~$\alpha$ (the position of the highest bit set). Reverse the bits of the number~$\alpha$ first by calling \, then apply \