我浏览了该论坛上的类似问题并得出了以下结论:
\documentclass[tikz]{standalone}
\usetikzlibrary{positioning,circuits.ee.IEC}
\usepackage{amssymb}
\begin{tikzpicture}[
thick, node distance=.25cm, circuit ee IEC,
box/.style={
draw, align=left, shape=rectangle, minimum width=1.5cm, minimum height=2cm,
append after command={% see also: https://tex.stackexchange.com/a/129668
\foreach \side in {east,west} {
\foreach \i in {1,...,#1} {
(\tikzlastnode.north \side) edge[draw=none, line to]
coordinate[pos=(\i-.5)/(#1)] (\tikzlastnode-\i-\side) (\tikzlastnode.south \side)
}}}}]
\node[box=2] (box-tt) {$2$ \\\\ DFT};
\node[box=2, below=of box-tt] (box-t) {$2$ \\\\DFT};
\node[box=2, below=of box-t] (box-b) {$2$ \\\\DFT};
\node[box=2, below=of box-b] (box-bb) {$2$ \\\\ DFT};
%Conexiones a derecha
\foreach \s [count=\i] in {0,4}
\path (box-tt-\i-east) edge node[at end, above,]{$\mathbb{X}[\s]$} ++(right:.5);
\foreach \s [count=\i] in {2,6}
\path (box-t-\i-east) edge node[at end, above]{$\mathbb{X}[\s]$} ++(right:.5);
\foreach \s [count=\i] in {1,6}
\path (box-b-\i-east) edge node[at end, above]{$\mathbb{X}[\s]$} ++(right:.5);
\foreach \s [count=\i] in {3,7}
\path (box-bb-\i-east) edge node[at end, above]{$\mathbb{X}[\s]$} ++(right:.5);
\newcounter{k}
\setcounter{k}{-1}
\foreach \b/\s in {tt/g,t/i, b/j, bb/h}
\foreach \i/\j in{1/0,2/1}
\addtocounter{k}{1}
\node [contact] (conn-\b-\i) at ([shift=(left:1)] box-\b-\i-west) {}
node [contact] (conn2-\b-\i) at ([shift=(left:2.5)] box-\b-\i-west) {}
node [contact] (connint2-\b-\i) at ([shift=(left:3)] box-\b-\i-west) {}
node [contact] (conn3-\b-\i) at ([shift=(left:4.5)] box-\b-\i-west) {}
node [contact] (connint3-\b-\i) at ([shift=(left:5)] box-\b-\i-west) {}
node [contact] (conn4-\b-\i) at ([shift=(left:5.5)] box-\b-\i-west) {}
edge node[at end,above left] {$\s[\j]$} (box-\b-\i-west)
node [contact, label=left:{$x[\thek]$}] (conn5-\b-\i') at ([shift=(left:8)] box-\b-\i-west) {};
\begin{scope}
\foreach \i in {1,...,2}
\path (conn5-tt-\i') edge[current direction={pos=.25, info=$+$}] (conn4-tt-\i) %Primer nivel
edge[current direction={pos=.99, info=$+$}] (conn4-b-\i) %Flechas abajp
(conn5-t-\i') edge[current direction={pos=.25, info=$+$}] (conn4-t-\i)
edge[current direction={pos=.99, info=$+$}] (conn4-bb-\i)
(conn5-bb-\i') edge[current direction={pos=.25, info=$-$}] (conn4-bb-\i)%Flechas arriba
edge[current direction={pos=.99, info=$+$}] (conn4-t-\i)
(conn5-b-\i') edge[current direction={pos=.25, info=$-$}] (conn4-b-\i)
edge[above right,current direction={pos=.99, info=$+$}] (conn4-tt-\i) %Segundo nivel
(conn3-tt-\i) edge[current direction={pos=.25, info=$+$}] (connint2-tt-\i)%Flechas abajo
edge[current direction={pos=.99, info=$+$}] (connint2-t-\i)
(conn3-b-\i) edge[current direction={pos=.25, info=$+$}] (connint2-b-\i)
edge[current direction={pos=.99, info=$+$}] (connint2-bb-\i)
(conn3-bb-\i) edge[current direction={pos=.25, info=$-$}] (connint2-bb-\i)%Flechas arriba
edge[current direction={pos=.99, info=$+$}] (connint2-b-\i)
(conn3-t-\i) edge[current direction={pos=.25, info=$-$}] (connint2-t-\i)
edge[current direction={pos=.99, info=$+$}] (connint2-tt-\i);%Tercer nivel
\foreach \j in {tt,t,b,bb}
\path (conn2-\j-1) edge[current direction={pos=.25, info=$+$}] (conn-\j-1) %Flechas abajo
edge[current direction={pos=.99, info=$+$}] (conn-\j-2)
(conn2-\j-2) edge[current direction={pos=.25, info=$-$}] (conn-\j-2) %Flechas arriba
edge[current direction={pos=.99, info=$+$}] (conn-\j-1);
\end{scope}
\end{tikzpicture}
\end{document}
上面的代码产生:
这接近我想要的结果。但是我想加入权重因子 W,以便更好地控制加号/减号的位置。如果您能帮助我,我将不胜感激!
答案1
欢迎来到 TeX.SE!!
这是可能的,使用两个嵌套的\foreach
s 来绘制 y 轴和 x 轴上的线条、节点和箭头。我不知道您想把加号/减号放在哪里,所以在我的例子中这可能是错误的(但很容易更改)。
我的代码:
\documentclass[border=2mm,tikz]{standalone}
\begin{document}
\begin{tikzpicture}[y=-1cm]
\foreach\y in {0,...,7}
{
\pgfmathtruncatemacro\yy{mod(abs(3.5-\y)+0.5,2)==0?\y:(\y<4?\y+3:\y-3)} % F value
\draw[-latex] (-1,\y) node [left] {$f(\y)$} -- (-0.05,\y);
\draw[-latex] (12,\y) -- (13,\y) node [right] {$F(\yy)$};
\foreach\x in {0,1,2}
{
\draw[-latex] (4*\x,\y) --++ (2.95,0) ;
\draw(4*\x+3,\y) --++ (1,0);
\foreach\z in {0,3}
\node[circle,fill,inner sep=0.5mm] at (4*\x+\z,\y) {};
\pgfmathtruncatemacro\i{pow(2,2-\x)}
\pgfmathtruncatemacro\j{\i-2*\i*mod(div(\y,\i),2)} % delta y for the arrows
\node (A) at (4*\x,\y) {};
\node (B) at (4*\x+3,\y+\j) {};
\draw[-latex,thick,red] (A) -- (B);
\ifnum\j < 0
\node[red] at (B) [shift={(225:0.2)}] {\tiny$+$};
\node[red] at (B) [shift={ (45:0.2)}] {\tiny$+$};
\else
\pgfmathtruncatemacro\k{mod(\y,\i)*(2-abs(\x-1))} % W exponent
\node[red] at (B) [shift={(315:0.2)}] {\tiny$+$};
\node[red] at (B) [shift={(135:0.2)}] {\tiny$-$};
\node[red] at (B) [shift={(0.4,0.2)}] {$W^\k$};
\fi
}
}
\end{tikzpicture}
\end{document}