## Creating a Hadamard encoding matrix for a particular pair of vectors.

Let's assume that you want to create a Hadamard matrix for the following vectors:
1. 1  1  1 -1  1 -1 -1 -1
2. 1 -1  1  1  1 -1  1  1
Since there is only one Hadamard matrix of order 8, up to the standard transformations, we start there.

We pick one of the vectors and try to convert one of the rows to that vector. Since the second row is almost B, and B does not have 4 -1's, let's start by fixing that row. In this case, we can do that by negating the fourth and eighth columns.

 1 1 1 1 1 1 1 1 1 -1 1 -1 1 -1 1 -1 1 1 -1 -1 1 1 -1 -1 1 -1 -1 1 1 -1 -1 1 1 1 1 1 -1 -1 -1 -1 1 -1 1 -1 -1 1 -1 1 1 1 -1 -1 -1 -1 1 1 1 -1 -1 1 -1 1 1 -1

This gives us the following matrix. We now wish to create a row of A. We should look for rows with 4 1's and 4 -1's. The highlighted rows are good candidates.

 1 1 1 -1 1 1 1 -1 1 -1 1 1 1 -1 1 1 1 1 -1 1 1 1 -1 1 1 -1 -1 -1 1 -1 -1 -1 1 1 1 -1 -1 -1 -1 1 1 -1 1 1 -1 1 -1 -1 1 1 -1 1 -1 -1 1 -1 1 -1 -1 -1 -1 1 1 1

We do not want to mess up the 1's and -1's in row 2, so we should only consider column exchanges that either have both 1's or both -1's in row 2. After a little consideration, we see that starting with row 5, we can exchange columns 5 and 8, and we will get the vector A without messing up row 2.

 1 1 1 -1 1 1 1 -1 1 -1 1 1 1 -1 1 1 1 1 -1 1 1 1 -1 1 1 -1 -1 -1 1 -1 -1 -1 1 1 1 -1 -1 -1 -1 1 1 -1 1 1 -1 1 -1 -1 1 1 -1 1 -1 -1 1 -1 1 -1 -1 -1 -1 1 1 1

The result is the following Hadamard matrix, with vector A as row 5 and vector B as row 2:

H =

 1 1 1 -1 -1 1 1 1 1 -1 1 1 1 -1 1 1 1 1 -1 1 1 1 -1 1 1 -1 -1 -1 -1 -1 -1 1 1 1 1 -1 1 -1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 1 -1 1 -1 -1 1 -1 1 -1 -1 -1 1 1 1 -1

Note that now the matrix is not symmetric, so if one uses H to encode the signal, one will have to use Ht to decode the signal.