- https://www.mathworks.com/help/signal/ref/fwht.html
- number of 1 bits - hamming weight - set bits (tutorialcup.com)
How do we calculate the branch number of any given binary matrix?
조회 수: 4 (최근 30일)
이전 댓글 표시
How do we calculate the hamming weight, branch number of any nxn binary matrix defined in GF(2^n)?
댓글 수: 0
답변 (1개)
Srivardhan
2023년 7월 6일
Hi Smita,
As per my understanding, you want to calculate the branch number and hamming weight of any nxn binary matrix.
In general, Hamming weight of binary matrix is the count of non-zero elements in the matrix. To calculate the branch number of given matrix we need to find absolute maximum in Walsh transform of the matrix. Subtract the maximum absolute value from 2^(n-1) to obtain the branch number.
We can use suitable algorithm to find Walsh transform of the matrix such as Fast Walsh Hadamard transform (FWHT).
Here is the sample code for reference:
function weight = hamming_weight(matrix)
weight = sum(matrix(:));
end
function bn = branch_number(matrix)
n = size(matrix, 1);
transform = fwht(matrix); % Fast Walsh–Hadamard transform
abs_transform = abs(transform);
max_value = max(abs_transform(:));
bn = 2^(n-1) - floor(max_value);
end
% Example usage
matrix = [1 0 1; 0 1 0; 1 1 1];
weight = hamming_weight(matrix);
bn = branch_number(matrix);
disp(weight);
disp(bn);
For further reference, please check out the links to learn more about hamming weight and branch number.
I hope this helps!
댓글 수: 1
曦
2024년 6월 5일
Can you explain why it is possible to calculate the branch number in this way, or do you have any relevant references.Thx
참고 항목
카테고리
Help Center 및 File Exchange에서 Hamming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!