TITLE: Determine the winner of a tic tac toe board with a single matrix expression?
QUESTION [11 upvotes]: Assume a tic-tac-toe board's state is stored in a matrix. 
$$
S=\begin{bmatrix}
-1 & 0 & 1 \\
1 & -1 & 0 \\
1 & 0 & -1 \\
\end{bmatrix}
$$
Here, $X$ is mapped to $1$, $O$ is mapped to $-1$ and an empty state is mapped to zero, but any other numeric mapping will do if there is one more suitable for solving the problem. Is it possible to create some single expression involving the matrix $S$ which will indicate whether the board is in a winning state?  For the above matrix, the expression should show a win for $O$.  
I recognize that there are more direct programmatic approaches to this, so this is more of an academic question.
Edit: I have been asked what to do if the board shows two winners.  You could either:

Assume only valid board states. Since gameplay would stop after once side wins, it is not possible to have a board with two winners. 
Alternatively (or equivalently?), your expression could arbitrarily pick a winner in a board that has two.

REPLY [3 votes]: Just a comment on the fact that more obscure solutions may exist that are easier to compute. I was able to construct one for the $2\times 2$ tic-tac-toe. Let
\begin{align}
\mathbf{Z}_1 = \left[\begin{array}{cc}2.3049 &  -2.2506 \\  -2.2310 &   2.2420 \end{array}\right]
\end{align}
and
\begin{align}
\mathbf{Z}_2 =\left[\begin{array}{cc}  -0.2072  &  0.2190 \\    0.3336  & -0.0792\end{array}\right]
\end{align}
Let the tic-tac-toe matrix be $\mathbf{Z}$ with entries $0$, $1$ or $-1$ in the same manner as defined in the question. Let
\begin{align}
\chi \triangleq \det(\mathbf{Z}_1+\mathbf{Z})|\det(\mathbf{Z}_2+\mathbf{Z})|
\end{align}
Then, unless $\mathbf{Z}$ specifies an illegal board where both sides have won, $\chi \geq 1.5 \iff $ user $1$ has won, $-1 < \chi < 1.5\iff$ the game has not ended yet, and $\chi \leq -1$ if user $-1$ has won. For example, for
\begin{align}
\mathbf{Z} = \left[\begin{array}{cc} 1 & 1 \\ -1 & 0\end{array}\right]
\end{align}
obviously user $1$ has won, and indeed we have $\chi = 2.5252$.
The above was found using a genetic algorithm and experimenting with different $\chi$ forms.