Skip to main content
Improve formatting with \operatorname for long function names
Source Link
Brian61354270
  • 2.2k
  • 3
  • 12
  • 20

For binary vectors like you have, it's called "population count", Many programming languages have a popcount( ) function (C++), and some microprocessors even have popcnt available as a single instruction (x86).

This is also mentioned as a special case in the Hamming weight article that @Maksim's answer refers to.

Reply to comment: I'm not sure what you mean by "apply to both sides of the symmetry". If it helps, popcount only counts the number of $1$s, not the number of $0$s. If you want the number of zeros, you could let $not()$$\operatorname{not}()$ be "bitwise not", and then $$zeros(v) = popcount( not(v))$$$$\operatorname{zeros}(v) = \operatorname{popcount}( \operatorname{not}(v))$$

If you want to know how to describe the symmetry, you could say "$not( )$$\operatorname{not}( )$ provides a bijection between $\{v \mid popcount(v) = N\}$$\{v \mid \operatorname{popcount}(v) = N\}$ and $\{v \mid popcount(v) =M-N\}$$\{v \mid \operatorname{popcount}(v) =M-N\}$.

For binary vectors like you have, it's called "population count", Many programming languages have a popcount( ) function (C++), and some microprocessors even have popcnt available as a single instruction (x86).

This is also mentioned as a special case in the Hamming weight article that @Maksim's answer refers to.

Reply to comment: I'm not sure what you mean by "apply to both sides of the symmetry". If it helps, popcount only counts the number of $1$s, not the number of $0$s. If you want the number of zeros, you could let $not()$ be "bitwise not", and then $$zeros(v) = popcount( not(v))$$

If you want to know how to describe the symmetry, you could say "$not( )$ provides a bijection between $\{v \mid popcount(v) = N\}$ and $\{v \mid popcount(v) =M-N\}$.

For binary vectors like you have, it's called "population count", Many programming languages have a popcount( ) function (C++), and some microprocessors even have popcnt available as a single instruction (x86).

This is also mentioned as a special case in the Hamming weight article that @Maksim's answer refers to.

Reply to comment: I'm not sure what you mean by "apply to both sides of the symmetry". If it helps, popcount only counts the number of $1$s, not the number of $0$s. If you want the number of zeros, you could let $\operatorname{not}()$ be "bitwise not", and then $$\operatorname{zeros}(v) = \operatorname{popcount}( \operatorname{not}(v))$$

If you want to know how to describe the symmetry, you could say "$\operatorname{not}( )$ provides a bijection between $\{v \mid \operatorname{popcount}(v) = N\}$ and $\{v \mid \operatorname{popcount}(v) =M-N\}$.

added 455 characters in body
Source Link
JonathanZ
  • 11.2k
  • 2
  • 21
  • 36

For binary vectors like you have, it's called "population count", Many programming languages have a popcount( ) function (C++), and some microprocessors even have popcnt available as a single instruction (x86).

This is also mentioned as a special case in the Hamming weight article that @Maksim's answer refers to.

Reply to comment: I'm not sure what you mean by "apply to both sides of the symmetry". If it helps, popcount only counts the number of $1$s, not the number of $0$s. If you want the number of zeros, you could let $not()$ be "bitwise not", and then $$zeros(v) = popcount( not(v))$$

If you want to know how to describe the symmetry, you could say "$not( )$ provides a bijection between $\{v \mid popcount(v) = N\}$ and $\{v \mid popcount(v) =M-N\}$.

For binary vectors like you have, it's called "population count", Many programming languages have a popcount( ) function (C++), and some microprocessors even have popcnt available as a single instruction (x86).

This is also mentioned as a special case in the Hamming weight article that @Maksim's answer refers to.

For binary vectors like you have, it's called "population count", Many programming languages have a popcount( ) function (C++), and some microprocessors even have popcnt available as a single instruction (x86).

This is also mentioned as a special case in the Hamming weight article that @Maksim's answer refers to.

Reply to comment: I'm not sure what you mean by "apply to both sides of the symmetry". If it helps, popcount only counts the number of $1$s, not the number of $0$s. If you want the number of zeros, you could let $not()$ be "bitwise not", and then $$zeros(v) = popcount( not(v))$$

If you want to know how to describe the symmetry, you could say "$not( )$ provides a bijection between $\{v \mid popcount(v) = N\}$ and $\{v \mid popcount(v) =M-N\}$.

added 155 characters in body
Source Link
JonathanZ
  • 11.2k
  • 2
  • 21
  • 36

For binary vectors like you have, it's called "population count", Many programming languages have a popcount( ) function (C++), and some microprocessors even have popcnt available as a single instruction (x86).

This is also mentioned as a special case in the Hamming weight article that @Maksim's answer refers to.

For binary vectors like you have, it's called "population count", Many programming languages have a popcount( ) function (C++), and some microprocessors even have popcnt available as a single instruction (x86).

For binary vectors like you have, it's called "population count", Many programming languages have a popcount( ) function (C++), and some microprocessors even have popcnt available as a single instruction (x86).

This is also mentioned as a special case in the Hamming weight article that @Maksim's answer refers to.

Source Link
JonathanZ
  • 11.2k
  • 2
  • 21
  • 36
Loading