Skip to content

[bit.permute] Create notation for the popcount of the first n bits.#9181

Merged
tkoeppe merged 2 commits into
cplusplus:mainfrom
tkoeppe:prefix_popcount
Jul 16, 2026
Merged

[bit.permute] Create notation for the popcount of the first n bits.#9181
tkoeppe merged 2 commits into
cplusplus:mainfrom
tkoeppe:prefix_popcount

Conversation

@tkoeppe

@tkoeppe tkoeppe commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

This avoids having to put a complex expression into sub- and superscripts in the definitions of "expand" and "compress".

This avoids having to put a complex expression into sub- and
superscripts in the definitions of "expand" and "compress".
@tkoeppe tkoeppe requested review from jwakely and opensdh July 15, 2026 16:35
Comment thread source/utilities.tex
Comment on lines 16734 to +16741
\pnum
In the following descriptions,
let $N$ denote the value of \tcode{numeric_limits<T>::digits}, and
let $N$ denote the value of \tcode{numeric_limits<T>::digits},
let $\alpha_n$ denote the value of the $n^\text{th}$ least significant bit
in the base-2 representation of an integer $\alpha$,
so that $\alpha$ equals $\sum_{n=0}^{N-1} \alpha_n 2^n$.
so that $\alpha$ equals $\sum_{n=0}^{N-1} \alpha_n 2^n$,
and let $\sigma(\alpha, n) = \sum_{k=0}^{n-1} \alpha_k$
be the count of one-bits among the lowest $n$ bits of $\alpha$.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is going to be three relatively complex items, maybe it this should be using bullets.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done as a separate commit. I'm not sure that it makes a big difference. (Generally, what helps make complex expressions more scannable is to put them in a displayed equation, but I don't really see any good opportunities for this here.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

@tkoeppe tkoeppe merged commit 22c03f7 into cplusplus:main Jul 16, 2026
2 checks passed
@tkoeppe tkoeppe deleted the prefix_popcount branch July 16, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants