## Hadamard Codes and C Implementation Using the Octave GNU Tool

### 2. Introduction

##### Let’s replace in (24): 1 => 0 and -1 => 1. Next combine the rows of the matrix (24) into the uint32 words. As a result we get a table of 64 code words:

/* Hadamard Code (2^5,5+1,2^(5-1))=(32,6,16): 64×32 bit words with 0/1 values */
const uint32 H_MessageList[64]=
{
0x00000000, 0x55555555, 0x33333333, 0x66666666, 0x0F0F0F0F,
0x5A5A5A5A, 0x3C3C3C3C, 0x69696969, 0x00FF00FF, 0x55AA55AA,
0x33CC33CC, 0x66996699, 0x0FF00FF0, 0x5AA55AA5, 0x3CC33CC3,
0x69966996, 0x0000FFFF, 0x5555AAAA, 0x3333CCCC, 0x66669999,
0x0F0FF0F0, 0x5A5AA5A5, 0x3C3CC3C3, 0x69699696, 0x00FFFF00,
0x55AAAA55, 0x33CCCC33, 0x66999966, 0x0FF0F00F, 0x5AA5A55A,
0x3CC3C33C, 0x69969669, 0xFFFFFFFF, 0xAAAAAAAA, 0xCCCCCCCC,
0x99999999, 0xF0F0F0F0, 0xA5A5A5A5, 0xC3C3C3C3, 0x96969696,
0xFF00FF00, 0xAA55AA55, 0xCC33CC33, 0x99669966, 0xF00FF00F,
0xA55AA55A, 0xC33CC33C, 0x96699669, 0xFFFF0000, 0xAAAA5555,
0xCCCC3333, 0x99996666, 0xF0F00F0F, 0xA5A55A5A, 0xC3C33C3C,
0x96966969, 0xFF0000FF, 0xAA5555AA, 0xCC3333CC, 0x99666699,
0xF00F0FF0, 0xA55A5AA5, 0xC33C3CC3, 0x96696996
};

### 6. Octave GNU file HadamardCode.m

##### The script generates and tests Hadamard Code: (32,6,16) и R(1,5)

% Comparing two Messages: Input and Pattern
% Input parameters:
% InMessage – input message
% PatternMessage – Hadamard pattern message list
% Output parameters:
% CompareValue – correlation value
function CompareValue = MessageCompare(InMessage, PatternMessage, HadamardMessageLength)

% Receiving the Hadamard code message
% Majority logic decoding
% Input parameters:
% InMessage – input message
% Output parameters:
% Majority – max compare value
% MessageNmb – number of the message in the HadamardMessageList
% OutputValues – compare results for all the HadamardMessageList

% Hex Integer Table to File
% Support C-Code
% Input parameters:
% ParameterVector – data array
% FileNameString – output file name
function HexIntegerParamVector2file(ParameterVector, FileNameString)

##### Support the Hadamard Code: (32,6,16)

/*
Hamming Distance between code1 and code2
Input
uint32 code1
uint32 code2
Return
uint8 – Hamming Distance
*/
uint8 HammingDistance(uint32 code1, uint32 code2)

/*
Compare or correlate the code1 and code2
Input
uint32 code1
uint32 code2
Return
sint8 – correlation value
*/
sint8 MessageCompare(uint32 code1, uint32 code2)

/*
Input
uint32 code – input message
receiving_message_t* ptr_result – pointer on the receiving result
Return
void
*/