我想显示这个矩阵之间的乘法:
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{align}
y &= \begin{bmatrix}
x_{1} \\
x_{2} \\
\vdots \\
x_{m}
\end{bmatrix}
\end{align}
\]
但是我怎样才能显示矩阵向量乘法?
答案1
按照可能的定义如何在矩阵内排版垂直线和水平线?
\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}
答案2
有一些神奇的定义\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}
答案3
您可以使用此代码替换您想要的字母。
\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}