%%
%% Description: The Adams spectral sequence for $\tmf_2$
%%
%% File: example_tmfass.tex
%%
%%    From "The Homotopy Groups of tmf and of its Localizations" http://math.mit.edu/conferences/talbot/2007/tmfproc/Chapter16/TmfHomotopy.pdf
%%    This file has really bad performance.
%%


% 9.8 sec

% 1.7 seconds to set up
% 1.8 seconds to draw the classes
% 2.1 seconds to draw the edges
% --> ~5.7 seconds to draw page 0.

% edge drawing time:
%   1.0s to calculate but discard without off page handling
%   0.6s to deal with off-page edges
%   0.3s to draw

% 17 seconds to draw all pages =(
% 17 ~~ 1.7s setup + 5 page * 3 s/pp
%
% deleting off page edge handling cuts off 1.4s (1s?) so I haven't found any of the big time holes yet. WHY IS THIS SO SLOW??

\documentclass[tooltips]{spectralsequence-example}

\begin{document}

\NewSseqGroup\tower {} {% 25
    \class(0,0)
    \DoUntilOutOfBoundsThenNMore{2}{
        \class(\lastx,\lasty+1)
        \structline(\lastclass1) (\lastclass)
    }
}

\NewSseqGroup\towergroup {} {%9 + 25 = 36
    \tower(0,0)
    \class(1,1)
    \class(3,1)
    \class(2,2)
    \class(3,2)
    \class(3,3)
    \class(6,2)
    \structline(3,1,-1)(3,2,-1)
    \structline(3,2,-1)(3,3,-1)
    \structline(0,0,-1)(1,1,-1)
    \structline(1,1,-1)(2,2,-1)
    \structline(2,2,-1)(3,3,-1)
    \structline(0,0,-1)(3,1,-1)
    \structline(3,1,-1)(6,2,-1)
    \structline(0,1,-1)(3,2,-1)
    \structline(0,2,-1)(3,3,-1)
}


\NewSseqGroup\towergroupa {} {%25*2+9+21 = 80
    \towergroup(0,0)
    \tower(4,-1)
%
    \class(6,0)
    \class(6,1)
    \class(7,-1)
    \class(7,0)
    \class(7,1)
    \class(9,0)
    \class(9,1)
    \class(9,2)
    \class(10,0)
    \class(10,1)
    \class(12,0)
    \class(12,1)
    \class(12,2)
    \class(13,1)
    \structline(6,0,-1)(6,1,-1)
    \structline(6,1,-1)(6,2,-1)
    \structline(7,-1,-1)(7,0,-1)
    \structline(7,0,-1)(7,1,-1)
    \structline(9,0,-1)(9,1,-1)
    \structline(9,1,-1)(9,2,-1)
    \structline(10,0,-1)(10,1,-1)
    \structline(12,0,-1)(12,1,-1)
    \structline(12,1,-1)(12,2,-1)
%
    \structline(4,-1,-1)(7,0,-1)
    \structline(4,0,-1)(7,1,-1)
    \structline(6,0,-1)(9,1,-1)
    \structline(6,1,-1)(9,2,-1)
    \structline(6,0,-1)(7,1,-1)
    \structline(7,-1,-1)(10,0,-1)
    \structline(7,0,-1)(10,1,-1)
    \structline(9,0,-1)(12,1,-1)
    \structline(9,1,-1)(12,2,-1)
    \structline(9,0,-1)(10,1,-1)
    \structline(10,0,-1)(13,1,-1)
    \structline(12,0,-1)(13,1,-1)
%
    \d2(4,-1,-1,-1)
    \d2(4,0,-1,-1)
    \d2(4,1,-1,-1)
    \d2(7,-1,-1,-1)
    \d2(7,0,-1,-1)
    \d2(10,0,-1,-1)
}

\NewSseqGroup\towergroupb {} {%80 + 25 + 15 = 120
    \towergroupa(0,0)
    \tower(8,-2)
    \class(10,-1)
    \class(11,-1)
    \class(10,-2)
    \class(9,-3)
    \class(11,-2)
    \structline(8,-2)(11,-1)
    \structline(11,-1)(10,-2)
    \structline(10,-2)(9,-3)
    \structline(11,-2)(11,-1)

    \class(13,-1)
    \class(13,0)
    \class(14,-2)
    \class(15,0)
    \class(16,-1)\class(16,-1)
    \class(16,0)
    \class(16,1)
    \class(17,0)
    \class(18,0)
    \class(18,1)
    \class(19,-1)
    \structline(10,-1,-1)(10,0,-1)
    \structline(13,0,-1)(13,1,-1)
    \structline(13,-1,-1)(13,0,-1)
    \structline(16,0,-1)(16,1,-1)
    \structline(16,-1,-2)(16,0,-1)
    \structline(16,-1,-1)(16,0,-1)

    \structline(10,-1,-1)(13,0,-1)
    \structline(13,-1,-1)(16,0,-1)
    \structline(13,0,-1)(16,1,-1)
    \structline(15,0,-1)(18,1,-1)
    \structline(15,0,-1)(16,1,-1)
    \structline(16,-1,-1)(17,0,-1)
    \structline(17,0,-1)(18,1,-1)
    \structline(18,1,-1)(18,0,-1)
    \d2(10,-1,-1,-1)
    \d2(13,-1,-1,-1)
    \d2(13,0,-1,-1)
    \d3(14,-2,-1,-1)
    \d2(19,-1,-1,-1)
}

\begin{sseqdata}[
    x range={0}{50},
    y range={0}{20},
    x tick step=2,
    Adams grading,
    classes={fill,inner sep=0.3ex,tooltip={(\xcoord,\ycoord)}},
    class placement transform={scale=1.5},
    differentials={->,blue},
    struct lines=red, %no struct lines, no differentials,
    yscale=0.6, xscale=0.5,
    x axis extend end=0.2cm,
    name=tmfass,
    grid=go,
    run off differentials=->
]

\towergroup(0,0) % 36

\class(8,3)\class(9,4)
\structline(8,3)(9,4)
\towergroupa(8,4) % 80

\foreach \n in {2,3,4}{
    \towergroupb(8*\n,4*\n) % 120
}

\foreach \n in {1,2,3,4}{
    \begin{scope}[xshift=8*\n,yshift=4*\n]
    \class(8,3)
    \class(9,4)
    \structline(8,3,-1)(9,4,-1)
    \d3(9,0,-1,-1)
    \d3(10,1,-1,-1)
    \end{scope}
}


\foreach \n in {1,2,3,5,6,7}{
    \class(35+2*\n,7+\n)
}

%\d2(18,4)
\d3(24,6)

\class(36,9)
\d2(36,9)
\d4(37,8)
\d4(45,12)


\class(44,13)
\d2(44,13)
\class(45,9)
\class(47,10)
\class(49,11)
\d4(49,11,,1)
\d4(49,11,,2)
\replaceclass(48,15,1)
\towergroupb(40,20)
\towergroup(48,8)
\foreach \n in {0,...,5}{
    \class(40+2*\n,8+\n)
}

\d3(42,9)
\d4(44,10)
\d4(47,16)
\d2(48,8)
\d4(48,9)
\d3(49,9,,2)
\d3(50,13)
\class(50,10)
\d4(50,10,1)
\d4(50,10,2)
\replaceclass[offset={(0,0)}](50,10)
\class(51,12)
\d4(51,12)
\class(52,17)
\d2(52,17)

\foreach \n in {0,4,8}{
    \d3(32+2*\n,10+\n,1)
    \d4(31+2*\n,8+\n)
}
\end{sseqdata}


\printpage[name=tmfass,page=0]

\printpage[name=tmfass,page=2]

\printpage[name=tmfass,page=3]

\printpage[name=tmfass,page=4]

\begin{sseqpage}[name=tmfass,page=5,class labels={below=0.2em},tikz primitives=dashed]
\classoptions["\eta" {right=0.1em}](1,1)
\classoptions["\nu" below right](3,1)
\classoptions["\epsilon"](8,3)
\classoptions["c_4+\epsilon" left](8,4)
\classoptions["2c_6"](12,6)
\classoptions["\kappa"](14,4)
\classoptions["c_4^2"](16,8)
\classoptions["\overline\kappa"](20,4)
\classoptions["8\Delta"](24,7)
\classoptions["\eta\Delta"](25,5)
\classoptions["2\nu\Delta"](27,6)
\classoptions["c_4\Delta+q" left](32,7,1)
\classoptions["q"](32,7,2)
\classoptions["\overline\kappa^2"](40,8)
\classoptions["4\Delta^2"](48,10)
\draw(6,2)--(9,4);
\draw(21,5)--(22,8);
\draw[bend left=20] (25,5) to (28,8);
\draw (27,6) -- (28,8);
\draw(32,7,1)--(33,9);
\draw[bend right=10](32,7,2) to (35,10);
\draw(34,8) -- (35,10);
\draw(39,9)--(40,11,2);
\draw(39,9)--(42,12);
\draw(40,8)--(40,11,2);
\draw(40,11,1)--(41,13);
\draw(40,8)--(41,10) -- (42,12);
\draw(45,9)--(46,11);
\draw(48,15,1)--(48,16,1);
\draw[bend right=20] (48,15,1) to (49,17);
\structline[black](50,10,2)(51,11)
\end{sseqpage}

\end{document}
