Matrices restricted to a subspace Let $Q$ be an 
$n\times n$ stochastic matrix. Let $\mathcal S$ 
be the following subspace of $\mathbb R^n$:
$$\mathcal S:=\left\{x\in\mathbb R^n: \sum_{i=1}^nx_i=0 \right\}\, .$$
In a paper that I'm reading, there is a concept that I do not know: the restriction of $Q$ to $\mathcal S$, (denoted by $Q|_{\mathcal S}$). What does it mean? For example, if I have a given matrix $Q$, how could I calculate $Q|_{\mathcal S}$?
 A: As a matrix (stochastic or not), $Q$ can be thought of as a mapping $$\Bbb R^n \to \Bbb R^n : v \mapsto Qv$$
Thus the domain and codomain of $Q$ are $\Bbb R^n$. Since $S \subset \Bbb R^n$, we can consider the map $$S \to \Bbb R^n : v \mapsto Qv$$
instead. The only difference from $Q$ is that the domain is just $S$. This map is the restriction $Q|_S$ of $Q$ to $S$.
Since $S$ is in fact a vector subspace of $\Bbb R^n$, $Q|_S$ is also linear over $S$. If you wanted to represent is as a matrix, first you would need to pick a basis $\{v_i\}_{i=1}^{n-1}$ for $S$ (since $S$ is $n-1$ dimensional), then you could express the matrix elements as $\left[Q|_S\right]_{ij} = \langle v_i, Qe_j\rangle$, where $e_j$ is the $j$-th element of the standard basis of $\Bbb R^n$ (which is still the codomain of $Q|_S$). What matrix you get depends on the basis elements you selected.
For example, if you simply drop any one of the standard basis elements of $\Bbb R^n$, the remaining elements will form a basis for this particular space $S$. The resulting matrix will be original matrix $Q$ with one column removed. The column removed corresponds to the standard basis element you dropped.
A: Let $Q\in F^{n\times n}$ for a scalar field $F$ such as $\mathbb{R}$ or $\mathbb{C}$.
Let $S$ be a subspace of $F^n$.
The matrix $R\in F^{n\times n}$ with
$$Rx=
\left\{
\begin{array}{ll}
Qx&\mbox{if $x\in S$}\\
0&\mbox{if $x\in S^\perp$}
\end{array}
\right.
$$
is the restriction of $Q$ to $S$. Thus, if $S=\{0\}$, then $R$ is the zero matrix. To obtain $R$ for an $S$ with $d=\dim(S)\geq 1$, compute an orthonormal basis $\beta=(\beta_1,\ldots,\beta_n)$ of $F^n$ such that $(\beta_1,\ldots,\beta_d)$ is an orthonormal basis of $S$ using Gram-Schmidt. Let
$$R=UCU^*,$$
where


*

*$U\in F^{n\times n}$ is the (unitary) matrix such that the $j$-th column of $U$ is $\beta_j$ for each $j\in\{1,\ldots,n\}$ and

*$C\in F^{n\times n}$ is defined as follows:


*

*If $j\in\{1,\ldots,d\}$, then let the $j$-th column of $C$ be the coordinate  of vector $Q\beta_j$ with respect to basis $\beta$. That is, for each $i\in\{1,\ldots,n\}$, let
$C_{i,j}=\beta_i^* Q\beta_j$.

*If $j\in\{d+1,\ldots,n\}$, then let the $j$-th column of $C$ be the zero vector in $F^n$. That is, 
for each $i\in\{1,\ldots,n\}$, let $C_{i,j}=0$.
$R$ is unique, although $\beta$ is not.
