3

I am having some trouble when changing the order of the matrices. The dot product does not look very well, actually it is like it is embedded; hard to spot. How can add space between the two matrices to the right and make de dot point bigger?

CODE (Credits to Zarko)

\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{\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$}}
\cdot
\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}
\]
\end{document} 

enter image description here

2 Answers 2

2
\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{\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$}}
\bullet \quad
\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}
\]
\end{document} 

enter image description here

Or you can keep your code as it is and add to \cdot a space, for example: \cdot \quad just to add the space while keeping the dot product small. In this case, the result will be:

enter image description here

4

You don't need blkarray for the job; as you discovered, it does some tricks for placing inner fences that require explicit space around the big matrix if it is to be used together with other objects. Better using a standard array that encloses the two rows.

\documentclass{article}
\usepackage{amsmath}
\usepackage{array}

\begin{document}

\[
\renewcommand\arraystretch{1.1}
\begin{array}{@{} c *{2} { @{} >{{}}c<{{}} @{} c } @{} }
\mathbf{R} && \mathbf{\Theta}^T && \mathbf{X} \\
\begin{pmatrix}
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{pmatrix}
& \approx &
\begin{pmatrix}
\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{pmatrix}^{\textstyle T}
& \cdot &
\begin{pmatrix}
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{pmatrix}
\end{array}
\]

\end{document} 

The purpose of the outer array preamble is to have no intercolumn space, but the “middle” entries (corresponding to the relations or binary operations) are surrounded by {}, so as to insert the right spacing pertaining to them.

enter image description here

1
  • Thank you very much for such concise and good explanation!
    – NaveganTeX
    Aug 8, 2019 at 10:47

You must log in to answer this question.

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