7

I'm using LaTeX to show the butterfly visualization of fast Fourier transformation and I'm stuck at drawing the matrix.

I want something like this:

enter image description here

i.e. if I have a vector of length 8, in the next column (after the equal sign), I want two matrices each of length 4 on the same column one below the other, how can I achieve this?

\documentclass{article}
\begin{document}

\left[ \begin{array}{ccc}
1 \\
0 \\
0 \\
0 \\
3 \\
0 \\
0 \\
0 \\ 
\end{array} \right]

\end{document}
Gonzalo Medina
  • 505,128
TYZ
  • 215

2 Answers2

6

This requires some manual adjustment, but if you don't have too many of these butterflies, it might be sufficient:

\documentclass{article}
\usepackage{amsmath,xparse}

\ExplSyntaxOn
\RenewDocumentCommand{\vdots}{O{3}}
 {
  \vbox:n
   {
    \skip_set:Nn \baselineskip {4pt}
    \dim_set:Nn \lineskiplimit {0pt}
    \kern 6pt % no equivalent with expl3 at the moment
    \prg_replicate:nn { #1 } { \hbox:n { . } }
   }
 }
\ExplSyntaxOff

\begin{document}
\[
\begin{bmatrix}
0 \\ \vdots[16] \\ n
\end{bmatrix}
=
\begin{matrix}
\begin{bmatrix}
0 \\ \vdots \\ (n+1)/2
\end{bmatrix}
\\[4.7ex]
\begin{bmatrix}
0 \\ \vdots \\ (n+1)/2
\end{bmatrix}
\end{matrix}
\]
\end{document}

The new optional argument to \vdots tells how many dots are to be printed.

enter image description here

egreg
  • 1,121,712
  • nice solution. However, it does not work properly when the matrices are NOT one-column matrices. Here more details in a question. Any idea on how to solve the issue? – Leos313 Apr 30 '20 at 16:41
3
\documentclass[preview,border=12pt,12pt]{standalone}
\usepackage{amsmath}

\begin{document}

\begin{align*}
\begin{bmatrix}
a\\b\\c\\d\\e\\f\\g\\h
\end{bmatrix}
&=\!\begin{aligned}
        &\begin{bmatrix}a\\b\\c\\d\end{bmatrix}\\
        &\begin{bmatrix}a\\b\\c\\d\end{bmatrix}
    \end{aligned}\\
&=\ldots
\end{align*}

\end{document}

enter image description here

More practical example

\documentclass[preview,border=12pt,12pt]{standalone}
\usepackage{amsmath}

\begin{document}

\begin{align*}
\begin{bmatrix}
0\\1\\2\\3\\\vdots\\n-2\\n-1\\n
\end{bmatrix}
&=\!\begin{aligned}
        &\begin{bmatrix}0\\1\\\vdots\\\frac{n+1}{2}\end{bmatrix}\\
        &\begin{bmatrix}0\\1\\\vdots\\\frac{n+1}{2}\end{bmatrix}
    \end{aligned} + \text{ what ever \ldots}\\
&=\!\begin{aligned}
        &\begin{bmatrix}0\\1\\\vdots\\\frac{n+1}{2}\end{bmatrix}\\
        &\begin{bmatrix}0\\1\\\vdots\\\frac{n+1}{2}\end{bmatrix}
    \end{aligned} + \text{ forever \ldots}
\end{align*}

\end{document}

enter image description here