使用括号和文本可视化矩阵分解

使用括号和文本可视化矩阵分解

我想重新创建下面的图像,但我无法正确设置它。在此处输入图片描述 我尝试遵循这个例子:矩阵分解

答案1

代码

\documentclass[tikz]{standalone}
\usetikzlibrary{matrix, positioning}
\tikzset{
  tighter delimiters/.style={
    every left delimiter/.style={xshift=+.5ex},
    every right delimiter/.style={xshift=+-.5ex},
    every above delimiter/.style={yshift=+-.5ex},
    every below delimiter/.style={yshift=+.5ex}},
  @/.style args={#1>#2}{#1/.style={every #2 delimiter/.append style={label={##1}}}},
  @/.list={ld>left, rd>right, ad>above, bd>below}
}
\begin{document}
\begin{tikzpicture}[
  absolute, node distance=+0cm,
  big/.style args={#1x#2}{
    node font=\Huge, fill=blue!50,
    minimum width={(#1)*1cm}, minimum height={(#2)*1cm}},
  big'/.style={big={#1}, fill=none}]
\path[ld={left:$n$ samples}, bd={below:$p$ input features}]
 node[big=2x3, left delimiter=\{, below delimiter=\}] (X) {$X$};
\node[big'=0x0, base right=of X] (eq) {${}={}$};
\path[rd={right:$n$ samples}, bd={below:$k$ latent dimensions}]
 node[big=1x3, base right=of eq, right delimiter=\}, below delimiter=\}] (A) {$A$};
\path[rd={right:$k$ latent dimensions}, ad={above:$p$ input features}]
 node[big=2x1, anchor=south west, at=(A.north east),
      above delimiter=\{, right delimiter=\}] (B) {$B$};
\end{tikzpicture}
\end{document}

输出

在此处输入图片描述

相关内容