1

I want to multiply a column vector into a row vector and then vectorize the above 2 dimensional matrix.

\documentclass{article}
\usepackage{amsmath}

\def\A{
    \begin{bmatrix}
        p_1 & p_2 & \cdots & p_N
\end{bmatrix}}


\def\B{
\begin{bmatrix}
    p_1q_1 & p_1q_2  &\cdots &p_1q_N\\
    p_2q_1 & p_2q_2  &\cdots &p_2q_N\\
    \vdots & & &  \vdots\\
    p_Nq_1 & p_Nq_2 &\cdots &p_Nq_N\\
\end{bmatrix}}

\def\C{
    \begin{bmatrix}
        q_1 \\
        q_2 \\
        \vdots \\
        q_N
\end{bmatrix}}

\def\D{
    \begin{bmatrix}
        p_1q_1 & p_1q_2 &\cdots &p_1q_N &p_2q_1 &\cdots &p_Nq_N
\end{bmatrix}}


\begin{document}
\footnotesize
\begin{figure}
    \begin{equation}
    \C \A = \B   \Rightarrow  \D
    \end{equation}
\end{figure}
\end{document}

the above code produces what I actually mean, but I want to draw it using Tikz with array shape for vectors.

array shape

can anybody help me on that? Thanks in advance.

6
  • (i) array shape doesn't exist, (ii) for matrices exist matrix library (iii) do you expect for each matrix separate image? (iv) what benefits you expect writing matrices by tikz (v) your equation is very wide ... please clarify your question.
    – Zarko
    Oct 5 '17 at 11:30
  • @Zarko there is left/right delimiter option for \matrix
    – percusse
    Oct 5 '17 at 15:41
  • @percusse, i know. to me is not clear if op like to have image with of matrix equation or only tikz replacement for each matrix in equation :-(.
    – Zarko
    Oct 5 '17 at 16:31
  • @Zarko I just want to change its appearance, I draw what I expected. Oct 5 '17 at 20:19
  • sorry, but i don't see any picture. is @Ignasi answer what you looking for? i must confess that i don't understand your question. to write equation on more complicated way?
    – Zarko
    Oct 5 '17 at 21:09
3

While OP answers Zarko's question, here it's a version with all matrices inside one tikzpicture:

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{matrix, positioning}

\tikzset{
    every left delimiter/.style={xshift=1ex},
    every right delimiter/.style={xshift=-1ex},
    bmatrix/.style={matrix of math nodes,
        inner sep=0pt,
        left delimiter={[},
        right delimiter={]},
        nodes={anchor=center, inner sep=.3333em},
        }
}


\def\A{
    \begin{bmatrix}
        p_1 & p_2 & \cdots & p_N
\end{bmatrix}}


\def\B{
\begin{bmatrix}
    p_1q_1 & p_1q_2  &\cdots &p_1q_N\\
    p_2q_1 & p_2q_2  &\cdots &p_2q_N\\
    \vdots & & &  \vdots\\
    p_Nq_1 & p_Nq_2 &\cdots &p_Nq_N\\
\end{bmatrix}}

\def\C{
    \begin{bmatrix}
        q_1 \\
        q_2 \\
        \vdots \\
        q_N
\end{bmatrix}}

\def\D{
    \begin{bmatrix}
        p_1q_1 & p_1q_2 &\cdots &p_1q_N &p_2q_1 &\cdots &p_Nq_N
\end{bmatrix}}


\begin{document}
\footnotesize
\begin{figure}
    \begin{equation}
    \C \A = \B   \Rightarrow  \D
    \end{equation}
\end{figure}

\begin{equation}
\begin{tikzpicture}
\matrix (C) [bmatrix] {q_1 \\
        q_2 \\[-1ex]
        \vdots \\
        q_N\\};
\matrix (A) [bmatrix, right=3mm of C] {p_1 & p_2 & \cdots & p_N\\};
\node (eq) [right=1mm of A] {$=$};
\matrix (B) [bmatrix, right=1mm of eq] {
    p_1q_1 & p_1q_2  &\cdots &p_1q_N\\
   p_2q_1 & p_2q_2  &\cdots &p_2q_N\\[-1ex]
   \vdots & & &  \vdots\\
   p_Nq_1 & p_Nq_2 &\cdots &p_Nq_N\\};
\node (imp) [right=1mm of B] {$\Rightarrow$};
\matrix (D) [bmatrix, right=1mm of imp] {
    p_1q_1 & p_1q_2 &\cdots &p_1q_N &p_2q_1 &\cdots &p_Nq_N\\};
\end{tikzpicture}
\end{equation}
\end{document}

enter image description here

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.