-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnumpy_arrays.tex
86 lines (68 loc) · 2.38 KB
/
numpy_arrays.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
\documentclass[convert={density=300,size=1200x800,outext=.png}]{standalone}
\usepackage{tikz}
\usetikzlibrary{quotes,arrows.meta}
\usepackage{adjustbox}
\tikzstyle{annot}=[font=\fontsize{17}{0}\selectfont, text centered]
\tikzstyle{captionLabel}=[annot,font=\fontsize{20}{20}\selectfont,thick,text width=200]
\newcommand{\threeDimMatrix}[5]{% width, height, depth, scale, caption
\begin{tikzpicture}[scale=#4, line width=0.15em]
\foreach \x in {0,...,#1}{
% vertical 2d
\draw (\x ,0 ,#3 ) coordinate (a-\x) -- (\x ,#2 ,#3 );
% vertical 3d
\draw (\x ,#2 ,#3 ) coordinate (b-\x) -- (\x ,#2 ,0 );
}
\foreach \x in {0,...,#2}{
% horizontal bottom 3d
\draw (#1 ,\x ,#3 ) coordinate (c-\x) -- (#1 ,\x ,0 );
% horizontal bottom
\draw (0 ,\x ,#3 ) coordinate (d-\x) -- (#1 ,\x ,#3 );
}
\foreach \x in {0,...,#3}{
%vertical end line
\draw (#1 ,0 ,\x ) coordinate (e-\x) -- (#1 ,#2 ,\x );
% horizontal top
\draw (0 ,#2 ,\x ) coordinate (f-\x) -- (#1 ,#2 ,\x );
}
\ifnum1<0#2
\path[every edge/.append style={|-|}] ([yshift=-10]a-0) coordinate(x) edge [annot,"axis 1"'] ([yshift=-10]a-#1);
\path[every edge/.append style={|-|}] ([xshift=-10]d-0) coordinate(y) edge [annot,"axis 0"] ([xshift=-10]d-#2);
\fi
\def\xshiftValue{10}
\def\yshiftValue{-10}
\ifnum0<0#3
\path[every edge/.append style={|-|}] ([xshift=\xshiftValue,yshift=\yshiftValue] e-0) coordinate(z) edge [annot,"axis 2"] ([xshift=\xshiftValue,yshift=\yshiftValue]e-#3);
\node[captionLabel] at (1.5, -2.5) {\bfseries #5};
\else
\node[captionLabel] at (2.5, -1.5) {\bfseries #5};
\fi
\end{tikzpicture}
}
\newcommand{\twoDimMatrix}[4]{
\threeDimMatrix{#1}{#2}{0}{#3}{#4}
}
\newcommand{\oneDimMatrix}[3]{
\threeDimMatrix{#1}{1}{0}{#2}{#3}
}
\begin{document}
%\fbox{
\begin{tikzpicture}[line width=0.15em,scale=1.5]
\draw (0, -1) grid (-5, 0);
\node[captionLabel] at (-2.5, -2.5) {\bfseries 1D array};
\end{tikzpicture}
%}
%\oneDimMatrix{5}{1.5}{1D array}
%\fbox{
\begin{adjustbox}{margin=2em}
\twoDimMatrix{5}{4}{1.5}{2D array}
\end{adjustbox}
%}
%\fbox{
\threeDimMatrix{5}{4}{3}{1.5}{3D array}
%}
%\begin{tikzpicture}[line width=0.15em,scale=1.5]
%$ \draw (0, 0) grid (-5, 4);
% \draw[yslant=0.25] (0,0) grid (3, 4);
% \draw[yslant=0,xslant=0.5] (-7, 4) grid (-2, 7);
%\end{tikzpicture}
\end{document}