5

I have tried to replicate a portion of this matrix decomposition system in LaTeX, but I am unable to draw the first and the last matrices with rectangular boxes.enter image description here

This is what I could do until now, which of course, is easy to write. I can use LatexDraw to draw this figure, but the figure will not look very elegant as this one:

 \begin{equation}
\underbrace{\mathbf{A}}_{W \times D} = \underbrace{\mathbf{U}}_{W \times W} \times \underbrace{\mathbf{\Sigma}}_{W\times D} \times \underbrace{\mathbf{V}^{\text{T}}}_{D \times D} = 
\left(
 \begin{array}{ccccc}
   \sigma_1\\
    & . & & \text{\huge0}\\
    & & .\\
    & \text{\huge0} & & \sigma_r\\
    & & & & 0
 \end{array}
\right)
\end{equation}
2
  • It would be welcomed that the code you provided started with \documentclass and ended with \end{document}.
    – Manuel
    Jun 4, 2014 at 15:54
  • @Manuel: I am sorry about this. It has been two times since I have been reminded about it. Next time there won't be any complains, I promise.
    – puser
    Jun 5, 2014 at 0:13

3 Answers 3

4

Using TikZ and some matrix of math nodes:

Matrix factorization by SVD

The code:

\documentclass{article}
\usepackage[margin=2cm]{geometry}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{matrix,positioning,decorations.pathreplacing}

\DeclareMathOperator{\Mcol}{col}
\DeclareMathOperator{\Mrow}{row}
\DeclareMathOperator{\Mnull}{null}

\begin{document}

\begin{align*}
A &= U\Sigma V^{T} \\
&=
\begin{tikzpicture}[
baseline,
mymat/.style={
  matrix of math nodes,
  ampersand replacement=\&,
  left delimiter=(,
  right delimiter=),
  nodes in empty cells,
  nodes={outer sep=-\pgflinewidth,text depth=0.5ex,text height=2ex,text width=1.2em}
}
]
\begin{scope}[every right delimiter/.style={xshift=-3ex}]
\matrix[mymat] (matu)
{
 \& \& \& \& \& \\
\& \& \& \& \& \\
\& \& \& \& \& \\
\& \& \& \& \& \\
\& \& \& \& \& \\
\& \& \& \& \& \\
};
\node 
  at ([shift={(3pt,-7pt)}]matu-3-2.west) 
  {$\cdots$};
\node 
  at ([shift={(3pt,-7pt)}]matu-3-5.west) 
  {$\cdots$};
\foreach \Columna/\Valor in {1/1,3/r,4/{r+1},6/m}
{
\draw 
  (matu-1-\Columna.north west)
    rectangle
  ([xshift=4pt]matu-6-\Columna.south west);
\node[above] 
  at ([xshift=2pt]matu-1-\Columna.north west) 
  {$u_{\Valor}$};
}
\draw[decorate,decoration={brace,mirror,raise=3pt}] 
  (matu-6-1.south west) -- 
   node[below=4pt] {$\Mcol(A)$}
  ([xshift=4pt]matu-6-3.south west);
\draw[decorate,decoration={brace,mirror,raise=3pt}] 
  (matu-6-4.south west) -- 
   node[below=4pt] {$\Mnull(A)$}
  ([xshift=4pt]matu-6-6.south west);
\end{scope}
\matrix[mymat,right=10pt of matu] (matsigma)
{
\sigma_{1} \& \& \& \& \& \\
\& \ddots \& \& \& \& \\
\& \& \sigma_{r} \& \& \& \\
\& \& \& 0 \& \& \\
\& \& \& \& \ddots \& \\
\& \& \& \& \& 0 \\
};
%\begin{scope}[every right delimiter/.style={xshift=-3ex}]
\matrix[mymat,right=25pt of matsigma] (matv)
{
 \& \& \& \& \& \\
\& \& \& \& \& \\
\& \& \& \& \& \\
\& \& \& \& \& \\
\& \& \& \& \& \\
\& \& \& \& \& \\
};
\foreach \Fila/\Valor in {1/1,3/r,4/{r+1},6/n}
{
\draw 
  ([yshift=-6pt]matv-\Fila-1.north west)
    rectangle
  ([yshift=-10pt]matv-\Fila-6.north east);
\node[right=12pt] 
  at ([yshift=-8pt]matv-\Fila-6.north east) 
  {$v^{T}_{\Valor}$};
}
\draw[decorate,decoration={brace,raise=37pt}] 
  ([yshift=-6pt]matv-1-6.north east) -- 
   node[right=38pt] {$\Mrow(A)$}
  ([yshift=-10pt]matv-3-6.north east);
