1

Can you help me to get these matrices with its labels above:

enter image description here

MWE:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
    \[
    \underbrace{\!
    \begin{pmatrix}
    x_{11} & x_{12} & \dots  & x_{1n} \\
    x_{21} & x_{22} & \dots  & x_{2n} \\
    \vdots & \vdots & \ddots & \vdots \\
    x_{d1} & x_{d2} & \dots  & x_{dn}
    \end{pmatrix}\!
    }_{\mathbf{R}_{\text{Movies}\times \text{Users}}}
    \approx
    \underbrace{\!
    \begin{pmatrix}
    y_{11} & y_{12} & \dots  & y_{1n} \\
    y_{21} & y_{22} & \dots  & y_{2n} \\
    \vdots & \vdots & \ddots & \vdots \\
    y_{d1} & y_{d2} & \dots  & y_{dn}
    \end{pmatrix}\!
    }_{\mathbf{Q}_{\text{Movies}\times f\text{-factors}}}
    \cdot
    \underbrace{
    \begin{pmatrix}\!
    z_{11} & z_{12} & \dots  & z_{1n} \\
    z_{21} & z_{22} & \dots  & z_{2n} \\
    \vdots & \vdots & \ddots & \vdots \\
    z_{d1} & z_{d2} & \dots  & z_{dn}
    \end{pmatrix}\!
    }_{\mathbf{P}^T_{f\text{-factors}\times\text{Users}}}
    \]
\end{document}
  • 1
    See blkarray package and its block environment. – Zarko Aug 6 '19 at 21:40
  • 1
    See the answers of this question for a survey of possibilities. – user121799 Aug 6 '19 at 21:56
  • 1
    @user121799 Thank you !!! – NaveganTeX Aug 6 '19 at 21:57
5

enter image description here

With use of the blkarray package:

\documentclass{article}
\usepackage{blkarray}

\begin{document}
\[\renewcommand\arraystretch{1.1}
\begin{blockarray}{cccc}
    \BAmulticolumn{4}{c}{\mathbf{R}}\\
    \begin{block}{(cccc)}
r_1^{(1)}   & r_2^{(1)} & \dots  & r_b^{(1)}    \\
r_1^{(2)}   & r_2^{(2)} & \dots  & r_n^{(2)}    \\
\vdots      & \vdots    & \ddots & \vdots       \\
r_1^{(m)}   & r_2^{(m)} & \dots  & r_n^{(m)}    \\
    \end{block}
\end{blockarray}
\approx
\begin{blockarray}{cccc}
    \BAmulticolumn{4}{c}{\mathbf{X}}\\
    \begin{block}{(cccc)}
r_1^{(1)}   & r_2^{(1)} & \dots  & r_b^{(1)}    \\
r_1^{(2)}   & r_2^{(2)} & \dots  & r_n^{(2)}    \\
\vdots      & \vdots    & \ddots & \vdots       \\
r_1^{(m)}   & r_2^{(m)} & \dots  & r_n^{(m)}    \\
    \end{block}
\end{blockarray}
\cdot
\begin{blockarray}{cccc}
    \BAmulticolumn{4}{c}{\mathbf{\Theta}^T}\\
    \begin{block}{(cccc)}
\theta_1^{(1)}  & \theta_2^{(1)} & \dots  & \theta_b^{(1)}  \\
\theta_1^{(2)}  & \theta_2^{(2)} & \dots  & \theta_n^{(2)}  \\
\vdots          & \vdots         & \ddots & \vdots          \\
\theta_1^{(m)}  & \theta_2^{(m)} & \dots  & \theta_n^{(m)}  \\
    \end{block}
\end{blockarray}^{\raisebox{-1.5\baselineskip}{$T$}}
\]
\end{document} 

Edit (1): added symbol for transpose. Solution for it is not very elegant but it works.

Edit (2): maybe you more like the following solution for transpose symbol (code only for the last matrix):

\begin{blockarray}{ccccc}
    \BAmulticolumn{4}{c}{\mathbf{\Theta}^T}\\
    \begin{block}{(cccc) c}
\theta_1^{(1)}  & \theta_2^{(1)} & \dots  & \theta_b^{(1)}  &\kern-0.5em T  \\
\theta_1^{(2)}  & \theta_2^{(2)} & \dots  & \theta_n^{(2)}  &       \\
\vdots          & \vdots         & \ddots & \vdots          &       \\
\theta_1^{(m)}  & \theta_2^{(m)} & \dots  & \theta_n^{(m)}  &       \\
    \end{block}
\end{blockarray}

which gives:

enter image description here

| improve this answer | |
  • It looks really sharp! There is one thing that's missing. The Transpose in the third matrix. – NaveganTeX Aug 6 '19 at 22:14
  • 1
    @NaveganTeX, ups, I didn't see it. Thank you for pointing me on it. I will add it asap. – Zarko Aug 6 '19 at 22:17
  • I have used lot of the time to put the T of the transpose. :-( – Sebastiano Aug 6 '19 at 22:40
  • 1
    @Sebastiano, but on the end you manage it. +1 for your answer :-) – Zarko Aug 6 '19 at 22:47
  • 1
    @Zarko You know now that with all honesty, I'm not interested in the votes. Actually, I write it to you with my heart. Thank you for appreciating. I invent strange things like that symbol of the T that with bordermatrix is not possible to insert directly. At least I have read the manual. – Sebastiano Aug 6 '19 at 22:50
4

Also my answer it is not elegant :-) but it works using \bordermatrix. I have used the code of your MWE and it not is that of the image.

enter image description here

\documentclass[a4paper,12pt]{article}
\usepackage{mathtools,amssymb}
\usepackage{newtxtext,newtxmath}


\begin{document}
\[\bordermatrix{
    &    &   {\scriptstyle R}     &  &     \cr
    & x_{11} & x_{12} & \dots  & x_{1n} \cr
    & x_{21} & x_{22} & \dots  & x_{2n} \cr
    &\vdots & \vdots & \ddots & \vdots \cr
    & x_{d1} & x_{d2} & \dots  & x_{dn}
}
\simeq \bordermatrix{
   &    &    {\scriptstyle T}    &  &   \cr
   & y_{11} & y_{12} & \dots  & y_{1n}  \cr
   & y_{21} & y_{22} & \dots  & y_{2n}  \cr
   & \vdots & \vdots & \ddots & \vdots  \cr
   & y_{d1} & y_{d2} & \dots  & y_{dn}
} \bordermatrix{
   &    &    {\scriptstyle \Theta^T}    &  &   \cr
   & y_{11} & y_{12} & \dots  & y_{1n}  \cr 
   & y_{21} & y_{22} & \dots  & y_{2n}  \cr
   & \vdots & \vdots & \ddots & \vdots  \cr
   & y_{d1} & y_{d2} & \dots  & y_{dn}
}
\begin{matrix}
\overset{T}{}\\
\\
\\
\\
\end{matrix}
\]
\end{document}
| improve this answer | |
  • I happen to think that your example looks fantastic as well. Thank you! – NaveganTeX Aug 6 '19 at 22:42
  • 1
    @NaveganTeX I'm happy when I help others. The solution I gave you is a "hack" but it works. Aesthetically it's not beautiful, but you can put the bold and you can do, any modification. – Sebastiano Aug 6 '19 at 22:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.