在 LaTeX 中复制奇异值分解图

在 LaTeX 中复制奇异值分解图

我曾尝试在 LaTeX 中复制该矩阵分解系统的一部分,但无法用矩形框绘制第一个和最后一个矩阵。在此处输入图片描述

这是我目前能做的,当然写起来很容易。我可以使用 LatexDraw 来绘制这个图形,但是这个图形看起来不会像这个一样优雅:

 \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}

答案1

使用 TikZ 和一些matrix of math nodes

通过 SVD 进行矩阵分解

代码:

\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}

一些缺失的元素很容易添加。

答案2

不完全是您的方案,但它近似于......

\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}

奇异值分解

答案3

我愿意接受纠正和建议,这是我的解决方案:

\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}
}

渲染是通过 MathJax 在黑曜石中完成的。

在此处输入图片描述

相关内容