\draw[decorate,decoration={brace,raise=37pt}] 
  ([yshift=-6pt]matv-4-6.north east) -- 
   node[right=38pt] {$\Mnull(A)$}
  ([yshift=-10pt]matv-6-6.north east);
\end{tikzpicture}
\end{align*}

\end{document}

The few missing elements are easy to add.

4

Not exactly your scheme, but it approximates...

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\newcommand{\vect}{\mathbf}
\newcommand{\nul}{\operatorname{Nul}}
\newcommand{\col}{\operatorname{Col}}
\newcommand{\row}{\operatorname{Row}}

\[
   A= U\Sigma V^T=
  \begin{matrix}
    \underbrace{\left[\begin{matrix}\vect u_1 & \vect u_2 & \dots & \vect u_r\end{matrix}\right.}& 
    \underbrace{\left.\begin{matrix}\vect u_{r+1} & \dots &  \vect u_m\end{matrix}\right]}\\
    \col A & \nul A^T
  \end{matrix}
  \begin{bmatrix}
      \sigma_1 & 0 & \dots & 0 & 0 & \dots & 0 \\
         0 & \sigma_2  & \dots & 0 & 0 & \dots & 0 \\
         \dots& & & & &  \\
         0 & 0 & \dots & \sigma_r  & 0 & \dots & 0 \\
         0 & 0 & \dots & 0 & 0 & \dots & 0 \\
         \dots& & & & &  \\
         0 & 0 & \dots & 0 & 0 & \dots & 0 
  \end{bmatrix}
  \begin{bmatrix}
    \vect v_1^T \\ \vect v_2^T \\ \dots \\ \vect v_r^T \\
    \vect v_{r+1}^T \\ \dots \\ \vect v_n^T
  \end{bmatrix}
  \begin{matrix}
    \left.\vphantom{\begin{bmatrix}
       \vect v_1^T \\ \vect v_2^T \\ \dots \\ \vect v_r^T 
       \end{bmatrix}}\right\}\row A \\ 
    \left.\vphantom{\begin{bmatrix}
      \vect v_{r+1}^T \\ \dots \\ \vect v_n^T 
    \end{bmatrix}}\right\}\nul A
  \end{matrix}
\] 

\end{document}

singular values decomposition

1
  • Your solution seems very good as well. Thanks a lot. But unfortunately, I am forced to accept only one of the two.
    – puser
    Jun 5, 2014 at 0:15
0

I am open to corrections & suggestions, this is my solution:

\text{A} = 
\underset{m \times n}{
    \begin{bmatrix}
        x_{11} & x_{12} & \dots & x_{1m} \\
        x_{21} & x_{22} & \dots & x_{2m} \\
        \vdots & \vdots & \ddots & \vdots \\
        x_{n1} & x_{n2} & \dots & x_{nm}
    \end{bmatrix}
}
= \text{USV}^\text{T} = 
\underset{m \times m}{
    \begin{bmatrix}
        | & | & \ & | \\
        u_{1} & u_{2} & \dots & u_{m} \\
        | & | & \ & |
    \end{bmatrix}
}
\times
\underset{m \times n}{
\begin{bmatrix}
\sigma_{1} & 0 & \dots & 0 \\
0 & \sigma_{2} & \dots & 0 \\
\vdots & \vdots & \ddots & \vdots \\
0 & 0 & \dots & \sigma_{n} \\
0 & 0 & \vdots & 0 \\
\end{bmatrix}}
\times
\underset{n \times n}{
    \begin{bmatrix}
        \textemdash & V_{1}^T & \textemdash  \\
        \textemdash & V_{2}^T & \textemdash \\
        \ & \vdots &  \ \\
        \textemdash & V_{n}^T & \textemdash \\
    \end{bmatrix}
}

Rendering is done in obsidian via MathJax.

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .