We can "travel" on all the vector space $V =GF(2)^n$ by doing the following


(a) choose a primitive polynomial $P(t)$ of degree $n$ over $GF(2)$.


(b) change vector $ X = (x\_1, \ldots,x\_{n-1}) \in V$ into vector $Y = (y\_1, \ldots, y\_{n-1}) \in V$.


(c) repeat until $V$ is exhausted (2^n times)


where


$y\_1+y\_2z+ \cdots + y\_nz^{n-1} = z(x\_1+x\_2z+ \cdots + x\_nz^{n-1})$


and $z$ is a zero of $P$, i.e., $P(z)=0.$


I want to do the same with integral vectors containing only 1 and -1


I.e.: "travel" on all possible vectors $(r\_1, \ldots, r\_{n-1})$


with $r\_i^2=1$ 


How to do that ???


I do some trys without success...


reason of the question: I have only limited time on a computer 
((five days per job, two jobs allowed))
and I need to try some computations on all such vectors with moderately large $n$


the loop:


from r\_1=-1 to 1 by 2 do;


from r\_2=-1 to 1 by 2 do


$\cdots$


from r\_{n-1}=-1 to 1 by 2 do;


do not "fit" in my allowed time.


following suggestion (thanks) let consider the following:


I need to examine each of the $2^n$ vectors.


To fit time allowed suffices to break the $2^n$ in smaller parts and apply to each of them the method I am asking for here !


I tried:


(a) $r\_i \in \{−1,1\}$ go to $si=(r\_i+1)/2$ in $\{0,1\}$


(b) apply idea with primitive polynomial, to the $s\_i$'s


(So forced to take some reduction modulo $2$ in some coordinates)


(c) recover $R\_j$ the new $r\_j$, by $R\_j=2s\_j−1$


so that from vector


$(r\_1,…,r\_n)$ we get new vector $(R\_1,…,R\_n)$


and applying this $2^n$ times we should (hopefully) get all the $2^n$ vectors


but this does NOT work since I ended, e.g. to the cycle


$(−1,−1,…,−1)$ going to itself indefinitely


In other words: Can I write these $2^n$ vectors as a sequence


$v\_1,…,v\_{2^n}$ in such a manner


that I can with some simple algebraic computation,


(similar to the use of the primitive polynomial in case the vectors are in $GF(2)^n$))


get the vector


$v\_k$ from the vector $v\_{k−1}$


beginning with any fixed vector


$v\_1$


???



obtaining all  vectors of given length and with with $+-1$ entries from a given one
Simply represent each vector as a binary integer:


$v\_0 = "0 0 0 ... 0 0 0" = b\_{n-1} b\_{n-2}... b\_2 b\_1 b\_0 = 0$


so the binary digit sequence representing $i$ is a decimal number $d$


$$d = \sum\_{j=0}^{j=n-1} b\_j \cdot 2^{j}$$


Given such a binary representation, you can transform the binary digits into the coefficients by mapping $0 \to -1$ and $1 \to 1$


$b\_j = 0 \to r\_j = (-1)$ and


$b\_j = 1 \to r\_j = (+1)$


Then, given a $v\_j$ as a binary digit, generate $v\_{j+1}$ by adding $1$ to the binary representation.


There is no shortcut around having to test each of the $2^n$ possibilities, so this does not make your overall calculations faster. It just makes it easier to generate the binary digits.


A simpler way is to iterate your index as an integer (call it $z$) from $0$ to $n-1$ and generate the binary representation of each $z$. There are many ways to do that quickly which you can find with simple searches on the internet or by asking at stackexchange.com


