Question: I would like to create a diagram which has matrices as objects and arrows between these matrices. In particular, I'd like to have four matrices, two matrices in the upper row, and two in the lower row, with four arrows between them. 

I have drawn similar diagram with [`xymatrix`](http://www.ctan.org/pkg/xymatrix), but I have no clue how to do this when the objects are themselves matrices.

Help is appreciated.

I tried working in the `\xymatrix` environment, and then use code like this:

```
\[ \left( \begin{array}{cc}
1 & b^{-1} \\
0 & 1 \\
\end{array} \right) \]

```

for the matrices, but this doesn't work.

Answer: 
Using [`tikz-cd`](http://www.ctan.org/pkg/tikz-cd):

```
\documentclass{article}
\usepackage{tikz-cd}
\usepackage{amsmath}

\begin{document}

\begin{tikzcd}
\begin{pmatrix} 1 & a^{-1} \\ 0 & 1 \end{pmatrix}\arrow{r}{\phi}\arrow{d}{\eta} &
\begin{pmatrix} 1 & b^{-1} \\ 0 & 1 \end{pmatrix}\arrow{d}{\theta} \\
\begin{pmatrix} 1 & c^{-1} \\ 0 & 1 \end{pmatrix}\arrow{r}{\psi} &
\begin{pmatrix} 1 & d^{-1} \\ 0 & 1 \end{pmatrix} \\
\end{tikzcd}

\end{document}

```

![enter image description here](https://i.stack.imgur.com/QVmXf.png)

In my example I used `bmatrix` (from `amsmath`) to build the matrices; if you want to stick to `array`, some extra precautions with the management of the ampersand will be needed:

```
\documentclass{article}
\usepackage{tikz-cd}

\begin{document}

\begin{tikzcd}[ampersand replacement=\&]
\left(\begin{array}{cc} 1 & a^{-1} \\ 0 & 1 \end{array}\right)\arrow{r}{\phi}\arrow{d}{\eta} \&
\left(\begin{array}{cc} 1 & b^{-1} \\ 0 & 1 \end{array}\right)\arrow{d}{\theta} \\
\left(\begin{array}{cc} 1 & c^{-1} \\ 0 & 1 \end{array}\right)\arrow{r}{\psi} \&
\left(\begin{array}{cc} 1 & d^{-1} \\ 0 & 1 \end{array}\right) \\
\end{tikzcd}

\end{document}

```

![enter image description here](https://i.stack.imgur.com/zR8el.png)
Btw: matrices works just fine with `\xymatrix` just remember to hide the matrices from the `xy` parser:

```
\documentclass[a4paper]{memoir}
\usepackage{amsmath}
\usepackage[all]{xy}
\begin{document}
\begin{equation*}
  \xymatrix{
    {\begin{pmatrix}
      a & b \\ c & d
    \end{pmatrix}}
  \ar[r] \ar[d]
    & 
    {\begin{pmatrix}
        a & b \\ c & d
      \end{pmatrix}}
    \ar[d]
    \\
    {\begin{pmatrix}
      a & b \\ c & d
    \end{pmatrix}}
  \ar[r] 
    & 
    {\begin{pmatrix}
        a & b \\ c & d
      \end{pmatrix}}
  }
\end{equation*}
\end{document}

```

![enter image description here](https://i.stack.imgur.com/eN8wN.png)