6

I want to show multiplication between this matrix:

z^{[1]} = \[
\left[
  \begin{array}{ccc}
    \horzbar & w^{T}_{1} & \horzbar \\
    \horzbar & w^{T}_{2} & \horzbar \\
    \horzbar & w^{T}_{3} & \horzbar \\
    \horzbar & w^{T}_{4} & \horzbar \\
  \end{array}
\right]

and this vector:

[\  
\begin{align}
    y &= \begin{bmatrix}
           x_{1} \\
           x_{2} \\
           \vdots \\
           x_{m}
         \end{bmatrix}
\end{align}

\]

But how can I show the matrix-vector multiplication?

3 Answers3

10

Following the probable definition from How do I typeset vertical and horizontal lines inside a matrix?

\documentclass{article}
\usepackage{amsmath,array}
\newcommand*{\vertbar}{\rule[-1ex]{0.5pt}{2.5ex}}
\newcommand*{\horzbar}{\rule[.5ex]{2.5ex}{0.5pt}}
\begin{document}
\[
z^{[1]} = 
\left[
  \begin{array}{ccc}
    \horzbar & w^{T}_{1} & \horzbar \\
    \horzbar & w^{T}_{2} & \horzbar \\
    \horzbar & w^{T}_{3} & \horzbar \\
    \horzbar & w^{T}_{4} & \horzbar \\  
  \end{array}
\right]
\begin{bmatrix}
           x_{1} \\
           x_{2} \\
           \vdots \\
           x_{m}
         \end{bmatrix}
\]
\end{document}

enter image description here

percusse
  • 157,807
7

With some magical definition of \horzbar:

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\def\horzbar{\text{magic}}

\begin{align*}
Z^{[1]}y &= \left[\begin{array}{ccc}
  \horzbar & w^{T}_{1} & \horzbar \\
  \horzbar & w^{T}_{2} & \horzbar \\
  \horzbar & w^{T}_{3} & \horzbar \\
  \horzbar & w^{T}_{4} & \horzbar \\ 
\end{array}\right]
\begin{bmatrix}
  x_{1}  \\
  x_{2}  \\
  \vdots \\
  x_{m}
\end{bmatrix} \\
{} &= \begin{bmatrix}
  b_{1}  \\
  b_{2}  \\
  \vdots \\
  b_{m}
\end{bmatrix}
\end{align*}

\end{document}

enter image description here

AboAmmar
  • 46,352
  • 4
  • 58
  • 127
4

You can use this code substituting in place of the letters what you want.

enter image description here

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{hyperref}
\usepackage{url}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{bbold}
\usepackage{fancyvrb}
\usepackage{movie15}
\usepackage{array, amsmath}

\begin{document}

\[  \mathbf{z^{[1]}}\cdot \mathbf{y}=
  \left[
    \begin{array}{cccc}
      \rule[.2ex]{1em}{0.2pt} & w^{T}_{1} &  \rule[.2ex]{1em}{0.2pt}\\
      \rule[.2ex]{1em}{0.2pt} & w^{T}_{2} &  \rule[.2ex]{1em}{0.2pt}\\
      \rule[.2ex]{1em}{0.2pt} & w^{T}_{3} & \rule[.2ex]{1em}{0.2pt}
    \end{array}
  \right]\cdot
  \left[
    \begin{array}{c}
      x_1\\
      x_2\\
      \vdots\\
      x_n
    \end{array}
  \right]
\]


\end{document}
Sebastiano
  • 54,118
  • +1, this is better than magic, however from math point of view, the dimension of the matrix and the vector does not match :-) – Zarko Apr 01 '18 at 19:41
  • The best users, like you, are authorized to edit my answer. Authorized! :-) – Sebastiano Apr 01 '18 at 19:42
  • i'm not a mathematician; in my profession, math was only the main tool :-), so i doubt that i'm competent for this :-). hopefully op know what (s)e need/doing :-). – Zarko Apr 01 '18 at 19:54